summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-05-11 11:46:08 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-05-11 11:59:03 -0300
commitd7318f69653ca090575d1243256fcafe8d9ca25f (patch)
tree6de8054581185e42e987c1820bb8284d2519bc07 /scene/main
parent41db10a8ae6702709343b6b2cd38b0f5497cce38 (diff)
-begun implementing drag & drop editor wide
-filesystem dock dnd support -property list dnd support -scene tree dnd support
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp2
-rw-r--r--scene/main/node.h2
-rw-r--r--scene/main/viewport.cpp35
-rw-r--r--scene/main/viewport.h2
4 files changed, 40 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 8475ca0b39..da14fa1111 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2095,6 +2095,8 @@ void Node::_bind_methods() {
BIND_CONSTANT( NOTIFICATION_PAUSED );
BIND_CONSTANT( NOTIFICATION_UNPAUSED );
BIND_CONSTANT( NOTIFICATION_INSTANCED );
+ BIND_CONSTANT( NOTIFICATION_DRAG_BEGIN );
+ BIND_CONSTANT( NOTIFICATION_DRAG_END );
diff --git a/scene/main/node.h b/scene/main/node.h
index 560a2e588a..83086bb0cf 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -180,6 +180,8 @@ public:
NOTIFICATION_PARENTED=18,
NOTIFICATION_UNPARENTED=19,
NOTIFICATION_INSTANCED=20,
+ NOTIFICATION_DRAG_BEGIN=21,
+ NOTIFICATION_DRAG_END=22,
};
/* NODE/TREE */
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5017ae61ff..265ee53e58 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -985,6 +985,16 @@ void Viewport::_propagate_enter_world(Node *p_node) {
}
}
+void Viewport::_propagate_viewport_notification(Node* p_node,int p_what) {
+
+ p_node->notification(p_what);
+ for(int i=0;i<p_node->get_child_count();i++) {
+ Node *c = p_node->get_child(i);
+ if (c->cast_to<Viewport>())
+ continue;
+ _propagate_viewport_notification(c,p_what);
+ }
+}
void Viewport::_propagate_exit_world(Node *p_node) {
@@ -1676,6 +1686,9 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (p_event.mouse_button.button_index==BUTTON_LEFT) {
gui.drag_accum=Vector2();
gui.drag_attempted=false;
+ if (gui.drag_data.get_type()!=Variant::NIL) {
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ }
gui.drag_data=Variant();
}
@@ -1736,6 +1749,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_over->drop_data(pos,gui.drag_data);
gui.drag_data=Variant();
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
//change mouse accordingly
}
@@ -1759,6 +1773,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
gui.drag_data=Variant(); //always clear
}
@@ -1790,6 +1805,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_focus=NULL;
}
gui.drag_attempted=true;
+ if (gui.drag_data.get_type()!=Variant::NIL) {
+
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_BEGIN);
+ }
}
}
@@ -1814,6 +1833,8 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
}
+
+
if (over!=gui.mouse_over) {
if (gui.mouse_over)
@@ -1896,7 +1917,15 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
- /*bool can_drop =*/ over->can_drop_data(pos,gui.drag_data);
+
+ bool can_drop = over->can_drop_data(pos,gui.drag_data);
+
+ if (!can_drop) {
+ OS::get_singleton()->set_cursor_shape( OS::CURSOR_FORBIDDEN );
+ } else {
+ OS::get_singleton()->set_cursor_shape( OS::CURSOR_CAN_DROP );
+
+ }
//change mouse accordingly i guess
}
@@ -2367,6 +2396,9 @@ bool Viewport::is_input_disabled() const {
return disable_input;
}
+Variant Viewport::gui_get_drag_data() const {
+ return gui.drag_data;
+}
void Viewport::_bind_methods() {
@@ -2452,6 +2484,7 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
ObjectTypeDB::bind_method(_MD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
+ ObjectTypeDB::bind_method(_MD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
ObjectTypeDB::bind_method(_MD("set_disable_input","disable"), &Viewport::set_disable_input);
ObjectTypeDB::bind_method(_MD("is_input_disabled"), &Viewport::is_input_disabled);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index afabd499a9..6107cf570f 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -159,6 +159,7 @@ friend class RenderTargetTexture;
void _propagate_enter_world(Node *p_node);
void _propagate_exit_world(Node *p_node);
+ void _propagate_viewport_notification(Node *p_node, int p_what);
void _update_stretch_transform();
@@ -361,6 +362,7 @@ public:
bool gui_has_modal_stack() const;
+ Variant gui_get_drag_data() const;
Viewport();
~Viewport();