diff --git a/doc/classes/Theme.xml b/doc/classes/Theme.xml
index c92ad172d63..94adda2a93e 100644
--- a/doc/classes/Theme.xml
+++ b/doc/classes/Theme.xml
@@ -109,6 +109,13 @@
Returns all the [Color]s as a [PoolStringArray] filled with each [Color]'s name, for use in [method get_color], if the theme has [code]node_type[/code].
+
+
+
+
+ Returns all the [Color] types as a [PoolStringArray] filled with unique type names, for use in [method get_color] and/or [method get_color_list].
+
+
@@ -129,6 +136,13 @@
Returns all the constants as a [PoolStringArray] filled with each constant's name, for use in [method get_constant], if the theme has [code]node_type[/code].
+
+
+
+
+ Returns all the constant types as a [PoolStringArray] filled with unique type names, for use in [method get_constant] and/or [method get_constant_list].
+
+
@@ -149,6 +163,13 @@
Returns all the [Font]s as a [PoolStringArray] filled with each [Font]'s name, for use in [method get_font], if the theme has [code]node_type[/code].
+
+
+
+
+ Returns all the [Font] types as a [PoolStringArray] filled with unique type names, for use in [method get_font] and/or [method get_font_list].
+
+
@@ -169,6 +190,13 @@
Returns all the icons as a [PoolStringArray] filled with each [Texture]'s name, for use in [method get_icon], if the theme has [code]node_type[/code].
+
+
+
+
+ Returns all the icon types as a [PoolStringArray] filled with unique type names, for use in [method get_icon] and/or [method get_icon_list].
+
+
@@ -195,7 +223,7 @@
- Returns all the [StyleBox] types as a [PoolStringArray] filled with each [StyleBox]'s type, for use in [method get_stylebox] and/or [method get_stylebox_list], if the theme has [code]node_type[/code].
+ Returns all the [StyleBox] types as a [PoolStringArray] filled with unique type names, for use in [method get_stylebox] and/or [method get_stylebox_list].
@@ -204,7 +232,8 @@
- Returns all the types in [code]node_type[/code] as a [PoolStringArray] for use in any of the [code]get_*[/code] functions, if the theme has [code]node_type[/code].
+ Returns all the theme types as a [PoolStringArray] filled with unique type names, for use in other [code]get_*[/code] functions of this theme.
+ [b]Note:[/b] [code]node_type[/code] has no effect and will be removed in future version.
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 04b6b6d3aeb..c6d291df3b8 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -51,6 +51,21 @@ PoolVector Theme::_get_icon_list(const String &p_node_type) const {
return ilret;
}
+PoolVector Theme::_get_icon_types() const {
+ PoolVector ilret;
+ List il;
+
+ get_icon_types(&il);
+ ilret.resize(il.size());
+
+ int i = 0;
+ PoolVector::Write w = ilret.write();
+ for (List::Element *E = il.front(); E; E = E->next(), i++) {
+ w[i] = E->get();
+ }
+ return ilret;
+}
+
PoolVector Theme::_get_stylebox_list(const String &p_node_type) const {
PoolVector ilret;
List il;
@@ -96,6 +111,21 @@ PoolVector Theme::_get_font_list(const String &p_node_type) const {
return ilret;
}
+PoolVector Theme::_get_font_types() const {
+ PoolVector ilret;
+ List il;
+
+ get_font_types(&il);
+ ilret.resize(il.size());
+
+ int i = 0;
+ PoolVector::Write w = ilret.write();
+ for (List::Element *E = il.front(); E; E = E->next(), i++) {
+ w[i] = E->get();
+ }
+ return ilret;
+}
+
PoolVector Theme::_get_color_list(const String &p_node_type) const {
PoolVector ilret;
List il;
@@ -111,6 +141,21 @@ PoolVector Theme::_get_color_list(const String &p_node_type) const {
return ilret;
}
+PoolVector Theme::_get_color_types() const {
+ PoolVector ilret;
+ List il;
+
+ get_color_types(&il);
+ ilret.resize(il.size());
+
+ int i = 0;
+ PoolVector::Write w = ilret.write();
+ for (List::Element *E = il.front(); E; E = E->next(), i++) {
+ w[i] = E->get();
+ }
+ return ilret;
+}
+
PoolVector Theme::_get_constant_list(const String &p_node_type) const {
PoolVector ilret;
List il;
@@ -126,6 +171,21 @@ PoolVector Theme::_get_constant_list(const String &p_node_type) const {
return ilret;
}
+PoolVector Theme::_get_constant_types() const {
+ PoolVector ilret;
+ List il;
+
+ get_constant_types(&il);
+ ilret.resize(il.size());
+
+ int i = 0;
+ PoolVector::Write w = ilret.write();
+ for (List::Element *E = il.front(); E; E = E->next(), i++) {
+ w[i] = E->get();
+ }
+ return ilret;
+}
+
PoolVector Theme::_get_type_list(const String &p_node_type) const {
PoolVector ilret;
List il;
@@ -316,9 +376,11 @@ void Theme::set_project_default(const Ref &p_project_default) {
void Theme::set_default_icon(const Ref &p_icon) {
default_icon = p_icon;
}
+
void Theme::set_default_style(const Ref &p_style) {
default_style = p_style;
}
+
void Theme::set_default_font(const Ref &p_font) {
default_font = p_font;
}
@@ -343,6 +405,7 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_node_type, co
emit_changed();
}
}
+
Ref Theme::get_icon(const StringName &p_name, const StringName &p_node_type) const {
if (icon_map.has(p_node_type) && icon_map[p_node_type].has(p_name) && icon_map[p_node_type][p_name].is_valid()) {
return icon_map[p_node_type][p_name];
@@ -383,6 +446,15 @@ void Theme::get_icon_list(StringName p_node_type, List *p_list) cons
}
}
+void Theme::get_icon_types(List *p_list) const {
+ ERR_FAIL_NULL(p_list);
+
+ const StringName *key = nullptr;
+ while ((key = icon_map.next(key))) {
+ p_list->push_back(*key);
+ }
+}
+
void Theme::set_shader(const StringName &p_name, const StringName &p_node_type, const Ref &p_shader) {
bool new_value = !shader_map.has(p_node_type) || !shader_map[p_node_type].has(p_name);
@@ -519,6 +591,7 @@ void Theme::set_font(const StringName &p_name, const StringName &p_node_type, co
emit_changed();
}
}
+
Ref Theme::get_font(const StringName &p_name, const StringName &p_node_type) const {
if (font_map.has(p_node_type) && font_map[p_node_type].has(p_name) && font_map[p_node_type][p_name].is_valid()) {
return font_map[p_node_type][p_name];
@@ -560,6 +633,15 @@ void Theme::get_font_list(StringName p_node_type, List *p_list) cons
}
}
+void Theme::get_font_types(List *p_list) const {
+ ERR_FAIL_NULL(p_list);
+
+ const StringName *key = nullptr;
+ while ((key = font_map.next(key))) {
+ p_list->push_back(*key);
+ }
+}
+
void Theme::set_color(const StringName &p_name, const StringName &p_node_type, const Color &p_color) {
bool new_value = !color_map.has(p_node_type) || !color_map[p_node_type].has(p_name);
@@ -606,6 +688,15 @@ void Theme::get_color_list(StringName p_node_type, List *p_list) con
}
}
+void Theme::get_color_types(List *p_list) const {
+ ERR_FAIL_NULL(p_list);
+
+ const StringName *key = nullptr;
+ while ((key = color_map.next(key))) {
+ p_list->push_back(*key);
+ }
+}
+
void Theme::set_constant(const StringName &p_name, const StringName &p_node_type, int p_constant) {
bool new_value = !constant_map.has(p_node_type) || !constant_map[p_node_type].has(p_name);
constant_map[p_node_type][p_name] = p_constant;
@@ -651,6 +742,15 @@ void Theme::get_constant_list(StringName p_node_type, List *p_list)
}
}
+void Theme::get_constant_types(List *p_list) const {
+ ERR_FAIL_NULL(p_list);
+
+ const StringName *key = nullptr;
+ while ((key = constant_map.next(key))) {
+ p_list->push_back(*key);
+ }
+}
+
void Theme::clear() {
//these need disconnecting
{
@@ -801,6 +901,7 @@ void Theme::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_icon", "name", "node_type"), &Theme::has_icon);
ClassDB::bind_method(D_METHOD("clear_icon", "name", "node_type"), &Theme::clear_icon);
ClassDB::bind_method(D_METHOD("get_icon_list", "node_type"), &Theme::_get_icon_list);
+ ClassDB::bind_method(D_METHOD("get_icon_types"), &Theme::_get_icon_types);
ClassDB::bind_method(D_METHOD("set_stylebox", "name", "node_type", "texture"), &Theme::set_stylebox);
ClassDB::bind_method(D_METHOD("get_stylebox", "name", "node_type"), &Theme::get_stylebox);
@@ -814,18 +915,21 @@ void Theme::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_font", "name", "node_type"), &Theme::has_font);
ClassDB::bind_method(D_METHOD("clear_font", "name", "node_type"), &Theme::clear_font);
ClassDB::bind_method(D_METHOD("get_font_list", "node_type"), &Theme::_get_font_list);
+ ClassDB::bind_method(D_METHOD("get_font_types"), &Theme::_get_font_types);
ClassDB::bind_method(D_METHOD("set_color", "name", "node_type", "color"), &Theme::set_color);
ClassDB::bind_method(D_METHOD("get_color", "name", "node_type"), &Theme::get_color);
ClassDB::bind_method(D_METHOD("has_color", "name", "node_type"), &Theme::has_color);
ClassDB::bind_method(D_METHOD("clear_color", "name", "node_type"), &Theme::clear_color);
ClassDB::bind_method(D_METHOD("get_color_list", "node_type"), &Theme::_get_color_list);
+ ClassDB::bind_method(D_METHOD("get_color_types"), &Theme::_get_color_types);
ClassDB::bind_method(D_METHOD("set_constant", "name", "node_type", "constant"), &Theme::set_constant);
ClassDB::bind_method(D_METHOD("get_constant", "name", "node_type"), &Theme::get_constant);
ClassDB::bind_method(D_METHOD("has_constant", "name", "node_type"), &Theme::has_constant);
ClassDB::bind_method(D_METHOD("clear_constant", "name", "node_type"), &Theme::clear_constant);
ClassDB::bind_method(D_METHOD("get_constant_list", "node_type"), &Theme::_get_constant_list);
+ ClassDB::bind_method(D_METHOD("get_constant_types"), &Theme::_get_constant_types);
ClassDB::bind_method(D_METHOD("clear"), &Theme::clear);
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 33d3517d641..59bc1f7d818 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -52,11 +52,15 @@ class Theme : public Resource {
HashMap> constant_map;
PoolVector _get_icon_list(const String &p_node_type) const;
+ PoolVector _get_icon_types() const;
PoolVector _get_stylebox_list(const String &p_node_type) const;
PoolVector _get_stylebox_types() const;
PoolVector _get_font_list(const String &p_node_type) const;
+ PoolVector _get_font_types() const;
PoolVector _get_color_list(const String &p_node_type) const;
+ PoolVector _get_color_types() const;
PoolVector _get_constant_list(const String &p_node_type) const;
+ PoolVector _get_constant_types() const;
PoolVector _get_type_list(const String &p_node_type) const;
protected:
@@ -93,6 +97,7 @@ public:
bool has_icon(const StringName &p_name, const StringName &p_node_type) const;
void clear_icon(const StringName &p_name, const StringName &p_node_type);
void get_icon_list(StringName p_node_type, List *p_list) const;
+ void get_icon_types(List *p_list) const;
void set_shader(const StringName &p_name, const StringName &p_node_type, const Ref &p_shader);
Ref get_shader(const StringName &p_name, const StringName &p_node_type) const;
@@ -112,18 +117,21 @@ public:
bool has_font(const StringName &p_name, const StringName &p_node_type) const;
void clear_font(const StringName &p_name, const StringName &p_node_type);
void get_font_list(StringName p_node_type, List *p_list) const;
+ void get_font_types(List *p_list) const;
void set_color(const StringName &p_name, const StringName &p_node_type, const Color &p_color);
Color get_color(const StringName &p_name, const StringName &p_node_type) const;
bool has_color(const StringName &p_name, const StringName &p_node_type) const;
void clear_color(const StringName &p_name, const StringName &p_node_type);
void get_color_list(StringName p_node_type, List *p_list) const;
+ void get_color_types(List *p_list) const;
void set_constant(const StringName &p_name, const StringName &p_node_type, int p_constant);
int get_constant(const StringName &p_name, const StringName &p_node_type) const;
bool has_constant(const StringName &p_name, const StringName &p_node_type) const;
void clear_constant(const StringName &p_name, const StringName &p_node_type);
void get_constant_list(StringName p_node_type, List *p_list) const;
+ void get_constant_types(List *p_list) const;
void get_type_list(List *p_list) const;