Removed unneeded components, renamed reused.

Updated the components to start with a gui_ prefix, changed the layout
idea that each component is responsible for their own bounding box and
inner content.
This commit is contained in:
2026-06-17 07:46:24 +02:00
parent baca22a004
commit cccc4fb06c
5 changed files with 32 additions and 184 deletions
+62
View File
@@ -0,0 +1,62 @@
package simulator
import "core:fmt"
import rl "vendor:raylib"
StatusIconShape :: enum { CIRCLE, SQUARE }
// @TODO: render status bar text
gui_status_bar :: proc(rect: rl.Rectangle, sim: ^Simulator) {
// Left to right text draws
rl.DrawRectangleLinesEx(rect, 1, rl.DARKGRAY)
cursor: f32 = rect.x + PADDING_X
cy := rect.y + rect.height * 0.5
if sim.running && !sim.paused {
status_icon(&cursor, cy, rl.GREEN, .CIRCLE, "Running", sim.font)
} else {
status_icon(&cursor, cy, rl.RED, .SQUARE, "Paused", sim.font)
}
status_divider(&cursor, cy)
status_text(&cursor, cy, fmt.ctprintf("Rom Loaded: %v", sim.rom_loaded), sim.font)
// FPS set far right
fps_text := fmt.ctprintf("FPS: %d", rl.GetFPS())
fps_width := rl.MeasureTextEx(sim.font, fps_text, f32(sim.font.baseSize), 1).x
fps_x := rect.x + rect.width - PADDING_X - fps_width
rl.DrawTextEx(
sim.font,
fps_text,
{fps_x, cy - f32(sim.font.baseSize) * 0.5},
f32(sim.font.baseSize),
1,
rl.RAYWHITE,
)
}
status_icon :: proc(cursor: ^f32, cy: f32, color: rl.Color, shape: StatusIconShape, label: cstring, font: rl.Font) {
size: f32 = 10
ix := cursor^ + size * 0.5
switch shape {
case .CIRCLE: rl.DrawCircleV({ix, cy}, size * 0.5, color)
case .SQUARE: rl.DrawRectangleV({ix - size*0.5, cy - size*0.5}, {size, size}, color)
}
cursor^ += size + 6
rl.DrawTextEx(font, label, {cursor^, cy - f32(font.baseSize) * 0.5}, f32(font.baseSize), 1, rl.RAYWHITE)
cursor^ += rl.MeasureTextEx(font, label, f32(font.baseSize), 1).x + PADDING_X
}
status_divider :: proc(cursor: ^f32, cy: f32) {
rl.DrawLineV({cursor^, cy - 8}, {cursor^, cy + 8}, rl.DARKGRAY)
cursor^ += PADDING_X
}
status_text :: proc(cursor: ^f32, cy: f32, text: cstring, font: rl.Font) {
rl.DrawTextEx(font, text, {cursor^, cy - f32(font.baseSize) * 0.5}, f32(font.baseSize), 1, rl.RAYWHITE)
cursor^ += rl.MeasureTextEx(font, text, f32(font.baseSize), 1).x + PADDING_X
}