From 8d608cdc40b780e166c0b56a09055f4eb4ae8311 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 10 Apr 2020 17:50:28 +0300 Subject: Remove unused argument in Theme method and expose missing methods --- scene/resources/theme.cpp | 112 +++++++++++++++++++++++++++++++++++++++++++--- scene/resources/theme.h | 14 ++++-- 2 files changed, 117 insertions(+), 9 deletions(-) (limited to 'scene') diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 6a752d32e7..c8bfcdfab4 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -51,6 +51,21 @@ Vector Theme::_get_icon_list(const String &p_node_type) const { return ilret; } +Vector Theme::_get_icon_type_list() const { + Vector ilret; + List il; + + get_icon_type_list(&il); + ilret.resize(il.size()); + + int i = 0; + String *w = ilret.ptrw(); + for (List::Element *E = il.front(); E; E = E->next(), i++) { + w[i] = E->get(); + } + return ilret; +} + Vector Theme::_get_stylebox_list(const String &p_node_type) const { Vector ilret; List il; @@ -66,11 +81,11 @@ Vector Theme::_get_stylebox_list(const String &p_node_type) const { return ilret; } -Vector Theme::_get_stylebox_types() const { +Vector Theme::_get_stylebox_type_list() const { Vector ilret; List il; - get_stylebox_types(&il); + get_stylebox_type_list(&il); ilret.resize(il.size()); int i = 0; @@ -96,6 +111,21 @@ Vector Theme::_get_font_list(const String &p_node_type) const { return ilret; } +Vector Theme::_get_font_type_list() const { + Vector ilret; + List il; + + get_font_type_list(&il); + ilret.resize(il.size()); + + int i = 0; + String *w = ilret.ptrw(); + for (List::Element *E = il.front(); E; E = E->next(), i++) { + w[i] = E->get(); + } + return ilret; +} + Vector Theme::_get_font_size_list(const String &p_node_type) const { Vector ilret; List il; @@ -126,6 +156,21 @@ Vector Theme::_get_color_list(const String &p_node_type) const { return ilret; } +Vector Theme::_get_color_type_list() const { + Vector ilret; + List il; + + get_color_type_list(&il); + ilret.resize(il.size()); + + int i = 0; + String *w = ilret.ptrw(); + for (List::Element *E = il.front(); E; E = E->next(), i++) { + w[i] = E->get(); + } + return ilret; +} + Vector Theme::_get_constant_list(const String &p_node_type) const { Vector ilret; List il; @@ -141,7 +186,22 @@ Vector Theme::_get_constant_list(const String &p_node_type) const { return ilret; } -Vector Theme::_get_type_list(const String &p_node_type) const { +Vector Theme::_get_constant_type_list() const { + Vector ilret; + List il; + + get_constant_type_list(&il); + ilret.resize(il.size()); + + int i = 0; + String *w = ilret.ptrw(); + for (List::Element *E = il.front(); E; E = E->next(), i++) { + w[i] = E->get(); + } + return ilret; +} + +Vector Theme::_get_type_list() const { Vector ilret; List il; @@ -421,6 +481,15 @@ void Theme::get_icon_list(StringName p_node_type, List *p_list) cons } } +void Theme::get_icon_type_list(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_stylebox(const StringName &p_name, const StringName &p_node_type, const Ref &p_style) { //ERR_FAIL_COND(p_style.is_null()); @@ -482,7 +551,7 @@ void Theme::get_stylebox_list(StringName p_node_type, List *p_list) } } -void Theme::get_stylebox_types(List *p_list) const { +void Theme::get_stylebox_type_list(List *p_list) const { ERR_FAIL_NULL(p_list); const StringName *key = nullptr; @@ -553,6 +622,15 @@ void Theme::get_font_list(StringName p_node_type, List *p_list) cons } } +void Theme::get_font_type_list(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_font_size(const StringName &p_name, const StringName &p_node_type, int p_font_size) { bool new_value = !font_size_map.has(p_node_type) || !font_size_map[p_node_type].has(p_name); @@ -647,6 +725,15 @@ void Theme::get_color_list(StringName p_node_type, List *p_list) con } } +void Theme::get_color_type_list(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; @@ -692,6 +779,15 @@ void Theme::get_constant_list(StringName p_node_type, List *p_list) } } +void Theme::get_constant_type_list(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 { @@ -840,19 +936,21 @@ 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_type_list"), &Theme::_get_icon_type_list); 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); ClassDB::bind_method(D_METHOD("has_stylebox", "name", "node_type"), &Theme::has_stylebox); ClassDB::bind_method(D_METHOD("clear_stylebox", "name", "node_type"), &Theme::clear_stylebox); ClassDB::bind_method(D_METHOD("get_stylebox_list", "node_type"), &Theme::_get_stylebox_list); - ClassDB::bind_method(D_METHOD("get_stylebox_types"), &Theme::_get_stylebox_types); + ClassDB::bind_method(D_METHOD("get_stylebox_type_list"), &Theme::_get_stylebox_type_list); ClassDB::bind_method(D_METHOD("set_font", "name", "node_type", "font"), &Theme::set_font); ClassDB::bind_method(D_METHOD("get_font", "name", "node_type"), &Theme::get_font); 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_type_list"), &Theme::_get_font_type_list); ClassDB::bind_method(D_METHOD("set_font_size", "name", "node_type", "font_size"), &Theme::set_font_size); ClassDB::bind_method(D_METHOD("get_font_size", "name", "node_type"), &Theme::get_font_size); @@ -865,12 +963,14 @@ void Theme::_bind_methods() { 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_type_list"), &Theme::_get_color_type_list); 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_type_list"), &Theme::_get_constant_type_list); ClassDB::bind_method(D_METHOD("clear"), &Theme::clear); @@ -880,7 +980,7 @@ void Theme::_bind_methods() { ClassDB::bind_method(D_METHOD("set_default_font_size", "font_size"), &Theme::set_default_theme_font_size); ClassDB::bind_method(D_METHOD("get_default_font_size"), &Theme::get_default_theme_font_size); - ClassDB::bind_method(D_METHOD("get_type_list", "node_type"), &Theme::_get_type_list); + ClassDB::bind_method(D_METHOD("get_type_list"), &Theme::_get_type_list); ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme); ClassDB::bind_method(D_METHOD("copy_theme", "other"), &Theme::copy_theme); diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 6ac47e8931..ad05e0e2f5 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -51,13 +51,17 @@ class Theme : public Resource { HashMap> constant_map; Vector _get_icon_list(const String &p_node_type) const; + Vector _get_icon_type_list() const; Vector _get_stylebox_list(const String &p_node_type) const; - Vector _get_stylebox_types() const; + Vector _get_stylebox_type_list() const; Vector _get_font_list(const String &p_node_type) const; + Vector _get_font_type_list() const; Vector _get_font_size_list(const String &p_node_type) const; Vector _get_color_list(const String &p_node_type) const; + Vector _get_color_type_list() const; Vector _get_constant_list(const String &p_node_type) const; - Vector _get_type_list(const String &p_node_type) const; + Vector _get_constant_type_list() const; + Vector _get_type_list() const; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -99,19 +103,21 @@ 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_type_list(List *p_list) const; void set_stylebox(const StringName &p_name, const StringName &p_node_type, const Ref &p_style); Ref get_stylebox(const StringName &p_name, const StringName &p_node_type) const; bool has_stylebox(const StringName &p_name, const StringName &p_node_type) const; void clear_stylebox(const StringName &p_name, const StringName &p_node_type); void get_stylebox_list(StringName p_node_type, List *p_list) const; - void get_stylebox_types(List *p_list) const; + void get_stylebox_type_list(List *p_list) const; void set_font(const StringName &p_name, const StringName &p_node_type, const Ref &p_font); Ref get_font(const StringName &p_name, const StringName &p_node_type) const; 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_type_list(List *p_list) const; void set_font_size(const StringName &p_name, const StringName &p_node_type, int p_font_size); int get_font_size(const StringName &p_name, const StringName &p_node_type) const; @@ -124,12 +130,14 @@ public: 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_type_list(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_type_list(List *p_list) const; void get_type_list(List *p_list) const; -- cgit v1.2.3