Initial gui commit.

Very much WIP trying to find a good way to keep components self
contained and composable.
This commit is contained in:
2026-06-02 08:23:26 +02:00
parent 37da094469
commit cf572179ea
3 changed files with 137 additions and 6 deletions
+53
View File
@@ -0,0 +1,53 @@
package gui
import m "../machine"
import rl "vendor:raylib"
// Initial window size
WINDOW_WIDTH :: 1920
WINDOW_HEIGHT :: 1080
// Initialize main the gui 'window'
init_gui :: proc(s: ^m.System) {
rl.SetConfigFlags({.WINDOW_RESIZABLE})
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "raylib")
rl.InitAudioDevice()
rl.SetTargetFPS(60)
// Draw each of the components in its own window within the main window
for !rl.WindowShouldClose() {
// Recalculate layout each frame based on current window size
// Pass these down to gui functions so they can setup their sizes?
screen_width := f32(rl.GetScreenWidth())
screen_height := f32(rl.GetScreenHeight())
sidebar_width := screen_width * 0.20
display_rect := rl.Rectangle{
x = sidebar_width,
y = 0,
width = screen_width - (sidebar_width * 2),
height = screen_height * 0.30,
}
rl.BeginDrawing()
rl.ClearBackground(rl.BLACK)
// TODO: move this out / make better
// --------------------------------------
// CPU cycles
for _ in 0..<12 {
m.handle_input(s)
m.cycle(s)
}
// --------------------------------------
// run each gui "component"
gui_screen(display_rect, s)
rl.EndDrawing()
}
rl.CloseAudioDevice()
rl.CloseWindow()
}