summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-07-13 21:55:32 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-07-13 21:55:32 +0300
commitb648d3e1109bb029e60e05a4f924797c27b0681f (patch)
treedf80f9ed068ebc8c65d8852c90e8ad765b546e48 /editor
parent3bfffcc568d87342e867f95c35a4a19e09072189 (diff)
Fix TextureRegionEditorPlugin popping up even when explicitly hidden
Fixes #27468
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp16
-rw-r--r--editor/plugins/texture_region_editor_plugin.h6
2 files changed, 20 insertions, 2 deletions
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 8f58fbd6ab..cb48b5eaa5 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -1021,15 +1021,21 @@ bool TextureRegionEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture");
}
+void TextureRegionEditorPlugin::_editor_visiblity_changed() {
+ manually_hidden = !region_editor->is_visible_in_tree();
+}
+
void TextureRegionEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
texture_region_button->show();
- if (region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region()) || (region_editor->get_sprite_3d() && region_editor->get_sprite_3d()->is_region()) || texture_region_button->is_pressed()) {
+ bool is_node_configured = region_editor->is_stylebox() || region_editor->is_atlas_texture() || region_editor->is_ninepatch() || (region_editor->get_sprite() && region_editor->get_sprite()->is_region()) || (region_editor->get_sprite_3d() && region_editor->get_sprite_3d()->is_region());
+ if ((is_node_configured && !manually_hidden) || texture_region_button->is_pressed()) {
editor->make_bottom_panel_item_visible(region_editor);
}
} else {
if (region_editor->is_visible_in_tree()) {
editor->hide_bottom_panel();
+ manually_hidden = false;
}
texture_region_button->hide();
region_editor->edit(NULL);
@@ -1076,12 +1082,18 @@ void TextureRegionEditorPlugin::set_state(const Dictionary &p_state) {
}
}
+void TextureRegionEditorPlugin::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_editor_visiblity_changed"), &TextureRegionEditorPlugin::_editor_visiblity_changed);
+}
+
TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
+ manually_hidden = false;
editor = p_node;
- region_editor = memnew(TextureRegionEditor(p_node));
+ region_editor = memnew(TextureRegionEditor(p_node));
region_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
region_editor->hide();
+ region_editor->connect("visibility_changed", this, "_editor_visiblity_changed");
texture_region_button = p_node->add_bottom_panel_item(TTR("TextureRegion"), region_editor);
texture_region_button->hide();
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index a49e0fb96c..4eb84ae176 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -145,10 +145,16 @@ public:
class TextureRegionEditorPlugin : public EditorPlugin {
GDCLASS(TextureRegionEditorPlugin, EditorPlugin);
+ bool manually_hidden;
Button *texture_region_button;
TextureRegionEditor *region_editor;
EditorNode *editor;
+protected:
+ static void _bind_methods();
+
+ void _editor_visiblity_changed();
+
public:
virtual String get_name() const { return "TextureRegion"; }
bool has_main_screen() const { return false; }