diff --git a/editor/animation/animation_bezier_editor.cpp b/editor/animation/animation_bezier_editor.cpp index 5c97d735f51..17670ad5f63 100644 --- a/editor/animation/animation_bezier_editor.cpp +++ b/editor/animation/animation_bezier_editor.cpp @@ -266,7 +266,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } } break; - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_READY: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning")); } break; diff --git a/editor/animation/animation_blend_tree_editor_plugin.cpp b/editor/animation/animation_blend_tree_editor_plugin.cpp index c2940b3f248..6b55054438b 100644 --- a/editor/animation/animation_blend_tree_editor_plugin.cpp +++ b/editor/animation/animation_blend_tree_editor_plugin.cpp @@ -982,7 +982,7 @@ void AnimationNodeBlendTreeEditor::_update_editor_settings() { void AnimationNodeBlendTreeEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_READY: { _update_editor_settings(); } break; diff --git a/editor/animation/animation_player_editor_plugin.cpp b/editor/animation/animation_player_editor_plugin.cpp index 591da81badc..3ab09046bc5 100644 --- a/editor/animation/animation_player_editor_plugin.cpp +++ b/editor/animation/animation_player_editor_plugin.cpp @@ -34,11 +34,11 @@ #include "core/input/input.h" #include "core/os/keyboard.h" #include "editor/animation/animation_tree_editor_plugin.h" +#include "editor/docks/editor_dock_manager.h" #include "editor/docks/inspector_dock.h" #include "editor/docks/scene_tree_dock.h" #include "editor/editor_node.h" #include "editor/editor_undo_redo_manager.h" -#include "editor/gui/editor_bottom_panel.h" #include "editor/gui/editor_file_dialog.h" #include "editor/gui/editor_validation_panel.h" #include "editor/scene/3d/node_3d_editor_plugin.h" // For onion skinning. @@ -140,14 +140,14 @@ void AnimationPlayerEditor::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - tool_anim->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu)); - - onion_skinning->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu)); - - blend_editor.next->connect(SceneStringName(item_selected), callable_mp(this, &AnimationPlayerEditor::_blend_editor_next_changed)); - get_tree()->connect(SNAME("node_removed"), callable_mp(this, &AnimationPlayerEditor::_node_removed)); + } break; + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect(SNAME("node_removed"), callable_mp(this, &AnimationPlayerEditor::_node_removed)); + } break; + + case NOTIFICATION_READY: { EditorNode::get_singleton()->connect("scene_changed", callable_mp(this, &AnimationPlayerEditor::_find_player)); add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SceneStringName(panel), SNAME("Panel"))); @@ -929,7 +929,7 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) { } _update_player(); - EditorNode::get_bottom_panel()->make_item_visible(this); + make_visible(); set_process(true); ensure_visibility(); @@ -2042,11 +2042,19 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug plugin = p_plugin; singleton = this; + set_name(TTRC("Animation")); + set_icon_name("Animation"); + set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_bottom_panel", TTRC("Toggle Animation Dock"), KeyModifierMask::ALT | Key::N)); + set_default_slot(DockConstants::DOCK_SLOT_BOTTOM); + set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING); + set_focus_mode(FOCUS_ALL); set_process_shortcut_input(true); + VBoxContainer *main_vbox_container = memnew(VBoxContainer); + add_child(main_vbox_container); HBoxContainer *hb = memnew(HBoxContainer); - add_child(hb); + main_vbox_container->add_child(hb); HBoxContainer *playback_container = memnew(HBoxContainer); playback_container->set_layout_direction(LAYOUT_DIRECTION_LTR); @@ -2114,6 +2122,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug tool_anim->get_popup()->add_separator(); tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/remove_animation", TTRC("Remove")), TOOL_REMOVE_ANIM); tool_anim->set_disabled(true); + tool_anim->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu)); hb->add_child(tool_anim); animation = memnew(OptionButton); @@ -2163,6 +2172,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug onion_skinning->get_popup()->add_check_item(TTR("Differences Only"), ONION_SKINNING_DIFFERENCES_ONLY); onion_skinning->get_popup()->add_check_item(TTR("Force White Modulate"), ONION_SKINNING_FORCE_WHITE_MODULATE); onion_skinning->get_popup()->add_check_item(TTR("Include Gizmos (3D)"), ONION_SKINNING_INCLUDE_GIZMOS); + onion_skinning->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu)); hb->add_child(onion_skinning); hb->add_child(memnew(VSeparator)); @@ -2226,6 +2236,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug blend_editor.next = memnew(OptionButton); blend_editor.next->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); + blend_editor.next->connect(SceneStringName(item_selected), callable_mp(this, &AnimationPlayerEditor::_blend_editor_next_changed)); blend_vb->add_margin_child(TTR("Next (Auto Queue):"), blend_editor.next); autoplay->connect(SceneStringName(pressed), callable_mp(this, &AnimationPlayerEditor::_autoplay_pressed)); @@ -2241,7 +2252,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug frame->connect(SceneStringName(value_changed), callable_mp(this, &AnimationPlayerEditor::_seek_value_changed).bind(false)); scale->connect(SceneStringName(text_submitted), callable_mp(this, &AnimationPlayerEditor::_scale_changed)); - add_child(track_editor); + main_vbox_container->add_child(track_editor); track_editor->set_v_size_flags(SIZE_EXPAND_FILL); track_editor->connect(SNAME("timeline_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_seek)); track_editor->connect(SNAME("animation_len_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_anim_len_changed)); @@ -2309,7 +2320,7 @@ AnimationPlayerEditor::~AnimationPlayerEditor() { void AnimationPlayerEditorPlugin::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_READY: { Node3DEditor::get_singleton()->connect(SNAME("transform_key_request"), callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request)); InspectorDock::get_inspector_singleton()->connect(SNAME("property_keyed"), callable_mp(this, &AnimationPlayerEditorPlugin::_property_keyed)); anim_editor->get_track_editor()->connect(SNAME("keying_changed"), callable_mp(this, &AnimationPlayerEditorPlugin::_update_keying)); @@ -2437,7 +2448,7 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) { if (AnimationTreeEditor::get_singleton() && AnimationTreeEditor::get_singleton()->is_visible_in_tree()) { return; } - EditorNode::get_bottom_panel()->make_item_visible(anim_editor); + anim_editor->make_visible(); anim_editor->set_process(true); anim_editor->ensure_visibility(); } @@ -2445,7 +2456,7 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) { AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin() { anim_editor = memnew(AnimationPlayerEditor(this)); - EditorNode::get_bottom_panel()->add_item(TTRC("Animation"), anim_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_bottom_panel", TTRC("Toggle Animation Bottom Panel"), KeyModifierMask::ALT | Key::N)); + EditorDockManager::get_singleton()->add_dock(anim_editor); } AnimationPlayerEditorPlugin::~AnimationPlayerEditorPlugin() { diff --git a/editor/animation/animation_player_editor_plugin.h b/editor/animation/animation_player_editor_plugin.h index 1ac91c80914..28983a2490a 100644 --- a/editor/animation/animation_player_editor_plugin.h +++ b/editor/animation/animation_player_editor_plugin.h @@ -32,6 +32,7 @@ #include "editor/animation/animation_library_editor.h" #include "editor/animation/animation_track_editor.h" +#include "editor/docks/editor_dock.h" #include "editor/plugins/editor_plugin.h" #include "scene/animation/animation_player.h" #include "scene/gui/dialogs.h" @@ -43,8 +44,8 @@ class AnimationPlayerEditorPlugin; class ImageTexture; -class AnimationPlayerEditor : public VBoxContainer { - GDCLASS(AnimationPlayerEditor, VBoxContainer); +class AnimationPlayerEditor : public EditorDock { + GDCLASS(AnimationPlayerEditor, EditorDock); friend AnimationPlayerEditorPlugin; diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index c74c8e92308..44ded4d0f1c 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -1483,7 +1483,7 @@ void AnimationTimelineEdit::_notification(int p_what) { } [[fallthrough]]; } - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_READY: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning")); } break; @@ -5529,12 +5529,11 @@ void AnimationTrackEditor::_notification(int p_what) { if (!EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) { break; } - [[fallthrough]]; - } - case NOTIFICATION_ENTER_TREE: { + panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning")); } break; + case NOTIFICATION_THEME_CHANGED: { add_animation_player->set_button_icon(get_editor_theme_icon(SNAME("Add"))); zoom_icon->set_texture(get_editor_theme_icon(SNAME("Zoom"))); @@ -5577,6 +5576,9 @@ void AnimationTrackEditor::_notification(int p_what) { EditorNode::get_singleton()->connect("scene_changed", callable_mp(this, &AnimationTrackEditor::_scene_changed)); EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &AnimationTrackEditor::_selection_changed)); + + panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning"))); + panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning")); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/animation/animation_tree_editor_plugin.cpp b/editor/animation/animation_tree_editor_plugin.cpp index f4e9d7d46ad..7da0797211b 100644 --- a/editor/animation/animation_tree_editor_plugin.cpp +++ b/editor/animation/animation_tree_editor_plugin.cpp @@ -176,9 +176,6 @@ void AnimationTreeEditor::enter_editor(const String &p_path) { void AnimationTreeEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed)); - } break; case NOTIFICATION_PROCESS: { ObjectID root; if (tree && tree->get_root_animation_node().is_valid()) { @@ -193,6 +190,11 @@ void AnimationTreeEditor::_notification(int p_what) { edit_path(edited_path); } } break; + + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed)); + } break; + case NOTIFICATION_EXIT_TREE: { get_tree()->disconnect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed)); } break; @@ -256,20 +258,33 @@ Vector AnimationTreeEditor::get_animation_list() { } AnimationTreeEditor::AnimationTreeEditor() { - AnimationNodeAnimation::get_editable_animation_list = get_animation_list; - path_edit = memnew(ScrollContainer); - add_child(path_edit); - path_edit->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); - path_hb = memnew(HBoxContainer); - path_edit->add_child(path_hb); - path_hb->add_child(memnew(Label(TTR("Path:")))); - - add_child(memnew(HSeparator)); - singleton = this; + AnimationNodeAnimation::get_editable_animation_list = get_animation_list; + + set_name(TTRC("AnimationTree")); + set_icon_name("AnimationTreeDock"); + set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_tree_bottom_panel", TTRC("Toggle AnimationTree Dock"))); + set_default_slot(DockConstants::DOCK_SLOT_BOTTOM); + set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING); + set_global(false); + set_transient(true); + + VBoxContainer *main_vbox_container = memnew(VBoxContainer); + add_child(main_vbox_container); + + path_edit = memnew(ScrollContainer); + path_edit->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); + main_vbox_container->add_child(path_edit); + + path_hb = memnew(HBoxContainer); + path_hb->add_child(memnew(Label(TTR("Path:")))); + path_edit->add_child(path_hb); + + main_vbox_container->add_child(memnew(HSeparator)); + editor_base = memnew(MarginContainer); editor_base->set_v_size_flags(SIZE_EXPAND_FILL); - add_child(editor_base); + main_vbox_container->add_child(editor_base); add_plugin(memnew(AnimationNodeBlendTreeEditor)); add_plugin(memnew(AnimationNodeBlendSpace1DEditor)); @@ -287,24 +302,17 @@ bool AnimationTreeEditorPlugin::handles(Object *p_object) const { void AnimationTreeEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - //editor->hide_animation_player_editors(); - //editor->animation_panel_make_visible(true); - button->show(); - EditorNode::get_bottom_panel()->make_item_visible(anim_tree_editor); - anim_tree_editor->set_process(true); + anim_tree_editor->make_visible(); } else { - if (anim_tree_editor->is_visible_in_tree()) { - EditorNode::get_bottom_panel()->hide_bottom_panel(); - } - button->hide(); - anim_tree_editor->set_process(false); + anim_tree_editor->close(); } + + anim_tree_editor->set_process(p_visible); } AnimationTreeEditorPlugin::AnimationTreeEditorPlugin() { anim_tree_editor = memnew(AnimationTreeEditor); anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); - - button = EditorNode::get_bottom_panel()->add_item(TTRC("AnimationTree"), anim_tree_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_tree_bottom_panel", TTRC("Toggle AnimationTree Bottom Panel"))); - button->hide(); + EditorDockManager::get_singleton()->add_dock(anim_tree_editor); + anim_tree_editor->close(); } diff --git a/editor/animation/animation_tree_editor_plugin.h b/editor/animation/animation_tree_editor_plugin.h index aa081846b7f..32db6f1a549 100644 --- a/editor/animation/animation_tree_editor_plugin.h +++ b/editor/animation/animation_tree_editor_plugin.h @@ -30,6 +30,7 @@ #pragma once +#include "editor/docks/editor_dock.h" #include "editor/plugins/editor_plugin.h" #include "scene/animation/animation_tree.h" #include "scene/gui/graph_edit.h" @@ -46,8 +47,8 @@ public: virtual void edit(const Ref &p_node) = 0; }; -class AnimationTreeEditor : public VBoxContainer { - GDCLASS(AnimationTreeEditor, VBoxContainer); +class AnimationTreeEditor : public EditorDock { + GDCLASS(AnimationTreeEditor, EditorDock); ScrollContainer *path_edit = nullptr; HBoxContainer *path_hb = nullptr; @@ -96,7 +97,6 @@ class AnimationTreeEditorPlugin : public EditorPlugin { GDCLASS(AnimationTreeEditorPlugin, EditorPlugin); AnimationTreeEditor *anim_tree_editor = nullptr; - Button *button = nullptr; public: virtual String get_plugin_name() const override { return "AnimationTree"; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 98804a4feb7..6499198e3b2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -8967,9 +8967,6 @@ EditorNode::EditorNode() { gui_base->add_child(project_data_missing); - add_editor_plugin(memnew(AnimationPlayerEditorPlugin)); - add_editor_plugin(memnew(AnimationTrackKeyEditEditorPlugin)); - add_editor_plugin(memnew(AnimationMarkerKeyEditEditorPlugin)); add_editor_plugin(memnew(CanvasItemEditorPlugin)); add_editor_plugin(memnew(Node3DEditorPlugin)); add_editor_plugin(memnew(ScriptEditorPlugin)); @@ -8990,7 +8987,9 @@ EditorNode::EditorNode() { } // More visually meaningful to have this later. - bottom_panel->move_item_to_end(AnimationPlayerEditor::get_singleton()); + add_editor_plugin(memnew(AnimationPlayerEditorPlugin)); + add_editor_plugin(memnew(AnimationTrackKeyEditEditorPlugin)); + add_editor_plugin(memnew(AnimationMarkerKeyEditEditorPlugin)); add_editor_plugin(VersionControlEditorPlugin::get_singleton()); diff --git a/editor/icons/AnimationTreeDock.svg b/editor/icons/AnimationTreeDock.svg new file mode 100644 index 00000000000..73f7f94837b --- /dev/null +++ b/editor/icons/AnimationTreeDock.svg @@ -0,0 +1 @@ +