summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-19 20:27:27 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-19 20:28:20 -0300
commit891e31b139b269fb154d30b8c7d7887267708d8b (patch)
tree65e3c85540d003200592dd2847fe148bee01ad7d /scene/gui
parentd67df42cc864c3bc5cd1911406e284c3cb84f8e8 (diff)
-Some fixes to drag and drop and canvas offset for GUI that were introduced after rewrite
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp24
-rw-r--r--scene/gui/control.h2
2 files changed, 24 insertions, 2 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 90c72989bd..8f6a0b4d53 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -606,14 +606,14 @@ void Control::force_drag(const Variant& p_data,Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
- get_viewport()->_gui_force_drag(p_data,p_control);
+ get_viewport()->_gui_force_drag(this,p_data,p_control);
}
void Control::set_drag_preview(Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
- get_viewport()->_gui_set_drag_preview(p_control);
+ get_viewport()->_gui_set_drag_preview(this,p_control);
}
@@ -2046,6 +2046,26 @@ Vector2 Control::get_scale() const{
return data.scale;
}
+Control *Control::get_root_parent_control() const {
+
+ const CanvasItem *ci=this;
+ const Control *root=this;
+
+ while(ci) {
+
+ const Control *c = ci->cast_to<Control>();
+ if (c) {
+ root=c;
+
+ if (c->data.RI || c->data.MI || c->is_toplevel_control())
+ break;
+ }
+
+ ci=ci->get_parent_item();
+ }
+
+ return const_cast<Control*>(root);
+}
void Control::_bind_methods() {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index ab777a6a6c..a16d88a6df 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -360,6 +360,8 @@ public:
virtual bool is_text_field() const;
+ Control *get_root_parent_control() const;
+
Control();
~Control();