From 1459507ed28d68e0066ee2631c0b3671c1c76faa Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Wed, 7 Sep 2022 02:30:54 +0300 Subject: [PATCH] Rename EditorInterface.get_editor_main_control to get_editor_main_screen --- doc/classes/EditorInterface.xml | 7 +++--- doc/classes/EditorPlugin.xml | 2 +- editor/editor_node.cpp | 25 ++++++++++--------- editor/editor_node.h | 4 +-- editor/editor_plugin.cpp | 6 ++--- editor/editor_plugin.h | 2 +- editor/export/editor_export_platform.cpp | 2 +- .../plugins/asset_library_editor_plugin.cpp | 2 +- editor/plugins/camera_3d_editor_plugin.cpp | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- .../cpu_particles_3d_editor_plugin.cpp | 2 +- .../gpu_particles_3d_editor_plugin.cpp | 2 +- .../mesh_instance_3d_editor_plugin.cpp | 2 +- editor/plugins/mesh_library_editor_plugin.cpp | 2 +- editor/plugins/multimesh_editor_plugin.cpp | 2 +- editor/plugins/node_3d_editor_plugin.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 2 +- editor/plugins/skeleton_2d_editor_plugin.cpp | 2 +- editor/plugins/sprite_2d_editor_plugin.cpp | 2 +- editor/project_converter_3_to_4.cpp | 2 +- .../editor/navigation_mesh_editor_plugin.cpp | 2 +- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index c4bbc7c108b..1e3b1f07eea 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -60,11 +60,10 @@ Returns the edited (current) scene's root [Node]. - - + + - Returns the main editor control. Use this as a parent for main screens. - [b]Note:[/b] This returns the main editor control containing the whole editor, not the 2D or 3D viewports specifically. + Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement [method EditorPlugin._has_main_screen]. [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash. diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index fdd3807b698..418b44e74bf 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -303,7 +303,7 @@ func _enter_tree(): plugin_control = preload("my_plugin_control.tscn").instantiate() - get_editor_interface().get_editor_main_control().add_child(plugin_control) + get_editor_interface().get_editor_main_screen().add_child(plugin_control) plugin_control.hide() func _has_main_screen(): diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 7a7576b2415..dc0235491fb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3095,14 +3095,14 @@ void EditorNode::_screenshot(bool p_use_utc) { } void EditorNode::_save_screenshot(NodePath p_path) { - Control *editor_main_control = EditorInterface::get_singleton()->get_editor_main_control(); - ERR_FAIL_COND_MSG(!editor_main_control, "Cannot get editor main control."); - Viewport *viewport = editor_main_control->get_viewport(); - ERR_FAIL_COND_MSG(!viewport, "Cannot get editor main control viewport."); + Control *editor_main_screen = EditorInterface::get_singleton()->get_editor_main_screen(); + ERR_FAIL_COND_MSG(!editor_main_screen, "Cannot get the editor main screen control."); + Viewport *viewport = editor_main_screen->get_viewport(); + ERR_FAIL_COND_MSG(!viewport, "Cannot get a viewport from the editor main screen."); Ref texture = viewport->get_texture(); - ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get editor main control viewport texture."); + ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get a viewport texture from the editor main screen."); Ref img = texture->get_image(); - ERR_FAIL_COND_MSG(img.is_null(), "Cannot get editor main control viewport texture image."); + ERR_FAIL_COND_MSG(img.is_null(), "Cannot get an image from a viewport texture of the editor main screen."); Error error = img->save_png(p_path); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'."); } @@ -3286,8 +3286,8 @@ void EditorNode::_update_file_menu_closed() { file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false); } -Control *EditorNode::get_main_control() { - return main_control; +VBoxContainer *EditorNode::get_main_screen_control() { + return main_screen_vbox; } void EditorNode::_editor_select(int p_which) { @@ -6583,10 +6583,11 @@ EditorNode::EditorNode() { scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); - main_control = memnew(VBoxContainer); - main_control->set_v_size_flags(Control::SIZE_EXPAND_FILL); - main_control->add_theme_constant_override("separation", 0); - scene_root_parent->add_child(main_control); + 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")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU); bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE); diff --git a/editor/editor_node.h b/editor/editor_node.h index c3b4c985cc5..df3d2ae0f82 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -323,7 +323,7 @@ private: Control *vp_base = nullptr; EditorTitleBar *menu_hb = nullptr; - Control *main_control = nullptr; + VBoxContainer *main_screen_vbox = nullptr; MenuBar *main_menu = nullptr; PopupMenu *file_menu = nullptr; PopupMenu *project_menu = nullptr; @@ -788,7 +788,7 @@ public: bool is_changing_scene() const; - Control *get_main_control(); + VBoxContainer *get_main_screen_control(); SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited. void set_edited_scene(Node *p_scene); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 1efbb7e40fe..f3ac8f4ba0e 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -156,8 +156,8 @@ void EditorInterface::set_main_screen_editor(const String &p_name) { EditorNode::get_singleton()->select_editor_by_name(p_name); } -Control *EditorInterface::get_editor_main_control() { - return EditorNode::get_singleton()->get_main_control(); +VBoxContainer *EditorInterface::get_editor_main_screen() { + return EditorNode::get_singleton()->get_main_screen_control(); } void EditorInterface::edit_resource(const Ref &p_resource) { @@ -352,7 +352,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root); ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer); ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system); - ClassDB::bind_method(D_METHOD("get_editor_main_control"), &EditorInterface::get_editor_main_control); + ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen); ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews); ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 1d6f48caa3b..fe01524bea3 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -72,7 +72,7 @@ protected: public: static EditorInterface *get_singleton() { return singleton; } - Control *get_editor_main_control(); + VBoxContainer *get_editor_main_screen(); void edit_resource(const Ref &p_resource); void edit_node(Node *p_node); void edit_script(const Ref