Skip to content

Commit 7a82648

Browse files
committed
Merge pull request godotengine#110404 from bruvzg/empty_shader_file
Shader Editor: Show "File" menu when no shaders are opened.
2 parents 62273fa + 75bbe3a commit 7a82648

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

editor/shader/shader_editor_plugin.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
459459
if (make_floating->get_parent()) {
460460
make_floating->get_parent()->remove_child(make_floating);
461461
}
462+
empty_menu->set_visible(false);
462463
ShaderEditor *shader_editor = Object::cast_to<ShaderEditor>(shader_tabs->get_tab_control(p_index));
463464
ERR_FAIL_NULL(shader_editor);
464465

@@ -469,6 +470,8 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
469470

470471
if (shader_tabs->get_tab_count() == 0) {
471472
shader_list->show(); // Make sure the panel is visible, because it can't be toggled without open shaders.
473+
empty_menu->add_child(file_menu);
474+
empty_menu->set_visible(true);
472475
} else {
473476
_switch_to_editor(edited_shaders[shader_tabs->get_current_tab()].shader_editor);
474477
}
@@ -788,6 +791,7 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
788791
if (make_floating->get_parent()) {
789792
make_floating->get_parent()->remove_child(make_floating);
790793
}
794+
empty_menu->set_visible(false);
791795
p_editor->use_menu_bar_items(file_menu, make_floating);
792796
}
793797

@@ -896,11 +900,20 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
896900
main_container->add_child(files_split);
897901
main_container->set_custom_minimum_size(Size2(100, 300) * EDSCALE);
898902

903+
VBoxContainer *shader_vb = memnew(VBoxContainer);
904+
shader_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
905+
files_split->add_child(shader_vb);
906+
empty_menu = memnew(HBoxContainer);
907+
shader_vb->add_child(empty_menu);
908+
empty_menu->add_child(file_menu);
909+
empty_menu->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("ScriptEditorPanel"), EditorStringName(EditorStyles)));
910+
899911
shader_tabs = memnew(TabContainer);
900912
shader_tabs->set_custom_minimum_size(Size2(460, 300) * EDSCALE);
901913
shader_tabs->set_tabs_visible(false);
902914
shader_tabs->set_h_size_flags(Control::SIZE_EXPAND_FILL);
903-
files_split->add_child(shader_tabs);
915+
shader_tabs->set_v_size_flags(Control::SIZE_EXPAND_FILL);
916+
shader_vb->add_child(shader_tabs);
904917
Ref<StyleBoxEmpty> empty;
905918
empty.instantiate();
906919
shader_tabs->add_theme_style_override(SceneStringName(panel), empty);

editor/shader/shader_editor_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class ShaderEditorPlugin : public EditorPlugin {
8686

8787
ItemList *shader_list = nullptr;
8888
TabContainer *shader_tabs = nullptr;
89+
HBoxContainer *empty_menu = nullptr;
8990

9091
Button *button = nullptr;
9192
MenuButton *file_menu = nullptr;

0 commit comments

Comments
 (0)