Add ThemeDB, expose previously static Theme methods
This commit is contained in:
parent
c8ef12a03a
commit
6320a0fc18
25 changed files with 589 additions and 311 deletions
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/core_string_names.h"
|
||||
#include "scene/resources/theme.h"
|
||||
#include "scene/theme/theme_db.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#include "thirdparty/misc/clipper.hpp"
|
||||
#include "thirdparty/misc/polypartition.h"
|
||||
|
|
@ -2984,13 +2985,13 @@ Ref<Font> TextMesh::_get_font_or_default() const {
|
|||
}
|
||||
|
||||
// Check the project-defined Theme resource.
|
||||
if (Theme::get_project_default().is_valid()) {
|
||||
if (ThemeDB::get_singleton()->get_project_theme().is_valid()) {
|
||||
List<StringName> theme_types;
|
||||
Theme::get_project_default()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
|
||||
for (const StringName &E : theme_types) {
|
||||
if (Theme::get_project_default()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return Theme::get_project_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2998,17 +2999,17 @@ Ref<Font> TextMesh::_get_font_or_default() const {
|
|||
// Lastly, fall back on the items defined in the default Theme, if they exist.
|
||||
{
|
||||
List<StringName> theme_types;
|
||||
Theme::get_default()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
|
||||
for (const StringName &E : theme_types) {
|
||||
if (Theme::get_default()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return Theme::get_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If they don't exist, use any type to return the default/empty value.
|
||||
return Theme::get_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName());
|
||||
return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName());
|
||||
}
|
||||
|
||||
void TextMesh::set_font_size(int p_size) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue