Small cleanup and fixed height control/status bars.

This commit is contained in:
2026-06-10 08:03:39 +02:00
parent eb702890bb
commit 3b24dc8566
2 changed files with 43 additions and 48 deletions
+40 -44
View File
@@ -10,7 +10,8 @@ WINDOW_HEIGHT :: 1080
// @TODO: If this grows lets move it into its own file
SIDEBAR_PERCENT :: 0.20
DISPLAY_PERCENT :: 0.30
CONTROLBAR_PERCENT :: 0.05
CONTROL_BAR_H :: f32(50)
STATUS_BAR_H :: f32(30)
Layout :: struct {
control_bar : rl.Rectangle,
@@ -33,11 +34,9 @@ run_gui :: proc(sim: ^Simulator) {
rl.SetTextureFilter(font.texture, .BILINEAR)
sim.font = font
// Initialize style system first
rl.GuiLoadStyleDefault()
// Then load dark theme
rl.GuiLoadStyle("./assets/raygui_styles/style_dark.rgs")
// Then override font AFTER (style load resets it)
rl.GuiSetFont(font)
rl.GuiSetStyle(.DEFAULT, cast(i32)rl.GuiDefaultProperty.TEXT_SIZE, 18)
@@ -56,7 +55,6 @@ run_gui :: proc(sim: ^Simulator) {
rl.ClearBackground(rl.BLACK)
// Cycle the machine to update memory etc
// if (sim.is_running) else don't run machine, here we can start,pause etc
if (!sim.paused) {
emu.run_machine(sim.machine, 12)
@@ -75,7 +73,7 @@ run_gui :: proc(sim: ^Simulator) {
}
gui_control_bar(layout.control_bar, sim)
// gui_left_panel(layout.left_panel, s.machine)
gui_left_panel(layout.left_panel, sim)
// gui_right_panel(layout.right_panel, s.machine)
// Screen is just drawing the display buffer just needs that as arg
@@ -87,49 +85,47 @@ run_gui :: proc(sim: ^Simulator) {
}
rl.UnloadFont(sim.font)
rl.UnloadFont(font)
rl.UnloadSound(beep)
rl.CloseAudioDevice()
rl.CloseWindow()
}
// @TODO: If this grows lets move it into its own file
calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
control_bar_height := screen_height * CONTROLBAR_PERCENT
sidebar_width := screen_width * SIDEBAR_PERCENT
sidebar_height := screen_height - control_bar_height
display_height := screen_height * DISPLAY_PERCENT - control_bar_height
return Layout {
control_bar = rl.Rectangle {
x = 0,
y = 0,
width = screen_width,
height = control_bar_height
},
left_panel = rl.Rectangle {
x = 0,
y = control_bar_height,
width = sidebar_width,
height = sidebar_height
},
display = rl.Rectangle {
x = sidebar_width,
y = control_bar_height,
width = screen_width - (sidebar_width * 2),
height = display_height
},
right_panel = rl.Rectangle {
x = screen_width - sidebar_width,
y = control_bar_height,
width = sidebar_width,
height = sidebar_height
},
status_bar = rl.Rectangle {
x = 0,
y = screen_height - control_bar_height,
width = screen_width,
height = control_bar_height
},
}
calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
sidebar_width := screen_width * SIDEBAR_PERCENT
content_height := screen_height - CONTROL_BAR_H - STATUS_BAR_H
display_height := screen_height * DISPLAY_PERCENT - CONTROL_BAR_H - STATUS_BAR_H
return Layout {
control_bar = rl.Rectangle {
x = 0,
y = 0,
width = screen_width,
height = CONTROL_BAR_H,
},
left_panel = rl.Rectangle {
x = 0,
y = CONTROL_BAR_H,
width = sidebar_width,
height = content_height,
},
display = rl.Rectangle {
x = sidebar_width,
y = CONTROL_BAR_H,
width = screen_width - (sidebar_width * 2),
height = display_height,
},
right_panel = rl.Rectangle {
x = screen_width - sidebar_width,
y = CONTROL_BAR_H,
width = sidebar_width,
height = content_height,
},
status_bar = rl.Rectangle {
x = 0,
y = screen_height - STATUS_BAR_H,
width = screen_width, height = STATUS_BAR_H,
},
}
}
+2 -3
View File
@@ -4,12 +4,11 @@ import emu "../machine"
import rl "vendor:raylib"
Simulator :: struct {
font: rl.Font,
machine: ^emu.System,
running: bool,
paused: bool,
cycles_per_second: int
cycles_per_second: int,
font: rl.Font,
}
// Requires an initilized emulatore System Struct