Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Source default theme items from ThemeDB

kobewi695f79b7f2c6
diff --git a/editor/scene/gui/theme_editor_plugin.cpp b/editor/scene/gui/theme_editor_plugin.cpp
index 6bb7a1d6e17..30a311f6cce 100644
--- a/editor/scene/gui/theme_editor_plugin.cpp
+++ b/editor/scene/gui/theme_editor_plugin.cpp
@@ -151,7 +151,17 @@ void ThemeItemImportTree::_update_items_tree() {
names.clear();
filtered_names.clear();
- base_theme->get_theme_item_list(dt, E, &names);
+
+ if (base_theme == ThemeDB::get_singleton()->get_default_theme()) {
+ // For the default theme, include all registered theme items, even if they aren't assigned.
+ List<ThemeDB::ThemeItemBind> binds;
+ ThemeDB::get_singleton()->get_class_items(E, &binds, false, dt);
+ for (const ThemeDB::ThemeItemBind &bind : binds) {
+ names.push_back(bind.item_name);
+ }
+ } else {
+ base_theme->get_theme_item_list(dt, E, &names);
+ }
bool data_type_has_filtered_items = false;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index a3858e76c68..8ebd32d3d6a 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -1571,6 +1571,11 @@ void Theme::get_type_list(List<StringName> *p_list) const {
types.insert(E.key);
}
+ // If it's the default theme, ask also ThemeDB, in case some types don't have assigned items.
+ if (ThemeDB::get_singleton()->get_default_theme() == this) {
+ ThemeDB::get_singleton()->get_class_list(types);
+ }
+
for (const StringName &E : types) {
p_list->push_back(E);
}
diff --git a/scene/theme/theme_db.cpp b/scene/theme/theme_db.cpp
index 933e4a7f049..391b273b28b 100644
--- a/scene/theme/theme_db.cpp
+++ b/scene/theme/theme_db.cpp
@@ -388,6 +388,15 @@ void ThemeDB::update_class_instance_items(Node *p_instance) {
}
}
+void ThemeDB::get_class_list(HashSet<StringName> &r_list) const {
+ for (const KeyValue<StringName, List<ThemeDB::ThemeItemBind>> &KV : theme_item_binds_list) {
+ if (ClassDB::get_api_type(KV.key) == ClassDB::API_CORE) {
+ // Don't include editor and extension classes.
+ r_list.insert(KV.key);
+ }
+ }
+}
+
void ThemeDB::get_class_items(const StringName &p_class_name, List<ThemeItemBind> *r_list, bool p_include_inherited, Theme::DataType p_filter_type) {
List<StringName> class_hierarchy;
StringName class_name = p_class_name;
diff --git a/scene/theme/theme_db.h b/scene/theme/theme_db.h
index bf021cd79cf..2008d33613d 100644
--- a/scene/theme/theme_db.h
+++ b/scene/theme/theme_db.h
@@ -177,6 +177,7 @@ public:
void bind_class_external_item(Theme::DataType p_data_type, const StringName &p_class_name, const StringName &p_prop_name, const StringName &p_item_name, const StringName &p_type_name, ThemeItemSetter p_setter);
void update_class_instance_items(Node *p_instance);
+ void get_class_list(HashSet<StringName> &r_list) const;
void get_class_items(const StringName &p_class_name, List<ThemeItemBind> *r_list, bool p_include_inherited = false, Theme::DataType p_filter_type = Theme::DATA_TYPE_MAX);
// Memory management, reference, and initialization.