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:
+14
-1
@@ -103,9 +103,13 @@ run_gui :: proc(sim: ^Simulator) {
|
|||||||
|
|
||||||
// Bottom
|
// Bottom
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
gui_bottom_tabs(layout.bottom_panel, sim)
|
gui_bottom_panel(layout.bottom_panel, sim)
|
||||||
gui_status_bar(layout.status_bar, sim)
|
gui_status_bar(layout.status_bar, sim)
|
||||||
|
|
||||||
|
// Info Box
|
||||||
|
// ------------------------------------------
|
||||||
|
gui_info_box(layout.info_box, sim, screen_width, screen_height)
|
||||||
|
|
||||||
rl.EndDrawing()
|
rl.EndDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,5 +200,14 @@ calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
|
|||||||
width = screen_width,
|
width = screen_width,
|
||||||
height = STATUS_BAR_H,
|
height = STATUS_BAR_H,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ------------------------------------------
|
||||||
|
// Info Box
|
||||||
|
info_box = rl.Rectangle{
|
||||||
|
x = (screen_width / 2 - 200),
|
||||||
|
y = (screen_height / 2 - 200),
|
||||||
|
width = 400,
|
||||||
|
height = 140
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,40 +2,30 @@ package simulator
|
|||||||
|
|
||||||
import rl "vendor:raylib"
|
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)
|
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 {
|
memory_view_bounds := rl.Rectangle {
|
||||||
x = rect.x + PADDING_X,
|
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,
|
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 {
|
disasm_view_bounds := rl.Rectangle {
|
||||||
x = rect.x + memory_view_bounds.width + PADDING_X,
|
x = rect.x + memory_view_bounds.width + PADDING_X,
|
||||||
y = rect.y + PADDING_Y + tab_bar_rect.height,
|
y = rect.y + PADDING_Y,
|
||||||
width = (rect.width - (PADDING_X * 2)) / 2,
|
width = ((rect.width - (PADDING_X * 2)) / 2) / 2,
|
||||||
height = rect.height - (PADDING_Y * 2) - tab_bar_rect.height,
|
height = rect.height - (PADDING_Y * 2),
|
||||||
}
|
}
|
||||||
|
gui_tab_disasm(disasm_view_bounds, sim)
|
||||||
|
|
||||||
switch sim.active_tab {
|
stack_view_bounds := rl.Rectangle {
|
||||||
case 0: // draw registers panel
|
x = disasm_view_bounds.x + disasm_view_bounds.width,
|
||||||
gui_tab_memory(memory_view_bounds, sim)
|
y = rect.y + PADDING_Y,
|
||||||
gui_tab_disasm(disasm_view_bounds, sim)
|
width = ((rect.width - (PADDING_X * 2)) / 2) / 2,
|
||||||
case 1: // draw memory panel
|
height = rect.height - (PADDING_Y * 2),
|
||||||
case 2: // draw display panel
|
|
||||||
}
|
}
|
||||||
|
gui_tab_stack(stack_view_bounds, sim)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ gui_file_loader :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
|||||||
content_rect := rl.Rectangle {
|
content_rect := rl.Rectangle {
|
||||||
x = panel_rect.x,
|
x = panel_rect.x,
|
||||||
y = panel_rect.y - PANEL_HEADER,
|
y = panel_rect.y - PANEL_HEADER,
|
||||||
width = panel_rect.width + PANEL_HEADER,
|
width = panel_rect.width - 15,
|
||||||
height = f32(len(roms)) * LINE_HEIGHT
|
height = f32(len(roms)) * LINE_HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package simulator
|
package simulator
|
||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:strings"
|
|
||||||
import rl "vendor:raylib"
|
import rl "vendor:raylib"
|
||||||
|
|
||||||
gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
gui_tab_disasm :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
||||||
rl.DrawRectangleRec(rect, rl.DARKGRAY)
|
|
||||||
|
|
||||||
// Header background
|
// Header background
|
||||||
rl.DrawRectangle(i32(rect.x), i32(rect.y), i32(rect.width), i32(PANEL_HEADER), 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, "Disassembled Instructions", {rect.x + 4, rect.y + 4}, 18, 1, rl.WHITE)
|
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"
|
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)
|
rl.GuiPanel(panel_rect, nil)
|
||||||
|
|
||||||
// Total height of all instructions
|
|
||||||
content_rect := rl.Rectangle {
|
content_rect := rl.Rectangle {
|
||||||
x = panel_rect.x,
|
x = panel_rect.x,
|
||||||
y = panel_rect.y - PANEL_HEADER,
|
y = panel_rect.y - PANEL_HEADER,
|
||||||
width = panel_rect.width + PANEL_HEADER,
|
width = panel_rect.width - 15,
|
||||||
height = f32(len(sim.disasm)) * LINE_HEIGHT
|
height = f32(len(sim.disasm)) * LINE_HEIGHT,
|
||||||
}
|
}
|
||||||
|
|
||||||
view: rl.Rectangle
|
view: rl.Rectangle
|
||||||
rl.GuiScrollPanel(panel_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))
|
rl.BeginScissorMode(i32(view.x), i32(view.y), i32(view.width), i32(view.height))
|
||||||
defer rl.EndScissorMode()
|
defer rl.EndScissorMode()
|
||||||
|
|
||||||
|
index_x := panel_rect.x + PADDING_X
|
||||||
|
disasm_x := index_x + 70
|
||||||
|
|
||||||
for entry, i in sim.disasm[:sim.disasm_count] {
|
for entry, i in sim.disasm[:sim.disasm_count] {
|
||||||
y_pos := panel_rect.y + (f32(i) * LINE_HEIGHT) + sim.disasm_scroll.y
|
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)
|
if is_active {
|
||||||
bg_color := rl.DARKGRAY if entry.address != sim.machine.pc else rl.BLACK
|
rl.DrawRectangleV(
|
||||||
txt_color := rl.WHITE
|
{panel_rect.x + sim.disasm_scroll.x, y_pos},
|
||||||
|
{panel_rect.width, LINE_HEIGHT},
|
||||||
|
rl.BLACK,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
rl.DrawRectangleV(
|
txt_index := fmt.ctprintf("0x%04X", entry.address)
|
||||||
{panel_rect.x + sim.disasm_scroll.x, y_pos},
|
txt_disasm := fmt.ctprintf(": %s", entry.str)
|
||||||
{panel_rect.width, LINE_HEIGHT},
|
|
||||||
bg_color,
|
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)
|
||||||
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,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if sim.disasm_follow {
|
if sim.disasm_follow {
|
||||||
for entry, i in sim.disasm[:sim.disasm_count] {
|
for entry, i in sim.disasm[:sim.disasm_count] {
|
||||||
if entry.address == sim.machine.pc {
|
if entry.address == sim.machine.pc {
|
||||||
target_y := f32(i) * LINE_HEIGHT
|
target_y := f32(i) * LINE_HEIGHT
|
||||||
visible_height := panel_rect.height
|
visible_height := panel_rect.height
|
||||||
|
|
||||||
// Center the active instruction in the panel
|
|
||||||
sim.disasm_scroll.y = -(target_y - visible_height / 2)
|
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)
|
max_scroll := -(f32(sim.disasm_count) * LINE_HEIGHT - visible_height)
|
||||||
sim.disasm_scroll.y = clamp(sim.disasm_scroll.y, max_scroll, 0)
|
sim.disasm_scroll.y = clamp(sim.disasm_scroll.y, max_scroll, 0)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ gui_tab_memory :: proc(rect: rl.Rectangle, sim: ^Simulator) {
|
|||||||
|
|
||||||
content_rect := rl.Rectangle{
|
content_rect := rl.Rectangle{
|
||||||
0, 0,
|
0, 0,
|
||||||
rect.width - 12,
|
rect.width - 15,
|
||||||
f32(MEM_VIRTUAL_ROWS) * MEM_ROW_H,
|
f32(MEM_VIRTUAL_ROWS) * MEM_ROW_H,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user