Rename EditorInterface.get_editor_main_control to get_editor_main_screen

This commit is contained in:
Yuri Sizov 2022-09-07 02:30:54 +03:00
parent 432c4c40a9
commit 1459507ed2
21 changed files with 38 additions and 38 deletions

View File

@ -60,11 +60,10 @@
Returns the edited (current) scene's root [Node]. Returns the edited (current) scene's root [Node].
</description> </description>
</method> </method>
<method name="get_editor_main_control"> <method name="get_editor_main_screen">
<return type="Control" /> <return type="VBoxContainer" />
<description> <description>
Returns the main editor control. Use this as a parent for main screens. Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement [method EditorPlugin._has_main_screen].
[b]Note:[/b] This returns the main editor control containing the whole editor, not the 2D or 3D viewports specifically.
[b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash. [b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
</description> </description>
</method> </method>

View File

@ -303,7 +303,7 @@
func _enter_tree(): func _enter_tree():
plugin_control = preload("my_plugin_control.tscn").instantiate() 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() plugin_control.hide()
func _has_main_screen(): func _has_main_screen():

View File

@ -3095,14 +3095,14 @@ void EditorNode::_screenshot(bool p_use_utc) {
} }
void EditorNode::_save_screenshot(NodePath p_path) { void EditorNode::_save_screenshot(NodePath p_path) {
Control *editor_main_control = EditorInterface::get_singleton()->get_editor_main_control(); Control *editor_main_screen = EditorInterface::get_singleton()->get_editor_main_screen();
ERR_FAIL_COND_MSG(!editor_main_control, "Cannot get editor main control."); ERR_FAIL_COND_MSG(!editor_main_screen, "Cannot get the editor main screen control.");
Viewport *viewport = editor_main_control->get_viewport(); Viewport *viewport = editor_main_screen->get_viewport();
ERR_FAIL_COND_MSG(!viewport, "Cannot get editor main control viewport."); ERR_FAIL_COND_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 editor main control viewport texture."); ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get a viewport texture from the editor main screen.");
Ref<Image> img = texture->get_image(); Ref<Image> 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); Error error = img->save_png(p_path);
ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + 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); file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false);
} }
Control *EditorNode::get_main_control() { VBoxContainer *EditorNode::get_main_screen_control() {
return main_control; return main_screen_vbox;
} }
void EditorNode::_editor_select(int p_which) { void EditorNode::_editor_select(int p_which) {
@ -6583,10 +6583,11 @@ 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_control = memnew(VBoxContainer); main_screen_vbox = memnew(VBoxContainer);
main_control->set_v_size_flags(Control::SIZE_EXPAND_FILL); main_screen_vbox->set_name("MainScreen");
main_control->add_theme_constant_override("separation", 0); main_screen_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL);
scene_root_parent->add_child(main_control); 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 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); bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE);

View File

@ -323,7 +323,7 @@ private:
Control *vp_base = nullptr; Control *vp_base = nullptr;
EditorTitleBar *menu_hb = nullptr; EditorTitleBar *menu_hb = nullptr;
Control *main_control = nullptr; VBoxContainer *main_screen_vbox = nullptr;
MenuBar *main_menu = nullptr; MenuBar *main_menu = nullptr;
PopupMenu *file_menu = nullptr; PopupMenu *file_menu = nullptr;
PopupMenu *project_menu = nullptr; PopupMenu *project_menu = nullptr;
@ -788,7 +788,7 @@ public:
bool is_changing_scene() const; 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. 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

@ -156,8 +156,8 @@ void EditorInterface::set_main_screen_editor(const String &p_name) {
EditorNode::get_singleton()->select_editor_by_name(p_name); EditorNode::get_singleton()->select_editor_by_name(p_name);
} }
Control *EditorInterface::get_editor_main_control() { VBoxContainer *EditorInterface::get_editor_main_screen() {
return EditorNode::get_singleton()->get_main_control(); return EditorNode::get_singleton()->get_main_screen_control();
} }
void EditorInterface::edit_resource(const Ref<Resource> &p_resource) { void EditorInterface::edit_resource(const Ref<Resource> &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_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_previewer"), &EditorInterface::get_resource_previewer);
ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system); 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("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("select_file", "file"), &EditorInterface::select_file);
ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path);

View File

@ -72,7 +72,7 @@ protected:
public: public:
static EditorInterface *get_singleton() { return singleton; } static EditorInterface *get_singleton() { return singleton; }
Control *get_editor_main_control(); VBoxContainer *get_editor_main_screen();
void edit_resource(const Ref<Resource> &p_resource); void edit_resource(const Ref<Resource> &p_resource);
void edit_node(Node *p_node); void edit_node(Node *p_node);
void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true); void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);

