diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 648 |
1 files changed, 351 insertions, 297 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 4fe2d2bb2a..c9d3df9ce2 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -134,7 +134,7 @@ public: undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, key); undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, new_time, val, trans); undo_redo->add_do_method(this, "_key_ofs_changed", animation, key_ofs, new_time); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", track, new_time); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, new_time); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, key_ofs, val, trans); undo_redo->add_undo_method(this, "_key_ofs_changed", animation, new_time, key_ofs); @@ -165,7 +165,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); d_new[p_name] = p_value; @@ -412,7 +412,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND_V(!d.has(name), false); r_ret = d[p_name]; @@ -523,9 +523,9 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "location")); - p_list->push_back(PropertyInfo(Variant::QUAT, "rotation")); + p_list->push_back(PropertyInfo(Variant::QUATERNION, "rotation")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale")); } break; @@ -598,12 +598,12 @@ public: if (ap) { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { + for (const StringName &E : anims) { if (animations != String()) { animations += ","; } - animations += String(E->get()); + animations += String(E); } } } @@ -702,8 +702,8 @@ public: for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; if (from != key_ofs) { key++; continue; @@ -728,8 +728,8 @@ public: bool change_notify_deserved = false; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -758,7 +758,7 @@ public: undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, key); undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, new_time, val, trans); undo_redo->add_do_method(this, "_key_ofs_changed", animation, key_ofs, new_time); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", track, new_time); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, new_time); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, key_ofs, val, trans); undo_redo->add_undo_method(this, "_key_ofs_changed", animation, new_time, key_ofs); @@ -781,7 +781,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); d_new[p_name] = p_value; @@ -986,8 +986,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1012,7 +1012,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND_V(!d.has(name), false); r_ret = d[p_name]; @@ -1137,8 +1137,8 @@ public: same_key_type = false; } - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); + for (float &F : E->value()) { + int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { first_key = key; @@ -1162,37 +1162,35 @@ public: if (same_track_type) { switch (animation->track_get_type(first_track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "location")); - p_list->push_back(PropertyInfo(Variant::QUAT, "rotation")); + p_list->push_back(PropertyInfo(Variant::QUATERNION, "rotation")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale")); } break; case Animation::TYPE_VALUE: { - if (!same_key_type) { - break; - } + if (same_key_type) { + Variant v = animation->track_get_key_value(first_track, first_key); - Variant v = animation->track_get_key_value(first_track, first_key); - - if (hint.type != Variant::NIL) { - PropertyInfo pi = hint; - pi.name = "value"; - p_list->push_back(pi); - } else { - PropertyHint hint = PROPERTY_HINT_NONE; - String hint_string; - - if (v.get_type() == Variant::OBJECT) { - //could actually check the object property if exists..? yes i will! - Ref<Resource> res = v; - if (res.is_valid()) { - hint = PROPERTY_HINT_RESOURCE_TYPE; - hint_string = res->get_class(); + if (hint.type != Variant::NIL) { + PropertyInfo pi = hint; + pi.name = "value"; + p_list->push_back(pi); + } else { + PropertyHint hint = PROPERTY_HINT_NONE; + String hint_string; + + if (v.get_type() == Variant::OBJECT) { + //could actually check the object property if exists..? yes i will! + Ref<Resource> res = v; + if (res.is_valid()) { + hint = PROPERTY_HINT_RESOURCE_TYPE; + hint_string = res->get_class(); + } } - } - if (v.get_type() != Variant::NIL) { - p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string)); + if (v.get_type() != Variant::NIL) { + p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string)); + } } } @@ -1292,7 +1290,7 @@ public: void AnimationTimelineEdit::_zoom_changed(double) { update(); play_position->update(); - emit_signal("zoom_changed"); + emit_signal(SNAME("zoom_changed")); } float AnimationTimelineEdit::get_zoom_scale() const { @@ -1323,7 +1321,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { editing = false; update(); - emit_signal("length_changed", p_new_len); + emit_signal(SNAME("length_changed"), p_new_len); } void AnimationTimelineEdit::_anim_loop_pressed() { @@ -1334,11 +1332,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { } int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons"); - Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons"); - Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture2D> remove_icon = get_theme_icon("Remove", "EditorIcons"); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")); + Ref<Texture2D> interp_type = get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")); + Ref<Texture2D> loop_type = get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")); + Ref<Texture2D> remove_icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1347,7 +1345,7 @@ int AnimationTimelineEdit::get_buttons_width() const { } int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1358,17 +1356,17 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - add_track->set_icon(get_theme_icon("Add", "EditorIcons")); - loop->set_icon(get_theme_icon("Loop", "EditorIcons")); - time_icon->set_texture(get_theme_icon("Time", "EditorIcons")); + add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); + time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons"))); add_track->get_popup()->clear(); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyValue", "EditorIcons"), TTR("Property Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyCall", "EditorIcons"), TTR("Call Method Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), TTR("3D Transform Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track")); } if (p_what == NOTIFICATION_RESIZED) { @@ -1383,9 +1381,9 @@ void AnimationTimelineEdit::_notification(int p_what) { return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); int zoomw = key_range; float scale = get_zoom_scale(); @@ -1396,7 +1394,7 @@ void AnimationTimelineEdit::_notification(int p_what) { l = 0.001; //avoid crashor } - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1445,7 +1443,7 @@ void AnimationTimelineEdit::_notification(int p_what) { int end_px = (l - get_value()) * scale; int begin_px = -get_value() * scale; - Color notimecol = get_theme_color("dark_color_2", "Editor"); + Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); Color timecolor = color; timecolor.a = 0.2; Color linecolor = color; @@ -1570,10 +1568,10 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { Size2 AnimationTimelineEdit::get_minimum_size() const { Size2 ms = add_track->get_minimum_size(); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); ms.height = MAX(ms.height, font->get_height(font_size)); - ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2; + ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"))->get_width() + 2; return ms; } @@ -1586,6 +1584,10 @@ void AnimationTimelineEdit::set_zoom(Range *p_zoom) { zoom->connect("value_changed", callable_mp(this, &AnimationTimelineEdit::_zoom_changed)); } +void AnimationTimelineEdit::set_track_edit(AnimationTrackEdit *p_track_edit) { + track_edit = p_track_edit; +} + void AnimationTimelineEdit::set_play_position(float p_pos) { play_position_pos = p_pos; play_position->update(); @@ -1631,11 +1633,11 @@ void AnimationTimelineEdit::_play_position_draw() { int px = (-get_value() + play_position_pos) * scale + get_name_limit(); if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); play_position->draw_texture( - get_theme_icon("TimelineIndicator", "EditorIcons"), - Point2(px - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), + Point2(px - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), color); } } @@ -1643,7 +1645,31 @@ void AnimationTimelineEdit::_play_position_draw() { void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); - Ref<InputEventMouseButton> mb = p_event; + const Ref<InputEventMouseButton> mb = p_event; + + if (mb.is_valid() && mb->is_pressed() && mb->is_command_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { + get_zoom()->set_value(get_zoom()->get_value() * 1.05); + accept_event(); + } + + if (mb.is_valid() && mb->is_pressed() && mb->is_command_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { + get_zoom()->set_value(get_zoom()->get_value() / 1.05); + accept_event(); + } + + if (mb.is_valid() && mb->is_pressed() && mb->is_alt_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { + if (track_edit) { + track_edit->get_editor()->goto_prev_step(true); + } + accept_event(); + } + + if (mb.is_valid() && mb->is_pressed() && mb->is_alt_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { + if (track_edit) { + track_edit->get_editor()->goto_next_step(true); + } + accept_event(); + } if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && hsize_rect.has_point(mb->get_position())) { dragging_hsize = true; @@ -1659,7 +1685,7 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int x = mb->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); dragging_timeline = true; } if (!dragging_timeline && mb->get_button_index() == MOUSE_BUTTON_MIDDLE) { @@ -1692,13 +1718,13 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; update(); - emit_signal("name_limit_changed"); + emit_signal(SNAME("name_limit_changed")); play_position->update(); } if (dragging_timeline) { int x = mm->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); } if (panning_timeline) { int x = mm->get_position().x - get_name_limit(); @@ -1724,7 +1750,7 @@ void AnimationTimelineEdit::set_hscroll(HScrollBar *p_hscroll) { } void AnimationTimelineEdit::_track_added(int p_track) { - emit_signal("track_added", p_track); + emit_signal(SNAME("track_added"), p_track); } void AnimationTimelineEdit::_bind_methods() { @@ -1742,6 +1768,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { editing = false; name_limit = 150 * EDSCALE; zoom = nullptr; + track_edit = nullptr; play_position_pos = 0; play_position = memnew(Control); @@ -1805,31 +1832,31 @@ void AnimationTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color("accent_color", "Editor"); + 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); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; - int hsep = get_theme_constant("hseparation", "ItemList"); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; // NAMES AND ICONS // { - Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox")); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1850,7 +1877,7 @@ void AnimationTrackEdit::_notification(int p_what) { String text; Color text_color = color; if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) { - text_color = get_theme_color("accent_color", "Editor"); + text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } if (in_group) { @@ -1925,25 +1952,25 @@ void AnimationTrackEdit::_notification(int p_what) { { Ref<Texture2D> wrap_icon[2] = { - get_theme_icon("InterpWrapClamp", "EditorIcons"), - get_theme_icon("InterpWrapLoop", "EditorIcons"), + get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), }; Ref<Texture2D> interp_icon[3] = { - get_theme_icon("InterpRaw", "EditorIcons"), - get_theme_icon("InterpLinear", "EditorIcons"), - get_theme_icon("InterpCubic", "EditorIcons") + get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")) }; Ref<Texture2D> cont_icon[4] = { - get_theme_icon("TrackContinuous", "EditorIcons"), - get_theme_icon("TrackDiscrete", "EditorIcons"), - get_theme_icon("TrackTrigger", "EditorIcons"), - get_theme_icon("TrackCapture", "EditorIcons") + get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")) }; int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -1980,7 +2007,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_theme_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2007,7 +2034,7 @@ void AnimationTrackEdit::_notification(int p_what) { interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; interp_mode_rect.size = icon->get_size(); - if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM) { + if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM3D) { draw_texture(icon, interp_mode_rect.position); } //make it easier to click @@ -2017,7 +2044,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += icon->get_width() + hsep; interp_mode_rect.size.x += hsep; - if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM) { + if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM3D) { draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); interp_mode_rect.size.x += down_icon->get_width(); } else { @@ -2040,7 +2067,7 @@ void AnimationTrackEdit::_notification(int p_what) { loop_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; loop_mode_rect.size = icon->get_size(); - if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM) { + if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM3D) { draw_texture(icon, loop_mode_rect.position); } @@ -2050,7 +2077,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += icon->get_width() + hsep; loop_mode_rect.size.x += hsep; - if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM) { + if (animation->track_get_type(track) == Animation::TYPE_VALUE || animation->track_get_type(track) == Animation::TYPE_TRANSFORM3D) { draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); loop_mode_rect.size.x += down_icon->get_width(); } else { @@ -2065,7 +2092,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture2D> icon = get_theme_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2082,7 +2109,7 @@ void AnimationTrackEdit::_notification(int p_what) { } if (dropping_at != 0) { - Color drop_color = get_theme_color("accent_color", "Editor"); + Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); if (dropping_at < 0) { draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE)); } else { @@ -2134,7 +2161,7 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, return; } - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; int from_x = MAX(p_x, p_clip_left); @@ -2159,16 +2186,16 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool const Variant &v = animation->track_get_key_value(track, p_index); Variant::Type valid_type = Variant::NIL; if (!_is_value_key_valid(v, valid_type)) { - icon_to_draw = get_theme_icon("KeyInvalid", "EditorIcons"); + icon_to_draw = get_theme_icon(SNAME("KeyInvalid"), SNAME("EditorIcons")); } } Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; Dictionary d = animation->track_get_key_value(track, p_index); @@ -2271,19 +2298,19 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati update(); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); type_icon = type_icons[animation->track_get_type(track)]; - selected_icon = get_theme_icon("KeySelected", "EditorIcons"); + selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); } NodePath AnimationTrackEdit::get_path() const { @@ -2291,10 +2318,10 @@ NodePath AnimationTrackEdit::get_path() const { } Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons"); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); int max_h = MAX(texture->get_height(), font->get_height(font_size)); max_h = MAX(max_h, get_key_height()); @@ -2308,6 +2335,7 @@ void AnimationTrackEdit::set_undo_redo(UndoRedo *p_undo_redo) { void AnimationTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) { timeline = p_timeline; + timeline->set_track_edit(this); timeline->connect("zoom_changed", callable_mp(this, &AnimationTrackEdit::_zoom_changed)); timeline->connect("name_limit_changed", callable_mp(this, &AnimationTrackEdit::_zoom_changed)); } @@ -2327,7 +2355,7 @@ void AnimationTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -2350,7 +2378,7 @@ void AnimationTrackEdit::_zoom_changed() { play_position->update(); } -void AnimationTrackEdit::_path_entered(const String &p_text) { +void AnimationTrackEdit::_path_submitted(const String &p_text) { undo_redo->create_action(TTR("Change Track Path")); undo_redo->add_do_method(animation.ptr(), "track_set_path", track, p_text); undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); @@ -2441,7 +2469,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (key_idx != -1) { String text = TTR("Time (s): ") + rtos(animation->track_get_key_time(track, key_idx)) + "\n"; switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { Dictionary d = animation->track_get_key_value(track, key_idx); if (d.has("location")) { text += "Pos: " + String(d["location"]) + "\n"; @@ -2527,18 +2555,18 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); if (p_event->is_pressed()) { - if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { - emit_signal("duplicate_request"); + if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->matches_event(p_event)) { + emit_signal(SNAME("duplicate_request")); accept_event(); } - if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->is_shortcut(p_event)) { - emit_signal("duplicate_transpose_request"); + if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->matches_event(p_event)) { + emit_signal(SNAME("duplicate_transpose_request")); accept_event(); } - if (ED_GET_SHORTCUT("animation_editor/delete_selection")->is_shortcut(p_event)) { - emit_signal("delete_request"); + if (ED_GET_SHORTCUT("animation_editor/delete_selection")->matches_event(p_event)) { + emit_signal(SNAME("delete_request")); accept_event(); } } @@ -2569,10 +2597,10 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_theme_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); - menu->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); + menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); @@ -2588,9 +2616,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_theme_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_theme_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); @@ -2606,8 +2634,8 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_theme_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height); @@ -2617,13 +2645,13 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (remove_rect.has_point(pos)) { - emit_signal("remove_request", track); + emit_signal(SNAME("remove_request"), track); accept_event(); return; } if (bezier_edit_rect.has_point(pos)) { - emit_signal("bezier_edit"); + emit_signal(SNAME("bezier_edit")); accept_event(); } @@ -2662,18 +2690,18 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (key_idx != -1) { - if (mb->get_command() || mb->get_shift()) { + if (mb->is_command_pressed() || mb->is_shift_pressed()) { if (editor->is_key_selected(track, key_idx)) { - emit_signal("deselect_key", key_idx); + emit_signal(SNAME("deselect_key"), key_idx); } else { - emit_signal("select_key", key_idx, false); + emit_signal(SNAME("select_key"), key_idx, false); moving_selection_attempt = true; select_single_attempt = -1; moving_selection_from_ofs = (mb->get_position().x - limit) / timeline->get_zoom_scale(); } } else { if (!editor->is_key_selected(track, key_idx)) { - emit_signal("select_key", key_idx, true); + emit_signal(SNAME("select_key"), key_idx, true); select_single_attempt = -1; } else { select_single_attempt = key_idx; @@ -2699,12 +2727,12 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); - menu->add_icon_item(get_theme_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT); + menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); if (editor->is_selection_active()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -2725,16 +2753,16 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { path = memnew(LineEdit); path_popup->add_child(path); path->set_anchors_and_offsets_preset(PRESET_WIDE); - path->connect("text_entered", callable_mp(this, &AnimationTrackEdit::_path_entered)); + path->connect("text_submitted", callable_mp(this, &AnimationTrackEdit::_path_submitted)); } path->set_text(animation->track_get_path(track)); - Vector2 theme_ofs = path->get_theme_stylebox("normal", "LineEdit")->get_offset(); + Vector2 theme_ofs = path->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->get_offset(); path_popup->set_position(get_screen_position() + path_rect.position - theme_ofs); path_popup->set_size(path_rect.size); path_popup->popup(); path->grab_focus(); - path->set_cursor_position(path->get_text().length()); + path->set_caret_column(path->get_text().length()); clicking_on_name = false; } @@ -2742,9 +2770,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { moving_selection_attempt = false; if (moving_selection) { - emit_signal("move_selection_commit"); + emit_signal(SNAME("move_selection_commit")); } else if (select_single_attempt != -1) { - emit_signal("select_key", select_single_attempt, true); + emit_signal(SNAME("select_key"), select_single_attempt, true); } moving_selection = false; select_single_attempt = -1; @@ -2753,7 +2781,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (moving_selection && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) { moving_selection_attempt = false; moving_selection = false; - emit_signal("move_selection_cancel"); + emit_signal(SNAME("move_selection_cancel")); } } @@ -2761,11 +2789,11 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT && moving_selection_attempt) { if (!moving_selection) { moving_selection = true; - emit_signal("move_selection_begin"); + emit_signal(SNAME("move_selection_begin")); } float new_ofs = (mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); - emit_signal("move_selection", new_ofs - moving_selection_from_ofs); + emit_signal(SNAME("move_selection"), new_ofs - moving_selection_from_ofs); } } @@ -2819,7 +2847,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d } const_cast<AnimationTrackEdit *>(this)->update(); - const_cast<AnimationTrackEdit *>(this)->emit_signal("drop_attempted", track); + const_cast<AnimationTrackEdit *>(this)->emit_signal(SNAME("drop_attempted"), track); return true; } @@ -2847,9 +2875,9 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) int from_track = d["index"]; if (dropping_at < 0) { - emit_signal("dropped", from_track, track); + emit_signal(SNAME("dropped"), from_track, track); } else { - emit_signal("dropped", from_track, track + 1); + emit_signal(SNAME("dropped"), from_track, track + 1); } } @@ -2888,14 +2916,14 @@ void AnimationTrackEdit::_menu_selected(int p_index) { } break; case MENU_KEY_INSERT: { - emit_signal("insert_key", insert_at_pos); + emit_signal(SNAME("insert_key"), insert_at_pos); } break; case MENU_KEY_DUPLICATE: { - emit_signal("duplicate_request"); + emit_signal(SNAME("duplicate_request")); } break; case MENU_KEY_DELETE: { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); } break; } @@ -2928,9 +2956,9 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect if (select_rect.intersects(rect)) { if (p_deselection) { - emit_signal("deselect_key", i); + emit_signal(SNAME("deselect_key"), i); } else { - emit_signal("select_key", i, false); + emit_signal(SNAME("select_key"), i, false); } } } @@ -3029,19 +3057,19 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object void AnimationTrackEditGroup::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("hseparation", "ItemList"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); if (root && root->has_node(node)) { Node *n = root->get_node(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } } - Color bgcol = get_theme_color("dark_color_2", "Editor"); + Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); bgcol.a *= 0.6; draw_rect(Rect2(Point2(), get_size()), bgcol); Color linecolor = color; @@ -3059,7 +3087,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } @@ -3074,9 +3102,9 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co } Size2 AnimationTrackEditGroup::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); return Vector2(0, MAX(font->get_height(font_size), icon->get_height()) + separation); } @@ -3198,7 +3226,7 @@ void AnimationTrackEditor::update_keying() { keying = keying_enabled; - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } bool AnimationTrackEditor::has_keying() const { @@ -3254,8 +3282,8 @@ void AnimationTrackEditor::_name_limit_changed() { } } -void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag) { - emit_signal("timeline_changed", p_new_pos, p_drag); +void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only) { + emit_signal(SNAME("timeline_changed"), p_new_pos, p_drag, p_timeline_only); } void AnimationTrackEditor::_track_remove_request(int p_track) { @@ -3310,7 +3338,7 @@ static bool track_type_is_resettable(Animation::TrackType p_type) { [[fallthrough]]; case Animation::TYPE_BEZIER: [[fallthrough]]; - case Animation::TYPE_TRANSFORM: + case Animation::TYPE_TRANSFORM3D: return true; default: return false; @@ -3328,9 +3356,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) { + for (const InsertData &E : insert_data) { //prevent insertion of multiple tracks - if (E->get().path == p_id.path) { + if (E.path == p_id.path) { return; //already inserted a track for this on this frame } } @@ -3376,7 +3404,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { case Variant::FLOAT: case Variant::VECTOR2: case Variant::VECTOR3: - case Variant::QUAT: + case Variant::QUATERNION: case Variant::PLANE: case Variant::COLOR: { // Valid. @@ -3402,14 +3430,14 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { insert_confirm->popup_centered(); insert_query = true; } else { - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); insert_queue = true; } } else { if (!insert_query && !insert_queue) { // Create Beziers wouldn't make sense in this case, where no tracks are being created - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); insert_queue = true; } } @@ -3454,12 +3482,12 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi pos = animation->get_length(); } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } insert_queue = false; } -void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) { +void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform3D &p_xform) { if (!keying) { return; } @@ -3479,7 +3507,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ int track_idx = -1; for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM) { + if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM3D) { continue; } if (animation->track_get_path(i) != np) { @@ -3496,7 +3524,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ id.path = np; id.track_idx = track_idx; id.value = p_xform; - id.type = Animation::TYPE_TRANSFORM; + id.type = Animation::TYPE_TRANSFORM3D; id.query = "node '" + p_node->get_name() + "'"; id.advance = false; @@ -3732,7 +3760,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { return player->get_animation("RESET"); } else { Ref<Animation> reset_anim; - reset_anim.instance(); + reset_anim.instantiate(); reset_anim->set_length(ANIM_MIN_LENGTH); undo_redo->add_do_method(player, "add_animation", "RESET", reset_anim); undo_redo->add_do_method(AnimationPlayerEditor::singleton, "_animation_player_changed", player); @@ -3815,9 +3843,9 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List<PropertyInfo> pinfo; property_info_base.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { - return E->get(); + for (const PropertyInfo &E : pinfo) { + if (E.name == leftover_path[leftover_path.size() - 1]) { + return E; } } @@ -3845,7 +3873,7 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool subindices.push_back(":y"); subindices.push_back(":z"); } break; - case Variant::QUAT: { + case Variant::QUATERNION: { subindices.push_back(":x"); subindices.push_back(":y"); subindices.push_back(":z"); @@ -3911,11 +3939,11 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD h.type == Variant::RECT2 || h.type == Variant::VECTOR3 || h.type == Variant::AABB || - h.type == Variant::QUAT || + h.type == Variant::QUATERNION || h.type == Variant::COLOR || h.type == Variant::PLANE || h.type == Variant::TRANSFORM2D || - h.type == Variant::TRANSFORM) { + h.type == Variant::TRANSFORM3D) { update_mode = Animation::UPDATE_CONTINUOUS; } @@ -3945,12 +3973,12 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD value = p_id.value; } break; - case Animation::TYPE_TRANSFORM: { - Transform tr = p_id.value; + case Animation::TYPE_TRANSFORM3D: { + Transform3D tr = p_id.value; Dictionary d; d["location"] = tr.origin; d["scale"] = tr.basis.get_scale(); - d["rotation"] = Quat(tr.basis); + d["rotation"] = Quaternion(tr.basis); value = d; } break; case Animation::TYPE_BEZIER: { @@ -3979,7 +4007,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); p_next_tracks.normal++; } else { - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_id.track_idx, time); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_id.track_idx, time); int existing = animation->track_find_key(p_id.track_idx, time, true); if (existing != -1) { Variant v = animation->track_get_key_value(p_id.track_idx, existing); @@ -4028,7 +4056,7 @@ bool AnimationTrackEditor::is_selection_active() const { } bool AnimationTrackEditor::is_snap_enabled() const { - return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL); + return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(KEY_CTRL); } void AnimationTrackEditor::_update_tracks() { @@ -4138,7 +4166,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -4217,7 +4245,7 @@ void AnimationTrackEditor::_animation_changed() { } animation_changing_awaiting_update = true; - call_deferred("_animation_update"); + call_deferred(SNAME("_animation_update")); } void AnimationTrackEditor::_snap_mode_changed(int p_mode) { @@ -4285,8 +4313,8 @@ void AnimationTrackEditor::_animation_update() { bezier_edit->update(); _update_step_spinbox(); - emit_signal("animation_step_changed", animation->get_step()); - emit_signal("animation_len_changed", animation->get_length()); + emit_signal(SNAME("animation_step_changed"), animation->get_step()); + emit_signal(SNAME("animation_len_changed"), animation->get_length()); animation_changing_awaiting_update = false; } @@ -4297,13 +4325,13 @@ MenuButton *AnimationTrackEditor::get_edit_menu() { void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - zoom_icon->set_texture(get_theme_icon("Zoom", "EditorIcons")); - snap->set_icon(get_theme_icon("Snap", "EditorIcons")); + zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); - selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); - imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon("Reload", "EditorIcons")); + selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); + imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_READY) { @@ -4313,7 +4341,7 @@ void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { update_keying(); EditorNode::get_singleton()->update_keying(); - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } } @@ -4339,11 +4367,11 @@ void AnimationTrackEditor::_update_step(double p_new_step) { step->set_block_signals(true); undo_redo->commit_action(); step->set_block_signals(false); - emit_signal("animation_step_changed", step_value); + emit_signal(SNAME("animation_step_changed"), step_value); } void AnimationTrackEditor::_update_length(double p_new_len) { - emit_signal("animation_len_changed", p_new_len); + emit_signal(SNAME("animation_len_changed"), p_new_len); } void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { @@ -4368,8 +4396,8 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { ERR_FAIL_COND(!node); NodePath path_to = root->get_path_to(node); - if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Node3D")) { - EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to 3D-based nodes.")); + if (adding_track_type == Animation::TYPE_TRANSFORM3D && !node->is_class("Node3D")) { + EditorNode::get_singleton()->show_warning(TTR("Transform3D tracks only apply to 3D-based nodes.")); return; } @@ -4379,7 +4407,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { prop_selector->set_type_filter(Vector<Variant::Type>()); prop_selector->select_property_from_instance(node); } break; - case Animation::TYPE_TRANSFORM: + case Animation::TYPE_TRANSFORM3D: case Animation::TYPE_METHOD: { undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); @@ -4394,7 +4422,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { filter.push_back(Variant::FLOAT); filter.push_back(Variant::VECTOR2); filter.push_back(Variant::VECTOR3); - filter.push_back(Variant::QUAT); + filter.push_back(Variant::QUATERNION); filter.push_back(Variant::PLANE); filter.push_back(Variant::COLOR); @@ -4422,7 +4450,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { } if (node == AnimationPlayerEditor::singleton->get_player()) { - EditorNode::get_singleton()->show_warning(TTR("An animation player can't animate itself, only other players.")); + EditorNode::get_singleton()->show_warning(TTR("AnimationPlayer can't animate itself, only other players.")); return; } @@ -4464,11 +4492,11 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { h.type == Variant::RECT2 || h.type == Variant::VECTOR3 || h.type == Variant::AABB || - h.type == Variant::QUAT || + h.type == Variant::QUATERNION || h.type == Variant::COLOR || h.type == Variant::PLANE || h.type == Variant::TRANSFORM2D || - h.type == Variant::TRANSFORM) { + h.type == Variant::TRANSFORM3D) { update_mode = Animation::UPDATE_CONTINUOUS; } @@ -4548,7 +4576,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { } switch (animation->track_get_type(p_track)) { - case Animation::TYPE_TRANSFORM: { + case Animation::TYPE_TRANSFORM3D: { if (!root->has_node(animation->track_get_path(p_track))) { EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key.")); return; @@ -4560,15 +4588,15 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { return; } - Transform xf = base->get_transform(); + Transform3D xf = base->get_transform(); Vector3 loc = xf.get_origin(); Vector3 scale = xf.basis.get_scale_local(); - Quat rot = xf.basis; + Quaternion rot = xf.basis; undo_redo->create_action(TTR("Add Transform Track Key")); undo_redo->add_do_method(animation.ptr(), "transform_track_insert_key", p_track, p_ofs, loc, rot, scale); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); } break; @@ -4580,7 +4608,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, value); undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); } break; @@ -4611,7 +4639,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, arr); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); } break; @@ -4623,7 +4651,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, ak); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); } break; case Animation::TYPE_ANIMATION: { @@ -4631,7 +4659,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, anim); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); } break; } @@ -4647,21 +4675,21 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List<MethodInfo> minfo; base->get_method_list(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - if (E->get().name == p_method) { + for (const MethodInfo &E : minfo) { + if (E.name == p_method) { Dictionary d; d["method"] = p_method; Array params; - int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); + int first_defarg = E.arguments.size() - E.default_arguments.size(); - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.arguments.size(); i++) { if (i >= first_defarg) { - Variant arg = E->get().default_arguments[i - first_defarg]; + Variant arg = E.default_arguments[i - first_defarg]; params.push_back(arg); } else { Callable::CallError ce; Variant arg; - Variant::construct(E->get().arguments[i].type, arg, nullptr, 0, ce); + Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce); params.push_back(arg); } } @@ -4669,7 +4697,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { undo_redo->create_action(TTR("Add Method Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", insert_key_from_track_call_track, insert_key_from_track_call_ofs, d); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", insert_key_from_track_call_track, insert_key_from_track_call_ofs); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", insert_key_from_track_call_track, insert_key_from_track_call_ofs); undo_redo->commit_action(); return; @@ -4879,7 +4907,7 @@ void AnimationTrackEditor::_move_selection_commit() { continue; //already in selection, don't save } - undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newtime); + undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newtime); _AnimMoveRestore amr; amr.key = animation->track_get_key_value(E->key().track, idx); @@ -4899,7 +4927,7 @@ void AnimationTrackEditor::_move_selection_commit() { // 4 - (undo) remove inserted keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = snap_time(E->get().pos + motion); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newpos); } // 5 - (undo) reinsert keys @@ -4908,8 +4936,7 @@ void AnimationTrackEditor::_move_selection_commit() { } // 6 - (undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -4952,23 +4979,33 @@ float AnimationTrackEditor::get_moving_selection_offset() const { void AnimationTrackEditor::_box_selection_draw() { const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor")); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { + if (mb.is_valid() && mb->is_pressed() && mb->is_command_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() * 1.05); scroll->accept_event(); } - if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { + if (mb.is_valid() && mb->is_pressed() && mb->is_command_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / 1.05); scroll->accept_event(); } + if (mb.is_valid() && mb->is_pressed() && mb->is_alt_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { + goto_prev_step(true); + scroll->accept_event(); + } + + if (mb.is_valid() && mb->is_pressed() && mb->is_alt_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { + goto_next_step(true); + scroll->accept_event(); + } + if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (mb->is_pressed()) { box_selecting = true; @@ -4980,7 +5017,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { for (int i = 0; i < track_edits.size(); i++) { Rect2 local_rect = box_select_rect; local_rect.position -= track_edits[i]->get_global_position(); - track_edits[i]->append_to_selection(local_rect, mb->get_command()); + track_edits[i]->append_to_selection(local_rect, mb->is_command_pressed()); } if (_get_track_selected() == -1 && track_edits.size() > 0) { //minimal hack to make shortcuts work @@ -5010,7 +5047,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { } if (!box_selection->is_visible_in_tree()) { - if (!mm->get_command() && !mm->get_shift()) { + if (!mm->is_command_pressed() && !mm->is_shift_pressed()) { _clear_selection(); } box_selection->show(); @@ -5096,7 +5133,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { int existing_idx = animation->track_find_key(dst_track, dst_time, true); undo_redo->add_do_method(animation.ptr(), "track_insert_key", dst_track, dst_time, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", dst_track, dst_time); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", dst_track, dst_time); Pair<int, float> p; p.first = dst_track; @@ -5113,9 +5150,9 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map<SelectedKey, KeyInfo> new_selection; - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (const Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); @@ -5143,6 +5180,56 @@ void AnimationTrackEditor::_edit_menu_about_to_popup() { edit->get_popup()->set_item_disabled(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), !player->can_apply_reset()); } +void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) { + if (animation.is_null()) { + return; + } + float step = animation->get_step(); + if (step == 0) { + step = 1; + } + if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + // Use more precise snapping when holding Shift. + // This is used when scrobbling the timeline using Alt + Mouse wheel. + step *= 0.25; + } + + float pos = timeline->get_play_position(); + pos = Math::snapped(pos - step, step); + if (pos < 0) { + pos = 0; + } + set_anim_pos(pos); + emit_signal(SNAME("timeline_changed"), pos, true); +} + +void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) { + if (animation.is_null()) { + return; + } + float step = animation->get_step(); + if (step == 0) { + step = 1; + } + if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + // Use more precise snapping when holding Shift. + // This is used when scrobbling the timeline using Alt + Mouse wheel. + // Do not use precise snapping when using the menu action or keyboard shortcut, + // as the default keyboard shortcut requires pressing Shift. + step *= 0.25; + } + + float pos = timeline->get_play_position(); + + pos = Math::snapped(pos + step, step); + if (pos > animation->get_length()) { + pos = animation->get_length(); + } + set_anim_pos(pos); + + emit_signal(SNAME("timeline_changed"), pos, true); +} + void AnimationTrackEditor::_edit_menu_pressed(int p_option) { last_menu_track_opt = p_option; switch (p_option) { @@ -5159,7 +5246,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); if (node) { if (has_theme_icon(node->get_class(), "EditorIcons")) { icon = get_theme_icon(node->get_class(), "EditorIcons"); @@ -5182,7 +5269,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } switch (animation->track_get_type(i)) { - case Animation::TYPE_TRANSFORM: + case Animation::TYPE_TRANSFORM3D: text += " (Transform)"; break; case Animation::TYPE_METHOD: @@ -5216,7 +5303,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { track_clipboard.clear(); TreeItem *root = track_copy_select->get_root(); if (root) { - TreeItem *it = root->get_children(); + TreeItem *it = root->get_first_child(); while (it) { Dictionary md = it->get_metadata(0); int idx = md["track_idx"]; @@ -5246,7 +5333,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_PASTE_TRACKS: { if (track_clipboard.size() == 0) { - EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty")); + EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty!")); break; } @@ -5344,7 +5431,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { continue; //already in selection, don't save } - undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newtime); + undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newtime); _AnimMoveRestore amr; amr.key = animation->track_get_key_value(E->key().track, idx); @@ -5365,7 +5452,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { // 4-(undo) remove inserted keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { float newpos = _NEW_POS(E->get().pos); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->key().track, newpos); } // 5-(undo) reinsert keys @@ -5374,8 +5461,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } // 6-(undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5428,42 +5514,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } break; case EDIT_GOTO_NEXT_STEP: { - if (animation.is_null()) { - break; - } - float step = animation->get_step(); - if (step == 0) { - step = 1; - } - - float pos = timeline->get_play_position(); - - pos = Math::snapped(pos + step, step); - if (pos > animation->get_length()) { - pos = animation->get_length(); - } - set_anim_pos(pos); - - emit_signal("timeline_changed", pos, true); - + goto_next_step(false); } break; case EDIT_GOTO_PREV_STEP: { - if (animation.is_null()) { - break; - } - float step = animation->get_step(); - if (step == 0) { - step = 1; - } - - float pos = timeline->get_play_position(); - pos = Math::snapped(pos - step, step); - if (pos < 0) { - pos = 0; - } - set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); - + goto_prev_step(false); } break; case EDIT_APPLY_RESET: { AnimationPlayerEditor::singleton->get_player()->apply_reset(true); @@ -5487,8 +5541,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List<StringName> names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + for (const StringName &E : names) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { _cleanup_animation(animation); @@ -5602,7 +5656,7 @@ void AnimationTrackEditor::_show_imported_anim_warning() { } void AnimationTrackEditor::_select_all_tracks_for_copy() { - TreeItem *track = track_copy_select->get_root()->get_children(); + TreeItem *track = track_copy_select->get_root()->get_first_child(); if (!track) { return; } @@ -5616,7 +5670,7 @@ void AnimationTrackEditor::_select_all_tracks_for_copy() { track = track->get_next(); } - track = track_copy_select->get_root()->get_children(); + track = track_copy_select->get_root()->get_first_child(); while (track) { track->set_checked(0, !all_selected); track = track->get_next(); @@ -5681,7 +5735,7 @@ void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const p_select_candidates.push_back(node); } - TreeItem *c = p_item->get_children(); + TreeItem *c = p_item->get_first_child(); while (c) { _pick_track_select_recursive(c, p_filter, p_select_candidates); @@ -5728,7 +5782,7 @@ AnimationTrackEditor::AnimationTrackEditor() { info_message->set_text(TTR("Select an AnimationPlayer node to create and edit animations.")); info_message->set_valign(Label::VALIGN_CENTER); info_message->set_align(Label::ALIGN_CENTER); - info_message->set_autowrap(true); + info_message->set_autowrap_mode(Label::AUTOWRAP_WORD_SMART); info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); main_panel->add_child(info_message); @@ -5927,7 +5981,7 @@ AnimationTrackEditor::AnimationTrackEditor() { //default plugins Ref<AnimationTrackEditDefaultPlugin> def_plugin; - def_plugin.instance(); + def_plugin.instantiate(); add_track_edit_plugin(def_plugin); //dialogs |