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
+41 -45
View File
@@ -10,7 +10,8 @@ WINDOW_HEIGHT :: 1080
// @TODO: If this grows lets move it into its own file // @TODO: If this grows lets move it into its own file
SIDEBAR_PERCENT :: 0.20 SIDEBAR_PERCENT :: 0.20
DISPLAY_PERCENT :: 0.30 DISPLAY_PERCENT :: 0.30
CONTROLBAR_PERCENT :: 0.05 CONTROL_BAR_H :: f32(50)
STATUS_BAR_H :: f32(30)
Layout :: struct { Layout :: struct {
control_bar : rl.Rectangle, control_bar : rl.Rectangle,
@@ -33,11 +34,9 @@ run_gui :: proc(sim: ^Simulator) {
rl.SetTextureFilter(font.texture, .BILINEAR) rl.SetTextureFilter(font.texture, .BILINEAR)
sim.font = font sim.font = font
// Initialize style system first
rl.GuiLoadStyleDefault() rl.GuiLoadStyleDefault()
// Then load dark theme
rl.GuiLoadStyle("./assets/raygui_styles/style_dark.rgs") rl.GuiLoadStyle("./assets/raygui_styles/style_dark.rgs")
// Then override font AFTER (style load resets it)
rl.GuiSetFont(font) rl.GuiSetFont(font)
rl.GuiSetStyle(.DEFAULT, cast(i32)rl.GuiDefaultProperty.TEXT_SIZE, 18) rl.GuiSetStyle(.DEFAULT, cast(i32)rl.GuiDefaultProperty.TEXT_SIZE, 18)
@@ -56,7 +55,6 @@ run_gui :: proc(sim: ^Simulator) {
rl.ClearBackground(rl.BLACK) rl.ClearBackground(rl.BLACK)
// Cycle the machine to update memory etc // 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) { if (!sim.paused) {
emu.run_machine(sim.machine, 12) emu.run_machine(sim.machine, 12)
@@ -75,7 +73,7 @@ run_gui :: proc(sim: ^Simulator) {
} }
gui_control_bar(layout.control_bar, sim) 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) // gui_right_panel(layout.right_panel, s.machine)
// Screen is just drawing the display buffer just needs that as arg // 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(sim.font)
rl.UnloadFont(font)
rl.UnloadSound(beep) rl.UnloadSound(beep)
rl.CloseAudioDevice() rl.CloseAudioDevice()
rl.CloseWindow() rl.CloseWindow()
} }
// @TODO: If this grows lets move it into its own file // @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 { calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
control_bar = rl.Rectangle { sidebar_width := screen_width * SIDEBAR_PERCENT
x = 0, content_height := screen_height - CONTROL_BAR_H - STATUS_BAR_H
y = 0, display_height := screen_height * DISPLAY_PERCENT - CONTROL_BAR_H - STATUS_BAR_H
width = screen_width,
height = control_bar_height return Layout {
}, control_bar = rl.Rectangle {
left_panel = rl.Rectangle { x = 0,
x = 0, y = 0,
y = control_bar_height, width = screen_width,
width = sidebar_width, height = CONTROL_BAR_H,
height = sidebar_height },
}, left_panel = rl.Rectangle {
display = rl.Rectangle { x = 0,
x = sidebar_width, y = CONTROL_BAR_H,
y = control_bar_height, width = sidebar_width,
width = screen_width - (sidebar_width * 2), height = content_height,
height = display_height },
}, display = rl.Rectangle {
right_panel = rl.Rectangle { x = sidebar_width,
x = screen_width - sidebar_width, y = CONTROL_BAR_H,
y = control_bar_height, width = screen_width - (sidebar_width * 2),
width = sidebar_width, height = display_height,
height = sidebar_height },
}, right_panel = rl.Rectangle {
status_bar = rl.Rectangle { x = screen_width - sidebar_width,
x = 0, y = CONTROL_BAR_H,
y = screen_height - control_bar_height, width = sidebar_width,
width = screen_width, height = content_height,
height = control_bar_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" import rl "vendor:raylib"
Simulator :: struct { Simulator :: struct {
font: rl.Font,
machine: ^emu.System, machine: ^emu.System,
running: bool, running: bool,
paused: bool, paused: bool,
cycles_per_second: int cycles_per_second: int,
font: rl.Font,
} }
// Requires an initilized emulatore System Struct // Requires an initilized emulatore System Struct