Skip to content

Commit ba44671

Browse files
committed
Merge pull request godotengine#112148 from carterwilson1337/master
Track groups in Animation tab hover highlight
2 parents 45b427f + 472c8df commit ba44671

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

editor/animation/animation_track_editor.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,8 @@ void AnimationTrackEditGroup::_notification(int p_what) {
37563756
const Color v_line_color = get_theme_color(SNAME("v_line_color"), SNAME("AnimationTrackEditGroup"));
37573757
const int h_separation = get_theme_constant(SNAME("h_separation"), SNAME("AnimationTrackEditGroup"));
37583758

3759+
const Ref<StyleBox> &stylebox_hover = get_theme_stylebox(SceneStringName(hover), SNAME("AnimationTrackEditGroup"));
3760+
37593761
if (root) {
37603762
Node *n = root->get_node_or_null(node);
37613763
if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
@@ -3765,6 +3767,13 @@ void AnimationTrackEditGroup::_notification(int p_what) {
37653767

37663768
draw_style_box(stylebox_header, Rect2(Point2(), get_size()));
37673769

3770+
if (hovered) {
3771+
// Draw hover feedback for AnimationTrackEditGroup.
3772+
// Add a limit to just show hover over portion with text.
3773+
int limit = timeline->get_name_limit();
3774+
draw_style_box(stylebox_hover, Rect2(Point2(1 * EDSCALE, 0), Size2(limit - 1 * EDSCALE, get_size().height)));
3775+
}
3776+
37683777
int limit = timeline->get_name_limit();
37693778

37703779
// Section preview.
@@ -3839,6 +3848,14 @@ void AnimationTrackEditGroup::_notification(int p_what) {
38393848
draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE));
38403849
}
38413850
} break;
3851+
3852+
case NOTIFICATION_MOUSE_EXIT: {
3853+
if (hovered) {
3854+
hovered = false;
3855+
// When the mouse cursor exits the AnimationTrackEditGroup, we're no longer hovering the group.
3856+
queue_redraw();
3857+
}
3858+
} break;
38423859
}
38433860
}
38443861

@@ -3859,6 +3876,18 @@ void AnimationTrackEditGroup::gui_input(const Ref<InputEvent> &p_event) {
38593876
}
38603877
}
38613878
}
3879+
Ref<InputEventMouseMotion> mm = p_event;
3880+
if (mm.is_valid()) {
3881+
Point2 pos = mm->get_position();
3882+
Rect2 node_name_rect = Rect2(0, 0, timeline->get_name_limit(), get_size().height);
3883+
3884+
bool was_hovered = hovered;
3885+
hovered = node_name_rect.has_point(pos);
3886+
3887+
if (was_hovered != hovered) {
3888+
queue_redraw();
3889+
}
3890+
}
38623891
}
38633892

38643893
void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node) {

editor/animation/animation_track_editor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ class AnimationTrackEditGroup : public Control {
566566
AnimationTimelineEdit *timeline = nullptr;
567567
AnimationTrackEditor *editor = nullptr;
568568

569+
bool hovered = false;
570+
569571
void _zoom_changed();
570572

571573
protected:

editor/themes/theme_classic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,10 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &p_theme, Edito
21492149

21502150
p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
21512151

2152+
Ref<StyleBoxFlat> style_animation_track_group_hover = p_config.base_style->duplicate();
2153+
style_animation_track_group_hover->set_bg_color(p_config.highlight_color);
2154+
p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEditGroup", style_animation_track_group_hover);
2155+
21522156
p_theme->set_color("h_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
21532157
p_theme->set_color("v_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
21542158

editor/themes/theme_modern.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,10 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
21312131

21322132
p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
21332133

2134+
Ref<StyleBoxFlat> style_animation_track_group_hover = p_config.base_style->duplicate();
2135+
style_animation_track_group_hover->set_bg_color(p_config.highlight_color);
2136+
p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEditGroup", style_animation_track_group_hover);
2137+
21342138
p_theme->set_color("bg_color", "AnimationTrackEditGroup", p_config.surface_base_color);
21352139
p_theme->set_color("h_line_color", "AnimationTrackEditGroup", Color(1, 1, 1, 0));
21362140
p_theme->set_color("v_line_color", "AnimationTrackEditGroup", Color(1, 1, 1, 0));

0 commit comments

Comments
 (0)