1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix theme application in various editor dialogs

99% of the time we shouldn't rely on the signal, we
should use the notification instead. I left some comments
in places where I couldn't quickly improve the code.
This commit is contained in:
Yuri Sizov
2023-12-04 13:18:48 +01:00
parent d76c1d0e51
commit 01888ae7ab
12 changed files with 54 additions and 73 deletions

View File

@@ -48,8 +48,6 @@ enum ShaderType {
void ShaderCreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_update_theme();
String last_lang = EditorSettings::get_singleton()->get_project_metadata("shader_setup", "last_selected_language", "");
if (!last_lang.is_empty()) {
for (int i = 0; i < type_menu->get_item_count(); i++) {
@@ -68,30 +66,19 @@ void ShaderCreateDialog::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
static const char *shader_types[3] = { "Shader", "VisualShader", "TextFile" };
for (int i = 0; i < 3; i++) {
Ref<Texture2D> icon = get_editor_theme_icon(shader_types[i]);
if (icon.is_valid()) {
type_menu->set_item_icon(i, icon);
}
}
path_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
} break;
}
}
void ShaderCreateDialog::_update_theme() {
Ref<Texture2D> shader_icon = gc->get_editor_theme_icon(SNAME("Shader"));
if (shader_icon.is_valid()) {
type_menu->set_item_icon(0, shader_icon);
}
Ref<Texture2D> visual_shader_icon = gc->get_editor_theme_icon(SNAME("VisualShader"));
if (visual_shader_icon.is_valid()) {
type_menu->set_item_icon(1, visual_shader_icon);
}
Ref<Texture2D> include_icon = gc->get_editor_theme_icon(SNAME("TextFile"));
if (include_icon.is_valid()) {
type_menu->set_item_icon(2, include_icon);
}
path_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
}
void ShaderCreateDialog::_update_language_info() {
type_data.clear();