1
0
Fork 0

Track groups in Animation tab hover highlight

Co-authored-by: Silc Lizard (Tokage) Renew <tokage.it.lab@gmail.com>

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
carterwilson1337 2025-10-29 05:02:56 -04:00
parent 2cc031f3a3
commit 472c8df99b
4 changed files with 39 additions and 0 deletions

View File

@ -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> &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<InputEvent> &p_event) {
}
}
}
Ref<InputEventMouseMotion> 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<Texture2D> &p_type, const String &p_name, const NodePath &p_node) {

View File

@ -566,6 +566,8 @@ class AnimationTrackEditGroup : public Control {
AnimationTimelineEdit *timeline = nullptr;
AnimationTrackEditor *editor = nullptr;
bool hovered = false;
void _zoom_changed();
protected:

View File

@ -2148,6 +2148,10 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &p_theme, Edito
p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
Ref<StyleBoxFlat> 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));

View File

@ -2130,6 +2130,10 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
Ref<StyleBoxFlat> 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));