Expose missing Theme methods
Backport of relevant, non-breaking parts of #37759
This commit is contained in:
parent
d84d5a9665
commit
83012d6927
3 changed files with 143 additions and 2 deletions
|
@ -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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_color_types" qualifiers="const">
|
||||
<return type="PoolStringArray">
|
||||
</return>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_constant" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
|
@ -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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_constant_types" qualifiers="const">
|
||||
<return type="PoolStringArray">
|
||||
</return>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_font" qualifiers="const">
|
||||
<return type="Font">
|
||||
</return>
|
||||
|
@ -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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_font_types" qualifiers="const">
|
||||
<return type="PoolStringArray">
|
||||
</return>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_icon" qualifiers="const">
|
||||
<return type="Texture">
|
||||
</return>
|
||||
|
@ -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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_icon_types" qualifiers="const">
|
||||
<return type="PoolStringArray">
|
||||
</return>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_stylebox" qualifiers="const">
|
||||
<return type="StyleBox">
|
||||
</return>
|
||||
|
@ -195,7 +223,7 @@
|
|||
<return type="PoolStringArray">
|
||||
</return>
|
||||
<description>
|
||||
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].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_type_list" qualifiers="const">
|
||||
|
@ -204,7 +232,8 @@
|
|||
<argument index="0" name="node_type" type="String">
|
||||
</argument>
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_color" qualifiers="const">
|
||||
|
|
|
@ -51,6 +51,21 @@ PoolVector<String> Theme::_get_icon_list(const String &p_node_type) const {
|
|||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_icon_types() const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
||||
get_icon_types(&il);
|
||||
ilret.resize(il.size());
|
||||
|
||||
int i = 0;
|
||||
PoolVector<String>::Write w = ilret.write();
|
||||
for (List<StringName>::Element *E = il.front(); E; E = E->next(), i++) {
|
||||
w[i] = E->get();
|
||||
}
|
||||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_stylebox_list(const String &p_node_type) const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
@ -96,6 +111,21 @@ PoolVector<String> Theme::_get_font_list(const String &p_node_type) const {
|
|||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_font_types() const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
||||
get_font_types(&il);
|
||||
ilret.resize(il.size());
|
||||
|
||||
int i = 0;
|
||||
PoolVector<String>::Write w = ilret.write();
|
||||
for (List<StringName>::Element *E = il.front(); E; E = E->next(), i++) {
|
||||
w[i] = E->get();
|
||||
}
|
||||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_color_list(const String &p_node_type) const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
@ -111,6 +141,21 @@ PoolVector<String> Theme::_get_color_list(const String &p_node_type) const {
|
|||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_color_types() const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
||||
get_color_types(&il);
|
||||
ilret.resize(il.size());
|
||||
|
||||
int i = 0;
|
||||
PoolVector<String>::Write w = ilret.write();
|
||||
for (List<StringName>::Element *E = il.front(); E; E = E->next(), i++) {
|
||||
w[i] = E->get();
|
||||
}
|
||||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_constant_list(const String &p_node_type) const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
@ -126,6 +171,21 @@ PoolVector<String> Theme::_get_constant_list(const String &p_node_type) const {
|
|||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_constant_types() const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
||||
get_constant_types(&il);
|
||||
ilret.resize(il.size());
|
||||
|
||||
int i = 0;
|
||||
PoolVector<String>::Write w = ilret.write();
|
||||
for (List<StringName>::Element *E = il.front(); E; E = E->next(), i++) {
|
||||
w[i] = E->get();
|
||||
}
|
||||
return ilret;
|
||||
}
|
||||
|
||||
PoolVector<String> Theme::_get_type_list(const String &p_node_type) const {
|
||||
PoolVector<String> ilret;
|
||||
List<StringName> il;
|
||||
|
@ -316,9 +376,11 @@ void Theme::set_project_default(const Ref<Theme> &p_project_default) {
|
|||
void Theme::set_default_icon(const Ref<Texture> &p_icon) {
|
||||
default_icon = p_icon;
|
||||
}
|
||||
|
||||
void Theme::set_default_style(const Ref<StyleBox> &p_style) {
|
||||
default_style = p_style;
|
||||
}
|
||||
|
||||
void Theme::set_default_font(const Ref<Font> &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<Texture> 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<StringName> *p_list) cons
|
|||
}
|
||||
}
|
||||
|
||||
void Theme::get_icon_types(List<StringName> *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<Shader> &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<Font> 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<StringName> *p_list) cons
|
|||
}
|
||||
}
|
||||
|
||||
void Theme::get_font_types(List<StringName> *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<StringName> *p_list) con
|
|||
}
|
||||
}
|
||||
|
||||
void Theme::get_color_types(List<StringName> *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<StringName> *p_list)
|
|||
}
|
||||
}
|
||||
|
||||
void Theme::get_constant_types(List<StringName> *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);
|
||||
|
||||
|
|
|
@ -52,11 +52,15 @@ class Theme : public Resource {
|
|||
HashMap<StringName, HashMap<StringName, int>> constant_map;
|
||||
|
||||
PoolVector<String> _get_icon_list(const String &p_node_type) const;
|
||||
PoolVector<String> _get_icon_types() const;
|
||||
PoolVector<String> _get_stylebox_list(const String &p_node_type) const;
|
||||
PoolVector<String> _get_stylebox_types() const;
|
||||
PoolVector<String> _get_font_list(const String &p_node_type) const;
|
||||
PoolVector<String> _get_font_types() const;
|
||||
PoolVector<String> _get_color_list(const String &p_node_type) const;
|
||||
PoolVector<String> _get_color_types() const;
|
||||
PoolVector<String> _get_constant_list(const String &p_node_type) const;
|
||||
PoolVector<String> _get_constant_types() const;
|
||||
PoolVector<String> _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<StringName> *p_list) const;
|
||||
void get_icon_types(List<StringName> *p_list) const;
|
||||
|
||||
void set_shader(const StringName &p_name, const StringName &p_node_type, const Ref<Shader> &p_shader);
|
||||
Ref<Shader> 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<StringName> *p_list) const;
|
||||
void get_font_types(List<StringName> *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<StringName> *p_list) const;
|
||||
void get_color_types(List<StringName> *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<StringName> *p_list) const;
|
||||
void get_constant_types(List<StringName> *p_list) const;
|
||||
|
||||
void get_type_list(List<StringName> *p_list) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue