summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-12 15:31:38 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-12 15:31:38 -0300
commitc1056a9bfb723d053c3bec9d9f8d84ecdc5e93f9 (patch)
treeaf3e0fe42efbd9fbcac775fb09ef78c7b518cc1e
parent4bb93c976c6b67b4538c8a012ea549ec24e3ac1a (diff)
Fixed ancient bug that prevented proper theme editing, closes #4924
-rw-r--r--scene/gui/control.cpp45
-rw-r--r--scene/resources/theme.cpp7
2 files changed, 21 insertions, 31 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bd56369746..dfad7d1432 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -223,7 +223,7 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
String sname=p_name;
- if (!sname.begins_with("custom"))
+ if (!sname.begins_with("custom")) {
if (sname.begins_with("margin/")) {
String dname = sname.get_slicec('/', 1);
if (dname == "left") {
@@ -248,6 +248,7 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
} else {
return false;
}
+ }
if (sname.begins_with("custom_icons/")) {
String name = sname.get_slicec('/',1);
@@ -489,6 +490,10 @@ void Control::_notification(int p_notification) {
}
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ data.theme_owner=data.parent->data.theme_owner;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -520,26 +525,9 @@ void Control::_notification(int p_notification) {
data.parent=NULL;
data.parent_canvas_item=NULL;
-
- } break;
-
-
- case NOTIFICATION_PARENTED: {
-
- Control * parent = get_parent()->cast_to<Control>();
-
- //make children reference them theme
-
- if (parent && data.theme.is_null() && parent->data.theme_owner) {
- _propagate_theme_changed(parent->data.theme_owner);
- }
-
- } break;
- case NOTIFICATION_UNPARENTED: {
-
- //make children unreference the theme
- if (data.theme.is_null() && data.theme_owner) {
- _propagate_theme_changed(NULL);
+ if (data.theme_owner && data.theme.is_null()) {
+ data.theme_owner=NULL;
+ //notification(NOTIFICATION_THEME_CHANGED);
}
} break;
@@ -785,7 +773,7 @@ Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type
while(theme_owner) {
if (theme_owner->data.theme->has_icon(p_name, type ) )
- return data.theme_owner->data.theme->get_icon(p_name, type );
+ return theme_owner->data.theme->get_icon(p_name, type );
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -815,7 +803,7 @@ Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_typ
while(theme_owner) {
if (theme_owner->data.theme->has_shader(p_name, type))
- return data.theme_owner->data.theme->get_shader(p_name, type );
+ return theme_owner->data.theme->get_shader(p_name, type );
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -843,8 +831,9 @@ Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p
while(theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) )
- return data.theme_owner->data.theme->get_stylebox(p_name, type );
+ if (theme_owner->data.theme->has_stylebox(p_name, type ) ) {
+ return theme_owner->data.theme->get_stylebox(p_name, type );
+ }
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -872,7 +861,7 @@ Ref<Font> Control::get_font(const StringName& p_name,const StringName& p_type) c
while(theme_owner) {
if (theme_owner->data.theme->has_font(p_name, type ) )
- return data.theme_owner->data.theme->get_font(p_name, type );
+ return theme_owner->data.theme->get_font(p_name, type );
if (theme_owner->data.theme->get_default_theme_font().is_valid())
return theme_owner->data.theme->get_default_theme_font();
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
@@ -902,7 +891,7 @@ Color Control::get_color(const StringName& p_name,const StringName& p_type) cons
while(theme_owner) {
if (theme_owner->data.theme->has_color(p_name, type ) )
- return data.theme_owner->data.theme->get_color(p_name, type );
+ return theme_owner->data.theme->get_color(p_name, type );
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -931,7 +920,7 @@ int Control::get_constant(const StringName& p_name,const StringName& p_type) con
while(theme_owner) {
if (theme_owner->data.theme->has_constant(p_name, type ) )
- return data.theme_owner->data.theme->get_constant(p_name, type );
+ return theme_owner->data.theme->get_constant(p_name, type );
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 8d0aedbf93..2f4d37053e 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -240,7 +240,7 @@ Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type)
bool Theme::has_icon(const StringName& p_name,const StringName& p_type) const {
- return (icon_map.has(p_type) && icon_map[p_type].has(p_name));
+ return (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid());
}
@@ -337,12 +337,13 @@ Ref<StyleBox> Theme::get_stylebox(const StringName& p_name,const StringName& p_t
return style_map[p_type][p_name];
} else {
return default_style;
+
}
}
bool Theme::has_stylebox(const StringName& p_name,const StringName& p_type) const {
- return (style_map.has(p_type) && style_map[p_type].has(p_name) );
+ return (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid());
}
void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) {
@@ -402,7 +403,7 @@ Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) con
bool Theme::has_font(const StringName& p_name,const StringName& p_type) const {
- return (font_map.has(p_type) && font_map[p_type].has(p_name));
+ return (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid());
}
void Theme::clear_font(const StringName& p_name,const StringName& p_type) {