From 313c672dc818e77dbc01a734c9d8af3c02a4bfef Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 21 Mar 2022 21:55:33 +0100 Subject: Improve the animation track editor drawing - Draw a background on alternate lines to ease readability of animations with many tracks. - Draw a background on the currently hovered line. - Use the editor focus stylebox instead of a custom rectangle for the focused track. --- editor/animation_track_editor.cpp | 19 ++++++++++++++++++- editor/animation_track_editor.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index e61a1aae9c..2abd0ff713 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1961,11 +1961,21 @@ void AnimationTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); + if (track % 2 == 1) { + // Draw a background over odd lines to make long lists of tracks easier to read. + draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), Color(0.5, 0.5, 0.5, 0.05)); + } + + if (hovered) { + // Draw hover feedback. + draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), Color(0.5, 0.5, 0.5, 0.1)); + } + if (has_focus()) { Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. - draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false); + draw_style_box(get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")), Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0))); } Ref font = get_theme_font(SNAME("font"), SNAME("Label")); @@ -2236,7 +2246,14 @@ void AnimationTrackEdit::_notification(int p_what) { } } break; + case NOTIFICATION_MOUSE_ENTER: + hovered = true; + update(); + break; case NOTIFICATION_MOUSE_EXIT: + hovered = false; + update(); + [[fallthrough]]; case NOTIFICATION_DRAG_END: { cancel_drop(); } break; diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 1baebc469e..57fd438d83 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -171,6 +171,7 @@ class AnimationTrackEdit : public Control { PopupMenu *menu; + bool hovered = false; bool clicking_on_name = false; void _zoom_changed(); -- cgit v1.2.3