Added a better way for drawing ui elements.

This commit is contained in:
2026-06-05 08:10:41 +02:00
parent 141aea0fc4
commit 2df6a14610
+21 -2
View File
@@ -1,11 +1,30 @@
package gui package gui
import "core:log"
import m "../machine" import m "../machine"
import rl "vendor:raylib" import rl "vendor:raylib"
CB_PADDING :: 20 PADDING :: 10
gui_control_bar :: proc(rect: rl.Rectangle, s: ^m.System) { gui_control_bar :: proc(rect: rl.Rectangle, s: ^m.System) {
rl.DrawRectangleLinesEx(rect, 1, rl.DARKGRAY) rl.DrawRectangleLinesEx(rect, 1, rl.DARKGRAY)
rl.GuiButton(rl.Rectangle{rect.x, rect.y, 100, rect.height}, "test")
// Small text area
// Control bar buttons
btn_w : f32 = 80
btn_h : f32 = rect.height - (PADDING * 2)
gap : f32 = 6
cursor : f32 = rect.x + PADDING
if btn(&cursor, rect, btn_h, btn_w, gap, "RUN") { log.info("RUN clicked") }
if btn(&cursor, rect, btn_h, btn_w, gap, "PAUSE") { log.info("PAUSE clicked") }
if btn(&cursor, rect, btn_h, btn_w, gap, "STEP") { log.info("STEP clicked") }
if btn(&cursor, rect, btn_h, btn_w, gap, "STOP") { log.info("STOP clicked") }
}
btn :: proc(cursor: ^f32, rect: rl.Rectangle, h, w, gap: f32, label: cstring) -> bool {
r := rl.Rectangle{cursor^, rect.y + PADDING, w, h}
cursor^ += w + gap
return rl.GuiButton(r, label)
} }