diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/canvas_item.cpp | 19 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 2 | ||||
-rw-r--r-- | scene/gui/control.cpp | 9 | ||||
-rw-r--r-- | scene/main/node.cpp | 17 | ||||
-rw-r--r-- | scene/resources/dynamic_font.cpp | 6 |
5 files changed, 46 insertions, 7 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) { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 05a2e725e9..d915f742ec 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 534bcbf16a..666ac88055 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<Control>()) { - parent_control=parent->cast_to<Control>(); + parent_control=parent->cast_to<Control>(); + + if (parent_control) { break; } else if (ci) { @@ -1843,7 +1844,7 @@ void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) { Control *c = p_at->cast_to<Control>(); - if (c && c->data.theme.is_valid()) // has a theme, this can't be propagated + if (c && c!=p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated return; for(int i=0;i<p_at->get_child_count();i++) { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index cfc7116d19..50b0fe224e 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -283,7 +283,11 @@ void Node::move_child(Node *p_child,int p_pos) { ERR_FAIL_INDEX( p_pos, data.children.size()+1 ); ERR_EXPLAIN("child is not a child of this node."); ERR_FAIL_COND(p_child->data.parent!=this); - ERR_FAIL_COND(data.blocked>0); + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, move_child() failed. Consider using call_deferred(\"move_child\") instead (or \"popup\" if this is from a popup)."); + ERR_FAIL_COND(data.blocked>0); + } + data.children.remove( p_child->data.pos ); data.children.insert( p_pos, p_child ); @@ -739,6 +743,12 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) { } ERR_EXPLAIN("Can't add child, already has a parent"); ERR_FAIL_COND( p_child->data.parent ); + + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead."); + ERR_FAIL_COND(data.blocked>0); + } + ERR_EXPLAIN("Can't add child while a notification is happening"); ERR_FAIL_COND( data.blocked > 0 ); @@ -800,7 +810,10 @@ void Node::_propagate_validate_owner() { void Node::remove_child(Node *p_child) { ERR_FAIL_NULL(p_child); - ERR_FAIL_COND( data.blocked > 0 ); + if (data.blocked>0) { + ERR_EXPLAIN("Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\",child) instead."); + ERR_FAIL_COND(data.blocked>0); + } int idx=-1; for (int i=0;i<data.children.size();i++) { diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 78a5571bf0..1edae01754 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -573,7 +573,11 @@ DynamicFontAtSize::~DynamicFontAtSize(){ void DynamicFont::set_font_data(const Ref<DynamicFontData>& p_data) { data=p_data; - data_at_size=data->_get_dynamic_font_at_size(size); + if (data.is_valid()) + data_at_size=data->_get_dynamic_font_at_size(size); + else + data_at_size=Ref<DynamicFontAtSize>(); + emit_changed(); } |