Skip to content

Commit fbc9539

Browse files
committed
Merge pull request #113275 from lodetrick/sprite-dock
Use new dock system for SpriteFrames Dock
2 parents d1ce454 + 3140ae1 commit fbc9539

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
@@ -620,7 +620,9 @@ void EditorDockManager::save_docks_to_config(Ref<ConfigFile> p_layout, const Str
620620
window_dump["window_screen_rect"] = DisplayServer::get_singleton()->screen_get_usable_rect(screen);
621621

622622
String name = dock->get_effective_layout_key();
623-
floating_docks_dump[name] = window_dump;
623+
if (!dock->transient) {
624+
floating_docks_dump[name] = window_dump;
625+
}
624626

625627
// Append to regular dock section so we know where to restore it to.
626628
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
@@ -39,7 +39,6 @@
3939
#include "editor/editor_string_names.h"
4040
#include "editor/editor_undo_redo_manager.h"
4141
#include "editor/file_system/editor_file_system.h"
42-
#include "editor/gui/editor_bottom_panel.h"
4342
#include "editor/gui/editor_file_dialog.h"
4443
#include "editor/settings/editor_command_palette.h"
4544
#include "editor/settings/editor_settings.h"
@@ -52,6 +51,7 @@
5251
#include "scene/gui/option_button.h"
5352
#include "scene/gui/panel_container.h"
5453
#include "scene/gui/separator.h"
54+
#include "scene/gui/split_container.h"
5555
#include "scene/resources/atlas_texture.h"
5656

5757
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) {
@@ -2118,9 +2118,20 @@ void SpriteFramesEditor::_node_removed(Node *p_node) {
21182118
}
21192119

21202120
SpriteFramesEditor::SpriteFramesEditor() {
2121+
set_name(TTRC("SpriteFrames"));
2122+
set_icon_name("SpriteFrames");
2123+
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTRC("Open SpriteFrames Dock")));
2124+
set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
2125+
set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
2126+
set_global(false);
2127+
set_transient(true);
2128+
2129+
HSplitContainer *main_split = memnew(HSplitContainer);
2130+
add_child(main_split);
2131+
21212132
VBoxContainer *vbc_animlist = memnew(VBoxContainer);
2122-
add_child(vbc_animlist);
2123-
vbc_animlist->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
2133+
main_split->add_child(vbc_animlist);
2134+
vbc_animlist->set_custom_minimum_size(Size2(150 * EDSCALE, 0));
21242135

21252136
VBoxContainer *sub_vb = memnew(VBoxContainer);
21262137
vbc_animlist->add_margin_child(TTRC("Animations:"), sub_vb, true);
@@ -2237,10 +2248,10 @@ SpriteFramesEditor::SpriteFramesEditor() {
22372248
missing_anim_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
22382249
missing_anim_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
22392250
missing_anim_label->hide();
2240-
add_child(missing_anim_label);
2251+
main_split->add_child(missing_anim_label);
22412252

22422253
anim_frames_vb = memnew(VBoxContainer);
2243-
add_child(anim_frames_vb);
2254+
main_split->add_child(anim_frames_vb);
22442255
anim_frames_vb->set_h_size_flags(SIZE_EXPAND_FILL);
22452256
anim_frames_vb->hide();
22462257

@@ -2731,7 +2742,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
27312742

27322743
// Ensure the anim search box is wide enough by default.
27332744
// Not by setting its minimum size so it can still be shrunk if desired.
2734-
set_split_offset(56 * EDSCALE);
2745+
main_split->set_split_offset(56 * EDSCALE);
27352746
}
27362747

27372748
void SpriteFramesEditorPlugin::edit(Object *p_object) {
@@ -2769,21 +2780,17 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
27692780

27702781
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
27712782
if (p_visible) {
2772-
button->show();
2773-
EditorNode::get_bottom_panel()->make_item_visible(frames_editor);
2783+
frames_editor->make_visible();
27742784
} else {
2775-
button->hide();
2776-
if (frames_editor->is_visible_in_tree()) {
2777-
EditorNode::get_bottom_panel()->hide_bottom_panel();
2778-
}
2785+
frames_editor->close();
27792786
}
27802787
}
27812788

27822789
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
27832790
frames_editor = memnew(SpriteFramesEditor);
27842791
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
2785-
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")));
2786-
button->hide();
2792+
EditorDockManager::get_singleton()->add_dock(frames_editor);
2793+
frames_editor->close();
27872794
}
27882795

27892796
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;
@@ -316,7 +316,6 @@ class SpriteFramesEditorPlugin : public EditorPlugin {
316316
GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
317317

318318
SpriteFramesEditor *frames_editor = nullptr;
319-
Button *button = nullptr;
320319

321320
public:
322321
virtual String get_plugin_name() const override { return "SpriteFrames"; }

0 commit comments

Comments
 (0)