@@ -149,7 +149,9 @@ void ShaderEditorPlugin::edit(Object *p_object) {
149149 }
150150 }
151151 es.shader_inc = Ref<ShaderInclude>(si);
152- es.shader_editor = memnew (TextShaderEditor);
152+ TextShaderEditor *text_shader = memnew (TextShaderEditor);
153+ text_shader->get_code_editor ()->set_toggle_list_control (left_panel);
154+ es.shader_editor = text_shader;
153155 es.shader_editor ->edit_shader_include (si);
154156 shader_tabs->add_child (es.shader_editor );
155157 } else {
@@ -166,7 +168,9 @@ void ShaderEditorPlugin::edit(Object *p_object) {
166168 if (vs.is_valid ()) {
167169 es.shader_editor = memnew (VisualShaderEditor);
168170 } else {
169- es.shader_editor = memnew (TextShaderEditor);
171+ TextShaderEditor *text_shader = memnew (TextShaderEditor);
172+ text_shader->get_code_editor ()->set_toggle_list_control (left_panel);
173+ es.shader_editor = text_shader;
170174 }
171175 shader_tabs->add_child (es.shader_editor );
172176 es.shader_editor ->edit_shader (es.shader );
@@ -434,6 +438,10 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
434438 edited_shaders.remove_at (p_index);
435439 _update_shader_list ();
436440 EditorUndoRedoManager::get_singleton ()->clear_history (); // To prevent undo on deleted graphs.
441+
442+ if (shader_tabs->get_tab_count () == 0 ) {
443+ left_panel->show (); // Make sure the panel is visible, because it can't be toggled without open shaders.
444+ }
437445}
438446
439447void ShaderEditorPlugin::_close_builtin_shaders_from_scene (const String &p_scene) {
@@ -768,10 +776,10 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
768776 Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND (" shader_editor/make_floating" , TTR (" Make Floating" ));
769777 window_wrapper->set_wrapped_control (main_split, make_floating_shortcut);
770778
771- VBoxContainer *vb = memnew (VBoxContainer);
779+ left_panel = memnew (VBoxContainer);
772780
773781 HBoxContainer *menu_hb = memnew (HBoxContainer);
774- vb ->add_child (menu_hb);
782+ left_panel ->add_child (menu_hb);
775783 file_menu = memnew (MenuButton);
776784 file_menu->set_text (TTR (" File" ));
777785 file_menu->set_shortcut_context (main_split);
@@ -803,14 +811,14 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
803811 shader_list = memnew (ItemList);
804812 shader_list->set_auto_translate_mode (AUTO_TRANSLATE_MODE_DISABLED);
805813 shader_list->set_v_size_flags (Control::SIZE_EXPAND_FILL);
806- vb ->add_child (shader_list);
814+ left_panel ->add_child (shader_list);
807815 shader_list->connect (SceneStringName (item_selected), callable_mp (this , &ShaderEditorPlugin::_shader_selected));
808816 shader_list->connect (" item_clicked" , callable_mp (this , &ShaderEditorPlugin::_shader_list_clicked));
809817 shader_list->set_allow_rmb_select (true );
810818 SET_DRAG_FORWARDING_GCD (shader_list, ShaderEditorPlugin);
811819
812- main_split->add_child (vb );
813- vb ->set_custom_minimum_size (Size2 (200 , 300 ) * EDSCALE);
820+ main_split->add_child (left_panel );
821+ left_panel ->set_custom_minimum_size (Size2 (200 , 300 ) * EDSCALE);
814822
815823 shader_tabs = memnew (TabContainer);
816824 shader_tabs->set_tabs_visible (false );
@@ -823,7 +831,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
823831 button = EditorNode::get_bottom_panel ()->add_item (TTR (" Shader Editor" ), window_wrapper, ED_SHORTCUT_AND_COMMAND (" bottom_panels/toggle_shader_editor_bottom_panel" , TTR (" Toggle Shader Editor Bottom Panel" ), KeyModifierMask::ALT | Key::S));
824832
825833 shader_create_dialog = memnew (ShaderCreateDialog);
826- vb ->add_child (shader_create_dialog);
834+ main_split ->add_child (shader_create_dialog);
827835 shader_create_dialog->connect (" shader_created" , callable_mp (this , &ShaderEditorPlugin::_shader_created));
828836 shader_create_dialog->connect (" shader_include_created" , callable_mp (this , &ShaderEditorPlugin::_shader_include_created));
829837}
0 commit comments