summaryrefslogtreecommitdiff
path: root/scene/2d/canvas_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/canvas_item.cpp')
-rw-r--r--scene/2d/canvas_item.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 17e5503a2d..8864459dfb 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;i<get_child_count();i++) {
+ CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
+ 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) {