Skip to content

Commit

Permalink
Rename EditorInterface.get_editor_main_control to get_editor_main_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizov committed Sep 6, 2022
1 parent 432c4c4 commit 8ab5ba2
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 37 deletions.
5 changes: 2 additions & 3 deletions doc/classes/EditorInterface.xml
Expand Up @@ -60,11 +60,10 @@
Returns the edited (current) scene's root [Node].
</description>
</method>
<method name="get_editor_main_control">
<method name="get_editor_main_screen">
<return type="Control" />
<description>
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.
</description>
</method>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorPlugin.xml
Expand Up @@ -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():
Expand Down
25 changes: 13 additions & 12 deletions editor/editor_node.cpp
Expand Up @@ -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<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();
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 + "'.");
}
Expand Down Expand Up @@ -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;
Control *EditorNode::get_main_screen_control() {
return main_screen_vbox;
}

void EditorNode::_editor_select(int p_which) {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_node.h
Expand Up @@ -323,7 +323,7 @@ class EditorNode : public Node {
Control *vp_base = nullptr;

EditorTitleBar *menu_hb = nullptr;
Control *main_control = nullptr;
Control *main_screen_vbox = nullptr;
MenuBar *main_menu = nullptr;
PopupMenu *file_menu = nullptr;
PopupMenu *project_menu = nullptr;
Expand Down Expand Up @@ -788,7 +788,7 @@ class EditorNode : public Node {

bool is_changing_scene() const;

Control *get_main_control();
Control *get_main_screen_control();
SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited.

void set_edited_scene(Node *p_scene);
Expand Down
6 changes: 3 additions & 3 deletions editor/editor_plugin.cpp
Expand Up @@ -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();
Control *EditorInterface::get_editor_main_screen() {
return EditorNode::get_singleton()->get_main_screen_control();
}

void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_plugin.h
Expand Up @@ -72,7 +72,7 @@ class EditorInterface : public Node {
public:
static EditorInterface *get_singleton() { return singleton; }

Control *get_editor_main_control();
Control *get_editor_main_screen();
void edit_resource(const Ref<Resource> &p_resource);
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);
Expand Down
2 changes: 1 addition & 1 deletion editor/export/editor_export_platform.cpp
Expand Up @@ -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<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
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"));
} else {
return theme->get_icon(SNAME("Play"), SNAME("EditorIcons"));
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/asset_library_editor_plugin.cpp
Expand Up @@ -1617,7 +1617,7 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() {
addon_library = memnew(EditorAssetLibrary);
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->hide();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/camera_3d_editor_plugin.cpp
Expand Up @@ -98,7 +98,7 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) {

Camera3DEditorPlugin::Camera3DEditorPlugin() {
/* 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_RIGHT,Control::ANCHOR_END);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/canvas_item_editor_plugin.cpp
Expand Up @@ -5459,7 +5459,7 @@ void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
CanvasItemEditorPlugin::CanvasItemEditorPlugin() {
canvas_item_editor = memnew(CanvasItemEditor);
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->hide();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/cpu_particles_3d_editor_plugin.cpp
Expand Up @@ -126,7 +126,7 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {

CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin() {
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();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/gpu_particles_3d_editor_plugin.cpp
Expand Up @@ -454,7 +454,7 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {

GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin() {
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();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/mesh_instance_3d_editor_plugin.cpp
Expand Up @@ -567,7 +567,7 @@ void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {

MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin() {
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();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/mesh_library_editor_plugin.cpp
Expand Up @@ -319,7 +319,7 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) {
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin() {
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_end(Point2(0, 22));
mesh_library_editor->hide();
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/multimesh_editor_plugin.cpp
Expand Up @@ -379,7 +379,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) {

MultiMeshEditorPlugin::MultiMeshEditorPlugin() {
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();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/node_3d_editor_plugin.cpp
Expand Up @@ -8449,7 +8449,7 @@ void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
Node3DEditorPlugin::Node3DEditorPlugin() {
spatial_editor = memnew(Node3DEditor);
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();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/script_editor_plugin.cpp
Expand Up @@ -4049,7 +4049,7 @@ void ScriptEditorPlugin::edited_scene_changed() {

ScriptEditorPlugin::ScriptEditorPlugin() {
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->hide();
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/skeleton_2d_editor_plugin.cpp
Expand Up @@ -131,7 +131,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) {

Skeleton2DEditorPlugin::Skeleton2DEditorPlugin() {
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);

//sprite_editor->options->hide();
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/sprite_2d_editor_plugin.cpp
Expand Up @@ -604,7 +604,7 @@ void Sprite2DEditorPlugin::make_visible(bool p_visible) {

Sprite2DEditorPlugin::Sprite2DEditorPlugin() {
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);

//sprite_editor->options->hide();
Expand Down
2 changes: 1 addition & 1 deletion editor/project_converter_3_to_4.cpp
Expand Up @@ -295,7 +295,7 @@ static const char *gdscript_function_renames[][2] = {
{ "get_d", "get_distance" }, // LineShape2D
{ "get_drag_data", "_get_drag_data" }, // Control
{ "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_endian_swap", "is_big_endian" }, // File
{ "get_error_string", "get_error_message" }, // JSON
Expand Down
Expand Up @@ -145,7 +145,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) {

NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() {
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);
navigation_mesh_editor->hide();
navigation_mesh_editor->bake_hbox->hide();
Expand Down

0 comments on commit 8ab5ba2

Please sign in to comment.