summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp23
-rw-r--r--scene/main/node.h2
-rw-r--r--scene/main/viewport.cpp74
-rw-r--r--scene/main/viewport.h1
4 files changed, 74 insertions, 26 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index bea6e75aef..55106f5ee7 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1206,7 +1206,6 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) {
GroupData gd;
- SceneTree::Group *gptr=NULL;
if (data.tree) {
gd.group=data.tree->add_to_group(p_identifier,this);
} else {
@@ -1513,7 +1512,7 @@ int Node::get_position_in_parent() const {
-Node *Node::duplicate(bool p_use_instancing) const {
+Node *Node::_duplicate(bool p_use_instancing) const {
Node *node=NULL;
@@ -1592,9 +1591,21 @@ Node *Node::duplicate(bool p_use_instancing) const {
node->add_child(dup);
}
+
return node;
}
+Node *Node::duplicate(bool p_use_instancing) const {
+
+ Node* dupe = _duplicate(p_use_instancing);
+
+ if (dupe) {
+ _duplicate_signals(this,dupe);
+ }
+
+ return dupe;
+}
+
void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const {
@@ -1664,12 +1675,13 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_re
void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const {
- if (this!=p_original && get_owner()!=p_original)
+ if (this!=p_original && (get_owner()!=p_original && get_owner()!=p_original->get_owner()))
return;
List<Connection> conns;
get_all_signal_connections(&conns);
+
for (List<Connection>::Element *E=conns.front();E;E=E->next()) {
if (E->get().flags&CONNECT_PERSIST) {
@@ -1678,14 +1690,17 @@ void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const {
Node *copy = p_copy->get_node(p);
Node *target = E->get().target->cast_to<Node>();
- if (!target)
+ if (!target) {
continue;
+ }
NodePath ptarget = p_original->get_path_to(target);
Node *copytarget = p_copy->get_node(ptarget);
+
if (copy && copytarget) {
copy->connect(E->get().signal,copytarget,E->get().method,E->get().binds,CONNECT_PERSIST);
}
+
}
}
diff --git a/scene/main/node.h b/scene/main/node.h
index dcc3829d15..10cfc5f9e6 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -138,6 +138,8 @@ private:
void _duplicate_signals(const Node* p_original,Node* p_copy) const;
void _duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const;
+ Node *_duplicate(bool p_use_instancing) const;
+
Array _get_children() const;
Array _get_groups() const;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index ff8f0d05f1..bb6e6e289b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1083,7 +1083,7 @@ void Viewport::_propagate_exit_world(Node *p_node) {
Spatial *s = p_node->cast_to<Spatial>();
if (s) {
- s->notification(Spatial::NOTIFICATION_EXIT_WORLD,false);
+ s->notification(Spatial::NOTIFICATION_EXIT_WORLD, true);
} else {
Viewport *v = p_node->cast_to<Viewport>();
if (v) {
@@ -1331,11 +1331,11 @@ Matrix32 Viewport::_get_input_pre_xform() const {
Matrix32 pre_xf;
if (render_target) {
- ERR_FAIL_COND_V(to_screen_rect.size.x==0,pre_xf);
- ERR_FAIL_COND_V(to_screen_rect.size.y==0,pre_xf);
+ if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-to_screen_rect.pos;
- pre_xf.scale(rect.size/to_screen_rect.size);
+ pre_xf.elements[2]=-to_screen_rect.pos;
+ pre_xf.scale(rect.size/to_screen_rect.size);
+ }
} else {
pre_xf.elements[2]=-rect.pos;
@@ -1788,15 +1788,12 @@ 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();
}
}
+
p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
@@ -1832,30 +1829,55 @@ void Viewport::_gui_input_event(InputEvent p_event) {
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
+
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+
+ //alternate drop use (when using force_drag(), as proposed by #5342
+ if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos,gui.drag_data)) {
+ gui.mouse_focus->drop_data(pos,gui.drag_data);
+ }
+
+ gui.drag_data=Variant();
+
+ if (gui.drag_preview) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+
+
_gui_cancel_tooltip();
//gui.tooltip_popup->hide();
} else {
- if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
- memdelete( gui.drag_preview );
- gui.drag_preview=NULL;
- }
- if (!gui.mouse_focus) {
- if (gui.mouse_over && gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.mouse_over) {
Size2 pos = mpos;
pos = gui.focus_inv_xform.xform(pos);
if (gui.mouse_over->can_drop_data(pos,gui.drag_data)) {
gui.mouse_over->drop_data(pos,gui.drag_data);
}
- gui.drag_data=Variant();
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
- //change mouse accordingly
}
+ if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+
+ gui.drag_data=Variant();
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+ if (!gui.mouse_focus) {
+ //release event is only sent if a mouse focus (previously pressed button) exists
break;
}
@@ -1875,10 +1897,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_focus_button=-1;
}
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ /*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
- }
+ }*/
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
@@ -2036,7 +2058,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
case InputEvent::JOYSTICK_BUTTON:
case InputEvent::KEY: {
- if (gui.key_focus) {
+
+ if (gui.key_focus && !gui.key_focus->is_visible()) {
+ gui.key_focus->release_focus();
+ }
+
+ if (gui.key_focus) {
gui.key_event_accepted=false;
if (gui.key_focus->can_process()) {
@@ -2176,6 +2203,9 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
void Viewport::_gui_force_drag(Control *p_base, const Variant& p_data, Control *p_control) {
+ ERR_EXPLAIN("Drag data must be a value");
+ ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
+
gui.drag_data=p_data;
gui.mouse_focus=NULL;
@@ -2372,8 +2402,8 @@ void Viewport::input(const InputEvent& p_event) {
ERR_FAIL_COND(!is_inside_tree());
+ get_tree()->_call_input_pause(input_group,"_input",p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
_gui_input_event(p_event);
- get_tree()->_call_input_pause(input_group,"_input",p_event);
//get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index aaa640e0e6..22a97a9888 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -39,6 +39,7 @@
*/
class Camera;
+class Camera2D;
class Listener;
class Control;
class CanvasItem;