Reset view
This commit is contained in:
parent
2a302f7b1d
commit
07732bd2ae
3 changed files with 26 additions and 6 deletions
22
program.odin
22
program.odin
|
|
@ -72,6 +72,7 @@ UiButtonType :: enum {
|
|||
MatrixDelete,
|
||||
MatrixMoveUp,
|
||||
MatrixMoveDown,
|
||||
CenterView,
|
||||
}
|
||||
|
||||
UiButtonRecalculateFinishGroup :: bit_set[UiButtonType]{
|
||||
|
|
@ -609,23 +610,29 @@ program_build_workspace_ui :: proc(ctx: ^ui.Context) ->
|
|||
button_data = new(UiElementData_Button, context.temp_allocator)
|
||||
switch program.animation_state {
|
||||
case .Ready:
|
||||
button_config.label = RAYGUI_ICON_PLAY
|
||||
button_config = {margin = button_margin, label = RAYGUI_ICON_PLAY, tooltip = "Play\nanimation"}
|
||||
button_data^ = {type = .StartTransformation}
|
||||
case .Paused:
|
||||
button_config.label = RAYGUI_ICON_PLAY
|
||||
button_config = {margin = button_margin, label = RAYGUI_ICON_PLAY, tooltip = "Resume\nanimation"}
|
||||
button_data^ = {type = .ResumeTransformation}
|
||||
case .Playing:
|
||||
button_config.label = RAYGUI_ICON_PAUSE
|
||||
button_config = {margin = button_margin, label = RAYGUI_ICON_PAUSE, tooltip = "Pause\nanimation"}
|
||||
button_data^ = {type = .PauseTransformation}
|
||||
}
|
||||
ui.same_line()
|
||||
ui.element(.Button, button_dimensions, button_config, button_data)
|
||||
|
||||
button_config = {margin = button_margin, label = RAYGUI_ICON_RESET, tooltip = "Reset\nanimation"}
|
||||
button_data = new(UiElementData_Button, context.temp_allocator)
|
||||
button_config.label = RAYGUI_ICON_RESET
|
||||
button_data^ = {type = .ResetTransformation}
|
||||
ui.same_line()
|
||||
ui.element(.Button, button_dimensions, button_config, button_data)
|
||||
|
||||
button_config = {margin = button_margin, label = "1", tooltip = "Center\nanimation"}
|
||||
button_data = new(UiElementData_Button, context.temp_allocator)
|
||||
button_data^ = {type = .CenterView}
|
||||
ui.same_line()
|
||||
ui.element(.Button, button_dimensions, button_config, button_data)
|
||||
}
|
||||
ui.container_end()
|
||||
|
||||
|
|
@ -867,6 +874,13 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u
|
|||
case .MatrixMoveDown:
|
||||
if data.target_matrix + 1 >= program.matrix_count do break;
|
||||
matrix_move_to(program.matrix_float_pool, program.matrix_value_string_pool, data.target_matrix, data.target_matrix + 1)
|
||||
case .CenterView:
|
||||
// TODO (synthas): Could be improved to center the whole animation
|
||||
// TODO (synthas): Reset zoom
|
||||
world_to_grid_matrix := grid_world_to_grid_matrix(program.grid.zoom, program.grid.offset)
|
||||
grid_to_world_matrix := linalg.inverse(world_to_grid_matrix)
|
||||
center := animation_get_center(program.animation) / grid_get_zoom(program.grid.zoom) - program.grid.world_size / 2.0
|
||||
program.grid.offset = center
|
||||
}
|
||||
if data.type in UiButtonRecalculateFinishGroup {
|
||||
program.animation.matrix_count = program.matrix_count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue