mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 21:22:48 +00:00
Refactor toggling script list
This commit is contained in:
parent
f648de1a83
commit
b4c92dbd0e
@ -1548,7 +1548,8 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CodeTextEditor::_toggle_scripts_pressed() {
|
void CodeTextEditor::_toggle_scripts_pressed() {
|
||||||
ScriptEditor::get_singleton()->toggle_scripts_panel();
|
ERR_FAIL_NULL(toggle_scripts_list);
|
||||||
|
toggle_scripts_list->set_visible(!toggle_scripts_list->is_visible());
|
||||||
update_toggle_scripts_button();
|
update_toggle_scripts_button();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1723,16 +1724,18 @@ void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_cod
|
|||||||
code_complete_ud = p_ud;
|
code_complete_ud = p_ud;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeTextEditor::set_toggle_list_control(Control *p_control) {
|
||||||
|
toggle_scripts_list = p_control;
|
||||||
|
}
|
||||||
|
|
||||||
void CodeTextEditor::show_toggle_scripts_button() {
|
void CodeTextEditor::show_toggle_scripts_button() {
|
||||||
toggle_scripts_button->show();
|
toggle_scripts_button->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeTextEditor::update_toggle_scripts_button() {
|
void CodeTextEditor::update_toggle_scripts_button() {
|
||||||
if (is_layout_rtl()) {
|
ERR_FAIL_NULL(toggle_scripts_list);
|
||||||
toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back")));
|
bool forward = toggle_scripts_list->is_visible() == is_layout_rtl();
|
||||||
} else {
|
toggle_scripts_button->set_icon(get_editor_theme_icon(forward ? SNAME("Forward") : SNAME("Back")));
|
||||||
toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward")));
|
|
||||||
}
|
|
||||||
toggle_scripts_button->set_tooltip_text(vformat("%s (%s)", TTR("Toggle Scripts Panel"), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text()));
|
toggle_scripts_button->set_tooltip_text(vformat("%s (%s)", TTR("Toggle Scripts Panel"), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ class CodeTextEditor : public VBoxContainer {
|
|||||||
HBoxContainer *status_bar = nullptr;
|
HBoxContainer *status_bar = nullptr;
|
||||||
|
|
||||||
Button *toggle_scripts_button = nullptr;
|
Button *toggle_scripts_button = nullptr;
|
||||||
|
Control *toggle_scripts_list = nullptr;
|
||||||
Button *error_button = nullptr;
|
Button *error_button = nullptr;
|
||||||
Button *warning_button = nullptr;
|
Button *warning_button = nullptr;
|
||||||
|
|
||||||
@ -285,6 +286,7 @@ public:
|
|||||||
|
|
||||||
void validate_script();
|
void validate_script();
|
||||||
|
|
||||||
|
void set_toggle_list_control(Control *p_control);
|
||||||
void show_toggle_scripts_button();
|
void show_toggle_scripts_button();
|
||||||
void update_toggle_scripts_button();
|
void update_toggle_scripts_button();
|
||||||
|
|
||||||
|
@ -2373,6 +2373,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
|||||||
|
|
||||||
ScriptTextEditor::ScriptTextEditor() {
|
ScriptTextEditor::ScriptTextEditor() {
|
||||||
code_editor = memnew(CodeTextEditor);
|
code_editor = memnew(CodeTextEditor);
|
||||||
|
code_editor->set_toggle_list_control(ScriptEditor::get_singleton()->get_left_list_split());
|
||||||
code_editor->add_theme_constant_override("separation", 2);
|
code_editor->add_theme_constant_override("separation", 2);
|
||||||
code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
|
code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
|
||||||
code_editor->set_code_complete_func(_code_complete_scripts, this);
|
code_editor->set_code_complete_func(_code_complete_scripts, this);
|
||||||
|
@ -149,7 +149,9 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
es.shader_inc = Ref<ShaderInclude>(si);
|
es.shader_inc = Ref<ShaderInclude>(si);
|
||||||
es.shader_editor = memnew(TextShaderEditor);
|
TextShaderEditor *text_shader = memnew(TextShaderEditor);
|
||||||
|
text_shader->get_code_editor()->set_toggle_list_control(left_panel);
|
||||||
|
es.shader_editor = text_shader;
|
||||||
es.shader_editor->edit_shader_include(si);
|
es.shader_editor->edit_shader_include(si);
|
||||||
shader_tabs->add_child(es.shader_editor);
|
shader_tabs->add_child(es.shader_editor);
|
||||||
} else {
|
} else {
|
||||||
@ -166,7 +168,9 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
if (vs.is_valid()) {
|
if (vs.is_valid()) {
|
||||||
es.shader_editor = memnew(VisualShaderEditor);
|
es.shader_editor = memnew(VisualShaderEditor);
|
||||||
} else {
|
} else {
|
||||||
es.shader_editor = memnew(TextShaderEditor);
|
TextShaderEditor *text_shader = memnew(TextShaderEditor);
|
||||||
|
text_shader->get_code_editor()->set_toggle_list_control(left_panel);
|
||||||
|
es.shader_editor = text_shader;
|
||||||
}
|
}
|
||||||
shader_tabs->add_child(es.shader_editor);
|
shader_tabs->add_child(es.shader_editor);
|
||||||
es.shader_editor->edit_shader(es.shader);
|
es.shader_editor->edit_shader(es.shader);
|
||||||
@ -434,6 +438,10 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
|
|||||||
edited_shaders.remove_at(p_index);
|
edited_shaders.remove_at(p_index);
|
||||||
_update_shader_list();
|
_update_shader_list();
|
||||||
EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs.
|
EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs.
|
||||||
|
|
||||||
|
if (shader_tabs->get_tab_count() == 0) {
|
||||||
|
left_panel->show(); // Make sure the panel is visible, because it can't be toggled without open shaders.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) {
|
void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) {
|
||||||
@ -768,10 +776,10 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
|
|||||||
Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND("shader_editor/make_floating", TTR("Make Floating"));
|
Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND("shader_editor/make_floating", TTR("Make Floating"));
|
||||||
window_wrapper->set_wrapped_control(main_split, make_floating_shortcut);
|
window_wrapper->set_wrapped_control(main_split, make_floating_shortcut);
|
||||||
|
|
||||||
VBoxContainer *vb = memnew(VBoxContainer);
|
left_panel = memnew(VBoxContainer);
|
||||||
|
|
||||||
HBoxContainer *menu_hb = memnew(HBoxContainer);
|
HBoxContainer *menu_hb = memnew(HBoxContainer);
|
||||||
vb->add_child(menu_hb);
|
left_panel->add_child(menu_hb);
|
||||||
file_menu = memnew(MenuButton);
|
file_menu = memnew(MenuButton);
|
||||||
file_menu->set_text(TTR("File"));
|
file_menu->set_text(TTR("File"));
|
||||||
file_menu->set_shortcut_context(main_split);
|
file_menu->set_shortcut_context(main_split);
|
||||||
@ -803,14 +811,14 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
|
|||||||
shader_list = memnew(ItemList);
|
shader_list = memnew(ItemList);
|
||||||
shader_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
shader_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||||
shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
vb->add_child(shader_list);
|
left_panel->add_child(shader_list);
|
||||||
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected));
|
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected));
|
||||||
shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked));
|
shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked));
|
||||||
shader_list->set_allow_rmb_select(true);
|
shader_list->set_allow_rmb_select(true);
|
||||||
SET_DRAG_FORWARDING_GCD(shader_list, ShaderEditorPlugin);
|
SET_DRAG_FORWARDING_GCD(shader_list, ShaderEditorPlugin);
|
||||||
|
|
||||||
main_split->add_child(vb);
|
main_split->add_child(left_panel);
|
||||||
vb->set_custom_minimum_size(Size2(200, 300) * EDSCALE);
|
left_panel->set_custom_minimum_size(Size2(200, 300) * EDSCALE);
|
||||||
|
|
||||||
shader_tabs = memnew(TabContainer);
|
shader_tabs = memnew(TabContainer);
|
||||||
shader_tabs->set_tabs_visible(false);
|
shader_tabs->set_tabs_visible(false);
|
||||||
@ -823,7 +831,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
|
|||||||
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));
|
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));
|
||||||
|
|
||||||
shader_create_dialog = memnew(ShaderCreateDialog);
|
shader_create_dialog = memnew(ShaderCreateDialog);
|
||||||
vb->add_child(shader_create_dialog);
|
main_split->add_child(shader_create_dialog);
|
||||||
shader_create_dialog->connect("shader_created", callable_mp(this, &ShaderEditorPlugin::_shader_created));
|
shader_create_dialog->connect("shader_created", callable_mp(this, &ShaderEditorPlugin::_shader_created));
|
||||||
shader_create_dialog->connect("shader_include_created", callable_mp(this, &ShaderEditorPlugin::_shader_include_created));
|
shader_create_dialog->connect("shader_include_created", callable_mp(this, &ShaderEditorPlugin::_shader_include_created));
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ class ShaderCreateDialog;
|
|||||||
class ShaderEditor;
|
class ShaderEditor;
|
||||||
class TabContainer;
|
class TabContainer;
|
||||||
class TextShaderEditor;
|
class TextShaderEditor;
|
||||||
|
class VBoxContainer;
|
||||||
class VisualShaderEditor;
|
class VisualShaderEditor;
|
||||||
class WindowWrapper;
|
class WindowWrapper;
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ class ShaderEditorPlugin : public EditorPlugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
HSplitContainer *main_split = nullptr;
|
HSplitContainer *main_split = nullptr;
|
||||||
|
VBoxContainer *left_panel = nullptr;
|
||||||
ItemList *shader_list = nullptr;
|
ItemList *shader_list = nullptr;
|
||||||
TabContainer *shader_tabs = nullptr;
|
TabContainer *shader_tabs = nullptr;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "scene/gui/menu_button.h"
|
#include "scene/gui/menu_button.h"
|
||||||
|
#include "scene/gui/split_container.h"
|
||||||
|
|
||||||
void TextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) {
|
void TextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) {
|
||||||
ERR_FAIL_COND(p_highlighter.is_null());
|
ERR_FAIL_COND(p_highlighter.is_null());
|
||||||
@ -606,6 +607,7 @@ TextEditor::TextEditor() {
|
|||||||
code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
|
code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
|
||||||
code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
code_editor->show_toggle_scripts_button();
|
code_editor->show_toggle_scripts_button();
|
||||||
|
code_editor->set_toggle_list_control(ScriptEditor::get_singleton()->get_left_list_split());
|
||||||
|
|
||||||
update_settings();
|
update_settings();
|
||||||
|
|
||||||
|
@ -1256,4 +1256,5 @@ TextShaderEditor::TextShaderEditor() {
|
|||||||
add_child(disk_changed);
|
add_child(disk_changed);
|
||||||
|
|
||||||
_editor_settings_changed();
|
_editor_settings_changed();
|
||||||
|
code_editor->show_toggle_scripts_button(); // TODO: Disabled for now, because it doesn't work properly.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user