diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index 7432c095637..f3bb37421f6 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -258,12 +258,23 @@ void ClassDB::get_inheriters_from_class( const StringName& p_class,Listinherits; + +} + StringName ClassDB::get_parent_class(const StringName& p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); - ERR_FAIL_COND_V(!ti,""); + ERR_FAIL_COND_V(!ti,StringName()); return ti->inherits; } @@ -272,6 +283,7 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V(!ti,API_NONE); return ti->api; } diff --git a/core/object_type_db.h b/core/object_type_db.h index 158a4dae23a..f745e3d5fda 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -239,6 +239,7 @@ public: static void get_class_list( List *p_classes); static void get_inheriters_from_class( const StringName& p_class,List *p_classes); + static StringName get_parent_class_nocheck(const StringName& p_class); static StringName get_parent_class(const StringName& p_class); static bool class_exists(const StringName &p_class); static bool is_parent_class(const StringName &p_class,const StringName& p_inherits); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index b3d86f85eaf..437fbba0e97 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -754,8 +754,16 @@ Ref 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 theme_owner->data.theme->get_icon(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_icon(p_name, class_name ) ) { + return theme_owner->data.theme->get_icon(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -784,8 +792,16 @@ Ref 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 theme_owner->data.theme->get_shader(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_shader(p_name, class_name ) ) { + return theme_owner->data.theme->get_shader(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -813,9 +829,16 @@ Ref Control::get_stylebox(const StringName& p_name,const StringName& p while(theme_owner) { - if (theme_owner->data.theme->has_stylebox(p_name, type ) ) { - return theme_owner->data.theme->get_stylebox(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) { + return theme_owner->data.theme->get_stylebox(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -842,8 +865,16 @@ Ref 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 theme_owner->data.theme->get_font(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_font(p_name, class_name ) ) { + return theme_owner->data.theme->get_font(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + 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():NULL; @@ -872,8 +903,16 @@ 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 theme_owner->data.theme->get_color(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_color(p_name, class_name ) ) { + return theme_owner->data.theme->get_color(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -901,8 +940,16 @@ 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 theme_owner->data.theme->get_constant(p_name, type ); + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_constant(p_name, class_name ) ) { + return theme_owner->data.theme->get_constant(p_name, class_name ); + } + + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -985,8 +1032,15 @@ bool Control::has_icon(const StringName& p_name,const StringName& p_type) const while(theme_owner) { - if (theme_owner->data.theme->has_icon(p_name, type ) ) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_icon(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -1014,8 +1068,15 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con while(theme_owner) { - if (theme_owner->data.theme->has_shader(p_name, type)) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_shader(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -1042,8 +1103,15 @@ bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) co while(theme_owner) { - if (theme_owner->data.theme->has_stylebox(p_name, type ) ) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -1071,8 +1139,15 @@ bool Control::has_font(const StringName& p_name,const StringName& p_type) const while(theme_owner) { - if (theme_owner->data.theme->has_font(p_name, type ) ) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_font(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -1100,8 +1175,15 @@ bool Control::has_color(const StringName& p_name, const StringName& p_type) cons while(theme_owner) { - if (theme_owner->data.theme->has_color(p_name, type ) ) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_color(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent) @@ -1130,8 +1212,15 @@ bool Control::has_constant(const StringName& p_name,const StringName& p_type) co while(theme_owner) { - if (theme_owner->data.theme->has_constant(p_name, type ) ) - return true; + StringName class_name = type; + + while(class_name!=StringName()) { + if (theme_owner->data.theme->has_constant(p_name, class_name ) ) { + return true; + } + class_name = ClassDB::get_parent_class_nocheck(class_name); + } + Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to():NULL; if (parent)