diff options
author | Juan Linietsky <juan@godotengine.org> | 2020-03-03 22:51:12 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-03-26 15:49:38 +0100 |
commit | 9e08742de81b062c30b7984900a55d5150a4bd17 (patch) | |
tree | 6570bbc8bdcc17e0538d0361156f041b24c2614d /editor | |
parent | f8a79a97c7d12da43b111a756f09ee7ad5ea28e9 (diff) |
Added a Window node, and made it the scene root.
Still a lot of work to do.
Diffstat (limited to 'editor')
26 files changed, 36 insertions, 33 deletions
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 <stdio.h> #include <stdlib.h> @@ -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<SubViewport>(EditorInterface::get_singleton()->get_editor_viewport()->get_viewport()); + viewport->set_clear_mode(SubViewport::CLEAR_MODE_ONLY_NEXT_FRAME); Ref<Image> 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<AnimationNode> &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<Script> &p_script) { diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 10d13f0188..dee595c119 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -40,7 +40,7 @@ #include "editor/editor_settings.h" #include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning. #include "editor/plugins/spatial_editor_plugin.h" // For onion skinning. -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "servers/visual_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { @@ -1420,7 +1420,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Tweak the root viewport to ensure it's rendered before our target. RID root_vp = get_tree()->get_root()->get_viewport_rid(); - Rect2 root_vp_screen_rect = get_tree()->get_root()->get_attach_to_screen_rect(); + Rect2 root_vp_screen_rect = Rect2(Vector2(), get_tree()->get_root()->get_size()); VS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2()); VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_ALWAYS); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 1fe57665eb..3fd0cb94a2 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_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 AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index cf99d2ef78..795bd3eb1b 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -44,7 +44,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" #include "scene/scene_string_names.h" void AnimationTreeEditor::edit(AnimationTree *p_tree) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 13f4979ba2..90d3bf0641 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -50,7 +50,7 @@ #include "scene/gui/nine_patch_rect.h" #include "scene/gui/viewport_container.h" #include "scene/main/canvas_layer.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #define MIN_ZOOM 0.01 diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index d388296927..a13a594d95 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -114,7 +114,7 @@ MaterialEditor::MaterialEditor() { vc->set_stretch(true); add_child(vc); vc->set_anchors_and_margins_preset(PRESET_WIDE); - viewport = memnew(Viewport); + viewport = memnew(SubViewport); Ref<World> world; world.instance(); viewport->set_world(world); //use own world diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 84e69425d0..895c3f80bd 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -48,7 +48,7 @@ class MaterialEditor : public Control { GDCLASS(MaterialEditor, Control); ViewportContainer *vc; - Viewport *viewport; + SubViewport *viewport; MeshInstance *sphere_instance; MeshInstance *box_instance; DirectionalLight *light1; diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 5a17f0d4f1..c921ca46cd 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -115,7 +115,7 @@ void MeshEditor::_bind_methods() { MeshEditor::MeshEditor() { - viewport = memnew(Viewport); + viewport = memnew(SubViewport); Ref<World> world; world.instance(); viewport->set_world(world); //use own world diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 87c4a1776b..6d39d49de1 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -46,7 +46,7 @@ class MeshEditor : public ViewportContainer { float rot_x; float rot_y; - Viewport *viewport; + SubViewport *viewport; MeshInstance *mesh_instance; Spatial *rotation; DirectionalLight *light1; diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 4e63a498b8..f341d9ca86 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -36,7 +36,7 @@ #include "scene/3d/mesh_instance.h" #include "scene/3d/navigation_region.h" #include "scene/3d/physics_body.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "spatial_editor_plugin.h" diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index d932305c63..daea2eec6b 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "root_motion_editor_plugin.h" #include "editor/editor_node.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" void EditorPropertyRootMotion::_confirmed() { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 06d1c664b5..f435856cdf 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -45,7 +45,7 @@ #include "editor/find_in_files.h" #include "editor/node_dock.h" #include "editor/plugins/shader_editor_plugin.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/scene_string_names.h" #include "script_text_editor.h" #include "servers/display_server.h" diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index d514b50460..2af64b6ed6 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3834,7 +3834,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed c->set_stretch(true); add_child(c); c->set_anchors_and_margins_preset(Control::PRESET_WIDE); - viewport = memnew(Viewport); + viewport = memnew(SubViewport); viewport->set_disable_input(true); c->add_child(viewport); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index b67459b9d0..9dad66b647 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -262,7 +262,7 @@ private: PopupMenu *display_submenu; Control *surface; - Viewport *viewport; + SubViewport *viewport; Camera *camera; bool transforming; bool orthogonal; @@ -467,7 +467,7 @@ public: AABB *p_preview_bounds, AcceptDialog *p_accept); - Viewport *get_viewport_node() { return viewport; } + SubViewport *get_viewport_node() { return viewport; } Camera *get_camera() { return camera; } // return the default camera object. SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 8070e2b4d5..3b7c4897b2 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -42,7 +42,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" #include "scene/resources/visual_shader_nodes.h" #include "servers/display_server.h" #include "servers/visual/shader_types.h" diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index feef274d33..7ba43d1246 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -53,7 +53,7 @@ #include "editor/multi_node_edit.h" #include "editor/property_selector.h" #include "scene/gui/label.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/font.h" #include "scene/resources/packed_scene.h" #include "scene/scene_string_names.h" diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 4382b63747..3df4367b43 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -44,7 +44,7 @@ #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" #include "servers/visual_server.h" diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 782df12d4b..0f8e748dfb 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -37,7 +37,7 @@ #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "scene/gui/label.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" Node *SceneTreeEditor::get_scene_node() { |