diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-03-21 21:55:33 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-03-21 23:52:48 +0100 |
commit | 313c672dc818e77dbc01a734c9d8af3c02a4bfef (patch) | |
tree | 7882c5c859cf3a3eb91fd59d6389757b44611e4d /editor | |
parent | 422a45a69e0c6f63bbb01fbe62931289b7c4651c (diff) |
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.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/animation_track_editor.cpp | 19 | ||||
-rw-r--r-- | editor/animation_track_editor.h | 1 |
2 files changed, 19 insertions, 1 deletions
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> 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(); |