diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 115 |
1 files changed, 92 insertions, 23 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 5d49290612..4274fb993f 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -634,7 +634,7 @@ public: bool use_fps = false; void notify_change() { - _change_notify(); + notify_property_list_changed(); } Node *get_root_path() { @@ -643,7 +643,7 @@ public: void set_use_fps(bool p_enable) { use_fps = p_enable; - _change_notify(); + notify_property_list_changed(); } }; @@ -1276,7 +1276,7 @@ public: UndoRedo *undo_redo = nullptr; void notify_change() { - _change_notify(); + notify_property_list_changed(); } Node *get_root_path() { @@ -1285,7 +1285,7 @@ public: void set_use_fps(bool p_enable) { use_fps = p_enable; - _change_notify(); + notify_property_list_changed(); } }; @@ -1643,24 +1643,24 @@ void AnimationTimelineEdit::_play_position_draw() { void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && hsize_rect.has_point(mb->get_position())) { + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && hsize_rect.has_point(mb->get_position())) { dragging_hsize = true; dragging_hsize_from = mb->get_position().x; dragging_hsize_at = name_limit; } - if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && dragging_hsize) { + if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && dragging_hsize) { dragging_hsize = false; } if (mb.is_valid() && mb->get_position().x > get_name_limit() && mb->get_position().x < (get_size().width - get_buttons_width())) { - if (!panning_timeline && mb->get_button_index() == BUTTON_LEFT) { + if (!panning_timeline && mb->get_button_index() == MOUSE_BUTTON_LEFT) { int x = mb->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); emit_signal("timeline_changed", ofs, false); dragging_timeline = true; } - if (!dragging_timeline && mb->get_button_index() == BUTTON_MIDDLE) { + if (!dragging_timeline && mb->get_button_index() == MOUSE_BUTTON_MIDDLE) { int x = mb->get_position().x - get_name_limit(); panning_timeline_from = x / get_zoom_scale(); panning_timeline = true; @@ -1668,11 +1668,11 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - if (dragging_timeline && mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) { + if (dragging_timeline && mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT && !mb->is_pressed()) { dragging_timeline = false; } - if (panning_timeline && mb.is_valid() && mb->get_button_index() == BUTTON_MIDDLE && !mb->is_pressed()) { + if (panning_timeline && mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_MIDDLE && !mb->is_pressed()) { panning_timeline = false; } @@ -2540,7 +2540,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { Point2 pos = mb->get_position(); if (check_rect.has_point(pos)) { @@ -2683,7 +2683,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) { Point2 pos = mb->get_position(); if (pos.x >= timeline->get_name_limit() && pos.x <= get_size().width - timeline->get_buttons_width()) { // Can do something with menu too! show insert key. @@ -2713,7 +2713,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } } - if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && clicking_on_name) { + if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT && clicking_on_name) { if (!path) { path_popup = memnew(Popup); path_popup->set_wrap_controls(true); @@ -2735,7 +2735,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && moving_selection_attempt) { - if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { + if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { moving_selection_attempt = false; if (moving_selection) { emit_signal("move_selection_commit"); @@ -2746,7 +2746,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { select_single_attempt = -1; } - if (moving_selection && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { + 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"); @@ -2754,7 +2754,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT && moving_selection_attempt) { + 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"); @@ -4283,7 +4283,6 @@ void AnimationTrackEditor::_animation_update() { _update_step_spinbox(); emit_signal("animation_step_changed", animation->get_step()); emit_signal("animation_len_changed", animation->get_length()); - EditorNode::get_singleton()->get_inspector()->refresh(); animation_changing_awaiting_update = false; } @@ -4440,6 +4439,8 @@ void AnimationTrackEditor::_add_track(int p_type) { } adding_track_type = p_type; pick_track->popup_scenetree_dialog(); + pick_track->get_filter_line_edit()->clear(); + pick_track->get_filter_line_edit()->grab_focus(); } void AnimationTrackEditor::_new_track_property_selected(String p_name) { @@ -4954,17 +4955,17 @@ void AnimationTrackEditor::_box_selection_draw() { 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() == BUTTON_WHEEL_UP) { + if (mb.is_valid() && mb->is_pressed() && mb->get_command() && 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() == BUTTON_WHEEL_DOWN) { + if (mb.is_valid() && mb->is_pressed() && mb->get_command() && 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->get_button_index() == BUTTON_LEFT) { + if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (mb->is_pressed()) { box_selecting = true; box_selecting_from = scroll->get_global_transform().xform(mb->get_position()); @@ -4992,12 +4993,12 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) { + if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_MIDDLE) { timeline->set_value(timeline->get_value() - mm->get_relative().x / timeline->get_zoom_scale()); } if (mm.is_valid() && box_selecting) { - if (!(mm->get_button_mask() & BUTTON_MASK_LEFT)) { + if (!(mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT)) { //no longer box_selection->hide(); box_selecting = false; @@ -5636,6 +5637,70 @@ void AnimationTrackEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("animation_step_changed", PropertyInfo(Variant::FLOAT, "step"))); } +void AnimationTrackEditor::_pick_track_filter_text_changed(const String &p_newtext) { + TreeItem *root_item = pick_track->get_scene_tree()->get_scene_tree()->get_root(); + + Vector<Node *> select_candidates; + Node *to_select = nullptr; + + String filter = pick_track->get_filter_line_edit()->get_text(); + + _pick_track_select_recursive(root_item, filter, select_candidates); + + if (!select_candidates.is_empty()) { + for (int i = 0; i < select_candidates.size(); ++i) { + Node *candidate = select_candidates[i]; + + if (((String)candidate->get_name()).to_lower().begins_with(filter.to_lower())) { + to_select = candidate; + break; + } + } + + if (!to_select) { + to_select = select_candidates[0]; + } + } + + pick_track->get_scene_tree()->set_selected(to_select); +} + +void AnimationTrackEditor::_pick_track_select_recursive(TreeItem *p_item, const String &p_filter, Vector<Node *> &p_select_candidates) { + if (!p_item) { + return; + } + + NodePath np = p_item->get_metadata(0); + Node *node = get_node(np); + + if (p_filter != String() && ((String)node->get_name()).findn(p_filter) != -1) { + p_select_candidates.push_back(node); + } + + TreeItem *c = p_item->get_children(); + + while (c) { + _pick_track_select_recursive(c, p_filter, p_select_candidates); + c = c->get_next(); + } +} + +void AnimationTrackEditor::_pick_track_filter_input(const Ref<InputEvent> &p_ie) { + Ref<InputEventKey> k = p_ie; + + if (k.is_valid()) { + switch (k->get_keycode()) { + case KEY_UP: + case KEY_DOWN: + case KEY_PAGEUP: + case KEY_PAGEDOWN: { + pick_track->get_scene_tree()->get_scene_tree()->call("_gui_input", k); + pick_track->get_filter_line_edit()->accept_event(); + } break; + } + } +} + AnimationTrackEditor::AnimationTrackEditor() { root = nullptr; @@ -5806,8 +5871,12 @@ AnimationTrackEditor::AnimationTrackEditor() { pick_track = memnew(SceneTreeDialog); add_child(pick_track); + pick_track->register_text_enter(pick_track->get_filter_line_edit()); pick_track->set_title(TTR("Pick a node to animate:")); pick_track->connect("selected", callable_mp(this, &AnimationTrackEditor::_new_track_node_selected)); + pick_track->get_filter_line_edit()->connect("text_changed", callable_mp(this, &AnimationTrackEditor::_pick_track_filter_text_changed)); + pick_track->get_filter_line_edit()->connect("gui_input", callable_mp(this, &AnimationTrackEditor::_pick_track_filter_input)); + prop_selector = memnew(PropertySelector); add_child(prop_selector); prop_selector->connect("selected", callable_mp(this, &AnimationTrackEditor::_new_track_property_selected)); @@ -5886,7 +5955,7 @@ AnimationTrackEditor::AnimationTrackEditor() { optimize_max_angle->set_value(22); optimize_dialog->get_ok_button()->set_text(TTR("Optimize")); - optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_CLEAN_UP_ANIMATION_CONFIRM)); + optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_OPTIMIZE_ANIMATION_CONFIRM)); // |