From 472c8df99bdc916889d426683c428110360fc87a Mon Sep 17 00:00:00 2001 From: carterwilson1337 Date: Wed, 29 Oct 2025 05:02:56 -0400 Subject: [PATCH] Track groups in Animation tab hover highlight Co-authored-by: Silc Lizard (Tokage) Renew Co-authored-by: Tomasz Chabora --- editor/animation/animation_track_editor.cpp | 29 +++++++++++++++++++++ editor/animation/animation_track_editor.h | 2 ++ editor/themes/theme_classic.cpp | 4 +++ editor/themes/theme_modern.cpp | 4 +++ 4 files changed, 39 insertions(+) diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index 5abf088fd67..ac3d8654b68 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -3756,6 +3756,8 @@ void AnimationTrackEditGroup::_notification(int p_what) { const Color v_line_color = get_theme_color(SNAME("v_line_color"), SNAME("AnimationTrackEditGroup")); const int h_separation = get_theme_constant(SNAME("h_separation"), SNAME("AnimationTrackEditGroup")); + const Ref &stylebox_hover = get_theme_stylebox(SceneStringName(hover), SNAME("AnimationTrackEditGroup")); + if (root) { Node *n = root->get_node_or_null(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { @@ -3765,6 +3767,13 @@ void AnimationTrackEditGroup::_notification(int p_what) { draw_style_box(stylebox_header, Rect2(Point2(), get_size())); + if (hovered) { + // Draw hover feedback for AnimationTrackEditGroup. + // Add a limit to just show hover over portion with text. + int limit = timeline->get_name_limit(); + draw_style_box(stylebox_hover, Rect2(Point2(1 * EDSCALE, 0), Size2(limit - 1 * EDSCALE, get_size().height))); + } + int limit = timeline->get_name_limit(); // Section preview. @@ -3839,6 +3848,14 @@ void AnimationTrackEditGroup::_notification(int p_what) { draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } break; + + case NOTIFICATION_MOUSE_EXIT: { + if (hovered) { + hovered = false; + // When the mouse cursor exits the AnimationTrackEditGroup, we're no longer hovering the group. + queue_redraw(); + } + } break; } } @@ -3859,6 +3876,18 @@ void AnimationTrackEditGroup::gui_input(const Ref &p_event) { } } } + Ref mm = p_event; + if (mm.is_valid()) { + Point2 pos = mm->get_position(); + Rect2 node_name_rect = Rect2(0, 0, timeline->get_name_limit(), get_size().height); + + bool was_hovered = hovered; + hovered = node_name_rect.has_point(pos); + + if (was_hovered != hovered) { + queue_redraw(); + } + } } void AnimationTrackEditGroup::set_type_and_name(const Ref &p_type, const String &p_name, const NodePath &p_node) { diff --git a/editor/animation/animation_track_editor.h b/editor/animation/animation_track_editor.h index 8e80a5bc35d..fe877170583 100644 --- a/editor/animation/animation_track_editor.h +++ b/editor/animation/animation_track_editor.h @@ -566,6 +566,8 @@ class AnimationTrackEditGroup : public Control { AnimationTimelineEdit *timeline = nullptr; AnimationTrackEditor *editor = nullptr; + bool hovered = false; + void _zoom_changed(); protected: diff --git a/editor/themes/theme_classic.cpp b/editor/themes/theme_classic.cpp index 146d811fd41..b97e18a7e1c 100644 --- a/editor/themes/theme_classic.cpp +++ b/editor/themes/theme_classic.cpp @@ -2148,6 +2148,10 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header); + Ref style_animation_track_group_hover = p_config.base_style->duplicate(); + style_animation_track_group_hover->set_bg_color(p_config.highlight_color); + p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEditGroup", style_animation_track_group_hover); + p_theme->set_color("h_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2)); p_theme->set_color("v_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2)); diff --git a/editor/themes/theme_modern.cpp b/editor/themes/theme_modern.cpp index 69eb6fbc3f8..0111099c60c 100644 --- a/editor/themes/theme_modern.cpp +++ b/editor/themes/theme_modern.cpp @@ -2130,6 +2130,10 @@ void ThemeModern::populate_editor_styles(const Ref &p_theme, Editor p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header); + Ref style_animation_track_group_hover = p_config.base_style->duplicate(); + style_animation_track_group_hover->set_bg_color(p_config.highlight_color); + p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEditGroup", style_animation_track_group_hover); + p_theme->set_color("bg_color", "AnimationTrackEditGroup", p_config.surface_base_color); p_theme->set_color("h_line_color", "AnimationTrackEditGroup", Color(1, 1, 1, 0)); p_theme->set_color("v_line_color", "AnimationTrackEditGroup", Color(1, 1, 1, 0));