diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-04-05 12:39:30 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-04-05 12:39:30 -0300 |
commit | 9f33134c93ecbadda70e8eefc50563e29b2eb7f2 (patch) | |
tree | 299ded94fe74a61bf8094935d0f3283f6f30e435 /scene | |
parent | 35b84d2c85fd152bee05d7d5a05e20a5f602a285 (diff) |
-Support for changing fonts
-Detect when free() might crash the project and throw error
-fixed 2D Bounce in physics (3d still broken)
-renamed “on_top” property to “behind_parent”, which makes more sense, old on_top remains there for compatibility but is invisible.
-large amount of fixes
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/canvas_item.cpp | 25 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 9 | ||||
-rw-r--r-- | scene/gui/control.cpp | 2 | ||||
-rw-r--r-- | scene/main/node.h | 2 |
4 files changed, 25 insertions, 13 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 8a461c76fc..0f87d52d63 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -715,17 +715,18 @@ bool CanvasItem::is_block_transform_notify_enabled() const { return block_transform_notify; } -void CanvasItem::set_on_top(bool p_on_top) { +void CanvasItem::set_draw_behind_parent(bool p_enable) { - if (on_top==p_on_top) + if (behind==p_enable) return; - on_top=p_on_top; - VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,on_top); + behind=p_enable; + VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind); + } -bool CanvasItem::is_on_top() const { +bool CanvasItem::is_draw_behind_parent_enabled() const{ - return on_top; + return behind; } @@ -764,8 +765,11 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity); ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity); - ObjectTypeDB::bind_method(_MD("set_on_top","on_top"),&CanvasItem::set_on_top); - ObjectTypeDB::bind_method(_MD("is_on_top"),&CanvasItem::is_on_top); + ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enabe"),&CanvasItem::set_draw_behind_parent); + ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled); + + ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top); + ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top); //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); @@ -796,7 +800,8 @@ void CanvasItem::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") ); ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top"), _SCS("set_on_top"),_SCS("is_on_top") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), _SCS("set_blend_mode"),_SCS("get_blend_mode") ); //exporting these two things doesn't really make much sense i think @@ -859,7 +864,7 @@ CanvasItem::CanvasItem() : xform_change(this) { first_draw=false; blend_mode=BLEND_MODE_MIX; drawing=false; - on_top=true; + behind=false; block_transform_notify=false; viewport=NULL; canvas_layer=NULL; diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 0da4aa3086..5489e105d9 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -77,7 +77,7 @@ private: bool pending_children_sort; bool drawing; bool block_transform_notify; - bool on_top; + bool behind; mutable Matrix32 global_transform; mutable bool global_invalid; @@ -102,6 +102,9 @@ private: void _notify_transform(CanvasItem *p_node); + void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); } + bool _is_on_top() const { return !is_draw_behind_parent_enabled(); } + protected: @@ -175,8 +178,8 @@ public: void set_as_toplevel(bool p_toplevel); bool is_set_as_toplevel() const; - void set_on_top(bool p_on_top); - bool is_on_top() const; + void set_draw_behind_parent(bool p_enable); + bool is_draw_behind_parent_enabled() const; CanvasItem *get_parent_item() const; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 53d36e64ea..83c0397554 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -351,11 +351,13 @@ void Control::_notification(int p_notification) { window->tooltip_timer = memnew( Timer ); add_child(window->tooltip_timer); + window->tooltip_timer->force_parent_owned(); window->tooltip_timer->set_wait_time( GLOBAL_DEF("display/tooltip_delay",0.7)); window->tooltip_timer->connect("timeout",this,"_window_show_tooltip"); window->tooltip=NULL; window->tooltip_popup = memnew( TooltipPanel ); add_child(window->tooltip_popup); + window->tooltip_popup->force_parent_owned(); window->tooltip_label = memnew( TooltipLabel ); window->tooltip_popup->add_child(window->tooltip_label); window->tooltip_popup->set_as_toplevel(true); diff --git a/scene/main/node.h b/scene/main/node.h index ec03fb19e8..828acb8de7 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -264,6 +264,8 @@ public: static void set_human_readable_collision_renaming(bool p_enabled); static void init_node_hrcr(); + void force_parent_owned() { data.parent_owned=true; } //hack to avoid duplicate nodes + /* CANVAS */ Node(); |