Cleaning up ui components making uniform.

This commit is contained in:
2026-06-13 09:31:32 +02:00
parent d28aa8a401
commit 2c664b24a9
4 changed files with 138 additions and 93 deletions
+74 -55
View File
@@ -8,26 +8,25 @@ WINDOW_WIDTH :: 1920
WINDOW_HEIGHT :: 1080
// @TODO: If this grows lets move it into its own file
// ─── Layout constants ───────────────────────────────────────────────────
SIDEBAR_PERCENT :: 0.20
DISPLAY_PERCENT :: 0.30
CONTROL_BAR_H :: f32(50)
STATUS_BAR_H :: f32(30)
// ─── Layout constants ───────────────────────────────────────────────────
PANEL_PADDING :: 10
PANEL_HEADER :: 24
BUTTON_HEIGHT :: 30
BUTTON_WIDTH :: 120
DROP_FONT_SIZE :: 20
KEYPAD_FONT_SIZE :: 18
PANEL_PADDING :: 10
PANEL_HEADER :: 24
BUTTON_HEIGHT :: 30
BUTTON_WIDTH :: 120
BIG_FONT_SIZE :: 20
KEYPAD_FONT_SIZE :: 18
Layout :: struct {
control_bar : rl.Rectangle,
left_panel : rl.Rectangle,
display : rl.Rectangle,
right_panel : rl.Rectangle,
status_bar : rl.Rectangle,
control_bar : rl.Rectangle,
left_panel : rl.Rectangle,
display : rl.Rectangle,
bottom_panel : rl.Rectangle,
right_panel : rl.Rectangle,
status_bar : rl.Rectangle,
}
// Initialize main the gui 'window'
@@ -63,8 +62,8 @@ run_gui :: proc(sim: ^Simulator) {
rl.BeginDrawing()
rl.ClearBackground(rl.BLACK)
// Cycle the machine to update memory etc
if (!sim.paused) {
// Cycle the machine to update memory etc
emu.run_machine(sim.machine, 12)
// Handle delay timer
@@ -78,16 +77,11 @@ run_gui :: proc(sim: ^Simulator) {
} else {
rl.StopSound(beep)
}
}
gui_control_bar(layout.control_bar, sim)
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
// Not the whole sim struct
gui_screen(layout.display, sim.machine)
gui_screen(layout.display, sim)
gui_status_bar(layout.status_bar, sim)
rl.EndDrawing()
@@ -101,39 +95,64 @@ run_gui :: proc(sim: ^Simulator) {
// @TODO: If this grows lets move it into its own file
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
top_h := CONTROL_BAR_H
bottom_h := STATUS_BAR_H
content_h := screen_height - top_h - bottom_h
content_y := top_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,
},
}
sidebar_w := screen_width * SIDEBAR_PERCENT
screen_h_ratio := 0.40
bottom_panel_h := content_h * f32(1.0 - screen_h_ratio)
screen_h := content_h * f32(screen_h_ratio)
memory_h := content_h - screen_h
center_x := sidebar_w
center_w := screen_width - sidebar_w * 2
return Layout {
control_bar = rl.Rectangle{
x = 0,
y = 0,
width = screen_width,
height = top_h,
},
left_panel = rl.Rectangle{
x = 0,
y = top_h,
width = sidebar_w,
height = content_h,
},
// CHIP-8 screen (top center)
display = rl.Rectangle{
x = center_x,
y = top_h,
width = center_w,
height = screen_h,
},
// MEMORY / DEBUG panel (bottom center)
bottom_panel = rl.Rectangle{
x = center_x,
y = top_h + screen_h,
width = center_w,
height = memory_h,
},
right_panel = rl.Rectangle{
x = screen_width - sidebar_w,
y = top_h,
width = sidebar_w,
height = content_h,
},
status_bar = rl.Rectangle{
x = 0,
y = screen_height - bottom_h,
width = screen_width,
height = bottom_h,
},
}
}