Small cleanup and fixed height control/status bars.
This commit is contained in:
+16
-20
@@ -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 {
|
calc_layout :: proc(screen_width: f32, screen_height: f32) -> Layout {
|
||||||
control_bar_height := screen_height * CONTROLBAR_PERCENT
|
|
||||||
sidebar_width := screen_width * SIDEBAR_PERCENT
|
sidebar_width := screen_width * SIDEBAR_PERCENT
|
||||||
sidebar_height := screen_height - control_bar_height
|
content_height := screen_height - CONTROL_BAR_H - STATUS_BAR_H
|
||||||
display_height := screen_height * DISPLAY_PERCENT - control_bar_height
|
display_height := screen_height * DISPLAY_PERCENT - CONTROL_BAR_H - STATUS_BAR_H
|
||||||
|
|
||||||
return Layout {
|
return Layout {
|
||||||
control_bar = rl.Rectangle {
|
control_bar = rl.Rectangle {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
width = screen_width,
|
width = screen_width,
|
||||||
height = control_bar_height
|
height = CONTROL_BAR_H,
|
||||||
},
|
},
|
||||||
left_panel = rl.Rectangle {
|
left_panel = rl.Rectangle {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = control_bar_height,
|
y = CONTROL_BAR_H,
|
||||||
width = sidebar_width,
|
width = sidebar_width,
|
||||||
height = sidebar_height
|
height = content_height,
|
||||||
},
|
},
|
||||||
display = rl.Rectangle {
|
display = rl.Rectangle {
|
||||||
x = sidebar_width,
|
x = sidebar_width,
|
||||||
y = control_bar_height,
|
y = CONTROL_BAR_H,
|
||||||
width = screen_width - (sidebar_width * 2),
|
width = screen_width - (sidebar_width * 2),
|
||||||
height = display_height
|
height = display_height,
|
||||||
},
|
},
|
||||||
right_panel = rl.Rectangle {
|
right_panel = rl.Rectangle {
|
||||||
x = screen_width - sidebar_width,
|
x = screen_width - sidebar_width,
|
||||||
y = control_bar_height,
|
y = CONTROL_BAR_H,
|
||||||
width = sidebar_width,
|
width = sidebar_width,
|
||||||
height = sidebar_height
|
height = content_height,
|
||||||
},
|
},
|
||||||
status_bar = rl.Rectangle {
|
status_bar = rl.Rectangle {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = screen_height - control_bar_height,
|
y = screen_height - STATUS_BAR_H,
|
||||||
width = screen_width,
|
width = screen_width, height = STATUS_BAR_H,
|
||||||
height = control_bar_height
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user