Extract editor main screen

This commit is contained in:
kit 2024-08-19 18:08:31 -04:00
parent d0dc3896ad
commit 5e1c9d68aa
27 changed files with 484 additions and 354 deletions

View File

@ -34,6 +34,7 @@
#include "core/templates/hash_set.h" #include "core/templates/hash_set.h"
#include "editor/editor_help.h" #include "editor/editor_help.h"
#include "editor/editor_inspector.h" #include "editor/editor_inspector.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -1191,7 +1192,7 @@ void ConnectionsDock::_go_to_method(TreeItem &p_item) {
} }
if (scr.is_valid() && ScriptEditor::get_singleton()->script_goto_method(scr, cd.method)) { if (scr.is_valid() && ScriptEditor::get_singleton()->script_goto_method(scr, cd.method)) {
EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT); EditorNode::get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} }
} }
@ -1199,7 +1200,7 @@ void ConnectionsDock::_handle_class_menu_option(int p_option) {
switch (p_option) { switch (p_option) {
case CLASS_MENU_OPEN_DOCS: case CLASS_MENU_OPEN_DOCS:
ScriptEditor::get_singleton()->goto_help("class:" + class_menu_doc_class_name); ScriptEditor::get_singleton()->goto_help("class:" + class_menu_doc_class_name);
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
break; break;
} }
} }
@ -1229,7 +1230,7 @@ void ConnectionsDock::_handle_signal_menu_option(int p_option) {
} break; } break;
case SIGNAL_MENU_OPEN_DOCS: { case SIGNAL_MENU_OPEN_DOCS: {
ScriptEditor::get_singleton()->goto_help("class_signal:" + String(meta["class"]) + ":" + String(meta["name"])); ScriptEditor::get_singleton()->goto_help("class_signal:" + String(meta["class"]) + ":" + String(meta["name"]));
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} break; } break;
} }
} }

View File

@ -39,6 +39,7 @@
#include "core/string/string_builder.h" #include "core/string/string_builder.h"
#include "core/version_generated.gen.h" #include "core/version_generated.gen.h"
#include "editor/doc_data_compressed.gen.h" #include "editor/doc_data_compressed.gen.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_property_name_processor.h" #include "editor/editor_property_name_processor.h"
@ -2310,7 +2311,7 @@ void EditorHelp::_update_doc() {
void EditorHelp::_request_help(const String &p_string) { void EditorHelp::_request_help(const String &p_string) {
Error err = _goto_desc(p_string); Error err = _goto_desc(p_string);
if (err == OK) { if (err == OK) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} }
} }
@ -3605,7 +3606,7 @@ void EditorHelpBit::_update_labels() {
} }
void EditorHelpBit::_go_to_help(const String &p_what) { void EditorHelpBit::_go_to_help(const String &p_what) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->goto_help(p_what); ScriptEditor::get_singleton()->goto_help(p_what);
emit_signal(SNAME("request_hide")); emit_signal(SNAME("request_hide"));
} }

View File

@ -32,6 +32,7 @@
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/editor_feature_profile.h" #include "editor/editor_feature_profile.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -201,7 +202,7 @@ void EditorHelpSearch::_confirmed() {
} }
// Activate the script editor and emit the signal with the documentation link to display. // Activate the script editor and emit the signal with the documentation link to display.
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
emit_signal(SNAME("go_to_help"), item->get_metadata(0)); emit_signal(SNAME("go_to_help"), item->get_metadata(0));

View File

@ -34,6 +34,7 @@
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/doc_tools.h" #include "editor/doc_tools.h"
#include "editor/editor_feature_profile.h" #include "editor/editor_feature_profile.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_property_name_processor.h" #include "editor/editor_property_name_processor.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
@ -1037,7 +1038,7 @@ void EditorProperty::menu_option(int p_option) {
} break; } break;
case MENU_OPEN_DOCUMENTATION: { case MENU_OPEN_DOCUMENTATION: {
ScriptEditor::get_singleton()->goto_help(doc_path); ScriptEditor::get_singleton()->goto_help(doc_path);
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} break; } break;
} }
} }
@ -1297,7 +1298,7 @@ void EditorInspectorCategory::_handle_menu_option(int p_option) {
switch (p_option) { switch (p_option) {
case MENU_OPEN_DOCS: case MENU_OPEN_DOCS:
ScriptEditor::get_singleton()->goto_help("class:" + doc_class_name); ScriptEditor::get_singleton()->goto_help("class:" + doc_class_name);
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
break; break;
} }
} }

View File

