mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Show marker lines/sections in the animation bezier editor
This commit is contained in:
parent
4fcd85551c
commit
0f614cd63f
2 changed files with 63 additions and 8 deletions
|
@ -321,6 +321,60 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
||||||
subtracks.clear();
|
subtracks.clear();
|
||||||
subtrack_icons.clear();
|
subtrack_icons.clear();
|
||||||
|
|
||||||
|
// Marker sections.
|
||||||
|
{
|
||||||
|
float scale = timeline->get_zoom_scale();
|
||||||
|
int limit_end = get_size().width - timeline->get_buttons_width();
|
||||||
|
|
||||||
|
PackedStringArray section = editor->get_selected_section();
|
||||||
|
if (section.size() == 2) {
|
||||||
|
StringName start_marker = section[0];
|
||||||
|
StringName end_marker = section[1];
|
||||||
|
double start_time = animation->get_marker_time(start_marker);
|
||||||
|
double end_time = animation->get_marker_time(end_marker);
|
||||||
|
|
||||||
|
// When AnimationPlayer is playing, don't move the preview rect, so it still indicates the playback section.
|
||||||
|
AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player();
|
||||||
|
if (editor->is_marker_moving_selection() && !(player && player->is_playing())) {
|
||||||
|
start_time += editor->get_marker_moving_selection_offset();
|
||||||
|
end_time += editor->get_marker_moving_selection_offset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_time < animation->get_length() && end_time >= 0) {
|
||||||
|
float start_ofs = MAX(0, start_time) - timeline->get_value();
|
||||||
|
float end_ofs = MIN(animation->get_length(), end_time) - timeline->get_value();
|
||||||
|
start_ofs = start_ofs * scale + limit;
|
||||||
|
end_ofs = end_ofs * scale + limit;
|
||||||
|
start_ofs = MAX(start_ofs, limit);
|
||||||
|
end_ofs = MIN(end_ofs, limit_end);
|
||||||
|
Rect2 rect;
|
||||||
|
rect.set_position(Vector2(start_ofs, 0));
|
||||||
|
rect.set_size(Vector2(end_ofs - start_ofs, get_size().height));
|
||||||
|
|
||||||
|
draw_rect(rect, Color(1, 0.1, 0.1, 0.2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marker overlays.
|
||||||
|
{
|
||||||
|
float scale = timeline->get_zoom_scale();
|
||||||
|
PackedStringArray markers = animation->get_marker_names();
|
||||||
|
for (const StringName marker : markers) {
|
||||||
|
double time = animation->get_marker_time(marker);
|
||||||
|
if (editor->is_marker_selected(marker) && editor->is_marker_moving_selection()) {
|
||||||
|
time += editor->get_marker_moving_selection_offset();
|
||||||
|
}
|
||||||
|
if (time >= 0) {
|
||||||
|
float offset = time - timeline->get_value();
|
||||||
|
offset = offset * scale + limit;
|
||||||
|
Color marker_color = animation->get_marker_color(marker);
|
||||||
|
marker_color.a = 0.2;
|
||||||
|
draw_line(Point2(offset, 0), Point2(offset, get_size().height), marker_color, Math::round(EDSCALE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RBMap<String, Vector<int>> track_indices;
|
RBMap<String, Vector<int>> track_indices;
|
||||||
int track_count = animation->get_track_count();
|
int track_count = animation->get_track_count();
|
||||||
for (int i = 0; i < track_count; ++i) {
|
for (int i = 0; i < track_count; ++i) {
|
||||||
|
|
|
@ -7778,6 +7778,14 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
||||||
box_selection_container->set_clip_contents(true);
|
box_selection_container->set_clip_contents(true);
|
||||||
timeline_vbox->add_child(box_selection_container);
|
timeline_vbox->add_child(box_selection_container);
|
||||||
|
|
||||||
|
bezier_edit = memnew(AnimationBezierTrackEdit);
|
||||||
|
timeline_vbox->add_child(bezier_edit);
|
||||||
|
bezier_edit->set_editor(this);
|
||||||
|
bezier_edit->set_timeline(timeline);
|
||||||
|
bezier_edit->hide();
|
||||||
|
bezier_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
bezier_edit->connect("timeline_changed", callable_mp(this, &AnimationTrackEditor::_timeline_changed));
|
||||||
|
|
||||||
marker_edit = memnew(AnimationMarkerEdit);
|
marker_edit = memnew(AnimationMarkerEdit);
|
||||||
timeline->get_child(0)->add_child(marker_edit);
|
timeline->get_child(0)->add_child(marker_edit);
|
||||||
marker_edit->set_editor(this);
|
marker_edit->set_editor(this);
|
||||||
|
@ -7786,6 +7794,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
||||||
marker_edit->set_anchors_and_offsets_preset(Control::LayoutPreset::PRESET_FULL_RECT);
|
marker_edit->set_anchors_and_offsets_preset(Control::LayoutPreset::PRESET_FULL_RECT);
|
||||||
marker_edit->connect(SceneStringName(draw), callable_mp(this, &AnimationTrackEditor::_redraw_groups));
|
marker_edit->connect(SceneStringName(draw), callable_mp(this, &AnimationTrackEditor::_redraw_groups));
|
||||||
marker_edit->connect(SceneStringName(draw), callable_mp(this, &AnimationTrackEditor::_redraw_tracks));
|
marker_edit->connect(SceneStringName(draw), callable_mp(this, &AnimationTrackEditor::_redraw_tracks));
|
||||||
|
marker_edit->connect(SceneStringName(draw), callable_mp((CanvasItem *)bezier_edit, &CanvasItem::queue_redraw));
|
||||||
|
|
||||||
scroll = memnew(ScrollContainer);
|
scroll = memnew(ScrollContainer);
|
||||||
box_selection_container->add_child(scroll);
|
box_selection_container->add_child(scroll);
|
||||||
|
@ -7801,14 +7810,6 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
||||||
scroll->get_v_scroll_bar()->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTrackEditor::_v_scroll_changed));
|
scroll->get_v_scroll_bar()->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTrackEditor::_v_scroll_changed));
|
||||||
scroll->get_h_scroll_bar()->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTrackEditor::_h_scroll_changed));
|
scroll->get_h_scroll_bar()->connect(SceneStringName(value_changed), callable_mp(this, &AnimationTrackEditor::_h_scroll_changed));
|
||||||
|
|
||||||
bezier_edit = memnew(AnimationBezierTrackEdit);
|
|
||||||
timeline_vbox->add_child(bezier_edit);
|
|
||||||
bezier_edit->set_editor(this);
|
|
||||||
bezier_edit->set_timeline(timeline);
|
|
||||||
bezier_edit->hide();
|
|
||||||
bezier_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
||||||
bezier_edit->connect("timeline_changed", callable_mp(this, &AnimationTrackEditor::_timeline_changed));
|
|
||||||
|
|
||||||
timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE);
|
timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE);
|
||||||
|
|
||||||
hscroll = memnew(HScrollBar);
|
hscroll = memnew(HScrollBar);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue