Skip to content

Commit 3140ae1

Browse files
committed
Use new dock system for SpriteFrames Dock
1 parent 7ed0b61 commit 3140ae1

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

editor/docks/editor_dock_manager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,9 @@ void EditorDockManager::save_docks_to_config(Ref<ConfigFile> p_layout, const Str
613613
window_dump["window_screen_rect"] = DisplayServer::get_singleton()->screen_get_usable_rect(screen);
614614

615615
String name = dock->get_effective_layout_key();
616-
floating_docks_dump[name] = window_dump;
616+
if (!dock->transient) {
617+
floating_docks_dump[name] = window_dump;
618+
}
617619

618620
// Append to regular dock section so we know where to restore it to.
619621
int dock_slot_id = dock->dock_slot_index;

editor/scene/sprite_frames_editor_plugin.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "editor/editor_string_names.h"
3939
#include "editor/editor_undo_redo_manager.h"
4040
#include "editor/file_system/editor_file_system.h"
41-
#include "editor/gui/editor_bottom_panel.h"
4241
#include "editor/gui/editor_file_dialog.h"
4342
#include "editor/settings/editor_command_palette.h"
4443
#include "editor/settings/editor_settings.h"
@@ -51,6 +50,7 @@
5150
#include "scene/gui/option_button.h"
5251
#include "scene/gui/panel_container.h"
5352
#include "scene/gui/separator.h"
53+
#include "scene/gui/split_container.h"
5454
#include "scene/resources/atlas_texture.h"
5555

5656
static void _draw_shadowed_line(Control *p_control, const Point2 &p_from, const Size2 &p_size, const Size2 &p_shadow_offset, Color p_color, Color p_shadow_color) {
@@ -2067,9 +2067,20 @@ void SpriteFramesEditor::_node_removed(Node *p_node) {
20672067
}
20682068

20692069
SpriteFramesEditor::SpriteFramesEditor() {
2070+
set_name(TTRC("SpriteFrames"));
2071+
set_icon_name("SpriteFrames");
2072+
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTRC("Open SpriteFrames Dock")));
2073+
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
2074+
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
2075+
set_global(false);
2076+
set_transient(true);
2077+
2078+
HSplitContainer *main_split = memnew(HSplitContainer);
2079+
add_child(main_split);
2080+
20702081
VBoxContainer *vbc_animlist = memnew(VBoxContainer);
2071-
add_child(vbc_animlist);
2072-
vbc_animlist->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
2082+
main_split->add_child(vbc_animlist);
2083+
vbc_animlist->set_custom_minimum_size(Size2(150 * EDSCALE, 0));
20732084

20742085
VBoxContainer *sub_vb = memnew(VBoxContainer);
20752086
vbc_animlist->add_margin_child(TTRC("Animations:"), sub_vb, true);
@@ -2186,10 +2197,10 @@ SpriteFramesEditor::SpriteFramesEditor() {
21862197
missing_anim_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
21872198
missing_anim_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
21882199
missing_anim_label->hide();
2189-
add_child(missing_anim_label);
2200+
main_split->add_child(missing_anim_label);
21902201

21912202
anim_frames_vb = memnew(VBoxContainer);
2192-
add_child(anim_frames_vb);
2203+
main_split->add_child(anim_frames_vb);
21932204
anim_frames_vb->set_h_size_flags(SIZE_EXPAND_FILL);
21942205
anim_frames_vb->hide();
21952206

@@ -2670,7 +2681,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
26702681

26712682
// Ensure the anim search box is wide enough by default.
26722683
// Not by setting its minimum size so it can still be shrunk if desired.
2673-
set_split_offset(56 * EDSCALE);
2684+
main_split->set_split_offset(56 * EDSCALE);
26742685
}
26752686

26762687
void SpriteFramesEditorPlugin::edit(Object *p_object) {
@@ -2708,21 +2719,17 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
27082719

27092720
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
27102721
if (p_visible) {
2711-
button->show();
2712-
EditorNode::get_bottom_panel()->make_item_visible(frames_editor);
2722+
frames_editor->make_visible();
27132723
} else {
2714-
button->hide();
2715-
if (frames_editor->is_visible_in_tree()) {
2716-
EditorNode::get_bottom_panel()->hide_bottom_panel();
2717-
}
2724+
frames_editor->close();
27182725
}
27192726
}
27202727

27212728
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
27222729
frames_editor = memnew(SpriteFramesEditor);
27232730
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
2724-
button = EditorNode::get_bottom_panel()->add_item(TTRC("SpriteFrames"), frames_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTRC("Toggle SpriteFrames Bottom Panel")));
2725-
button->hide();
2731+
EditorDockManager::get_singleton()->add_dock(frames_editor);
2732+
frames_editor->close();
27262733
}
27272734

27282735
Ref<ClipboardAnimation> ClipboardAnimation::from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim) {

editor/scene/sprite_frames_editor_plugin.h

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

3131
#pragma once
3232

33+
#include "editor/docks/editor_dock.h"
3334
#include "editor/plugins/editor_plugin.h"
3435
#include "scene/gui/button.h"
3536
#include "scene/gui/dialogs.h"
3637
#include "scene/gui/item_list.h"
3738
#include "scene/gui/line_edit.h"
3839
#include "scene/gui/scroll_container.h"
3940
#include "scene/gui/spin_box.h"
40-
#include "scene/gui/split_container.h"
4141
#include "scene/gui/texture_rect.h"
4242
#include "scene/gui/tree.h"
4343
#include "scene/resources/image_texture.h"
@@ -69,8 +69,8 @@ class ClipboardAnimation : public Resource {
6969
static Ref<ClipboardAnimation> from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim);
7070
};
7171

72-
class SpriteFramesEditor : public HSplitContainer {
73-
GDCLASS(SpriteFramesEditor, HSplitContainer);
72+
class SpriteFramesEditor : public EditorDock {
73+
GDCLASS(SpriteFramesEditor, EditorDock);
7474

7575
Ref<SpriteFrames> frames;
7676
Node *animated_sprite = nullptr;
@@ -313,7 +313,6 @@ class SpriteFramesEditorPlugin : public EditorPlugin {
313313
GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
314314

315315
SpriteFramesEditor *frames_editor = nullptr;
316-
Button *button = nullptr;
317316

318317
public:
319318
virtual String get_plugin_name() const override { return "SpriteFrames"; }

0 commit comments

Comments
 (0)