From 9aee47c12c46b7abc2cabadeb1ab007517581070 Mon Sep 17 00:00:00 2001 From: Synthasmagoria Date: Wed, 9 Sep 2026 05:58:33 +0200 Subject: [PATCH] Animation modes - part 2 --- src/animation.odin | 9 ++++++++- src/program.odin | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/animation.odin b/src/animation.odin index d5ea02f..af6f155 100644 --- a/src/animation.odin +++ b/src/animation.odin @@ -239,7 +239,14 @@ animation_draw :: proc(animation: Animation, global_transform: mat3, mode: Anima rectangle_current_color := linalg.lerp(color_origin, color_end, animation_progress_fraction) draw_animation_rectangle_corners(rectangle_current, rl.Color(rectangle_current_color)) case .All: - + animation_progress := math.clamp(animation.matrix_index / f32(animation.matrix_count), 0.0, 1.0) + animation_progress = ease.ease(animation.ease, animation_progress) + color := linalg.lerp(color_origin, color_end, animation_progress) + rectangle_end := rectangle_corners_transform_mat3(transform, animation.shapes.rectangle) + rectangle_end_world := rectangle_corners_transform_mat3(global_transform, rectangle_end) + rectangle_origin_world := rectangle_corners_transform_mat3(global_transform, animation.shapes.rectangle) + rectangle := rectangle_corners_lerp(rectangle_origin_world, rectangle_end_world, animation_progress) + draw_animation_rectangle_corners(rectangle, rl.Color(color)) } } } diff --git a/src/program.odin b/src/program.odin index 9b133ed..491835f 100644 --- a/src/program.odin +++ b/src/program.odin @@ -878,8 +878,11 @@ program_build_workspace_ui :: proc(ctx: ^ui.Context) -> (elements: []ui.Element, ui.same_line() ui.element(.Label, ui.dimensions_auto(), label_config) - toggle_group_config := ui.ElementConfiguration{margin = button_margin, label = enum_to_raygui_options_string(AnimationMode, context.temp_allocator)} - toggle_group_dimensions := ui.Dimensions{top_bar_button_width * 2.0, ui.Size_Percentage(1.0)} + toggle_group_config := ui.ElementConfiguration{ + margin = button_margin, + label = enum_to_raygui_options_string(AnimationMode, context.temp_allocator), + tooltip = "Play animation\nstep by step;Play animation using the\nfull transformation matrix"} + toggle_group_dimensions := ui.Dimensions{top_bar_button_width * 3.0, ui.Size_Percentage(1.0)} toggle_group_data: ^UiElementData_ToggleGroup toggle_group_data = new(UiElementData_ToggleGroup, context.temp_allocator) toggle_group_data^ = {value = cast(^i32)&program.animation_mode} @@ -1170,7 +1173,17 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u rl.DrawRectangleRec(rect2(ui.get_element_outer_area(element)), color) case .ToggleGroup: data := cast(^UiElementData_ToggleGroup)element.data - rl.GuiToggleGroup(area, element.label, data.value) + tooltips := strings.string_from_ptr(transmute(^byte)element.tooltip, len(element.tooltip)) + area_individual := area + area_individual.width /= f32(strings.count(tooltips, ";") + 1) + mouse := rl.GetMousePosition() + rl.GuiToggleGroup(area_individual, element.label, data.value) + if len(element.tooltip) > 0 && rect_has_point(area, mouse) { + tooltips_split := strings.split(tooltips, ";", context.temp_allocator) + tooltip_index := int((mouse.x - area_individual.x) / area_individual.width) + tooltip_text = strings.clone_to_cstring(tooltips_split[tooltip_index], context.temp_allocator) + tooltip_position = mouse + } case: rl.DrawRectangleRec(area, rl.MAGENTA) }