Dropped tab layout, floating info window and clean

No longer using tabs, all info in one bottom panel.
Added a floating info window, can open from control bar.
Cleanup vertical widths for scroll bars in some panes.
This commit is contained in:
2026-06-24 10:31:09 +02:00
parent 6a43058033
commit 6d706a34cd
5 changed files with 55 additions and 60 deletions
+14 -1
View File
@@ -103,9 +103,13 @@ run_gui :: proc(sim: ^Simulator) {
// Bottom
// ------------------------------------------
gui_bottom_tabs(layout.bottom_panel, sim)
gui_bottom_panel(layout.bottom_panel, sim)
gui_status_bar(layout.status_bar, sim)
// Info Box
// ------------------------------------------
gui_info_box(layout.info_box, sim, screen_width, screen_height)
rl.EndDrawing()
}
@@ -196,5 +200,14 @@ calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
width = screen_width,
height = STATUS_BAR_H,
},
// ------------------------------------------
// Info Box
info_box = rl.Rectangle{
x = (screen_width / 2 - 200),
y = (screen_height / 2 - 200),
width = 400,
height = 140
}
}
}
+15 -25
View File
@@ -2,40 +2,30 @@ package simulator
import rl "vendor:raylib"
gui_bottom_tabs :: proc(rect: rl.Rectangle, sim: ^Simulator) {
gui_bottom_panel :: proc(rect: rl.Rectangle, sim: ^Simulator) {
rl.DrawRectangleLinesEx(rect, 1, rl.GRAY)
// Setup tab bar
tabs := [?]cstring{ "Memory", "Log" }
tab_bar_rect := rl.Rectangle{
rect.x,
rect.y,
rect.width,
BUTTON_HEIGHT + PADDING_Y
}
// inside draw loop:
rl.GuiTabBar(tab_bar_rect, &tabs[0], i32(len(tabs)), &sim.active_tab)
memory_view_bounds := rl.Rectangle {
x = rect.x + PADDING_X,
y = rect.y + PADDING_Y + tab_bar_rect.height,
y = rect.y + PADDING_Y,
width = (rect.width - (PADDING_X * 2)) / 2,
height = rect.height - (PADDING_Y * 2) - tab_bar_rect.height,
height = rect.height - (PADDING_Y * 2),
}
gui_tab_memory(memory_view_bounds, sim)
disasm_view_bounds := rl.Rectangle {
x = rect.x + memory_view_bounds.width + PADDING_X,
y = rect.y + PADDING_Y + tab_bar_rect.height,
width = (rect.width - (PADDING_X * 2)) / 2,
height = rect.height - (PADDING_Y * 2) - tab_bar_rect.height,
y = rect.y + PADDING_Y,
width = ((rect.width - (PADDING_X * 2)) / 2) / 2,
height = rect.height - (PADDING_Y * 2),
}
switch sim.active_tab {
case 0: // draw registers panel
gui_tab_memory(memory_view_bounds, sim)
gui_tab_disasm(disasm_view_bounds, sim)
case 1: // draw memory panel
case 2: // draw display panel
stack_view_bounds := rl.Rectangle {
x = disasm_view_bounds.x + disasm_view_bounds.width,
y = rect.y + PADDING_Y,
width = ((rect.width - (PADDING_X * 2)) / 2) / 2,
height = rect.height - (PADDING_Y * 2),
}
gui_tab_stack(stack_view_bounds, sim)
}
+1 -1
View File
@@ -88,7 +88,7 @@ gui_file_loader :: proc(rect: rl.Rectangle, sim: ^Simulator) {
content_rect := rl.Rectangle {
x = panel_rect.x,
y = panel_rect.y - PANEL_HEADER,
width = panel_rect.width + PANEL_HEADER,
width = panel_rect.width - 15,
height = f32(len(roms)) * LINE_HEIGHT
}
+16 -24
View File
@@ -1,15 +1,11 @@
package simulator
import "core:fmt"
import "core:strings"
import rl "vendor:raylib"
gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) {
rl.DrawRectangleRec(rect, rl.DARKGRAY)
// 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)
follow_label : cstring = "Follow: ON" if sim.disasm_follow else "Follow: OFF"
@@ -27,51 +23,47 @@ gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) {
}
rl.GuiPanel(panel_rect, nil)
// Total height of all instructions
content_rect := rl.Rectangle {
x = panel_rect.x,
y = panel_rect.y - PANEL_HEADER,
width = panel_rect.width + PANEL_HEADER,
height = f32(len(sim.disasm)) * LINE_HEIGHT
width = panel_rect.width - 15,
height = f32(len(sim.disasm)) * LINE_HEIGHT,
}
view: rl.Rectangle
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()
index_x := panel_rect.x + PADDING_X
disasm_x := index_x + 70
for entry, i in sim.disasm[:sim.disasm_count] {
y_pos := panel_rect.y + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y
is_active := entry.address == sim.machine.pc
color := rl.WHITE
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
if is_active {
rl.DrawRectangleV(
{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),
{panel_rect.x + PADDING_X + sim.disasm_scroll.x, y_pos},
18, 1,
txt_color,
rl.BLACK,
)
}
txt_index := fmt.ctprintf("0x%04X", entry.address)
txt_disasm := fmt.ctprintf(": %s", entry.str)
rl.DrawTextEx(sim.font, txt_index, {index_x + sim.disasm_scroll.x, y_pos}, 18, 1, color)
rl.DrawTextEx(sim.font, txt_disasm, {disasm_x + sim.disasm_scroll.x, y_pos}, 18, 1, color)
}
if sim.disasm_follow {
for entry, i in sim.disasm[:sim.disasm_count] {
if entry.address == sim.machine.pc {
target_y := f32(i) * LINE_HEIGHT
visible_height := panel_rect.height
// Center the active instruction in the panel
sim.disasm_scroll.y = -(target_y - visible_height / 2)
// Clamp so we don't scroll past the content
max_scroll := -(f32(sim.disasm_count) * LINE_HEIGHT - visible_height)
sim.disasm_scroll.y = clamp(sim.disasm_scroll.y, max_scroll, 0)
break
+1 -1
View File
@@ -54,7 +54,7 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
content_rect := rl.Rectangle{
0, 0,
rect.width - 12,
rect.width - 15,
f32(MEM_VIRTUAL_ROWS) * MEM_ROW_H,
}