diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 8426dfd1ac..9eabc31621 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1522,6 +1522,8 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, boo animation = p_animation; read_only = p_read_only; + length->set_read_only(read_only); + if (animation.is_valid()) { len_hb->show(); if (read_only) { @@ -2003,7 +2005,6 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(down_icon, Vector2(ofs, int(get_size().height - down_icon->get_height()) / 2)); update_mode_rect.size.x += down_icon->get_width(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); update_mode_rect.size.x += down_icon->get_width(); update_mode_rect = Rect2(); } else { @@ -2228,7 +2229,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (i > 0) { text += ", "; } - text += String(args[i]); + text += args[i].get_construct_string(); } text += ")"; @@ -2540,7 +2541,7 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (i > 0) { text += ", "; } - text += String(args[i]); + text += args[i].get_construct_string(); } text += ")\n"; @@ -3311,25 +3312,15 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re snap->set_disabled(false); snap_mode->set_disabled(false); - bezier_edit_icon->set_disabled(true); - imported_anim_warning->hide(); - bool import_warning_done = false; - bool bezier_done = false; for (int i = 0; i < animation->get_track_count(); i++) { if (animation->track_is_imported(i)) { imported_anim_warning->show(); - import_warning_done = true; - } - if (animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { - bezier_edit_icon->set_disabled(false); - bezier_done = true; - } - if (import_warning_done && bezier_done) { break; } } + _check_bezier_exist(); } else { hscroll->hide(); edit->set_disabled(true); @@ -3343,6 +3334,24 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim, bool p_re } } +void AnimationTrackEditor::_check_bezier_exist() { + bool is_exist = false; + for (int i = 0; i < animation->get_track_count(); i++) { + if (animation->track_get_type(i) == Animation::TrackType::TYPE_BEZIER) { + is_exist = true; + break; + } + } + if (is_exist) { + bezier_edit_icon->set_disabled(false); + } else { + if (bezier_edit->is_visible()) { + _cancel_bezier_edit(); + } + bezier_edit_icon->set_disabled(true); + } +} + Ref<Animation> AnimationTrackEditor::get_current_animation() const { return animation; } @@ -4292,6 +4301,8 @@ void AnimationTrackEditor::_update_tracks() { memdelete(track_vbox->get_child(0)); } + timeline->set_track_edit(nullptr); + track_edits.clear(); groups.clear(); @@ -4490,6 +4501,8 @@ void AnimationTrackEditor::_animation_changed() { return; // All will be updated, don't bother with anything. } + _check_bezier_exist(); + if (key_edit) { if (key_edit->setting) { // If editing a key, just redraw the edited track, makes refresh less costly. @@ -4710,7 +4723,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { adding_track_path = path_to; prop_selector->set_type_filter(filter); prop_selector->select_property_from_instance(node); - bezier_edit_icon->set_disabled(false); } break; case Animation::TYPE_AUDIO: { if (!node->is_class("AudioStreamPlayer") && !node->is_class("AudioStreamPlayer2D") && !node->is_class("AudioStreamPlayer3D")) { |