Skip to content

Commit a0c2d3d

Browse files
committed
Use new dock system for Animation dock
1 parent a2db180 commit a0c2d3d

9 files changed

Lines changed: 71 additions & 49 deletions

editor/animation/animation_bezier_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
266266
}
267267
} break;
268268

269-
case NOTIFICATION_ENTER_TREE: {
269+
case NOTIFICATION_READY: {
270270
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")));
271271
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
272272
} break;

editor/animation/animation_blend_tree_editor_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ void AnimationNodeBlendTreeEditor::_update_editor_settings() {
982982

983983
void AnimationNodeBlendTreeEditor::_notification(int p_what) {
984984
switch (p_what) {
985-
case NOTIFICATION_ENTER_TREE: {
985+
case NOTIFICATION_READY: {
986986
_update_editor_settings();
987987
} break;
988988

editor/animation/animation_player_editor_plugin.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
#include "core/input/input.h"
3535
#include "core/os/keyboard.h"
3636
#include "editor/animation/animation_tree_editor_plugin.h"
37+
#include "editor/docks/editor_dock_manager.h"
3738
#include "editor/docks/inspector_dock.h"
3839
#include "editor/docks/scene_tree_dock.h"
3940
#include "editor/editor_node.h"
4041
#include "editor/editor_undo_redo_manager.h"
41-
#include "editor/gui/editor_bottom_panel.h"
4242
#include "editor/gui/editor_file_dialog.h"
4343
#include "editor/gui/editor_validation_panel.h"
4444
#include "editor/scene/3d/node_3d_editor_plugin.h" // For onion skinning.
@@ -140,14 +140,14 @@ void AnimationPlayerEditor::_notification(int p_what) {
140140
} break;
141141

142142
case NOTIFICATION_ENTER_TREE: {
143-
tool_anim->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
144-
145-
onion_skinning->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu));
146-
147-
blend_editor.next->connect(SceneStringName(item_selected), callable_mp(this, &AnimationPlayerEditor::_blend_editor_next_changed));
148-
149143
get_tree()->connect(SNAME("node_removed"), callable_mp(this, &AnimationPlayerEditor::_node_removed));
144+
} break;
150145

146+
case NOTIFICATION_EXIT_TREE: {
147+
get_tree()->disconnect(SNAME("node_removed"), callable_mp(this, &AnimationPlayerEditor::_node_removed));
148+
} break;
149+
150+
case NOTIFICATION_READY: {
151151
EditorNode::get_singleton()->connect("scene_changed", callable_mp(this, &AnimationPlayerEditor::_find_player));
152152

153153
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) {
929929
}
930930

931931
_update_player();
932-
EditorNode::get_bottom_panel()->make_item_visible(this);
932+
make_visible();
933933
set_process(true);
934934
ensure_visibility();
935935

@@ -2042,11 +2042,19 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
20422042
plugin = p_plugin;
20432043
singleton = this;
20442044

2045+
set_name(TTRC("Animation"));
2046+
set_icon_name("Animation");
2047+
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_bottom_panel", TTRC("Toggle Animation Dock"), KeyModifierMask::ALT | Key::N));
2048+
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
2049+
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
2050+
20452051
set_focus_mode(FOCUS_ALL);
20462052
set_process_shortcut_input(true);
20472053

2054+
VBoxContainer *main_vbox_container = memnew(VBoxContainer);
2055+
add_child(main_vbox_container);
20482056
HBoxContainer *hb = memnew(HBoxContainer);
2049-
add_child(hb);
2057+
main_vbox_container->add_child(hb);
20502058

20512059
HBoxContainer *playback_container = memnew(HBoxContainer);
20522060
playback_container->set_layout_direction(LAYOUT_DIRECTION_LTR);
@@ -2114,6 +2122,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
21142122
tool_anim->get_popup()->add_separator();
21152123
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/remove_animation", TTRC("Remove")), TOOL_REMOVE_ANIM);
21162124
tool_anim->set_disabled(true);
2125+
tool_anim->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu));
21172126
hb->add_child(tool_anim);
21182127

21192128
animation = memnew(OptionButton);
@@ -2163,6 +2172,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
21632172
onion_skinning->get_popup()->add_check_item(TTR("Differences Only"), ONION_SKINNING_DIFFERENCES_ONLY);
21642173
onion_skinning->get_popup()->add_check_item(TTR("Force White Modulate"), ONION_SKINNING_FORCE_WHITE_MODULATE);
21652174
onion_skinning->get_popup()->add_check_item(TTR("Include Gizmos (3D)"), ONION_SKINNING_INCLUDE_GIZMOS);
2175+
onion_skinning->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu));
21662176
hb->add_child(onion_skinning);
21672177

