From 9e08742de81b062c30b7984900a55d5150a4bd17 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 3 Mar 2020 22:51:12 -0300 Subject: Added a Window node, and made it the scene root. Still a lot of work to do. --- editor/animation_track_editor.cpp | 2 +- editor/editor_autoload_settings.cpp | 2 +- editor/editor_node.cpp | 11 ++++++----- editor/editor_node.h | 6 ++++-- editor/editor_properties.cpp | 2 +- editor/editor_settings.cpp | 2 +- editor/filesystem_dock.cpp | 2 +- editor/plugins/animation_blend_space_2d_editor.cpp | 2 +- editor/plugins/animation_blend_tree_editor_plugin.cpp | 2 +- editor/plugins/animation_player_editor_plugin.cpp | 4 ++-- editor/plugins/animation_state_machine_editor.cpp | 2 +- editor/plugins/animation_tree_editor_plugin.cpp | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- editor/plugins/material_editor_plugin.cpp | 2 +- editor/plugins/material_editor_plugin.h | 2 +- editor/plugins/mesh_editor_plugin.cpp | 2 +- editor/plugins/mesh_editor_plugin.h | 2 +- editor/plugins/mesh_library_editor_plugin.cpp | 2 +- editor/plugins/root_motion_editor_plugin.cpp | 2 +- editor/plugins/script_editor_plugin.cpp | 2 +- editor/plugins/spatial_editor_plugin.cpp | 2 +- editor/plugins/spatial_editor_plugin.h | 4 ++-- editor/plugins/visual_shader_editor_plugin.cpp | 2 +- editor/property_editor.cpp | 2 +- editor/scene_tree_dock.cpp | 2 +- editor/scene_tree_editor.cpp | 2 +- 26 files changed, 36 insertions(+), 33 deletions(-) (limited to 'editor') diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index d3205ff147..7a6f43497e 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -37,7 +37,7 @@ #include "editor/plugins/animation_player_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "servers/audio/audio_stream.h" class AnimationTrackKeyEdit : public Object { diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 83a1e2fca2..a02346c872 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -35,7 +35,7 @@ #include "editor_node.h" #include "editor_scale.h" #include "project_settings_editor.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #define PREVIEW_LIST_MAX_SIZE 10 diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 48cd479fcf..5f00bc59ac 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -169,6 +169,7 @@ #include "editor/register_exporters.h" #include "editor/run_settings_dialog.h" #include "editor/settings_config_dialog.h" +#include "scene/main/window.h" #include "servers/display_server.h" #include #include @@ -346,7 +347,7 @@ void EditorNode::_notification(int p_what) { editor_selection->update(); - scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); + //scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); { //TODO should only happen on settings changed int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter"); @@ -2668,10 +2669,10 @@ void EditorNode::_screenshot(bool p_use_utc) { void EditorNode::_save_screenshot(NodePath p_path) { - Viewport *viewport = EditorInterface::get_singleton()->get_editor_viewport()->get_viewport(); - viewport->set_clear_mode(Viewport::CLEAR_MODE_ONLY_NEXT_FRAME); + SubViewport *viewport = Object::cast_to(EditorInterface::get_singleton()->get_editor_viewport()->get_viewport()); + viewport->set_clear_mode(SubViewport::CLEAR_MODE_ONLY_NEXT_FRAME); Ref img = viewport->get_texture()->get_data(); - viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS); + viewport->set_clear_mode(SubViewport::CLEAR_MODE_ALWAYS); Error error = img->save_png(p_path); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'."); } @@ -5941,7 +5942,7 @@ EditorNode::EditorNode() { srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); - scene_root = memnew(Viewport); + scene_root = memnew(SubViewport); //scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); diff --git a/editor/editor_node.h b/editor/editor_node.h index bd285db224..c670d4954b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -84,6 +84,8 @@ class Tabs; class TextureProgress; class ToolButton; class VSplitContainer; +class Window; +class SubViewport; class EditorNode : public Node { @@ -206,7 +208,7 @@ private: TOOL_MENU_BASE = 1000 }; - Viewport *scene_root; //root of the scene being edited + SubViewport *scene_root; //root of the scene being edited PanelContainer *scene_root_parent; Control *theme_base; @@ -724,7 +726,7 @@ public: Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } - Viewport *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 fix_dependencies(const String &p_for_file); void clear_scene() { _cleanup_scene(); } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9a474ed4af..cc89f1c16a 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -35,7 +35,7 @@ #include "editor_node.h" #include "editor_properties_array_dict.h" #include "editor_scale.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" ///////////////////// NULL ///////////////////////// diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 18f0aba030..286ca7b184 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -49,7 +49,7 @@ #include "editor/editor_translations.gen.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" // PRIVATE METHODS diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 171bb4105d..d52a7f25be 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -42,7 +42,7 @@ #include "editor_scale.h" #include "editor_settings.h" #include "import_dock.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index dc8f7f3724..156237a452 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -40,7 +40,7 @@ #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref &p_node) { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 931bce65d7..ecc5982fea 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -40,7 +40,7 @@ #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" #include "scene/gui/progress_bar.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref