mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #113275 from lodetrick/sprite-dock
Use new dock system for SpriteFrames Dock
This commit is contained in:
commit
fbc9539764
3 changed files with 27 additions and 19 deletions
|
|
@ -620,7 +620,9 @@ void EditorDockManager::save_docks_to_config(Ref<ConfigFile> p_layout, const Str
|
||||||
window_dump["window_screen_rect"] = DisplayServer::get_singleton()->screen_get_usable_rect(screen);
|
window_dump["window_screen_rect"] = DisplayServer::get_singleton()->screen_get_usable_rect(screen);
|
||||||
|
|
||||||
String name = dock->get_effective_layout_key();
|
String name = dock->get_effective_layout_key();
|
||||||
floating_docks_dump[name] = window_dump;
|
if (!dock->transient) {
|
||||||
|
floating_docks_dump[name] = window_dump;
|
||||||
|
}
|
||||||
|
|
||||||
// Append to regular dock section so we know where to restore it to.
|
// Append to regular dock section so we know where to restore it to.
|
||||||
int dock_slot_id = dock->dock_slot_index;
|
int dock_slot_id = dock->dock_slot_index;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@
|
||||||
#include "editor/editor_string_names.h"
|
#include "editor/editor_string_names.h"
|
||||||
#include "editor/editor_undo_redo_manager.h"
|
#include "editor/editor_undo_redo_manager.h"
|
||||||
#include "editor/file_system/editor_file_system.h"
|
#include "editor/file_system/editor_file_system.h"
|
||||||
#include "editor/gui/editor_bottom_panel.h"
|
|
||||||
#include "editor/gui/editor_file_dialog.h"
|
#include "editor/gui/editor_file_dialog.h"
|
||||||
#include "editor/settings/editor_command_palette.h"
|
#include "editor/settings/editor_command_palette.h"
|
||||||
#include "editor/settings/editor_settings.h"
|
#include "editor/settings/editor_settings.h"
|
||||||
|
|
@ -52,6 +51,7 @@
|
||||||
#include "scene/gui/option_button.h"
|
#include "scene/gui/option_button.h"
|
||||||
#include "scene/gui/panel_container.h"
|
#include "scene/gui/panel_container.h"
|
||||||
#include "scene/gui/separator.h"
|
#include "scene/gui/separator.h"
|
||||||
|
#include "scene/gui/split_container.h"
|
||||||
#include "scene/resources/atlas_texture.h"
|
#include "scene/resources/atlas_texture.h"
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteFramesEditor::SpriteFramesEditor() {
|
SpriteFramesEditor::SpriteFramesEditor() {
|
||||||
|
set_name(TTRC("SpriteFrames"));
|
||||||
|
set_icon_name("SpriteFrames");
|
||||||
|
set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTRC("Open SpriteFrames 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);
|
||||||
|
|
||||||
|
HSplitContainer *main_split = memnew(HSplitContainer);
|
||||||
|
add_child(main_split);
|
||||||
|
|
||||||
VBoxContainer *vbc_animlist = memnew(VBoxContainer);
|
VBoxContainer *vbc_animlist = memnew(VBoxContainer);
|
||||||
add_child(vbc_animlist);
|
main_split->add_child(vbc_animlist);
|
||||||
vbc_animlist->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
|
vbc_animlist->set_custom_minimum_size(Size2(150 * EDSCALE, 0));
|
||||||
|
|
||||||
VBoxContainer *sub_vb = memnew(VBoxContainer);
|
VBoxContainer *sub_vb = memnew(VBoxContainer);
|
||||||
vbc_animlist->add_margin_child(TTRC("Animations:"), sub_vb, true);
|
vbc_animlist->add_margin_child(TTRC("Animations:"), sub_vb, true);
|
||||||
|
|
@ -2237,10 +2248,10 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
||||||
missing_anim_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
missing_anim_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
|
||||||
missing_anim_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
|
missing_anim_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
|
||||||
missing_anim_label->hide();
|
missing_anim_label->hide();
|
||||||
add_child(missing_anim_label);
|
main_split->add_child(missing_anim_label);
|
||||||
|
|
||||||
anim_frames_vb = memnew(VBoxContainer);
|
anim_frames_vb = memnew(VBoxContainer);
|
||||||
add_child(anim_frames_vb);
|
main_split->add_child(anim_frames_vb);
|
||||||
anim_frames_vb->set_h_size_flags(SIZE_EXPAND_FILL);
|
anim_frames_vb->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
anim_frames_vb->hide();
|
anim_frames_vb->hide();
|
||||||
|
|
||||||
|
|
@ -2731,7 +2742,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
||||||
|
|
||||||
// Ensure the anim search box is wide enough by default.
|
// Ensure the anim search box is wide enough by default.
|
||||||
// Not by setting its minimum size so it can still be shrunk if desired.
|
// Not by setting its minimum size so it can still be shrunk if desired.
|
||||||
set_split_offset(56 * EDSCALE);
|
main_split->set_split_offset(56 * EDSCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteFramesEditorPlugin::edit(Object *p_object) {
|
void SpriteFramesEditorPlugin::edit(Object *p_object) {
|
||||||
|
|
@ -2769,21 +2780,17 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const {
|
||||||
|
|
||||||
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
|
void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
button->show();
|
frames_editor->make_visible();
|
||||||
EditorNode::get_bottom_panel()->make_item_visible(frames_editor);
|
|
||||||
} else {
|
} else {
|
||||||
button->hide();
|
frames_editor->close();
|
||||||
if (frames_editor->is_visible_in_tree()) {
|
|
||||||
EditorNode::get_bottom_panel()->hide_bottom_panel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
|
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
|
||||||
frames_editor = memnew(SpriteFramesEditor);
|
frames_editor = memnew(SpriteFramesEditor);
|
||||||
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
|
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
|
||||||
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")));
|
EditorDockManager::get_singleton()->add_dock(frames_editor);
|
||||||
button->hide();
|
frames_editor->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ClipboardAnimation> ClipboardAnimation::from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim) {
|
Ref<ClipboardAnimation> ClipboardAnimation::from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "editor/docks/editor_dock.h"
|
||||||
#include "editor/plugins/editor_plugin.h"
|
#include "editor/plugins/editor_plugin.h"
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
#include "scene/gui/dialogs.h"
|
#include "scene/gui/dialogs.h"
|
||||||
|
|
@ -37,7 +38,6 @@
|
||||||
#include "scene/gui/line_edit.h"
|
#include "scene/gui/line_edit.h"
|
||||||
#include "scene/gui/scroll_container.h"
|
#include "scene/gui/scroll_container.h"
|
||||||
#include "scene/gui/spin_box.h"
|
#include "scene/gui/spin_box.h"
|
||||||
#include "scene/gui/split_container.h"
|
|
||||||
#include "scene/gui/texture_rect.h"
|
#include "scene/gui/texture_rect.h"
|
||||||
#include "scene/gui/tree.h"
|
#include "scene/gui/tree.h"
|
||||||
#include "scene/resources/image_texture.h"
|
#include "scene/resources/image_texture.h"
|
||||||
|
|
@ -69,8 +69,8 @@ public:
|
||||||
static Ref<ClipboardAnimation> from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim);
|
static Ref<ClipboardAnimation> from_sprite_frames(const Ref<SpriteFrames> &p_frames, const String &p_anim);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpriteFramesEditor : public HSplitContainer {
|
class SpriteFramesEditor : public EditorDock {
|
||||||
GDCLASS(SpriteFramesEditor, HSplitContainer);
|
GDCLASS(SpriteFramesEditor, EditorDock);
|
||||||
|
|
||||||
Ref<SpriteFrames> frames;
|
Ref<SpriteFrames> frames;
|
||||||
Node *animated_sprite = nullptr;
|
Node *animated_sprite = nullptr;
|
||||||
|
|
@ -316,7 +316,6 @@ class SpriteFramesEditorPlugin : public EditorPlugin {
|
||||||
GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
|
GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
|
||||||
|
|
||||||
SpriteFramesEditor *frames_editor = nullptr;
|
SpriteFramesEditor *frames_editor = nullptr;
|
||||||
Button *button = nullptr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_plugin_name() const override { return "SpriteFrames"; }
|
virtual String get_plugin_name() const override { return "SpriteFrames"; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue