Easier interface use
This commit is contained in:
parent
18e6f23d2b
commit
4261f07762
3 changed files with 73 additions and 29 deletions
34
program.odin
34
program.odin
|
|
@ -5,6 +5,7 @@ import ui "libraries/snths_ui"
|
|||
import "core:fmt"
|
||||
import "core:math/linalg"
|
||||
import "core:math/ease"
|
||||
import "core:math"
|
||||
|
||||
RAYGUI_ICON_PLAY :: "#131#"
|
||||
RAYGUI_ICON_PAUSE :: "#132#"
|
||||
|
|
@ -256,7 +257,7 @@ program_set_transformation_state :: proc(state: AnimationState) {
|
|||
switch program.animation_state {
|
||||
case .Ready:
|
||||
program.animation_matrix_index = -1
|
||||
program.animation.reset(&program.animation)
|
||||
animation_reset(&program.animation)
|
||||
case .Playing:
|
||||
|
||||
case .Paused:
|
||||
|
|
@ -264,6 +265,10 @@ program_set_transformation_state :: proc(state: AnimationState) {
|
|||
}
|
||||
}
|
||||
|
||||
float_slice_get_mat3 :: proc(floats: []f32, index: int) -> ^mat3 {
|
||||
return cast(^mat3)(&floats[index * 9])
|
||||
}
|
||||
|
||||
program_update :: proc() {
|
||||
ui_elements, matrix_container := program_build_workspace_ui(&program.ui_context)
|
||||
ui_overlay_elements: []ui.Element
|
||||
|
|
@ -305,7 +310,7 @@ program_update :: proc() {
|
|||
case .CreateScaleMatrix: program_add_scalar_matrix(vals[0], vals[1], vals[2])
|
||||
case .CreateRotationMatrix: program_add_rotation_matrix(vals[0])
|
||||
}
|
||||
program.animation.update_last(&program.animation, program_get_master_matrix())
|
||||
animation_update_last(&program.animation, program_get_master_matrix())
|
||||
program.state = .Normal
|
||||
}
|
||||
}
|
||||
|
|
@ -317,16 +322,23 @@ program_update :: proc() {
|
|||
if program.animation_state == .Playing {
|
||||
program.animation_matrix_progress += program.animation_speed * delta_time_fraction()
|
||||
if program.animation_matrix_progress >= 1.0 {
|
||||
program.animation_matrix_progress = 1.0;
|
||||
if program.animation_matrix_index + 1 < program.matrix_count {
|
||||
program.animation_matrix_index += 1
|
||||
animation_next_matrix(&program.animation, float_slice_get_mat3(program.matrix_float_pool, program.animation_matrix_index)^)
|
||||
program.animation_matrix_progress = fract(program.animation_matrix_progress)
|
||||
} else {
|
||||
program.animation_matrix_progress = 1.0;
|
||||
program.animation_state = .Finished
|
||||
}
|
||||
}
|
||||
program.animation.update(&program.animation, ease.ease(program.animation_ease, program.animation_matrix_progress))
|
||||
animation_update(&program.animation, ease.ease(program.animation_ease, program.animation_matrix_progress))
|
||||
}
|
||||
|
||||
switch program.animation_state {
|
||||
case .Ready:
|
||||
program.animation.draw_idle(program.animation)
|
||||
animation_draw_idle(program.animation)
|
||||
case .Playing, .Paused, .Finished:
|
||||
program.animation.draw_active(program.animation)
|
||||
animation_draw_active(program.animation)
|
||||
}
|
||||
|
||||
ui_element_focus := program.state == .Normal ? program.ui_element_focus : ui.element_id_invalid()
|
||||
|
|
@ -620,18 +632,18 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u
|
|||
case .StartTransformation:
|
||||
if program.matrix_count > 0 {
|
||||
program.animation_state = .Playing
|
||||
program.animation.reset(&program.animation)
|
||||
program.animation.next_matrix(&program.animation, (cast(^mat3)raw_data(program.matrix_float_pool))^)
|
||||
animation_reset(&program.animation)
|
||||
animation_next_matrix(&program.animation, (cast(^mat3)raw_data(program.matrix_float_pool))^)
|
||||
}
|
||||
case .PauseTransformation:
|
||||
program.animation_state = .Paused
|
||||
case .ResumeTransformation:
|
||||
program.animation_state = .Playing
|
||||
case .ResetTransformation:
|
||||
program.animation.reset(&program.animation)
|
||||
animation_reset(&program.animation)
|
||||
}
|
||||
if data.type in UiButtonRecalculateFinishGroup {
|
||||
program.animation.update_last(&program.animation, program_get_master_matrix())
|
||||
animation_update_last(&program.animation, program_get_master_matrix())
|
||||
}
|
||||
}
|
||||
case .Slider:
|
||||
|
|
@ -644,7 +656,7 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u
|
|||
focus_element_id = element.id
|
||||
}
|
||||
if value_previous != data.value^ && .UpdateMatrix in data.tag {
|
||||
program.animation.update_last(&program.animation, program_get_master_matrix())
|
||||
animation_update_last(&program.animation, program_get_master_matrix())
|
||||
}
|
||||
case .Dropdown:
|
||||
assert(element.data != nil, "Element data cannot be nil when creating a dropdown")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue