diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-04 22:43:41 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-10-04 22:43:41 +0200 |
commit | def5a04d06a92e538a4d899eab324f4ef9f3f40e (patch) | |
tree | 2294bb012e0e712d7a89c7075f1fea36fe454562 /editor/plugins/theme_editor_plugin.cpp | |
parent | e5688f51cb08076fef8c5720d8fe7177841d34e7 (diff) | |
parent | 66d2b0fc6a7f656f37e65a93eacc77642602aca9 (diff) | |
download | redot-engine-def5a04d06a92e538a4d899eab324f4ef9f3f40e.tar.gz |
Merge pull request #97543 from KoBeWi/to_edit_or_not_to_edit
Fix closing Theme Editor not actually closing it
Diffstat (limited to 'editor/plugins/theme_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/theme_editor_plugin.cpp | 78 |
1 files changed, 12 insertions, 66 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 8f646a7621..cc488ff340 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -3596,6 +3596,13 @@ void ThemeEditor::_theme_close_button_cbk() { } } +void ThemeEditor::_scene_closed(const String &p_path) { + if (theme.is_valid() && theme->is_built_in() && theme->get_path().get_slice("::", 0) == p_path) { + theme = Ref<Theme>(); + EditorNode::get_singleton()->hide_unused_editors(plugin); + } +} + void ThemeEditor::_add_preview_button_cbk() { preview_scene_dialog->popup_file_dialog(); } @@ -3679,7 +3686,10 @@ void ThemeEditor::_preview_control_picked(String p_class_name) { void ThemeEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_READY: { + EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ThemeEditor::_scene_closed)); + } break; + case NOTIFICATION_THEME_CHANGED: { preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), EditorStringName(EditorStyles))); preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), EditorStringName(EditorStyles))); @@ -3807,71 +3817,7 @@ void ThemeEditorPlugin::make_visible(bool p_visible) { } bool ThemeEditorPlugin::can_auto_hide() const { - Ref<Theme> edited_theme = theme_editor->theme; - if (edited_theme.is_null()) { - return true; - } - - Ref<Resource> edited_resource = Ref<Resource>(InspectorDock::get_inspector_singleton()->get_next_edited_object()); - if (edited_resource.is_null()) { - return true; - } - - // Don't hide if edited resource used by this theme. - Ref<StyleBox> sbox = edited_resource; - if (sbox.is_valid()) { - List<StringName> type_list; - edited_theme->get_stylebox_type_list(&type_list); - - for (const StringName &E : type_list) { - List<StringName> list; - edited_theme->get_stylebox_list(E, &list); - - for (const StringName &F : list) { - if (edited_theme->get_stylebox(F, E) == sbox) { - return false; - } - } - } - return true; - } - - Ref<Texture2D> tex = edited_resource; - if (tex.is_valid()) { - List<StringName> type_list; - edited_theme->get_icon_type_list(&type_list); - - for (const StringName &E : type_list) { - List<StringName> list; - edited_theme->get_icon_list(E, &list); - - for (const StringName &F : list) { - if (edited_theme->get_icon(F, E) == tex) { - return false; - } - } - } - return true; - } - - Ref<Font> fnt = edited_resource; - if (fnt.is_valid()) { - List<StringName> type_list; - edited_theme->get_font_type_list(&type_list); - - for (const StringName &E : type_list) { - List<StringName> list; - edited_theme->get_font_list(E, &list); - - for (const StringName &F : list) { - if (edited_theme->get_font(F, E) == fnt) { - return false; - } - } - } - return true; - } - return true; + return theme_editor->theme.is_null(); } ThemeEditorPlugin::ThemeEditorPlugin() { |