@ -33,6 +33,7 @@
#include "editor/editor_command_palette.h" #include "editor/editor_command_palette.h"
#include "editor/editor_feature_profile.h" #include "editor/editor_feature_profile.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_resource_preview.h" #include "editor/editor_resource_preview.h"
@ -215,7 +216,7 @@ Control *EditorInterface::get_base_control() const {
} }
VBoxContainer *EditorInterface::get_editor_main_screen() const { VBoxContainer *EditorInterface::get_editor_main_screen() const {
return EditorNode::get_singleton()->get_main_screen_control(); return EditorNode::get_singleton()->get_editor_main_screen()->get_control();
} }
ScriptEditor *EditorInterface::get_script_editor() const { ScriptEditor *EditorInterface::get_script_editor() const {
@ -232,7 +233,7 @@ SubViewport *EditorInterface::get_editor_viewport_3d(int p_idx) const {
} }
void EditorInterface::set_main_screen_editor(const String &p_name) { void EditorInterface::set_main_screen_editor(const String &p_name) {
EditorNode::get_singleton()->select_editor_by_name(p_name); EditorNode::get_singleton()->get_editor_main_screen()->select_by_name(p_name);
} }
void EditorInterface::set_distraction_free_mode(bool p_enter) { void EditorInterface::set_distraction_free_mode(bool p_enter) {

View File

@ -0,0 +1,291 @@
/**************************************************************************/
/* editor_main_screen.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "editor_main_screen.h"
#include "core/io/config_file.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/plugins/editor_plugin.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
void EditorMainScreen::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
if (EDITOR_3D < buttons.size() && buttons[EDITOR_3D]->is_visible()) {
// If the 3D editor is enabled, use this as the default.
select(EDITOR_3D);
return;
}
// Switch to the first main screen plugin that is enabled. Usually this is
// 2D, but may be subsequent ones if 2D is disabled in the feature profile.
for (int i = 0; i < buttons.size(); i++) {
Button *editor_button = buttons[i];
if (editor_button->is_visible()) {
select(i);
return;
}
}
select(-1);
} break;
case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < buttons.size(); i++) {
Button *tb = buttons[i];
EditorPlugin *p_editor = editor_table[i];
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_valid()) {
tb->set_icon(icon);
} else if (has_theme_icon(p_editor->get_name(), EditorStringName(EditorIcons))) {
tb->set_icon(get_theme_icon(p_editor->get_name(), EditorStringName(EditorIcons)));
}
}
} break;
}
}
void EditorMainScreen::set_button_container(HBoxContainer *p_button_hb) {
button_hb = p_button_hb;
}
void EditorMainScreen::save_layout_to_config(Ref<ConfigFile> p_config_file, const String &p_section) const {
int selected_main_editor_idx = -1;
for (int i = 0; i < buttons.size(); i++) {
if (buttons[i]->is_pressed()) {
selected_main_editor_idx = i;
break;
}
}
if (selected_main_editor_idx != -1) {
p_config_file->set_value(p_section, "selected_main_editor_idx", selected_main_editor_idx);
} else {
p_config_file->set_value(p_section, "selected_main_editor_idx", Variant());
}
}
void EditorMainScreen::load_layout_from_config(Ref<ConfigFile> p_config_file, const String &p_section) {
int selected_main_editor_idx = p_config_file->get_value(p_section, "selected_main_editor_idx", -1);
if (selected_main_editor_idx >= 0 && selected_main_editor_idx < buttons.size()) {
callable_mp(this, &EditorMainScreen::select).call_deferred(selected_main_editor_idx);
}
}
void EditorMainScreen::set_button_enabled(int p_index, bool p_enabled) {
ERR_FAIL_INDEX(p_index, buttons.size());
buttons[p_index]->set_visible(p_enabled);
if (!p_enabled && buttons[p_index]->is_pressed()) {
select(EDITOR_2D);
}
}
bool EditorMainScreen::is_button_enabled(int p_index) const {
ERR_FAIL_INDEX_V(p_index, buttons.size(), false);
return buttons[p_index]->is_visible();
}
int EditorMainScreen::_get_current_main_editor() const {
for (int i = 0; i < editor_table.size(); i++) {
if (editor_table[i] == selected_plugin) {
return i;
}
}
return 0;
}
void EditorMainScreen::select_next() {
int editor = _get_current_main_editor();
do {
if (editor == editor_table.size() - 1) {
editor = 0;
} else {
editor++;
}
} while (!buttons[editor]->is_visible());
select(editor);
}
void EditorMainScreen::select_prev() {
int editor = _get_current_main_editor();
do {
if (editor == 0) {
editor = editor_table.size() - 1;
} else {
editor--;
}
} while (!buttons[editor]->is_visible());
select(editor);
}
void EditorMainScreen::select_by_name(const String &p_name) {
ERR_FAIL_COND(p_name.is_empty());
for (int i = 0; i < buttons.size(); i++) {
if (buttons[i]->get_text() == p_name) {
select(i);
return;
}
}
ERR_FAIL_MSG("The editor name '" + p_name + "' was not found.");
}
void EditorMainScreen::select(int p_index) {
if (EditorNode::get_singleton()->is_changing_scene()) {
return;
}
ERR_FAIL_INDEX(p_index, editor_table.size());
if (!buttons[p_index]->is_visible()) { // Button hidden, no editor.
return;
}
for (int i = 0; i < buttons.size(); i++) {
buttons[i]->set_pressed_no_signal(i == p_index);
}
EditorPlugin *new_editor = editor_table[p_index];
ERR_FAIL_NULL(new_editor);
if (selected_plugin == new_editor) {
return;
}
if (selected_plugin) {
selected_plugin->make_visible(false);
}
selected_plugin = new_editor;
selected_plugin->make_visible(true);
selected_plugin->selected_notify();
EditorData &editor_data = EditorNode::get_editor_data();
int plugin_count = editor_data.get_editor_plugin_count();
for (int i = 0; i < plugin_count; i++) {
editor_data.get_editor_plugin(i)->notify_main_screen_changed(selected_plugin->get_name());
}
EditorNode::get_singleton()->update_distraction_free_mode();
}
int EditorMainScreen::get_selected_index() const {
for (int i = 0; i < editor_table.size(); i++) {
if (selected_plugin == editor_table[i]) {
return i;
}
}
return -1;
}
int EditorMainScreen::get_plugin_index(EditorPlugin *p_editor) const {
int screen = -1;
for (int i = 0; i < editor_table.size(); i++) {
if (p_editor == editor_table[i]) {
screen = i;
break;
}
}
return screen;
}
EditorPlugin *EditorMainScreen::get_selected_plugin() const {
return selected_plugin;
}
VBoxContainer *EditorMainScreen::get_control() const {
return main_screen_vbox;
}
void EditorMainScreen::add_main_plugin(EditorPlugin *p_editor) {
Button *tb = memnew(Button);
tb->set_toggle_mode(true);
tb->set_theme_type_variation("MainScreenButton");
tb->set_name(p_editor->get_name());
tb->set_text(p_editor->get_name());
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_null() && has_theme_icon(p_editor->get_name(), EditorStringName(EditorIcons))) {
icon = get_editor_theme_icon(p_editor->get_name());
}
if (icon.is_valid()) {
tb->set_icon(icon);
// Make sure the control is updated if the icon is reimported.
icon->connect_changed(callable_mp((Control *)tb, &Control::update_minimum_size));
}
tb->connect(SceneStringName(pressed), callable_mp(this, &EditorMainScreen::select).bind(buttons.size()));
buttons.push_back(tb);
button_hb->add_child(tb);
editor_table.push_back(p_editor);
}
void EditorMainScreen::remove_main_plugin(EditorPlugin *p_editor) {
// Remove the main editor button and update the bindings of
// all buttons behind it to point to the correct main window.
for (int i = buttons.size() - 1; i >= 0; i--) {
if (p_editor->get_name() == buttons[i]->get_text()) {
if (buttons[i]->is_pressed()) {
select(EDITOR_SCRIPT);
}
memdelete(buttons[i]);
buttons.remove_at(i);
break;
} else {
buttons[i]->disconnect(SceneStringName(pressed), callable_mp(this, &EditorMainScreen::select));
buttons[i]->connect(SceneStringName(pressed), callable_mp(this, &EditorMainScreen::select).bind(i - 1));
}
}
if (selected_plugin == p_editor) {
selected_plugin = nullptr;
}
editor_table.erase(p_editor);
}
EditorMainScreen::EditorMainScreen() {
main_screen_vbox = memnew(VBoxContainer);
main_screen_vbox->set_name("MainScreen");
main_screen_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_screen_vbox->add_theme_constant_override("separation", 0);
add_child(main_screen_vbox);
}

View File

@ -0,0 +1,91 @@
/**************************************************************************/
/* editor_main_screen.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef EDITOR_MAIN_SCREEN_H
#define EDITOR_MAIN_SCREEN_H
#include "scene/gui/panel_container.h"
class Button;
class ConfigFile;
class EditorPlugin;
class HBoxContainer;
class VBoxContainer;
class EditorMainScreen : public PanelContainer {
GDCLASS(EditorMainScreen, PanelContainer);
public:
enum EditorTable {
EDITOR_2D = 0,
EDITOR_3D,
EDITOR_SCRIPT,
EDITOR_ASSETLIB,
};
private:
VBoxContainer *main_screen_vbox = nullptr;
EditorPlugin *selected_plugin = nullptr;
HBoxContainer *button_hb = nullptr;
Vector<Button *> buttons;
Vector<EditorPlugin *> editor_table;
int _get_current_main_editor() const;
protected:
void _notification(int p_what);
public:
void set_button_container(HBoxContainer *p_button_hb);
void save_layout_to_config(Ref<ConfigFile> p_config_file, const String &p_section) const;
void load_layout_from_config(Ref<ConfigFile> p_config_file, const String &p_section);
void set_button_enabled(int p_index, bool p_enabled);
bool is_button_enabled(int p_index) const;
void select_next();
void select_prev();
void select_by_name(const String &p_name);
void select(int p_index);
int get_selected_index() const;
int get_plugin_index(EditorPlugin *p_editor) const;
EditorPlugin *get_selected_plugin() const;
VBoxContainer *get_control() const;
void add_main_plugin(EditorPlugin *p_editor);
void remove_main_plugin(EditorPlugin *p_editor);
EditorMainScreen();
};
#endif // EDITOR_MAIN_SCREEN_H

View File

@ -88,6 +88,7 @@
#include "editor/editor_interface.h" #include "editor/editor_interface.h"
#include "editor/editor_layouts_dialog.h" #include "editor/editor_layouts_dialog.h"
#include "editor/editor_log.h" #include "editor/editor_log.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_native_shader_source_visualizer.h" #include "editor/editor_native_shader_source_visualizer.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_properties.h" #include "editor/editor_properties.h"
@ -348,19 +349,19 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) {
if (ED_IS_SHORTCUT("editor/filter_files", p_event)) { if (ED_IS_SHORTCUT("editor/filter_files", p_event)) {
FileSystemDock::get_singleton()->focus_on_filter(); FileSystemDock::get_singleton()->focus_on_filter();
} else if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
editor_select(EDITOR_2D); editor_main_screen->select(EditorMainScreen::EDITOR_2D);
} else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
editor_select(EDITOR_3D); editor_main_screen->select(EditorMainScreen::EDITOR_3D);
} else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
editor_select(EDITOR_SCRIPT); editor_main_screen->select(EditorMainScreen::EDITOR_SCRIPT);
} else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
emit_signal(SNAME("request_help_search"), ""); emit_signal(SNAME("request_help_search"), "");
} else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && AssetLibraryEditorPlugin::is_available()) { } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && AssetLibraryEditorPlugin::is_available()) {
editor_select(EDITOR_ASSETLIB); editor_main_screen->select(EditorMainScreen::EDITOR_ASSETLIB);
} else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
_editor_select_next(); editor_main_screen->select_next();
} else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) { } else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) {
_editor_select_prev(); editor_main_screen->select_prev();
} else if (ED_IS_SHORTCUT("editor/command_palette", p_event)) { } else if (ED_IS_SHORTCUT("editor/command_palette", p_event)) {
_open_command_palette(); _open_command_palette();
} else if (ED_IS_SHORTCUT("editor/toggle_last_opened_bottom_panel", p_event)) { } else if (ED_IS_SHORTCUT("editor/toggle_last_opened_bottom_panel", p_event)) {
@ -489,26 +490,6 @@ void EditorNode::_gdextensions_reloaded() {
EditorHelp::generate_doc(); EditorHelp::generate_doc();
} }
void EditorNode::_select_default_main_screen_plugin() {
if (EDITOR_3D < main_editor_buttons.size() && main_editor_buttons[EDITOR_3D]->is_visible()) {
// If the 3D editor is enabled, use this as the default.
editor_select(EDITOR_3D);
return;
}
// Switch to the first main screen plugin that is enabled. Usually this is
// 2D, but may be subsequent ones if 2D is disabled in the feature profile.
for (int i = 0; i < main_editor_buttons.size(); i++) {
Button *editor_button = main_editor_buttons[i];
if (editor_button->is_visible()) {
editor_select(i);
return;
}
}
editor_select(-1);
}
void EditorNode::_update_theme(bool p_skip_creation) { void EditorNode::_update_theme(bool p_skip_creation) {
if (!p_skip_creation) { if (!p_skip_creation) {
theme = EditorThemeManager::generate_theme(theme); theme = EditorThemeManager::generate_theme(theme);
@ -546,7 +527,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, theme->get_constant(SNAME("window_border_margin"), EditorStringName(Editor))); main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, theme->get_constant(SNAME("window_border_margin"), EditorStringName(Editor)));
main_vbox->add_theme_constant_override("separation", theme->get_constant(SNAME("top_bar_separation"), EditorStringName(Editor))); main_vbox->add_theme_constant_override("separation", theme->get_constant(SNAME("top_bar_separation"), EditorStringName(Editor)));
scene_root_parent->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles))); editor_main_screen->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles)));
bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))); bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles)));
distraction_free->set_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons))); distraction_free->set_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons)));
distraction_free->add_theme_style_override(SceneStringName(pressed), theme->get_stylebox(CoreStringName(normal), "FlatMenuButton")); distraction_free->add_theme_style_override(SceneStringName(pressed), theme->get_stylebox(CoreStringName(normal), "FlatMenuButton"));
@ -560,18 +541,6 @@ void EditorNode::_update_theme(bool p_skip_creation) {
bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))); bottom_panel->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles)));
} }
for (int i = 0; i < main_editor_buttons.size(); i++) {
Button *tb = main_editor_buttons[i];
EditorPlugin *p_editor = editor_table[i];
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_valid()) {
tb->set_icon(icon);
} else if (theme->has_icon(p_editor->get_name(), EditorStringName(EditorIcons))) {
tb->set_icon(theme->get_icon(p_editor->get_name(), EditorStringName(EditorIcons)));
}
}
_update_renderer_color(); _update_renderer_color();
} }
@ -748,8 +717,6 @@ void EditorNode::_notification(int p_what) {
feature_profile_manager->notify_changed(); feature_profile_manager->notify_changed();
_select_default_main_screen_plugin();
// Save the project after opening to mark it as last modified, except in headless mode. // Save the project after opening to mark it as last modified, except in headless mode.
if (DisplayServer::get_singleton()->window_can_draw()) { if (DisplayServer::get_singleton()->window_can_draw()) {
ProjectSettings::get_singleton()->save(); ProjectSettings::get_singleton()->save();
@ -1293,38 +1260,10 @@ void EditorNode::_node_renamed() {
} }
} }
void EditorNode::_editor_select_next() {
int editor = _get_current_main_editor();
do {
if (editor == editor_table.size() - 1) {
editor = 0;
} else {
editor++;
}
} while (!main_editor_buttons[editor]->is_visible());
editor_select(editor);
}
void EditorNode::_open_command_palette() { void EditorNode::_open_command_palette() {
command_palette->open_popup(); command_palette->open_popup();
} }
void EditorNode::_editor_select_prev() {
int editor = _get_current_main_editor();
do {
if (editor == 0) {
editor = editor_table.size() - 1;
} else {
editor--;
}
} while (!main_editor_buttons[editor]->is_visible());
editor_select(editor);
}
Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) { Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) {
dependency_errors.clear(); dependency_errors.clear();
@ -2645,16 +2584,11 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
if (!inspector_only) { if (!inspector_only) {
EditorPlugin *main_plugin = editor_data.get_handling_main_editor(current_obj); EditorPlugin *main_plugin = editor_data.get_handling_main_editor(current_obj);
int plugin_index = 0; int plugin_index = editor_main_screen->get_plugin_index(main_plugin);
for (; plugin_index < editor_table.size(); plugin_index++) { if (main_plugin && plugin_index >= 0 && !editor_main_screen->is_button_enabled(plugin_index)) {
if (editor_table[plugin_index] == main_plugin) { main_plugin = nullptr;
if (!main_editor_buttons[plugin_index]->is_visible()) {
main_plugin = nullptr; // If button is not visible, then no plugin is active.
}
break;
}
} }
EditorPlugin *editor_plugin_screen = editor_main_screen->get_selected_plugin();
ObjectID editor_owner_id = editor_owner->get_instance_id(); ObjectID editor_owner_id = editor_owner->get_instance_id();
if (main_plugin && !skip_main_plugin) { if (main_plugin && !skip_main_plugin) {
@ -2671,7 +2605,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
editor_plugin_screen->edit(nullptr); editor_plugin_screen->edit(nullptr);
active_plugins[editor_owner_id].erase(editor_plugin_screen); active_plugins[editor_owner_id].erase(editor_plugin_screen);
// Update screen main_plugin. // Update screen main_plugin.
editor_select(plugin_index); editor_main_screen->select(plugin_index);
main_plugin->edit(current_obj); main_plugin->edit(current_obj);
} else { } else {
editor_plugin_screen->edit(current_obj); editor_plugin_screen->edit(current_obj);
@ -3294,9 +3228,9 @@ void EditorNode::_screenshot(bool p_use_utc) {
} }
void EditorNode::_save_screenshot(NodePath p_path) { void EditorNode::_save_screenshot(NodePath p_path) {
Control *editor_main_screen = EditorInterface::get_singleton()->get_editor_main_screen(); Control *main_screen_control = editor_main_screen->get_control();
ERR_FAIL_NULL_MSG(editor_main_screen, "Cannot get the editor main screen control."); ERR_FAIL_NULL_MSG(main_screen_control, "Cannot get the editor main screen control.");
Viewport *viewport = editor_main_screen->get_viewport(); Viewport *viewport = main_screen_control->get_viewport();
ERR_FAIL_NULL_MSG(viewport, "Cannot get a viewport from the editor main screen."); ERR_FAIL_NULL_MSG(viewport, "Cannot get a viewport from the editor main screen.");
Ref<ViewportTexture> texture = viewport->get_texture(); Ref<ViewportTexture> texture = viewport->get_texture();
ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get a viewport texture from the editor main screen."); ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get a viewport texture from the editor main screen.");
@ -3501,97 +3435,9 @@ void EditorNode::_update_file_menu_closed() {
file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false); file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false);
} }
VBoxContainer *EditorNode::get_main_screen_control() {
return main_screen_vbox;
}
void EditorNode::editor_select(int p_which) {
static bool selecting = false;
if (selecting || changing_scene) {
return;
}
ERR_FAIL_INDEX(p_which, editor_table.size());
if (!main_editor_buttons[p_which]->is_visible()) { // Button hidden, no editor.
return;
}
selecting = true;
for (int i = 0; i < main_editor_buttons.size(); i++) {
main_editor_buttons[i]->set_pressed(i == p_which);
}
selecting = false;
EditorPlugin *new_editor = editor_table[p_which];
ERR_FAIL_NULL(new_editor);
if (editor_plugin_screen == new_editor) {
return;
}
if (editor_plugin_screen) {
editor_plugin_screen->make_visible(false);
}
editor_plugin_screen = new_editor;
editor_plugin_screen->make_visible(true);
editor_plugin_screen->selected_notify();
int plugin_count = editor_data.get_editor_plugin_count();
for (int i = 0; i < plugin_count; i++) {
editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name());
}
if (EDITOR_GET("interface/editor/separate_distraction_mode")) {
if (p_which == EDITOR_SCRIPT) {
set_distraction_free_mode(script_distraction_free);
} else {
set_distraction_free_mode(scene_distraction_free);
}
}
}
void EditorNode::select_editor_by_name(const String &p_name) {
ERR_FAIL_COND(p_name.is_empty());
for (int i = 0; i < main_editor_buttons.size(); i++) {
if (main_editor_buttons[i]->get_text() == p_name) {
editor_select(i);
return;
}
}
ERR_FAIL_MSG("The editor name '" + p_name + "' was not found.");
}
void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) { if (p_editor->has_main_screen()) {
Button *tb = memnew(Button); singleton->editor_main_screen->add_main_plugin(p_editor);
tb->set_toggle_mode(true);
tb->set_theme_type_variation("MainScreenButton");
tb->set_name(p_editor->get_name());
tb->set_text(p_editor->get_name());
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_null() && singleton->theme->has_icon(p_editor->get_name(), EditorStringName(EditorIcons))) {
icon = singleton->theme->get_icon(p_editor->get_name(), EditorStringName(EditorIcons));
}
if (icon.is_valid()) {
tb->set_icon(icon);
// Make sure the control is updated if the icon is reimported.
icon->connect_changed(callable_mp((Control *)tb, &Control::update_minimum_size));
}
tb->connect(SceneStringName(pressed), callable_mp(singleton, &EditorNode::editor_select).bind(singleton->main_editor_buttons.size()));
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_hb->add_child(tb);
singleton->editor_table.push_back(p_editor);
singleton->distraction_free->move_to_front();
} }
singleton->editor_data.add_editor_plugin(p_editor); singleton->editor_data.add_editor_plugin(p_editor);
singleton->add_child(p_editor); singleton->add_child(p_editor);
@ -3602,29 +3448,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) { if (p_editor->has_main_screen()) {
// Remove the main editor button and update the bindings of singleton->editor_main_screen->remove_main_plugin(p_editor);
// all buttons behind it to point to the correct main window.
for (int i = singleton->main_editor_buttons.size() - 1; i >= 0; i--) {
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->editor_select(EDITOR_SCRIPT);
}
memdelete(singleton->main_editor_buttons[i]);
singleton->main_editor_buttons.remove_at(i);
break;
} else {
singleton->main_editor_buttons[i]->disconnect(SceneStringName(pressed), callable_mp(singleton, &EditorNode::editor_select));
singleton->main_editor_buttons[i]->connect(SceneStringName(pressed), callable_mp(singleton, &EditorNode::editor_select).bind(i - 1));
}
}
if (singleton->editor_plugin_screen == p_editor) {
singleton->editor_plugin_screen = nullptr;
}
singleton->editor_table.erase(p_editor);
} }
p_editor->make_visible(false); p_editor->make_visible(false);
p_editor->clear(); p_editor->clear();
@ -3848,19 +3672,8 @@ void EditorNode::set_edited_scene_root(Node *p_scene, bool p_auto_add) {
} }
} }
int EditorNode::_get_current_main_editor() {
for (int i = 0; i < editor_table.size(); i++) {
if (editor_table[i] == editor_plugin_screen) {
return i;
}
}
return 0;
}
Dictionary EditorNode::_get_main_scene_state() { Dictionary EditorNode::_get_main_scene_state() {
Dictionary state; Dictionary state;
state["main_tab"] = _get_current_main_editor();
state["scene_tree_offset"] = SceneTreeDock::get_singleton()->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value(); state["scene_tree_offset"] = SceneTreeDock::get_singleton()->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
state["property_edit_offset"] = InspectorDock::get_inspector_singleton()->get_scroll_offset(); state["property_edit_offset"] = InspectorDock::get_inspector_singleton()->get_scroll_offset();
state["node_filter"] = SceneTreeDock::get_singleton()->get_filter(); state["node_filter"] = SceneTreeDock::get_singleton()->get_filter();
@ -3874,32 +3687,19 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
changing_scene = false; changing_scene = false;
int current_tab = -1;
for (int i = 0; i < editor_table.size(); i++) {
if (editor_plugin_screen == editor_table[i]) {
current_tab = i;
break;
}
}
if (p_state.has("editor_index")) {
int index = p_state["editor_index"];
if (current_tab < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
if (index < 2 || !get_edited_scene()) {
editor_select(index);
}
}
}
if (get_edited_scene()) { if (get_edited_scene()) {
int current_tab = editor_main_screen->get_selected_index();
if (current_tab < 2) { if (current_tab < 2) {
Node *editor_node = SceneTreeDock::get_singleton()->get_tree_editor()->get_selected(); // Switch between 2D and 3D if currently in 2D or 3D.
editor_node = editor_node == nullptr ? get_edited_scene() : editor_node; Node *selected_node = SceneTreeDock::get_singleton()->get_tree_editor()->get_selected();
if (!selected_node) {
selected_node = get_edited_scene();
}
if (Object::cast_to<CanvasItem>(editor_node)) { if (Object::cast_to<CanvasItem>(selected_node)) {
editor_select(EDITOR_2D); editor_main_screen->select(EditorMainScreen::EDITOR_2D);
} else if (Object::cast_to<Node3D>(editor_node)) { } else if (Object::cast_to<Node3D>(selected_node)) {
editor_select(EDITOR_3D); editor_main_screen->select(EditorMainScreen::EDITOR_3D);
} }
} }
} }
@ -5357,18 +5157,7 @@ void EditorNode::_save_central_editor_layout_to_config(Ref<ConfigFile> p_config_
// Main editor (plugin). // Main editor (plugin).
int selected_main_editor_idx = -1; editor_main_screen->save_layout_to_config(p_config_file, EDITOR_NODE_CONFIG_SECTION);
for (int i = 0; i < main_editor_buttons.size(); i++) {
if (main_editor_buttons[i]->is_pressed()) {
selected_main_editor_idx = i;
break;
}
}
if (selected_main_editor_idx != -1) {
p_config_file->set_value(EDITOR_NODE_CONFIG_SECTION, "selected_main_editor_idx", selected_main_editor_idx);
} else {
p_config_file->set_value(EDITOR_NODE_CONFIG_SECTION, "selected_main_editor_idx", Variant());
}
} }
void EditorNode::_load_central_editor_layout_from_config(Ref<ConfigFile> p_config_file) { void EditorNode::_load_central_editor_layout_from_config(Ref<ConfigFile> p_config_file) {
@ -5390,12 +5179,7 @@ void EditorNode::_load_central_editor_layout_from_config(Ref<ConfigFile> p_confi
// Main editor (plugin). // Main editor (plugin).
if (p_config_file->has_section_key(EDITOR_NODE_CONFIG_SECTION, "selected_main_editor_idx")) { editor_main_screen->load_layout_from_config(p_config_file, EDITOR_NODE_CONFIG_SECTION);
int selected_main_editor_idx = p_config_file->get_value(EDITOR_NODE_CONFIG_SECTION, "selected_main_editor_idx");
if (selected_main_editor_idx >= 0 && selected_main_editor_idx < main_editor_buttons.size()) {
callable_mp(this, &EditorNode::editor_select).call_deferred(selected_main_editor_idx);
}
}
} }
void EditorNode::_save_window_settings_to_config(Ref<ConfigFile> p_layout, const String &p_section) { void EditorNode::_save_window_settings_to_config(Ref<ConfigFile> p_layout, const String &p_section) {
@ -5716,15 +5500,9 @@ void EditorNode::_cancel_close_scene_tab() {
void EditorNode::_toggle_distraction_free_mode() { void EditorNode::_toggle_distraction_free_mode() {
if (EDITOR_GET("interface/editor/separate_distraction_mode")) { if (EDITOR_GET("interface/editor/separate_distraction_mode")) {
int screen = -1; int screen = editor_main_screen->get_selected_index();
for (int i = 0; i < editor_table.size(); i++) {
if (editor_plugin_screen == editor_table[i]) {
screen = i;
break;
}
}
if (screen == EDITOR_SCRIPT) { if (screen == EditorMainScreen::EDITOR_SCRIPT) {
script_distraction_free = !script_distraction_free; script_distraction_free = !script_distraction_free;
set_distraction_free_mode(script_distraction_free); set_distraction_free_mode(script_distraction_free);
} else { } else {
@ -5736,6 +5514,18 @@ void EditorNode::_toggle_distraction_free_mode() {
} }
} }
void EditorNode::update_distraction_free_mode() {
if (!EDITOR_GET("interface/editor/separate_distraction_mode")) {
return;
}
int screen = editor_main_screen->get_selected_index();
if (screen == EditorMainScreen::EDITOR_SCRIPT) {
set_distraction_free_mode(script_distraction_free);
} else {
set_distraction_free_mode(scene_distraction_free);
}
}
void EditorNode::set_distraction_free_mode(bool p_enter) { void EditorNode::set_distraction_free_mode(bool p_enter) {
distraction_free->set_pressed(p_enter); distraction_free->set_pressed(p_enter);
@ -6625,25 +6415,20 @@ void EditorNode::_feature_profile_changed() {
editor_dock_manager->set_dock_enabled(ImportDock::get_singleton(), !fs_dock_disabled && !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_IMPORT_DOCK)); editor_dock_manager->set_dock_enabled(ImportDock::get_singleton(), !fs_dock_disabled && !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_IMPORT_DOCK));
editor_dock_manager->set_dock_enabled(history_dock, !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_HISTORY_DOCK)); editor_dock_manager->set_dock_enabled(history_dock, !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_HISTORY_DOCK));
main_editor_buttons[EDITOR_3D]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_3D, !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D));
main_editor_buttons[EDITOR_SCRIPT]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT)); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_SCRIPT, !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT));
if (AssetLibraryEditorPlugin::is_available()) { if (AssetLibraryEditorPlugin::is_available()) {
main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_ASSETLIB, !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB));
}
if ((profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) && singleton->main_editor_buttons[EDITOR_3D]->is_pressed()) ||
(profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) && singleton->main_editor_buttons[EDITOR_SCRIPT]->is_pressed()) ||
(AssetLibraryEditorPlugin::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) {
editor_select(EDITOR_2D);
} }
} else { } else {
editor_dock_manager->set_dock_enabled(ImportDock::get_singleton(), true); editor_dock_manager->set_dock_enabled(ImportDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(NodeDock::get_singleton(), true); editor_dock_manager->set_dock_enabled(NodeDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(FileSystemDock::get_singleton(), true); editor_dock_manager->set_dock_enabled(FileSystemDock::get_singleton(), true);
editor_dock_manager->set_dock_enabled(history_dock, true); editor_dock_manager->set_dock_enabled(history_dock, true);
main_editor_buttons[EDITOR_3D]->set_visible(true); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_3D, true);
main_editor_buttons[EDITOR_SCRIPT]->set_visible(true); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_SCRIPT, true);
if (AssetLibraryEditorPlugin::is_available()) { if (AssetLibraryEditorPlugin::is_available()) {
main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true); editor_main_screen->set_button_enabled(EditorMainScreen::EDITOR_ASSETLIB, true);
} }
} }
} }
@ -7178,12 +6963,11 @@ EditorNode::EditorNode() {
scene_tabs->add_extra_button(distraction_free); scene_tabs->add_extra_button(distraction_free);
distraction_free->connect(SceneStringName(pressed), callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); distraction_free->connect(SceneStringName(pressed), callable_mp(this, &EditorNode::_toggle_distraction_free_mode));
scene_root_parent = memnew(PanelContainer); editor_main_screen = memnew(EditorMainScreen);
scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); editor_main_screen->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
scene_root_parent->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles))); editor_main_screen->set_draw_behind_parent(true);
scene_root_parent->set_draw_behind_parent(true); srt->add_child(editor_main_screen);
srt->add_child(scene_root_parent); editor_main_screen->set_v_size_flags(Control::SIZE_EXPAND_FILL);
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
scene_root = memnew(SubViewport); scene_root = memnew(SubViewport);
scene_root->set_embedding_subwindows(true); scene_root->set_embedding_subwindows(true);
@ -7191,12 +6975,6 @@ EditorNode::EditorNode() {
scene_root->set_disable_input(true); scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true); scene_root->set_as_audio_listener_2d(true);
main_screen_vbox = memnew(VBoxContainer);
main_screen_vbox->set_name("MainScreen");
main_screen_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_screen_vbox->add_theme_constant_override("separation", 0);
scene_root_parent->add_child(main_screen_vbox);
bool global_menu = !bool(EDITOR_GET("interface/editor/use_embedded_menu")) && NativeMenu::get_singleton()->has_feature(NativeMenu::FEATURE_GLOBAL_MENU); bool global_menu = !bool(EDITOR_GET("interface/editor/use_embedded_menu")) && NativeMenu::get_singleton()->has_feature(NativeMenu::FEATURE_GLOBAL_MENU);
bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE); bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE);
@ -7390,8 +7168,9 @@ EditorNode::EditorNode() {
left_spacer->add_child(project_title); left_spacer->add_child(project_title);
} }
main_editor_button_hb = memnew(HBoxContainer); HBoxContainer *main_editor_button_hb = memnew(HBoxContainer);
main_editor_button_hb->set_mouse_filter(Control::MOUSE_FILTER_STOP); main_editor_button_hb->set_mouse_filter(Control::MOUSE_FILTER_STOP);
editor_main_screen->set_button_container(main_editor_button_hb);
title_bar->add_child(main_editor_button_hb); title_bar->add_child(main_editor_button_hb);
// Options are added and handled by DebuggerEditorPlugin. // Options are added and handled by DebuggerEditorPlugin.
@ -7864,7 +7643,6 @@ EditorNode::EditorNode() {
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec(); update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn(); update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn();
editor_plugin_screen = nullptr;
editor_plugins_over = memnew(EditorPluginList); editor_plugins_over = memnew(EditorPluginList);
editor_plugins_force_over = memnew(EditorPluginList); editor_plugins_force_over = memnew(EditorPluginList);
editor_plugins_force_input_forwarding = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList);

View File

@ -42,27 +42,17 @@ typedef void (*EditorPluginInitializeCallback)();
typedef bool (*EditorBuildCallback)(); typedef bool (*EditorBuildCallback)();
class AcceptDialog; class AcceptDialog;
class CenterContainer;
class CheckBox;
class ColorPicker; class ColorPicker;
class ConfirmationDialog; class ConfirmationDialog;
class Control; class Control;
class FileDialog; class FileDialog;
class HBoxContainer;
class HSplitContainer;
class LinkButton;
class MenuBar; class MenuBar;
class MenuButton; class MenuButton;
class Node2D;
class OptionButton; class OptionButton;
class Panel; class Panel;
class PanelContainer; class PanelContainer;
class PopupPanel;
class RichTextLabel; class RichTextLabel;
class SubViewport; class SubViewport;
class TabBar;
class TabContainer;
class TextureRect;
class TextureProgressBar; class TextureProgressBar;
class Tree; class Tree;
class VBoxContainer; class VBoxContainer;
@ -83,44 +73,33 @@ class EditorCommandPalette;
class EditorDockManager; class EditorDockManager;
class EditorExport; class EditorExport;
class EditorExportPreset; class EditorExportPreset;
class EditorExtensionManager;
class EditorFeatureProfileManager; class EditorFeatureProfileManager;
class EditorFileDialog; class EditorFileDialog;
class EditorFolding; class EditorFolding;
class EditorInspector;
class EditorLayoutsDialog; class EditorLayoutsDialog;
class EditorLog; class EditorLog;
class EditorMainScreen;
class EditorNativeShaderSourceVisualizer; class EditorNativeShaderSourceVisualizer;
class EditorPluginList; class EditorPluginList;
class EditorQuickOpen; class EditorQuickOpen;
class EditorPropertyResource;
class EditorResourcePreview; class EditorResourcePreview;
class EditorResourceConversionPlugin; class EditorResourceConversionPlugin;
class EditorRunBar; class EditorRunBar;
class EditorRunNative;
class EditorSceneTabs; class EditorSceneTabs;
class EditorSelectionHistory; class EditorSelectionHistory;
class EditorSettingsDialog; class EditorSettingsDialog;
class EditorTitleBar; class EditorTitleBar;
class EditorToaster;
class EditorUndoRedoManager;
class ExportTemplateManager; class ExportTemplateManager;
class FBXImporterManager; class FBXImporterManager;
class FileSystemDock; class FileSystemDock;
class HistoryDock; class HistoryDock;
class ImportDock;
class NodeDock;
class OrphanResourcesDialog; class OrphanResourcesDialog;
class PluginConfigDialog;
class ProgressDialog; class ProgressDialog;
class ProjectExportDialog; class ProjectExportDialog;
class ProjectSettingsEditor; class ProjectSettingsEditor;
class RunSettingsDialog;
class SceneImportSettingsDialog; class SceneImportSettingsDialog;
class ScriptCreateDialog;
class SurfaceUpgradeTool; class SurfaceUpgradeTool;
class SurfaceUpgradeDialog; class SurfaceUpgradeDialog;
class WindowWrapper;
struct EditorProgress { struct EditorProgress {
String task; String task;
@ -135,13 +114,6 @@ class EditorNode : public Node {
GDCLASS(EditorNode, Node); GDCLASS(EditorNode, Node);
public: public:
enum EditorTable {
EDITOR_2D = 0,
EDITOR_3D,
EDITOR_SCRIPT,
EDITOR_ASSETLIB
};
enum SceneNameCasing { enum SceneNameCasing {
SCENE_NAME_CASING_AUTO, SCENE_NAME_CASING_AUTO,
SCENE_NAME_CASING_PASCAL_CASE, SCENE_NAME_CASING_PASCAL_CASE,
@ -286,7 +258,6 @@ private:
EditorExport *editor_export = nullptr; EditorExport *editor_export = nullptr;
EditorLog *log = nullptr; EditorLog *log = nullptr;
EditorNativeShaderSourceVisualizer *native_shader_source_visualizer = nullptr; EditorNativeShaderSourceVisualizer *native_shader_source_visualizer = nullptr;
EditorPlugin *editor_plugin_screen = nullptr;
EditorPluginList *editor_plugins_force_input_forwarding = nullptr; EditorPluginList *editor_plugins_force_input_forwarding = nullptr;
EditorPluginList *editor_plugins_force_over = nullptr; EditorPluginList *editor_plugins_force_over = nullptr;
EditorPluginList *editor_plugins_over = nullptr; EditorPluginList *editor_plugins_over = nullptr;
@ -308,7 +279,6 @@ private:
HashMap<ObjectID, HashSet<EditorPlugin *>> active_plugins; HashMap<ObjectID, HashSet<EditorPlugin *>> active_plugins;
bool is_main_screen_editing = false; bool is_main_screen_editing = false;
PanelContainer *scene_root_parent = nullptr;
Control *gui_base = nullptr; Control *gui_base = nullptr;
VBoxContainer *main_vbox = nullptr; VBoxContainer *main_vbox = nullptr;
OptionButton *renderer = nullptr; OptionButton *renderer = nullptr;
@ -349,7 +319,6 @@ private:
Control *right_menu_spacer = nullptr; Control *right_menu_spacer = nullptr;
EditorTitleBar *title_bar = nullptr; EditorTitleBar *title_bar = nullptr;
EditorRunBar *project_run_bar = nullptr; EditorRunBar *project_run_bar = nullptr;
VBoxContainer *main_screen_vbox = nullptr;
MenuBar *main_menu = nullptr; MenuBar *main_menu = nullptr;
PopupMenu *apple_menu = nullptr; PopupMenu *apple_menu = nullptr;
PopupMenu *file_menu = nullptr; PopupMenu *file_menu = nullptr;
@ -423,9 +392,7 @@ private:
String current_path; String current_path;
MenuButton *update_spinner = nullptr; MenuButton *update_spinner = nullptr;
HBoxContainer *main_editor_button_hb = nullptr; EditorMainScreen *editor_main_screen = nullptr;
Vector<Button *> main_editor_buttons;
Vector<EditorPlugin *> editor_table;
AudioStreamPreviewGenerator *audio_preview_gen = nullptr; AudioStreamPreviewGenerator *audio_preview_gen = nullptr;
ProgressDialog *progress_dialog = nullptr; ProgressDialog *progress_dialog = nullptr;
@ -575,8 +542,6 @@ private:
void _sources_changed(bool p_exist); void _sources_changed(bool p_exist);
void _node_renamed(); void _node_renamed();
void _editor_select_next();
void _editor_select_prev();
void _save_editor_states(const String &p_file, int p_idx = -1); void _save_editor_states(const String &p_file, int p_idx = -1);
void _load_editor_plugin_states_from_config(const Ref<ConfigFile> &p_config_file); void _load_editor_plugin_states_from_config(const Ref<ConfigFile> &p_config_file);
void _update_title(); void _update_title();
@ -649,8 +614,6 @@ private:
Dictionary _get_main_scene_state(); Dictionary _get_main_scene_state();
void _set_main_scene_state(Dictionary p_state, Node *p_for_scene); void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
int _get_current_main_editor();
void _save_editor_layout(); void _save_editor_layout();
void _load_editor_layout(); void _load_editor_layout();
@ -688,7 +651,6 @@ private:
void _pick_main_scene_custom_action(const String &p_custom_action_name); void _pick_main_scene_custom_action(const String &p_custom_action_name);
void _immediate_dialog_confirmed(); void _immediate_dialog_confirmed();
void _select_default_main_screen_plugin();
void _begin_first_scan(); void _begin_first_scan();
@ -707,9 +669,6 @@ public:
void init_plugins(); void init_plugins();
void _on_plugin_ready(Object *p_script, const String &p_activate_name); void _on_plugin_ready(Object *p_script, const String &p_activate_name);
void editor_select(int p_which);
void set_visible_editor(EditorTable p_table) { editor_select(p_table); }
bool call_build(); bool call_build();
// This is a very naive estimation, but we need something now. Will be reworked later. // This is a very naive estimation, but we need something now. Will be reworked later.
@ -724,6 +683,7 @@ public:
static EditorTitleBar *get_title_bar() { return singleton->title_bar; } static EditorTitleBar *get_title_bar() { return singleton->title_bar; }
static VSplitContainer *get_top_split() { return singleton->top_split; } static VSplitContainer *get_top_split() { return singleton->top_split; }
static EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; } static EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; }
static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; }
static String adjust_scene_name_casing(const String &p_root_name); static String adjust_scene_name_casing(const String &p_root_name);
static String adjust_script_name_casing(const String &p_file_name, ScriptLanguage::ScriptNameCasing p_auto_casing); static String adjust_script_name_casing(const String &p_file_name, ScriptLanguage::ScriptNameCasing p_auto_casing);
@ -755,7 +715,6 @@ public:
static void cleanup(); static void cleanup();
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; }
EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; } EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
@ -769,6 +728,7 @@ public:
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); } void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
void update_distraction_free_mode();
void set_distraction_free_mode(bool p_enter); void set_distraction_free_mode(bool p_enter);
bool is_distraction_free_mode_enabled() const; bool is_distraction_free_mode_enabled() const;
@ -791,8 +751,6 @@ public:
void push_node_item(Node *p_node); void push_node_item(Node *p_node);
void hide_unused_editors(const Object *p_editing_owner = nullptr); void hide_unused_editors(const Object *p_editing_owner = nullptr);
void select_editor_by_name(const String &p_name);
void open_request(const String &p_path); void open_request(const String &p_path);
void edit_foreign_resource(Ref<Resource> p_resource); void edit_foreign_resource(Ref<Resource> p_resource);
@ -802,7 +760,6 @@ public:
bool is_changing_scene() const; bool is_changing_scene() const;
VBoxContainer *get_main_screen_control();
SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited. SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited.
void set_edited_scene(Node *p_scene); void set_edited_scene(Node *p_scene);

View File

@ -270,7 +270,7 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat
Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const {
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>()); ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>());
if (EditorNode::get_singleton()->get_main_screen_control()->is_layout_rtl()) { if (EditorNode::get_singleton()->get_gui_base()->is_layout_rtl()) {
return theme->get_icon(SNAME("PlayBackwards"), EditorStringName(EditorIcons)); return theme->get_icon(SNAME("PlayBackwards"), EditorStringName(EditorIcons));
} else { } else {
return theme->get_icon(SNAME("Play"), EditorStringName(EditorIcons)); return theme->get_icon(SNAME("Play"), EditorStringName(EditorIcons));

View File

@ -30,6 +30,7 @@
#include "inspector_dock.h" #include "inspector_dock.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -97,7 +98,7 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
case OBJECT_REQUEST_HELP: { case OBJECT_REQUEST_HELP: {
if (current) { if (current) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
emit_signal(SNAME("request_help"), current->get_class()); emit_signal(SNAME("request_help"), current->get_class());
} }
} break; } break;

View File

@ -35,6 +35,7 @@
#include "core/io/stream_peer_tls.h" #include "core/io/stream_peer_tls.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "core/version.h" #include "core/version.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
@ -1794,7 +1795,7 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() { AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() {
addon_library = memnew(EditorAssetLibrary); addon_library = memnew(EditorAssetLibrary);
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL); addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
EditorNode::get_singleton()->get_main_screen_control()->add_child(addon_library); EditorNode::get_singleton()->get_editor_main_screen()->get_control()->add_child(addon_library);
addon_library->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); addon_library->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
addon_library->hide(); addon_library->hide();
} }

View File

@ -34,6 +34,7 @@
#include "core/input/input.h" #include "core/input/input.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -5735,7 +5736,7 @@ void CanvasItemEditorPlugin::_notification(int p_what) {
CanvasItemEditorPlugin::CanvasItemEditorPlugin() { CanvasItemEditorPlugin::CanvasItemEditorPlugin() {
canvas_item_editor = memnew(CanvasItemEditor); canvas_item_editor = memnew(CanvasItemEditor);
canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
EditorNode::get_singleton()->get_main_screen_control()->add_child(canvas_item_editor); EditorNode::get_singleton()->get_editor_main_screen()->get_control()->add_child(canvas_item_editor);
canvas_item_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); canvas_item_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
canvas_item_editor->hide(); canvas_item_editor->hide();
} }

View File

@ -208,7 +208,7 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin() { CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin() {
particles_editor = memnew(CPUParticles3DEditor); particles_editor = memnew(CPUParticles3DEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor); EditorNode::get_singleton()->get_gui_base()->add_child(particles_editor);
particles_editor->hide(); particles_editor->hide();
} }

View File

@ -452,7 +452,7 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin() { GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin() {
particles_editor = memnew(GPUParticles3DEditor); particles_editor = memnew(GPUParticles3DEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor); EditorNode::get_singleton()->get_gui_base()->add_child(particles_editor);
particles_editor->hide(); particles_editor->hide();
} }

View File

@ -689,7 +689,7 @@ void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {
MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin() { MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin() {
mesh_editor = memnew(MeshInstance3DEditor); mesh_editor = memnew(MeshInstance3DEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(mesh_editor); EditorNode::get_singleton()->get_gui_base()->add_child(mesh_editor);
mesh_editor->options->hide(); mesh_editor->options->hide();
} }

View File

@ -308,7 +308,7 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin() { MeshLibraryEditorPlugin::MeshLibraryEditorPlugin() {
mesh_library_editor = memnew(MeshLibraryEditor); mesh_library_editor = memnew(MeshLibraryEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(mesh_library_editor); EditorNode::get_singleton()->get_gui_base()->add_child(mesh_library_editor);
mesh_library_editor->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE); mesh_library_editor->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE);
mesh_library_editor->set_end(Point2(0, 22)); mesh_library_editor->set_end(Point2(0, 22));
mesh_library_editor->hide(); mesh_library_editor->hide();

View File

@ -384,7 +384,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) {
MultiMeshEditorPlugin::MultiMeshEditorPlugin() { MultiMeshEditorPlugin::MultiMeshEditorPlugin() {
multimesh_editor = memnew(MultiMeshEditor); multimesh_editor = memnew(MultiMeshEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(multimesh_editor); EditorNode::get_singleton()->get_gui_base()->add_child(multimesh_editor);
multimesh_editor->options->hide(); multimesh_editor->options->hide();
} }

View File

@ -37,6 +37,7 @@
#include "core/math/projection.h" #include "core/math/projection.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -9376,7 +9377,7 @@ Vector<Node3D *> Node3DEditor::gizmo_bvh_frustum_query(const Vector<Plane> &p_fr
Node3DEditorPlugin::Node3DEditorPlugin() { Node3DEditorPlugin::Node3DEditorPlugin() {
spatial_editor = memnew(Node3DEditor); spatial_editor = memnew(Node3DEditor);
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
EditorNode::get_singleton()->get_main_screen_control()->add_child(spatial_editor); EditorNode::get_singleton()->get_editor_main_screen()->get_control()->add_child(spatial_editor);
spatial_editor->hide(); spatial_editor->hide();
} }

View File

@ -44,6 +44,7 @@
#include "editor/editor_command_palette.h" #include "editor/editor_command_palette.h"
#include "editor/editor_help_search.h" #include "editor/editor_help_search.h"
#include "editor/editor_interface.h" #include "editor/editor_interface.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_script.h" #include "editor/editor_script.h"
@ -4612,7 +4613,7 @@ ScriptEditorPlugin::ScriptEditorPlugin() {
Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND("script_editor/make_floating", TTR("Make Floating")); Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND("script_editor/make_floating", TTR("Make Floating"));
window_wrapper->set_wrapped_control(script_editor, make_floating_shortcut); window_wrapper->set_wrapped_control(script_editor, make_floating_shortcut);
EditorNode::get_singleton()->get_main_screen_control()->add_child(window_wrapper); EditorNode::get_singleton()->get_editor_main_screen()->get_control()->add_child(window_wrapper);
window_wrapper->set_v_size_flags(Control::SIZE_EXPAND_FILL); window_wrapper->set_v_size_flags(Control::SIZE_EXPAND_FILL);
window_wrapper->hide(); window_wrapper->hide();
window_wrapper->connect("window_visibility_changed", callable_mp(this, &ScriptEditorPlugin::_window_visibility_changed)); window_wrapper->connect("window_visibility_changed", callable_mp(this, &ScriptEditorPlugin::_window_visibility_changed));

View File

@ -129,7 +129,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) {
Skeleton2DEditorPlugin::Skeleton2DEditorPlugin() { Skeleton2DEditorPlugin::Skeleton2DEditorPlugin() {
sprite_editor = memnew(Skeleton2DEditor); sprite_editor = memnew(Skeleton2DEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor); EditorNode::get_singleton()->get_gui_base()->add_child(sprite_editor);
make_visible(false); make_visible(false);
//sprite_editor->options->hide(); //sprite_editor->options->hide();

View File

@ -673,7 +673,7 @@ void Sprite2DEditorPlugin::make_visible(bool p_visible) {
Sprite2DEditorPlugin::Sprite2DEditorPlugin() { Sprite2DEditorPlugin::Sprite2DEditorPlugin() {
sprite_editor = memnew(Sprite2DEditor); sprite_editor = memnew(Sprite2DEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor); EditorNode::get_singleton()->get_gui_base()->add_child(sprite_editor);
make_visible(false); make_visible(false);
//sprite_editor->options->hide(); //sprite_editor->options->hide();

View File

@ -37,6 +37,7 @@
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_feature_profile.h" #include "editor/editor_feature_profile.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_quick_open.h" #include "editor/editor_quick_open.h"
@ -1197,7 +1198,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
ScriptEditor::get_singleton()->goto_help("class_name:" + class_name); ScriptEditor::get_singleton()->goto_help("class_name:" + class_name);
} }
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} break; } break;
case TOOL_AUTO_EXPAND: { case TOOL_AUTO_EXPAND: {
scene_tree->set_auto_expand_selected(!EDITOR_GET("docks/scene_tree/auto_expand_to_selected"), true); scene_tree->set_auto_expand_selected(!EDITOR_GET("docks/scene_tree/auto_expand_to_selected"), true);

View File

@ -541,7 +541,7 @@ EditorPluginCSG::EditorPluginCSG() {
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
csg_shape_editor = memnew(CSGShapeEditor); csg_shape_editor = memnew(CSGShapeEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(csg_shape_editor); EditorNode::get_singleton()->get_gui_base()->add_child(csg_shape_editor);
} }
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED

View File

@ -34,6 +34,7 @@
#include "core/input/input.h" #include "core/input/input.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
@ -958,7 +959,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform(); _update_selection_transform();
_update_paste_indicator(); _update_paste_indicator();
spatial_editor = Object::cast_to<Node3DEditorPlugin>(EditorNode::get_singleton()->get_editor_plugin_screen()); spatial_editor = Object::cast_to<Node3DEditorPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_selected_plugin());
if (!node) { if (!node) {
set_process(false); set_process(false);

View File

@ -41,6 +41,7 @@
#include "core/os/os.h" #include "core/os/os.h"
#include "core/version.h" #include "core/version.h"
#include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_paths.h" #include "editor/editor_paths.h"
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
@ -165,7 +166,7 @@ bool godot_icall_Internal_ScriptEditorEdit(Resource *p_resource, int32_t p_line,
} }
void godot_icall_Internal_EditorNodeShowScriptScreen() { void godot_icall_Internal_EditorNodeShowScriptScreen() {
EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT); EditorNode::get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
} }
void godot_icall_Internal_EditorRunPlay() { void godot_icall_Internal_EditorRunPlay() {

View File

@ -176,7 +176,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() { NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() {
navigation_mesh_editor = memnew(NavigationMeshEditor); navigation_mesh_editor = memnew(NavigationMeshEditor);
EditorNode::get_singleton()->get_main_screen_control()->add_child(navigation_mesh_editor); EditorNode::get_singleton()->get_gui_base()->add_child(navigation_mesh_editor);
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, navigation_mesh_editor->bake_hbox); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, navigation_mesh_editor->bake_hbox);
navigation_mesh_editor->hide(); navigation_mesh_editor->hide();
navigation_mesh_editor->bake_hbox->hide(); navigation_mesh_editor->bake_hbox->hide();