Text element
This commit is contained in:
parent
316ec8e178
commit
a02960283c
4 changed files with 194 additions and 132 deletions
61
program.odin
61
program.odin
|
|
@ -9,38 +9,67 @@ WINDOW_HEIGHT :: 720
|
|||
WINDOW_FRAMERATE :: 30
|
||||
WINDOW_CAPTION :: "Transformation Visualizer"
|
||||
|
||||
value: i32
|
||||
ui_style := UiStyle{margin = 4.0, padding = 4.0}
|
||||
ui_state: UiState
|
||||
program: Program
|
||||
|
||||
Program :: struct {
|
||||
ui_state: UiState,
|
||||
matrices: [dynamic; 1024]f32,
|
||||
matrix_type: MatrixType,
|
||||
}
|
||||
|
||||
MatrixType :: enum {
|
||||
Mat2,
|
||||
Mat3,
|
||||
Mat4,
|
||||
}
|
||||
|
||||
@rodata matrix_type_table := [MatrixType]typeid {
|
||||
.Mat2 = mat2,
|
||||
.Mat3 = mat3,
|
||||
.Mat4 = mat4,
|
||||
}
|
||||
|
||||
init :: proc() {
|
||||
rl.SetTraceLogLevel(.WARNING)
|
||||
rl.SetConfigFlags({.WINDOW_RESIZABLE, .VSYNC_HINT})
|
||||
rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_CAPTION)
|
||||
rl.SetTargetFPS(WINDOW_FRAMERATE)
|
||||
ui_init(&ui_state, ui_style, {0, 0}, context.temp_allocator)
|
||||
|
||||
ui_style := UiStyle{
|
||||
margin = 4.0,
|
||||
padding = 4.0,
|
||||
font = rl.GetFontDefault(),
|
||||
font_size = 16.0,
|
||||
font_sep = 1.0
|
||||
}
|
||||
ui_init(&program.ui_state, ui_style, {0, 0}, context.temp_allocator)
|
||||
}
|
||||
|
||||
update :: proc() {
|
||||
if rl.IsMouseButtonPressed(.LEFT) {
|
||||
ui_element_focus_reset(&ui_state)
|
||||
ui_element_focus_reset(&program.ui_state)
|
||||
}
|
||||
|
||||
rl.BeginDrawing()
|
||||
defer rl.EndDrawing()
|
||||
rl.ClearBackground(rl.BLACK)
|
||||
|
||||
ui_start(&ui_state)
|
||||
ui_button_size_top_bar := v2{32.0, 32.0}
|
||||
ui_start(&program.ui_state)
|
||||
ui_container_begin({label = ""})
|
||||
ui_button_size := v2{192.0, 32.0}
|
||||
ui_button(ui_button_size, {label = "Hi"})
|
||||
ui_button(ui_button_size_top_bar, {label = "#10#"})
|
||||
ui_same_line()
|
||||
ui_button(ui_button_size, {label = "Hi"})
|
||||
ui_button(ui_button_size_top_bar, {label = "#11#"})
|
||||
ui_same_line()
|
||||
ui_button(ui_button_size, {label = "Hi"})
|
||||
ui_input(ui_button_size, {label = "", value = &value, min = 0, max = 10})
|
||||
ui_button(ui_button_size_top_bar, {label = "#12#"})
|
||||
ui_container_end()
|
||||
ui_container_begin({label = "Matrices"})
|
||||
if len(program.matrices) == 0 {
|
||||
ui_text({text = "Add matrices", color = rl.WHITE})
|
||||
} else {
|
||||
|
||||
}
|
||||
ui_container_end()
|
||||
ui_button(ui_button_size, {label = "notheunoehunh"})
|
||||
ui_elements := ui_end()
|
||||
|
||||
for element in ui_elements {
|
||||
|
|
@ -50,9 +79,9 @@ update :: proc() {
|
|||
rl.GuiButton(element.area, data.label)
|
||||
case .Input:
|
||||
data := element.data.(UiElementData_Input)
|
||||
edit_mode := ui_element_is_editing(ui_state, element.id)
|
||||
edit_mode := ui_element_is_editing(program.ui_state, element.id)
|
||||
if (rl.GuiValueBox(element.area, "", data.value, data.min, data.max, edit_mode) == 1) {
|
||||
ui_element_focus(&ui_state, element.id)
|
||||
ui_element_focus(&program.ui_state, element.id)
|
||||
}
|
||||
case .Container:
|
||||
data := element.data.(UiElementData_Container)
|
||||
|
|
@ -61,6 +90,10 @@ update :: proc() {
|
|||
} else {
|
||||
rl.GuiGroupBox(element.area, data.label)
|
||||
}
|
||||
case .Text:
|
||||
data := element.data.(UiElementData_Text)
|
||||
style := program.ui_state.style
|
||||
rl.DrawTextEx(style.font, data.text, rect_get_tl(element.area), style.font_size, style.font_sep, data.color)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue