From 1a6346895a9430e20daf0ca6749fe802bc2aea35 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Thu, 18 Jun 2026 08:25:14 +0200 Subject: [PATCH] Small ui changes to fit the window better. --- src/simulator/gui_bottom_tabs.odin | 2 +- src/simulator/gui_tab_disasm.odin | 42 +++++++++++++++++++----------- src/simulator/gui_tab_memory.odin | 20 +++++++------- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/simulator/gui_bottom_tabs.odin b/src/simulator/gui_bottom_tabs.odin index 41ea657..27da36d 100644 --- a/src/simulator/gui_bottom_tabs.odin +++ b/src/simulator/gui_bottom_tabs.odin @@ -6,7 +6,7 @@ gui_bottom_tabs :: proc(rect: rl.Rectangle, sim: ^Simulator) { rl.DrawRectangleLinesEx(rect, 1, rl.GRAY) // Setup tab bar - tabs := [?]cstring{ "Memory", "Disassembly", "Log" } + tabs := [?]cstring{ "Memory", "Log" } tab_bar_rect := rl.Rectangle{ rect.x, diff --git a/src/simulator/gui_tab_disasm.odin b/src/simulator/gui_tab_disasm.odin index 0a36e24..328f810 100644 --- a/src/simulator/gui_tab_disasm.odin +++ b/src/simulator/gui_tab_disasm.odin @@ -6,44 +6,56 @@ import rl "vendor:raylib" gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) { rl.DrawRectangleRec(rect, rl.DARKGRAY) - rl.GuiPanel(rect, "Disassembly") - LINE_HEIGHT :: 22 + // Header background + rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), i32(PANEL_HEADER), rl.BLACK) + // Header: Address label + rl.DrawTextEx(sim.font, "Disassembled Instructions", {rect.x + 4, rect.y + 4}, 18, 1, rl.WHITE) + + + // Scroll panel area (below header) + panel_rect := rl.Rectangle{ + rect.x, + rect.y + PANEL_HEADER, + rect.width, + rect.height - PANEL_HEADER, + } + rl.GuiPanel(panel_rect, nil) + + LINE_HEIGHT :: 22 // Total height of all instructions - conten_height := f32(len(sim.disasm)) * LINE_HEIGHT - content_rect := rl.Rectangle { - x = rect.x, - y = rect.y, - width = rect.width + PANEL_HEADER, - height = conten_height, + x = panel_rect.x, + y = panel_rect.y - PANEL_HEADER, + width = panel_rect.width + PANEL_HEADER, + height = f32(len(sim.disasm)) * LINE_HEIGHT } view: rl.Rectangle - rl.GuiScrollPanel(rect, nil, content_rect, &sim.disasm_scroll, &view) + rl.GuiScrollPanel(panel_rect, nil, content_rect, &sim.disasm_scroll, &view) rl.BeginScissorMode(i32(view.x), i32(view.y), i32(view.width), i32(view.height)) - defer rl.EndScissorMode() + defer rl.EndScissorMode() for entry, i in sim.disasm { - y_pos := rect.y + PANEL_HEADER + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y + y_pos := panel_rect.y + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y txt := fmt.tprintf("%d : %s", i, entry.str) bg_color := rl.DARKGRAY if entry.address != sim.machine.pc else rl.BLACK txt_color := rl.WHITE rl.DrawRectangleV( - {rect.x + sim.disasm_scroll.x, y_pos}, - {rect.width, LINE_HEIGHT}, + {panel_rect.x + sim.disasm_scroll.x, y_pos}, + {panel_rect.width, LINE_HEIGHT}, bg_color, ) rl.DrawTextEx( sim.font, strings.clone_to_cstring(txt, context.temp_allocator), - {rect.x + PADDING_X + sim.disasm_scroll.x, y_pos}, + {panel_rect.x + PADDING_X + sim.disasm_scroll.x, y_pos}, 18, 1, txt_color, ) - } + } } diff --git a/src/simulator/gui_tab_memory.odin b/src/simulator/gui_tab_memory.odin index 4e2b705..d4f5722 100644 --- a/src/simulator/gui_tab_memory.odin +++ b/src/simulator/gui_tab_memory.odin @@ -7,7 +7,6 @@ import rl "vendor:raylib" MEM_INDICATOR_W :: 14 MEM_ADDRESS_W :: 72 MEM_ROW_H :: 20 -MEM_HEADER_H :: 24 MEM_BYTES_PER_ROW :: 16 MEM_TOTAL_ROWS :: 256 MEM_FONT_ROWS :: 5 @@ -25,32 +24,32 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) { rl.DrawRectangleRec(rect, rl.DARKGRAY) // Header background - rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), MEM_HEADER_H, rl.BLACK) + rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), i32(PANEL_HEADER), rl.BLACK) // Header: Address label - rl.DrawTextEx(sim.font, "Address", {rect.x + MEM_INDICATOR_W, rect.y + 4}, 16, 1, rl.GRAY) + rl.DrawTextEx(sim.font, "Address", {rect.x + MEM_INDICATOR_W, rect.y + 4}, 18, 1, rl.WHITE) // Header: column labels 0-F col_w := byte_col_w(rect) for col in 0..<16 { x := rect.x + MEM_INDICATOR_W + MEM_ADDRESS_W + f32(col) * col_w label := strings.clone_to_cstring(MEM_COL_LABELS[col], context.temp_allocator) - rl.DrawTextEx(sim.font, label, {x, rect.y + 4}, 16, 1, rl.GRAY) + rl.DrawTextEx(sim.font, label, {x, rect.y + 4}, 18, 1, rl.WHITE) } // Header separator rl.DrawLine( - i32(rect.x), i32(rect.y + MEM_HEADER_H), - i32(rect.x + rect.width), i32(rect.y + MEM_HEADER_H), + i32(rect.x), i32(rect.y + PANEL_HEADER), + i32(rect.x + rect.width), i32(rect.y + PANEL_HEADER), rl.GRAY, ) // Scroll panel area (below header) panel_rect := rl.Rectangle{ rect.x, - rect.y + MEM_HEADER_H, + rect.y + PANEL_HEADER, rect.width, - rect.height - MEM_HEADER_H, + rect.height - PANEL_HEADER, } content_rect := rl.Rectangle{ @@ -66,7 +65,7 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) { draw_row := 0 - // --- Font rows (0x000 - 0x04F) --- + // Font rows (0x000 - 0x04F) for row in 0..