summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRobert Hernandez <killerjaguar26@gmail.com>2017-03-29 19:30:24 -0400
committerRobert Hernandez <killerjaguar26@gmail.com>2017-06-29 10:49:24 -0400
commitf0f407e76eafdfe76b9439c7e527f085a6ff22d9 (patch)
treebcf8b3ecb7df8cee85de7a0611688cd14cafd1ab /editor
parent198bd9db02950d261c83b0c383fe737df3c5f152 (diff)
Texture region now updates when changing an Atlas
- Removed atlas_changed signal for AtlasTexture - Changes are now handled by _notify_change - Removed unneccesary signal connections - Texture preview now updates in real-time Fixed TextureRegionEditor constantly regenerating
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/texture_editor_plugin.cpp16
-rw-r--r--editor/plugins/texture_editor_plugin.h1
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp38
3 files changed, 27 insertions, 28 deletions
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index c4fe15e61c..df71ea99c6 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -102,14 +102,24 @@ void TextureEditor::_notification(int p_what) {
}
}
+void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+
+ if (!is_visible())
+ return;
+ update();
+}
+
void TextureEditor::edit(Ref<Texture> p_texture) {
+ if (!texture.is_null())
+ texture->remove_change_receptor(this);
+
texture = p_texture;
- if (!texture.is_null())
+ if (!texture.is_null()) {
+ texture->add_change_receptor(this);
update();
- else {
-
+ } else {
hide();
}
}
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index 9382983538..13f8dd7fbd 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -43,6 +43,7 @@ class TextureEditor : public Control {
protected:
void _notification(int p_what);
void _gui_input(Ref<InputEvent> p_event);
+ void _changed_callback(Object *p_changed, const char *p_prop);
static void _bind_methods();
public:
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 8a7dcea393..4cd18b090a 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -617,38 +617,24 @@ void TextureRegionEditor::_bind_methods() {
}
void TextureRegionEditor::edit(Object *p_obj) {
- if (node_sprite && node_sprite->is_connected("texture_changed", this, "_edit_region"))
- node_sprite->disconnect("texture_changed", this, "_edit_region");
- if (node_patch9 && node_patch9->is_connected("texture_changed", this, "_edit_region"))
- node_patch9->disconnect("texture_changed", this, "_edit_region");
- if (obj_styleBox.is_valid() && obj_styleBox->is_connected("texture_changed", this, "_edit_region"))
- obj_styleBox->disconnect("texture_changed", this, "_edit_region");
- if (atlas_tex.is_valid() && atlas_tex->is_connected("atlas_changed", this, "_edit_region"))
- atlas_tex->disconnect("atlas_changed", this, "_edit_region");
+ if (node_sprite)
+ node_sprite->remove_change_receptor(this);
+ if (node_patch9)
+ node_patch9->remove_change_receptor(this);
+ if (obj_styleBox.is_valid())
+ obj_styleBox->remove_change_receptor(this);
+ if (atlas_tex.is_valid())
+ atlas_tex->remove_change_receptor(this);
if (p_obj) {
node_sprite = p_obj->cast_to<Sprite>();
node_patch9 = p_obj->cast_to<NinePatchRect>();
if (p_obj->cast_to<StyleBoxTexture>())
obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>());
- if (p_obj->cast_to<AtlasTexture>()) {
+ if (p_obj->cast_to<AtlasTexture>())
atlas_tex = Ref<AtlasTexture>(p_obj->cast_to<AtlasTexture>());
- atlas_tex->connect("atlas_changed", this, "_edit_region");
- } else {
- p_obj->connect("texture_changed", this, "_edit_region");
- }
p_obj->add_change_receptor(this);
- p_obj->connect("tree_exited", this, "_node_removed", varray(p_obj), CONNECT_ONESHOT);
_edit_region();
} else {
- if (node_sprite)
- node_sprite->disconnect("tree_exited", this, "_node_removed");
- else if (node_patch9)
- node_patch9->disconnect("tree_exited", this, "_node_removed");
- else if (obj_styleBox.is_valid())
- obj_styleBox->disconnect("tree_exited", this, "_node_removed");
- else if (atlas_tex.is_valid())
- atlas_tex->disconnect("tree_exited", this, "_node_removed");
-
node_sprite = NULL;
node_patch9 = NULL;
obj_styleBox = Ref<StyleBoxTexture>(NULL);
@@ -658,9 +644,11 @@ void TextureRegionEditor::edit(Object *p_obj) {
}
void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) {
- if ((String)p_prop == "region_rect") {
+
+ if (!is_visible())
+ return;
+ if (p_prop == StringName("atlas") || p_prop == StringName("texture"))
_edit_region();
- }
}
void TextureRegionEditor::_edit_region() {