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

Re-organize UI in the shader editor

This commit is contained in:
Chaosus
2024-12-11 20:32:11 +03:00
parent 4b36c0491e
commit b983a05806
7 changed files with 153 additions and 18 deletions

View File

@@ -38,6 +38,7 @@
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/gui/separator.h"
#include "scene/gui/split_container.h"
#include "servers/rendering/shader_preprocessor.h"
#include "servers/rendering/shader_types.h"
@@ -749,8 +750,7 @@ void TextShaderEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
PopupMenu *popup = help_menu->get_popup();
popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_editor_theme_icon(SNAME("ExternalLink")));
site_search->set_button_icon(get_editor_theme_icon(SNAME("ExternalLink")));
} break;
case NOTIFICATION_APPLICATION_FOCUS_IN: {
@@ -976,6 +976,10 @@ void TextShaderEditor::validate_script() {
code_editor->_validate_script();
}
Control *TextShaderEditor::get_top_bar() {
return hbc;
}
bool TextShaderEditor::is_unsaved() const {
return code_editor->get_text_editor()->get_saved_version() != code_editor->get_text_editor()->get_version();
}
@@ -1149,7 +1153,7 @@ TextShaderEditor::TextShaderEditor() {
VBoxContainer *main_container = memnew(VBoxContainer);
main_container->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
HBoxContainer *hbc = memnew(HBoxContainer);
hbc = memnew(HBoxContainer);
edit_menu = memnew(MenuButton);
edit_menu->set_shortcut_context(this);
@@ -1205,18 +1209,21 @@ TextShaderEditor::TextShaderEditor() {
bookmarks_menu->connect("about_to_popup", callable_mp(this, &TextShaderEditor::_update_bookmark_list));
bookmarks_menu->connect("index_pressed", callable_mp(this, &TextShaderEditor::_bookmark_item_pressed));
help_menu = memnew(MenuButton);
help_menu->set_text(TTR("Help"));
help_menu->set_switch_on_hover(true);
help_menu->get_popup()->add_item(TTR("Online Docs"), HELP_DOCS);
help_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &TextShaderEditor::_menu_option));
add_child(main_container);
main_container->add_child(hbc);
hbc->add_child(search_menu);
hbc->add_child(edit_menu);
hbc->add_child(search_menu);
hbc->add_child(goto_menu);
hbc->add_child(help_menu);
hbc->add_spacer();
site_search = memnew(Button);
site_search->set_flat(true);
site_search->connect(SceneStringName(pressed), callable_mp(this, &TextShaderEditor::_menu_option).bind(HELP_DOCS));
site_search->set_text(TTR("Online Docs"));
site_search->set_tooltip_text(TTR("Open Godot online documentation."));
hbc->add_child(site_search);
hbc->add_child(memnew(VSeparator));
hbc->add_theme_style_override(SceneStringName(panel), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("ScriptEditorPanel"), EditorStringName(EditorStyles)));
VSplitContainer *editor_box = memnew(VSplitContainer);