21682178
hb->add_child(memnew(VSeparator));
@@ -2226,6 +2236,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
22262236

22272237
blend_editor.next = memnew(OptionButton);
22282238
blend_editor.next->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
2239+
blend_editor.next->connect(SceneStringName(item_selected), callable_mp(this, &AnimationPlayerEditor::_blend_editor_next_changed));
22292240
blend_vb->add_margin_child(TTR("Next (Auto Queue):"), blend_editor.next);
22302241

22312242
autoplay->connect(SceneStringName(pressed), callable_mp(this, &AnimationPlayerEditor::_autoplay_pressed));
@@ -2241,7 +2252,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
22412252
frame->connect(SceneStringName(value_changed), callable_mp(this, &AnimationPlayerEditor::_seek_value_changed).bind(false));
22422253
scale->connect(SceneStringName(text_submitted), callable_mp(this, &AnimationPlayerEditor::_scale_changed));
22432254

2244-
add_child(track_editor);
2255+
main_vbox_container->add_child(track_editor);
22452256
track_editor->set_v_size_flags(SIZE_EXPAND_FILL);
22462257
track_editor->connect(SNAME("timeline_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_seek));
22472258
track_editor->connect(SNAME("animation_len_changed"), callable_mp(this, &AnimationPlayerEditor::_animation_key_editor_anim_len_changed));
@@ -2309,7 +2320,7 @@ AnimationPlayerEditor::~AnimationPlayerEditor() {
23092320

23102321
void AnimationPlayerEditorPlugin::_notification(int p_what) {
23112322
switch (p_what) {
2312-
case NOTIFICATION_ENTER_TREE: {
2323+
case NOTIFICATION_READY: {
23132324
Node3DEditor::get_singleton()->connect(SNAME("transform_key_request"), callable_mp(this, &AnimationPlayerEditorPlugin::_transform_key_request));
23142325
InspectorDock::get_inspector_singleton()->connect(SNAME("property_keyed"), callable_mp(this, &AnimationPlayerEditorPlugin::_property_keyed));
23152326
anim_editor->get_track_editor()->connect(SNAME("keying_changed"), callable_mp(this, &AnimationPlayerEditorPlugin::_update_keying));
@@ -2437,15 +2448,15 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
24372448
if (AnimationTreeEditor::get_singleton() && AnimationTreeEditor::get_singleton()->is_visible_in_tree()) {
24382449
return;
24392450
}
2440-
EditorNode::get_bottom_panel()->make_item_visible(anim_editor);
2451+
anim_editor->make_visible();
24412452
anim_editor->set_process(true);
24422453
anim_editor->ensure_visibility();
24432454
}
24442455
}
24452456

24462457
AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin() {
24472458
anim_editor = memnew(AnimationPlayerEditor(this));
2448-
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));
2459+
EditorDockManager::get_singleton()->add_dock(anim_editor);
24492460
}
24502461

24512462
AnimationPlayerEditorPlugin::~AnimationPlayerEditorPlugin() {

editor/animation/animation_player_editor_plugin.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "editor/animation/animation_library_editor.h"
3434
#include "editor/animation/animation_track_editor.h"
35+
#include "editor/docks/editor_dock.h"
3536
#include "editor/plugins/editor_plugin.h"
3637
#include "scene/animation/animation_player.h"
3738
#include "scene/gui/dialogs.h"
@@ -43,8 +44,8 @@
4344
class AnimationPlayerEditorPlugin;
4445
class ImageTexture;
4546

46-
class AnimationPlayerEditor : public VBoxContainer {
47-
GDCLASS(AnimationPlayerEditor, VBoxContainer);
47+
class AnimationPlayerEditor : public EditorDock {
48+
GDCLASS(AnimationPlayerEditor, EditorDock);
4849

4950
friend AnimationPlayerEditorPlugin;
5051

editor/animation/animation_track_editor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
14831483
}
14841484
[[fallthrough]];
14851485
}
1486-
case NOTIFICATION_ENTER_TREE: {
1486+
case NOTIFICATION_READY: {
14871487
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")));
14881488
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
14891489
} break;
@@ -5520,12 +5520,11 @@ void AnimationTrackEditor::_notification(int p_what) {
55205520
if (!EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) {
55215521
break;
55225522
}
5523-
[[fallthrough]];
5524-
}
5525-
case NOTIFICATION_ENTER_TREE: {
5523+
55265524
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")));
55275525
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
55285526
} break;
5527+
55295528
case NOTIFICATION_THEME_CHANGED: {
55305529
add_animation_player->set_button_icon(get_editor_theme_icon(SNAME("Add")));
55315530
zoom_icon->set_texture(get_editor_theme_icon(SNAME("Zoom")));
@@ -5568,6 +5567,9 @@ void AnimationTrackEditor::_notification(int p_what) {
55685567

55695568
EditorNode::get_singleton()->connect("scene_changed", callable_mp(this, &AnimationTrackEditor::_scene_changed));
55705569
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &AnimationTrackEditor::_selection_changed));
5570+
5571+
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")));
5572+
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
55715573
} break;
55725574

55735575
case NOTIFICATION_VISIBILITY_CHANGED: {

editor/animation/animation_tree_editor_plugin.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ void AnimationTreeEditor::enter_editor(const String &p_path) {
176176

177177
void AnimationTreeEditor::_notification(int p_what) {
178178
switch (p_what) {
179-
case NOTIFICATION_ENTER_TREE: {
180-
get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
181-
} break;
182179
case NOTIFICATION_PROCESS: {
183180
ObjectID root;
184181
if (tree && tree->get_root_animation_node().is_valid()) {
@@ -193,6 +190,11 @@ void AnimationTreeEditor::_notification(int p_what) {
193190
edit_path(edited_path);
194191
}
195192
} break;
193+
194+
case NOTIFICATION_ENTER_TREE: {
195+
get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
196+
} break;
197+
196198
case NOTIFICATION_EXIT_TREE: {
197199
get_tree()->disconnect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
198200
} break;
@@ -256,20 +258,33 @@ Vector<String> AnimationTreeEditor::get_animation_list() {
256258
}
257259

258260
AnimationTreeEditor::AnimationTreeEditor() {
261+
singleton = this;
259262
AnimationNodeAnimation::get_editable_animation_list = get_animation_list;
263+
264+
set_name(TTRC("AnimationTree"));
265+
set_icon_name("AnimationTreeDock");
266+
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_tree_bottom_panel", TTRC("Toggle AnimationTree Dock")));
267+
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
268+
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
269+
set_global(false);
270+
set_transient(true);
271+
272+
VBoxContainer *main_vbox_container = memnew(VBoxContainer);
273+
add_child(main_vbox_container);
274+
260275
path_edit = memnew(ScrollContainer);
261-
add_child(path_edit);
262276
path_edit->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
277+
main_vbox_container->add_child(path_edit);
278+
263279
path_hb = memnew(HBoxContainer);
264-
path_edit->add_child(path_hb);
265280
path_hb->add_child(memnew(Label(TTR("Path:"))));
281+
path_edit->add_child(path_hb);
266282

267-
add_child(memnew(HSeparator));
283+
main_vbox_container->add_child(memnew(HSeparator));
268284

269-
singleton = this;
270285
editor_base = memnew(MarginContainer);
271286
editor_base->set_v_size_flags(SIZE_EXPAND_FILL);
272-
add_child(editor_base);
287+
main_vbox_container->add_child(editor_base);
273288

274289
add_plugin(memnew(AnimationNodeBlendTreeEditor));
275290
add_plugin(memnew(AnimationNodeBlendSpace1DEditor));
@@ -287,24 +302,17 @@ bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
287302

288303
void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
289304
if (p_visible) {
290-
//editor->hide_animation_player_editors();
291-
//editor->animation_panel_make_visible(true);
292-
button->show();
293-
EditorNode::get_bottom_panel()->make_item_visible(anim_tree_editor);
294-
anim_tree_editor->set_process(true);
305+
anim_tree_editor->make_visible();
295306
} else {
296-
if (anim_tree_editor->is_visible_in_tree()) {
297-
EditorNode::get_bottom_panel()->hide_bottom_panel();
298-
}
299-
button->hide();
300-
anim_tree_editor->set_process(false);
307+
anim_tree_editor->close();
301308
}
309+
310+
anim_tree_editor->set_process(p_visible);
302311
}
303312

304313
AnimationTreeEditorPlugin::AnimationTreeEditorPlugin() {
305314
anim_tree_editor = memnew(AnimationTreeEditor);
306315
anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
307-
308-
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")));
309-
button->hide();
316+
EditorDockManager::get_singleton()->add_dock(anim_tree_editor);
317+
anim_tree_editor->close();
310318
}

editor/animation/animation_tree_editor_plugin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#pragma once
3232

33+
#include "editor/docks/editor_dock.h"
3334
#include "editor/plugins/editor_plugin.h"
3435
#include "scene/animation/animation_tree.h"
3536
#include "scene/gui/graph_edit.h"
@@ -46,8 +47,8 @@ class AnimationTreeNodeEditorPlugin : public VBoxContainer {
4647
virtual void edit(const Ref<AnimationNode> &p_node) = 0;
4748
};
4849

49-
class AnimationTreeEditor : public VBoxContainer {
50-
GDCLASS(AnimationTreeEditor, VBoxContainer);
50+
class AnimationTreeEditor : public EditorDock {
51+
GDCLASS(AnimationTreeEditor, EditorDock);
5152

5253
ScrollContainer *path_edit = nullptr;
5354
HBoxContainer *path_hb = nullptr;
@@ -96,7 +97,6 @@ class AnimationTreeEditorPlugin : public EditorPlugin {
9697
GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);
9798

9899
AnimationTreeEditor *anim_tree_editor = nullptr;
99-
Button *button = nullptr;
100100

101101
public:
102102
virtual String get_plugin_name() const override { return "AnimationTree"; }

editor/editor_node.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8944,9 +8944,6 @@ EditorNode::EditorNode() {
89448944

89458945
gui_base->add_child(project_data_missing);
89468946

8947-
add_editor_plugin(memnew(AnimationPlayerEditorPlugin));
8948-
add_editor_plugin(memnew(AnimationTrackKeyEditEditorPlugin));
8949-
add_editor_plugin(memnew(AnimationMarkerKeyEditEditorPlugin));
89508947
add_editor_plugin(memnew(CanvasItemEditorPlugin));
89518948
add_editor_plugin(memnew(Node3DEditorPlugin));
89528949
add_editor_plugin(memnew(ScriptEditorPlugin));
@@ -8967,7 +8964,9 @@ EditorNode::EditorNode() {
89678964
}
89688965

89698966
// More visually meaningful to have this later.
8970-
bottom_panel->move_item_to_end(AnimationPlayerEditor::get_singleton());
8967+
add_editor_plugin(memnew(AnimationPlayerEditorPlugin));
8968+
add_editor_plugin(memnew(AnimationTrackKeyEditEditorPlugin));
8969+
add_editor_plugin(memnew(AnimationMarkerKeyEditEditorPlugin));
89718970

89728971
add_editor_plugin(VersionControlEditorPlugin::get_singleton());
89738972

editor/icons/AnimationTreeDock.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)