diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 17e5503a2d7..8864459dfb2 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1042,7 +1042,9 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate); ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect); + ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect); //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); + ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item); ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible); @@ -1195,6 +1197,23 @@ int CanvasItem::get_canvas_layer() const { return 0; } + +Rect2 CanvasItem::get_item_and_children_rect() const { + + Rect2 rect = get_item_rect(); + + + for(int i=0;icast_to(); + if (c) { + Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect()); + rect = rect.merge(sir); + } + } + + return rect; +} + CanvasItem::CanvasItem() : xform_change(this) { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 05a2e725e9a..d915f742ec5 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -240,6 +240,8 @@ public: virtual Matrix32 get_global_transform() const; virtual Matrix32 get_global_transform_with_canvas() const; + Rect2 get_item_and_children_rect() const; + CanvasItem *get_toplevel() const; _FORCE_INLINE_ RID get_canvas_item() const { return canvas_item; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 534bcbf16a4..b122ab4183e 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -447,7 +447,7 @@ void Control::_notification(int p_notification) { Node *parent=this; //meh - Node *parent_control=NULL; + Control *parent_control=NULL; bool subwindow=false; while(parent) { @@ -463,8 +463,9 @@ void Control::_notification(int p_notification) { break; } - if (parent->cast_to()) { - parent_control=parent->cast_to(); + parent_control=parent->cast_to(); + + if (parent_control) { break; } else if (ci) {