diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 87 |
1 files changed, 38 insertions, 49 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index e5a596f5f2..e61a1aae9c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1458,7 +1458,8 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); @@ -1813,13 +1814,6 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (hsize_rect.has_point(mm->get_position())) { - // Change the cursor to indicate that the track name column's width can be adjusted - set_default_cursor_shape(Control::CURSOR_HSIZE); - } else { - set_default_cursor_shape(Control::CURSOR_ARROW); - } - if (dragging_hsize) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; @@ -1835,6 +1829,15 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { } } +Control::CursorShape AnimationTimelineEdit::get_cursor_shape(const Point2 &p_pos) const { + if (dragging_hsize || hsize_rect.has_point(p_pos)) { + // Indicate that the track name column's width can be adjusted + return Control::CURSOR_HSIZE; + } else { + return get_default_cursor_shape(); + } +} + void AnimationTimelineEdit::_scroll_callback(Vector2 p_scroll_vec, bool p_alt) { // Timeline has no vertical scroll, so we change it to horizontal. p_scroll_vec.x += p_scroll_vec.y; @@ -1883,8 +1886,6 @@ void AnimationTimelineEdit::_bind_methods() { } AnimationTimelineEdit::AnimationTimelineEdit() { - use_fps = false; - editing = false; name_limit = 150 * EDSCALE; zoom = nullptr; track_edit = nullptr; @@ -1932,9 +1933,6 @@ AnimationTimelineEdit::AnimationTimelineEdit() { add_track->get_popup()->connect("index_pressed", callable_mp(this, &AnimationTimelineEdit::_track_added)); len_hb->hide(); - dragging_timeline = false; - dragging_hsize = false; - panner.instantiate(); panner->set_callbacks(callable_mp(this, &AnimationTimelineEdit::_scroll_callback), callable_mp(this, &AnimationTimelineEdit::_pan_callback), callable_mp(this, &AnimationTimelineEdit::_zoom_callback)); @@ -1945,6 +1943,16 @@ AnimationTimelineEdit::AnimationTimelineEdit() { void AnimationTrackEdit::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_THEME_CHANGED: { + if (animation.is_null()) { + return; + } + ERR_FAIL_INDEX(track, animation->get_track_count()); + + type_icon = _get_key_type_icon(); + selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + } break; + case NOTIFICATION_DRAW: { if (animation.is_null()) { return; @@ -1963,17 +1971,6 @@ void AnimationTrackEdit::_notification(int p_what) { 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[9] = { - get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackBlendShape"), 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(SNAME("hseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; @@ -1989,7 +1986,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)]; + Ref<Texture2D> type_icon = _get_key_type_icon(); draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; @@ -2425,22 +2422,10 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati track = p_track; update(); - Ref<Texture2D> type_icons[9] = { - get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXPosition"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXRotation"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXScale"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyBlendShape"), 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)]; + type_icon = _get_key_type_icon(); selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); } @@ -2541,6 +2526,21 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant return (!prop_exists || Variant::can_convert(p_key_value.get_type(), r_valid_type)); } +Ref<Texture2D> AnimationTrackEdit::_get_key_type_icon() const { + Ref<Texture2D> type_icons[9] = { + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackBlendShape"), 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")) + }; + return type_icons[animation->track_get_type(track)]; +} + String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (check_rect.has_point(p_pos)) { return TTR("Toggle this track on/off."); @@ -3146,13 +3146,8 @@ AnimationTrackEdit::AnimationTrackEdit() { path = nullptr; path_popup = nullptr; menu = nullptr; - clicking_on_name = false; dropping_at = 0; - in_group = false; - - moving_selection_attempt = false; - moving_selection = false; select_single_attempt = -1; play_position_pos = 0; @@ -6311,8 +6306,6 @@ AnimationTrackEditor::AnimationTrackEditor() { add_child(method_selector); method_selector->connect("selected", callable_mp(this, &AnimationTrackEditor::_add_method_key)); - insert_queue = false; - insert_confirm = memnew(ConfirmationDialog); add_child(insert_confirm); insert_confirm->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_confirm_insert_list)); @@ -6330,8 +6323,6 @@ AnimationTrackEditor::AnimationTrackEditor() { insert_confirm_reset->set_text(TTR("Create RESET Track(s)", "")); insert_confirm_reset->set_pressed(EDITOR_GET("editors/animation/default_create_reset_tracks")); ichb->add_child(insert_confirm_reset); - keying = false; - moving_selection = false; key_edit = nullptr; multi_key_edit = nullptr; @@ -6341,7 +6332,6 @@ AnimationTrackEditor::AnimationTrackEditor() { box_selection->set_mouse_filter(MOUSE_FILTER_IGNORE); box_selection->hide(); box_selection->connect("draw", callable_mp(this, &AnimationTrackEditor::_box_selection_draw)); - box_selecting = false; // Default Plugins. @@ -6438,7 +6428,6 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_select->set_hide_root(true); track_vbox->add_child(track_copy_select); track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_COPY_TRACKS_CONFIRM)); - animation_changing_awaiting_update = false; } AnimationTrackEditor::~AnimationTrackEditor() { |