Merge pull request #89311 from Mickeon/label_3d_is_a_mess

Fix Label3D, TextMesh & Font not following project default theme in editor
This commit is contained in:
Rémi Verschelde 2024-03-10 21:13:01 +01:00
commit 54f2916cf1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 23 additions and 4 deletions

View File

@ -782,6 +782,8 @@ Ref<Font> Label3D::get_font() const {
}
Ref<Font> Label3D::_get_font_or_default() const {
// Similar code taken from `FontVariation::_get_base_font_or_default`.
if (theme_font.is_valid()) {
theme_font->disconnect_changed(callable_mp(const_cast<Label3D *>(this), &Label3D::_font_changed));
theme_font.unref();
@ -791,12 +793,17 @@ Ref<Font> Label3D::_get_font_or_default() const {
return font_override;
}
StringName theme_name = "font";
const StringName theme_name = "font";
List<StringName> theme_types;
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types);
ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context();
for (const Ref<Theme> &theme : global_context->get_themes()) {
List<Ref<Theme>> themes = global_context->get_themes();
if (Engine::get_singleton()->is_editor_hint()) {
themes.push_front(ThemeDB::get_singleton()->get_project_theme());
}
for (const Ref<Theme> &theme : themes) {
if (theme.is_null()) {
continue;
}

View File

@ -3463,6 +3463,8 @@ Ref<Font> TextMesh::get_font() const {
}
Ref<Font> TextMesh::_get_font_or_default() const {
// Similar code taken from `FontVariation::_get_base_font_or_default`.
if (font_override.is_valid()) {
return font_override;
}
@ -3472,7 +3474,12 @@ Ref<Font> TextMesh::_get_font_or_default() const {
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types);
ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context();
for (const Ref<Theme> &theme : global_context->get_themes()) {
List<Ref<Theme>> themes = global_context->get_themes();
if (Engine::get_singleton()->is_editor_hint()) {
themes.push_front(ThemeDB::get_singleton()->get_project_theme());
}
for (const Ref<Theme> &theme : themes) {
if (theme.is_null()) {
continue;
}

View File

@ -2861,7 +2861,12 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types);
ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context();
for (const Ref<Theme> &theme : global_context->get_themes()) {
List<Ref<Theme>> themes = global_context->get_themes();
if (Engine::get_singleton()->is_editor_hint()) {
themes.push_front(ThemeDB::get_singleton()->get_project_theme());
}
for (const Ref<Theme> &theme : themes) {
if (theme.is_null()) {
continue;
}