Prepping for adding matrices
This commit is contained in:
parent
a90cfcae06
commit
e39d2db161
1 changed files with 38 additions and 20 deletions
58
program.odin
58
program.odin
|
|
@ -62,6 +62,7 @@ FontStyle :: struct {
|
|||
ProgramState :: enum {
|
||||
Normal,
|
||||
Message,
|
||||
Dialog,
|
||||
}
|
||||
|
||||
MouseState :: enum {
|
||||
|
|
@ -70,6 +71,18 @@ MouseState :: enum {
|
|||
HoverMatrices,
|
||||
}
|
||||
|
||||
ProgramDialogType :: enum {
|
||||
CreateTranslationMatrix,
|
||||
CreateScaleMatrix,
|
||||
CreateRotationMatrix,
|
||||
}
|
||||
|
||||
@rodata program_dialog_messages := [ProgramDialogType]cstring {
|
||||
.CreateTranslationMatrix = "Create tranlation matrix",
|
||||
.CreateScaleMatrix = "Create scale matrix",
|
||||
.CreateRotationMatrix = "Create rotation matrix",
|
||||
}
|
||||
|
||||
ProgramMessageType :: enum {
|
||||
ChangeMatrixTypeClearData,
|
||||
}
|
||||
|
|
@ -159,29 +172,34 @@ program_update :: proc() {
|
|||
|
||||
ui_elements, matrix_container := program_build_ui()
|
||||
|
||||
mouse := rl.GetMousePosition()
|
||||
switch program.mouse_state {
|
||||
case .Hover:
|
||||
if rl.IsMouseButtonPressed(.LEFT) {
|
||||
program.mouse_state = .DraggingGrid
|
||||
} else if rect_has_point(rect2(matrix_container.area), mouse) {
|
||||
program.mouse_state = .HoverMatrices
|
||||
switch program.state {
|
||||
case .Normal:
|
||||
mouse := rl.GetMousePosition()
|
||||
switch program.mouse_state {
|
||||
case .Hover:
|
||||
if rl.IsMouseButtonPressed(.LEFT) {
|
||||
program.mouse_state = .DraggingGrid
|
||||
} else if rect_has_point(rect2(matrix_container.area), mouse) {
|
||||
program.mouse_state = .HoverMatrices
|
||||
}
|
||||
case .DraggingGrid:
|
||||
program.grid.inner_area = rect_translate(program.grid.inner_area, rl.GetMouseDelta())
|
||||
if !rl.IsMouseButtonDown(.LEFT) {
|
||||
program.mouse_state = .Hover
|
||||
}
|
||||
case .HoverMatrices:
|
||||
program.matrix_scroll = max(0, program.matrix_scroll - rl.GetMouseWheelMove() * program.matrix_scroll_speed)
|
||||
if !rect_has_point(rect2(matrix_container.area), mouse) {
|
||||
program.mouse_state = .Hover
|
||||
}
|
||||
}
|
||||
case .DraggingGrid:
|
||||
program.grid.inner_area = rect_translate(program.grid.inner_area, rl.GetMouseDelta())
|
||||
if !rl.IsMouseButtonDown(.LEFT) {
|
||||
program.mouse_state = .Hover
|
||||
}
|
||||
case .HoverMatrices:
|
||||
program.matrix_scroll = max(0, program.matrix_scroll - rl.GetMouseWheelMove() * program.matrix_scroll_speed)
|
||||
if !rect_has_point(rect2(matrix_container.area), mouse) {
|
||||
program.mouse_state = .Hover
|
||||
if rl.IsKeyPressed(.TAB) {
|
||||
program.ui_element_focus = ui.focus_next_element(program.ui_element_focus, ui_elements, {.InputFloat})
|
||||
}
|
||||
case .Message:
|
||||
case .Dialog:
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(.TAB) {
|
||||
program.ui_element_focus = ui.focus_next_element(program.ui_element_focus, ui_elements, {.InputFloat})
|
||||
}
|
||||
|
||||
grid := program.grid
|
||||
grid_inner_position := rect_get_tl(grid.inner_area)
|
||||
|
|
@ -208,7 +226,7 @@ program_build_ui :: proc() -> (elements: []ui.Element, matrix_container: ^ui.Ele
|
|||
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 = top_bar_element_margin}
|
||||
top_bar_dropdown_dimensions := ui.Dimensions {ui.Size_Pixels(192.0), ui.Size_Percentage(1.0)}
|
||||
top_bar_dropdown_dimensions := ui.Dimensions {ui.Size_Pixels(160.0), ui.Size_Percentage(1.0)}
|
||||
top_bar_dropdown_config := ui.ElementConfiguration {margin = top_bar_element_margin}
|
||||
{
|
||||
button_config := top_bar_button_config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue