summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/icons/icon_GUI_viewport_hdiagsplitter.svg64
-rw-r--r--editor/icons/icon_GUI_viewport_vdiagsplitter.svg68
-rw-r--r--editor/icons/icon_GUI_viewport_vhsplitter.svg63
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp154
-rw-r--r--editor/plugins/spatial_editor_plugin.h5
5 files changed, 297 insertions, 57 deletions
diff --git a/editor/icons/icon_GUI_viewport_hdiagsplitter.svg b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg
new file mode 100644
index 0000000000..36769768fd
--- /dev/null
+++ b/editor/icons/icon_GUI_viewport_hdiagsplitter.svg
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="34"
+ version="1.1"
+ viewBox="0 0 64 34"
+ id="svg6"
+ sodipodi:docname="icon_GUI_vsplitter1.svg"
+ inkscape:version="0.92.2 2405546, 2018-03-11">
+ <metadata
+ id="metadata12">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs10" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="714"
+ id="namedview8"
+ showgrid="false"
+ inkscape:zoom="5.6568543"
+ inkscape:cx="37.006499"
+ inkscape:cy="15.680715"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg6" />
+ <g
+ transform="translate(0,-1018.4)"
+ id="g4" />
+ <g
+ transform="rotate(90,541.2,539.2)"
+ id="g4-3">
+ <path
+ id="path2-6"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
+ d="M 4.0306826,1048.4 H 34 m -30,30 v -60"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ </g>
+</svg>
diff --git a/editor/icons/icon_GUI_viewport_vdiagsplitter.svg b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg
new file mode 100644
index 0000000000..f23b4a0a74
--- /dev/null
+++ b/editor/icons/icon_GUI_viewport_vdiagsplitter.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="34"
+ height="64"
+ version="1.1"
+ viewBox="0 0 34 64"
+ id="svg6"
+ sodipodi:docname="icon_GUI_vsplitter2.svg"
+ inkscape:version="0.92.2 2405546, 2018-03-11">
+ <metadata
+ id="metadata12">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs10" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="714"
+ id="namedview8"
+ showgrid="false"
+ inkscape:zoom="4"
+ inkscape:cx="32.245723"
+ inkscape:cy="44.255214"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg6" />
+ <g
+ transform="translate(0,-988.4)"
+ id="g4" />
+ <g
+ id="g839"
+ transform="rotate(90,32.003536,32.003535)">
+ <g
+ id="g4-3"
+ transform="rotate(90,526.2,554.2)">
+ <path
+ sodipodi:nodetypes="cccc"
+ inkscape:connector-curvature="0"
+ d="M 4.0306826,1048.4 H 34 m -30,30 v -60"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
+ id="path2-6" />
+ </g>
+ </g>
+</svg>
diff --git a/editor/icons/icon_GUI_viewport_vhsplitter.svg b/editor/icons/icon_GUI_viewport_vhsplitter.svg
new file mode 100644
index 0000000000..429cf909ae
--- /dev/null
+++ b/editor/icons/icon_GUI_viewport_vhsplitter.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="64"
+ version="1.1"
+ viewBox="0 0 64 64"
+ id="svg6"
+ sodipodi:docname="icon_GUI_vsplitter.svg"
+ inkscape:version="0.92.2 2405546, 2018-03-11">
+ <metadata
+ id="metadata12">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs10" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1366"
+ inkscape:window-height="714"
+ id="namedview8"
+ showgrid="false"
+ inkscape:zoom="4.65625"
+ inkscape:cx="9.8488117"
+ inkscape:cy="20.04653"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg6" />
+ <g
+ transform="translate(0,-988.4)"
+ id="g4" />
+ <g
+ transform="rotate(90,526.2,554.2)"
+ id="g4-3">
+ <path
+ id="path2-6"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-opacity:0.39216003"
+ d="m -26,1048.4 h 60 m -30,30 v -60"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b68ea71cd4..114610c562 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -3543,69 +3543,77 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event)
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
- Vector2 size = get_size();
+ if (mb->is_pressed()) {
+ Vector2 size = get_size();
- int h_sep = get_constant("separation", "HSplitContainer");
- int v_sep = get_constant("separation", "VSplitContainer");
+ int h_sep = get_constant("separation", "HSplitContainer");
+ int v_sep = get_constant("separation", "VSplitContainer");
- int mid_w = size.width * ratio_h;
- int mid_h = size.height * ratio_v;
+ int mid_w = size.width * ratio_h;
+ int mid_h = size.height * ratio_v;
- dragging_h = mb->get_position().x > (mid_w - h_sep / 2) && mb->get_position().x < (mid_w + h_sep / 2);
- dragging_v = mb->get_position().y > (mid_h - v_sep / 2) && mb->get_position().y < (mid_h + v_sep / 2);
+ dragging_h = mb->get_position().x > (mid_w - h_sep / 2) && mb->get_position().x < (mid_w + h_sep / 2);
+ dragging_v = mb->get_position().y > (mid_h - v_sep / 2) && mb->get_position().y < (mid_h + v_sep / 2);
- drag_begin_pos = mb->get_position();
- drag_begin_ratio.x = ratio_h;
- drag_begin_ratio.y = ratio_v;
+ drag_begin_pos = mb->get_position();
+ drag_begin_ratio.x = ratio_h;
+ drag_begin_ratio.y = ratio_v;
- switch (view) {
- case VIEW_USE_1_VIEWPORT: {
+ switch (view) {
+ case VIEW_USE_1_VIEWPORT: {
- dragging_h = false;
- dragging_v = false;
-
- } break;
- case VIEW_USE_2_VIEWPORTS: {
-
- dragging_h = false;
+ dragging_h = false;
+ dragging_v = false;
- } break;
- case VIEW_USE_2_VIEWPORTS_ALT: {
+ } break;
+ case VIEW_USE_2_VIEWPORTS: {
- dragging_v = false;
+ dragging_h = false;
- } break;
- case VIEW_USE_3_VIEWPORTS: {
+ } break;
+ case VIEW_USE_2_VIEWPORTS_ALT: {
- if (dragging_v)
- dragging_h = false;
- else
dragging_v = false;
- } break;
- case VIEW_USE_3_VIEWPORTS_ALT: {
+ } break;
+ case VIEW_USE_3_VIEWPORTS:
+ case VIEW_USE_3_VIEWPORTS_ALT:
+ case VIEW_USE_4_VIEWPORTS: {
- if (dragging_h)
- dragging_v = false;
- else
- dragging_h = false;
- } break;
- case VIEW_USE_4_VIEWPORTS: {
+ // Do nothing.
- } break;
+ } break;
+ }
+ } else {
+ dragging_h = false;
+ dragging_v = false;
}
}
- if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
- dragging_h = false;
- dragging_v = false;
- }
-
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid() && (dragging_h || dragging_v)) {
+ if (mm.is_valid()) {
+
+ if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) {
+ Vector2 size = get_size();
+
+ int h_sep = get_constant("separation", "HSplitContainer");
+ int v_sep = get_constant("separation", "VSplitContainer");
+
+ int mid_w = size.width * ratio_h;
+ int mid_h = size.height * ratio_v;
+
+ bool was_hovering_h = hovering_h;
+ bool was_hovering_v = hovering_v;
+ hovering_h = mm->get_position().x > (mid_w - h_sep / 2) && mm->get_position().x < (mid_w + h_sep / 2);
+ hovering_v = mm->get_position().y > (mid_h - v_sep / 2) && mm->get_position().y < (mid_h + v_sep / 2);
+
+ if (was_hovering_h != hovering_h || was_hovering_v != hovering_v) {
+ update();
+ }
+ }
if (dragging_h) {
float new_ratio = drag_begin_ratio.x + (mm->get_position().x - drag_begin_pos.x) / get_size().width;
@@ -3635,9 +3643,12 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && mouseover) {
Ref<Texture> h_grabber = get_icon("grabber", "HSplitContainer");
-
Ref<Texture> v_grabber = get_icon("grabber", "VSplitContainer");
+ Ref<Texture> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
+ Ref<Texture> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
+ Ref<Texture> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
+
Vector2 size = get_size();
int h_sep = get_constant("separation", "HSplitContainer");
@@ -3654,35 +3665,62 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
case VIEW_USE_1_VIEWPORT: {
- //nothing to show
+ // Nothing to show.
} break;
case VIEW_USE_2_VIEWPORTS: {
draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
} break;
case VIEW_USE_2_VIEWPORTS_ALT: {
draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
} break;
case VIEW_USE_3_VIEWPORTS: {
- draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
- draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2));
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4));
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, mid_h + v_grabber->get_height() / 2 + (size_bottom - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
} break;
case VIEW_USE_3_VIEWPORTS_ALT: {
- draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
- draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, Vector2((size_left - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2));
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2));
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
+
} break;
case VIEW_USE_4_VIEWPORTS: {
Vector2 half(mid_w, mid_h);
- draw_texture(v_grabber, half - v_grabber->get_size() / 2.0);
- draw_texture(h_grabber, half - h_grabber->get_size() / 2.0);
+ if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) {
+ draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_DRAG);
+ } else if ((hovering_v && !dragging_h) || dragging_v) {
+ draw_texture(v_grabber, half - v_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_VSPLIT);
+ } else if (hovering_h || dragging_h) {
+ draw_texture(h_grabber, half - h_grabber->get_size() / 2.0);
+ set_default_cursor_shape(CURSOR_HSPLIT);
+ }
} break;
}
@@ -3726,6 +3764,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
case VIEW_USE_1_VIEWPORT: {
+ viewports[0]->show();
for (int i = 1; i < 4; i++) {
viewports[i]->hide();
@@ -3736,7 +3775,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_2_VIEWPORTS: {
- for (int i = 1; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
if (i == 1 || i == 3)
viewports[i]->hide();
@@ -3750,7 +3789,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_2_VIEWPORTS_ALT: {
- for (int i = 1; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
if (i == 1 || i == 3)
viewports[i]->hide();
@@ -3763,7 +3802,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_3_VIEWPORTS: {
- for (int i = 1; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
if (i == 1)
viewports[i]->hide();
@@ -3778,7 +3817,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_3_VIEWPORTS_ALT: {
- for (int i = 1; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
if (i == 1)
viewports[i]->hide();
@@ -3793,7 +3832,7 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
} break;
case VIEW_USE_4_VIEWPORTS: {
- for (int i = 1; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
viewports[i]->show();
}
@@ -3826,10 +3865,13 @@ void SpatialEditorViewportContainer::_bind_methods() {
SpatialEditorViewportContainer::SpatialEditorViewportContainer() {
+ set_clip_contents(true);
view = VIEW_USE_1_VIEWPORT;
mouseover = false;
ratio_h = 0.5;
ratio_v = 0.5;
+ hovering_v = false;
+ hovering_h = false;
dragging_v = false;
dragging_h = false;
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 773739d6e0..c552f21e39 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -404,6 +404,7 @@ public:
AcceptDialog *p_accept);
Viewport *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);
};
@@ -443,6 +444,9 @@ private:
float ratio_h;
float ratio_v;
+ bool hovering_v;
+ bool hovering_h;
+
bool dragging_v;
bool dragging_h;
Vector2 drag_begin_pos;
@@ -707,7 +711,6 @@ public:
void register_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> ref);
- Camera *get_camera() { return NULL; }
void edit(Spatial *p_spatial);
void clear();