View File

@ -287,7 +287,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_control()->is_layout_rtl()) { if (EditorNode::get_singleton()->get_main_screen_control()->is_layout_rtl()) {
return theme->get_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")); return theme->get_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"));
} else { } else {
return theme->get_icon(SNAME("Play"), SNAME("EditorIcons")); return theme->get_icon(SNAME("Play"), SNAME("EditorIcons"));

View File

@ -1617,7 +1617,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_control()->add_child(addon_library); EditorNode::get_singleton()->get_main_screen_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

@ -98,7 +98,7 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) {
Camera3DEditorPlugin::Camera3DEditorPlugin() { Camera3DEditorPlugin::Camera3DEditorPlugin() {
/* camera_editor = memnew( CameraEditor ); /* camera_editor = memnew( CameraEditor );
EditorNode::get_singleton()->get_main_control()->add_child(camera_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(camera_editor);
camera_editor->set_anchor(SIDE_LEFT,Control::ANCHOR_END); camera_editor->set_anchor(SIDE_LEFT,Control::ANCHOR_END);
camera_editor->set_anchor(SIDE_RIGHT,Control::ANCHOR_END); camera_editor->set_anchor(SIDE_RIGHT,Control::ANCHOR_END);

View File

@ -5459,7 +5459,7 @@ void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
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_control()->add_child(canvas_item_editor); EditorNode::get_singleton()->get_main_screen_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

@ -126,7 +126,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_control()->add_child(particles_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor);
particles_editor->hide(); particles_editor->hide();
} }

View File

@ -454,7 +454,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_control()->add_child(particles_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor);
particles_editor->hide(); particles_editor->hide();
} }

View File

@ -567,7 +567,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_control()->add_child(mesh_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(mesh_editor);
mesh_editor->options->hide(); mesh_editor->options->hide();
} }

View File

@ -319,7 +319,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_control()->add_child(mesh_library_editor); EditorNode::get_singleton()->get_main_screen_control()->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

@ -379,7 +379,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_control()->add_child(multimesh_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(multimesh_editor);
multimesh_editor->options->hide(); multimesh_editor->options->hide();
} }

View File

@ -8449,7 +8449,7 @@ void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
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_control()->add_child(spatial_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(spatial_editor);
spatial_editor->hide(); spatial_editor->hide();
} }

View File

@ -4049,7 +4049,7 @@ void ScriptEditorPlugin::edited_scene_changed() {
ScriptEditorPlugin::ScriptEditorPlugin() { ScriptEditorPlugin::ScriptEditorPlugin() {
script_editor = memnew(ScriptEditor); script_editor = memnew(ScriptEditor);
EditorNode::get_singleton()->get_main_control()->add_child(script_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(script_editor);
script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
script_editor->hide(); script_editor->hide();

View File

@ -131,7 +131,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_control()->add_child(sprite_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor);
make_visible(false); make_visible(false);
//sprite_editor->options->hide(); //sprite_editor->options->hide();

View File

@ -604,7 +604,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_control()->add_child(sprite_editor); EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor);
make_visible(false); make_visible(false);
//sprite_editor->options->hide(); //sprite_editor->options->hide();

View File

@ -295,7 +295,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_d", "get_distance" }, // LineShape2D { "get_d", "get_distance" }, // LineShape2D
{ "get_drag_data", "_get_drag_data" }, // Control { "get_drag_data", "_get_drag_data" }, // Control
{ "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor { "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor
{ "get_editor_viewport", "get_viewport" }, // EditorPlugin { "get_editor_viewport", "get_editor_main_screen" }, // EditorPlugin
{ "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton { "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton
{ "get_endian_swap", "is_big_endian" }, // File { "get_endian_swap", "is_big_endian" }, // File
{ "get_error_string", "get_error_message" }, // JSON { "get_error_string", "get_error_message" }, // JSON

View File

@ -145,7 +145,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_control()->add_child(navigation_mesh_editor); EditorNode::get_singleton()->get_main_screen_control()->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();