summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-04-05 12:39:30 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-04-05 12:39:30 -0300
commit9f33134c93ecbadda70e8eefc50563e29b2eb7f2 (patch)
tree299ded94fe74a61bf8094935d0f3283f6f30e435 /scene/2d
parent35b84d2c85fd152bee05d7d5a05e20a5f602a285 (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/2d')
-rw-r--r--scene/2d/canvas_item.cpp25
-rw-r--r--scene/2d/canvas_item.h9
2 files changed, 21 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;