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.
This commit is contained in:
parent
422a45a69e
commit
313c672dc8
|
@ -1961,11 +1961,21 @@ void AnimationTrackEdit::_notification(int p_what) {
|
||||||
|
|
||||||
int limit = timeline->get_name_limit();
|
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()) {
|
if (has_focus()) {
|
||||||
Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
||||||
accent.a *= 0.7;
|
accent.a *= 0.7;
|
||||||
// Offside so the horizontal sides aren't cutoff.
|
// 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"));
|
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||||
|
@ -2236,7 +2246,14 @@ void AnimationTrackEdit::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_MOUSE_ENTER:
|
||||||
|
hovered = true;
|
||||||
|
update();
|
||||||
|
break;
|
||||||
case NOTIFICATION_MOUSE_EXIT:
|
case NOTIFICATION_MOUSE_EXIT:
|
||||||
|
hovered = false;
|
||||||
|
update();
|
||||||
|
[[fallthrough]];
|
||||||
case NOTIFICATION_DRAG_END: {
|
case NOTIFICATION_DRAG_END: {
|
||||||
cancel_drop();
|
cancel_drop();
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -171,6 +171,7 @@ class AnimationTrackEdit : public Control {
|
||||||
|
|
||||||
PopupMenu *menu;
|
PopupMenu *menu;
|
||||||
|
|
||||||
|
bool hovered = false;
|
||||||
bool clicking_on_name = false;
|
bool clicking_on_name = false;
|
||||||
|
|
||||||
void _zoom_changed();
|
void _zoom_changed();
|
||||||
|
|
Loading…
Reference in New Issue