Skip to content

Commit 2a10291

Browse files
committed
Allow to resize the length of animations by dragging the timeline
1 parent 0870525 commit 2a10291

File tree

6 files changed

+202
-108
lines changed

6 files changed

+202
-108
lines changed

editor/animation/animation_bezier_editor.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,23 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
304304
const int v_separation = get_theme_constant(SNAME("h_separation"), SNAME("AnimationBezierTrackEdit"));
305305

306306
if (has_focus(true)) {
307-
draw_rect(Rect2(Point2(), get_size()), focus_color, false, Math::round(EDSCALE));
307+
draw_rect(Rect2(Point2(1, 1), get_size() - Point2(1, 1)), focus_color, false, Math::round(EDSCALE));
308308
}
309309

310-
draw_line(Point2(limit, 0), Point2(limit, get_size().height), v_line_color, Math::round(EDSCALE));
311-
312310
int right_limit = get_size().width;
313311

312+
// Unavailable timeline.
313+
{
314+
int px = (editor->get_current_animation()->get_length() - timeline->get_value()) * timeline->get_zoom_scale() + timeline->get_name_limit();
315+
px = MAX(px, timeline->get_name_limit());
316+
Rect2 rect = Rect2(px, 0, right_limit - px, get_size().height);
317+
if (rect.size.width > 0) {
318+
draw_rect(rect, Color(0, 0, 0, 0.2));
319+
}
320+
}
321+
322+
draw_line(Point2(limit, 0), Point2(limit, get_size().height), v_line_color, Math::round(EDSCALE));
323+
314324
track_v_scroll_max = v_separation;
315325

316326
int vofs = v_separation + track_v_scroll;

0 commit comments

Comments
 (0)