Started on ui
This commit is contained in:
parent
af82f9c2d4
commit
0ffaf7bb93
2 changed files with 42 additions and 5 deletions
43
program.odin
43
program.odin
|
|
@ -97,12 +97,47 @@ program_init :: proc(allocator := context.allocator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
program_update :: proc() {
|
program_update :: proc() {
|
||||||
|
ui_elements := program_build_ui()
|
||||||
|
program_render_ui(ui_elements)
|
||||||
}
|
}
|
||||||
|
|
||||||
program_build_ui :: proc() {
|
program_build_ui :: proc() -> []ui.Element {
|
||||||
|
container_margin: f32 = 4.0
|
||||||
|
container_config := ui.ElementConfiguration {
|
||||||
|
margin = V2_ONE * container_margin,
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.start(&program.ui_context, {0, 0}, {WINDOW_WIDTH, WINDOW_HEIGHT})
|
||||||
|
top_bar_container := ui.container_begin({ui.Size_Percentage(1.0), ui.Size_Pixels(64.0)}, container_config)
|
||||||
|
top_bar_inner_height := ui.get_element_inner_area(top_bar_container^).height
|
||||||
|
top_bar_button_dimensions := ui.Dimensions {ui.Size_Pixels(top_bar_inner_height), ui.Size_Pixels(top_bar_inner_height)}
|
||||||
|
top_bar_button_config := ui.ElementConfiguration {margin = {4.0, 4.0}}
|
||||||
|
{
|
||||||
|
config := top_bar_button_config
|
||||||
|
config.label = "+"
|
||||||
|
ui.button(top_bar_button_dimensions, config)
|
||||||
|
config.label = "-"
|
||||||
|
ui.same_line()
|
||||||
|
ui.button(top_bar_button_dimensions, config)
|
||||||
|
}
|
||||||
|
ui.container_end()
|
||||||
|
|
||||||
|
side_bar_container := ui.container_begin({ui.Size_Percentage(0.3), ui.Size_Percentage(1.0)}, container_config)
|
||||||
|
ui.container_end()
|
||||||
|
return ui.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
program_render_ui :: proc() {
|
program_render_ui :: proc(elements: []ui.Element) {
|
||||||
|
for element in elements {
|
||||||
|
area := rl.Rectangle(element.area)
|
||||||
|
switch element.type {
|
||||||
|
case .Container:
|
||||||
|
rl.GuiGroupBox(area, element.label)
|
||||||
|
case .Button:
|
||||||
|
rl.GuiButton(area, element.label)
|
||||||
|
case .Slider:
|
||||||
|
data := element.data.float_input_data
|
||||||
|
rl.GuiSlider(area, element.label, "", data.value, data.min, data.max)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ irect2 :: struct {x, y, width, height: i32}
|
||||||
tri2 :: [3]v2
|
tri2 :: [3]v2
|
||||||
Bezier :: [3]v2
|
Bezier :: [3]v2
|
||||||
|
|
||||||
|
V2_ONE :: v2{1.0, 1.0}
|
||||||
|
|
||||||
/// ### MISCELANIOUS ### ///
|
/// ### MISCELANIOUS ### ///
|
||||||
enum_to_raygui_options_string :: proc($T: typeid, allocator: mem.Allocator) -> cstring where intrinsics.type_is_enum(T) {
|
enum_to_raygui_options_string :: proc($T: typeid, allocator: mem.Allocator) -> cstring where intrinsics.type_is_enum(T) {
|
||||||
b := strings.builder_make(allocator)
|
b := strings.builder_make(allocator)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue