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.cpp77
1 files changed, 37 insertions, 40 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index b7d9ba7860..817707f96e 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -182,7 +182,7 @@ CanvasItemMaterial::~CanvasItemMaterial(){
-bool CanvasItem::is_visible() const {
+bool CanvasItem::is_visible_in_tree() const {
if (!is_inside_tree())
return false;
@@ -190,7 +190,7 @@ bool CanvasItem::is_visible() const {
const CanvasItem *p=this;
while(p) {
- if (p->hidden)
+ if (!p->visible)
return false;
p=p->get_parent_item();
}
@@ -199,13 +199,6 @@ bool CanvasItem::is_visible() const {
return true;
}
-bool CanvasItem::is_hidden() const {
-
- /*if (!is_inside_scene())
- return false;*/
-
- return hidden;
-}
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
@@ -221,7 +214,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
- if (c && !c->hidden) //should the toplevels stop propagation? i think so but..
+ if (c && c->visible) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
}
@@ -231,10 +224,10 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
void CanvasItem::show() {
- if (!hidden)
+ if (visible)
return;
- hidden=false;
+ visible=true;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true);
if (!is_inside_tree())
@@ -247,10 +240,10 @@ void CanvasItem::show() {
void CanvasItem::hide() {
- if (hidden)
+ if (!visible)
return;
- hidden=true;
+ visible=false;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
if (!is_inside_tree())
@@ -260,16 +253,6 @@ void CanvasItem::hide() {
_change_notify("visibility/visible");
}
-void CanvasItem::set_hidden(bool p_hidden) {
-
- if (hidden == p_hidden) {
- return;
- }
-
- _set_visible_(!p_hidden);
-}
-
-
Variant CanvasItem::edit_get_state() const {
@@ -306,7 +289,7 @@ void CanvasItem::_update_callback() {
VisualServer::get_singleton()->canvas_item_clear(get_canvas_item());
//todo updating = true - only allow drawing here
- if (is_visible()) { //todo optimize this!!
+ if (is_visible_in_tree()) { //todo optimize this!!
if (first_draw) {
notification(NOTIFICATION_VISIBILITY_CHANGED);
first_draw=false;
@@ -411,7 +394,7 @@ void CanvasItem::_enter_canvas() {
else
get_viewport()->gui_reset_canvas_sort_index();
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
@@ -461,7 +444,7 @@ void CanvasItem::_notification(int p_what) {
break;
if (group!="") {
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
@@ -495,16 +478,16 @@ void CanvasItem::_notification(int p_what) {
}
}
-void CanvasItem::_set_visible_(bool p_visible) {
+void CanvasItem::set_visible(bool p_visible) {
if (p_visible)
show();
else
hide();
}
-bool CanvasItem::_is_visible_() const {
+bool CanvasItem::is_visible() const {
- return !is_hidden();
+ return visible;
}
@@ -769,7 +752,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
p_node->global_invalid=true;
- if (!p_node->xform_change.in_list()) {
+ if (notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
if (p_node->is_inside_tree())
get_tree()->xform_change_list.add(&p_node->xform_change);
@@ -835,7 +818,7 @@ Ref<World2D> CanvasItem::get_world_2d() const {
RID CanvasItem::get_viewport_rid() const {
ERR_FAIL_COND_V(!is_inside_tree(),RID());
- return get_viewport()->get_viewport();
+ return get_viewport()->get_viewport_rid();
}
void CanvasItem::set_block_transform_notify(bool p_enable) {
@@ -924,8 +907,6 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(_MD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self);
ClassDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
- ClassDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
- ClassDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
ClassDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
ClassDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
@@ -938,11 +919,11 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);
+ ClassDB::bind_method(_MD("set_visible"),&CanvasItem::set_visible);
ClassDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
- ClassDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
+ ClassDB::bind_method(_MD("is_visible_in_tree"),&CanvasItem::is_visible_in_tree);
ClassDB::bind_method(_MD("show"),&CanvasItem::show);
ClassDB::bind_method(_MD("hide"),&CanvasItem::hide);
- ClassDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden);
ClassDB::bind_method(_MD("update"),&CanvasItem::update);
@@ -997,6 +978,12 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
+ ClassDB::bind_method(_MD("set_notify_local_transform","enable"),&CanvasItem::set_notify_local_transform);
+ ClassDB::bind_method(_MD("is_local_transform_notification_enabled"),&CanvasItem::is_local_transform_notification_enabled);
+
+ ClassDB::bind_method(_MD("set_notify_transform","enable"),&CanvasItem::set_notify_transform);
+ ClassDB::bind_method(_MD("is_transform_notification_enabled"),&CanvasItem::is_transform_notification_enabled);
+
ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
&CanvasItem::make_canvas_pos_local);
ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
@@ -1004,7 +991,7 @@ void CanvasItem::_bind_methods() {
BIND_VMETHOD(MethodInfo("_draw"));
ADD_GROUP("Visibility","");
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("set_visible"),_SCS("is_visible") );
ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"self_modulate"), _SCS("set_self_modulate"),_SCS("get_self_modulate") );
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"show_behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
@@ -1081,6 +1068,15 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
return notify_local_transform;
}
+
+void CanvasItem::set_notify_transform(bool p_enable) {
+ notify_transform=p_enable;
+}
+
+bool CanvasItem::is_transform_notification_enabled() const {
+ return notify_transform;
+}
+
int CanvasItem::get_canvas_layer() const {
if (canvas_layer)
@@ -1110,7 +1106,7 @@ CanvasItem::CanvasItem() : xform_change(this) {
canvas_item=VisualServer::get_singleton()->canvas_item_create();
- hidden=false;
+ visible=true;
pending_update=false;
modulate=Color(1,1,1,1);
self_modulate=Color(1,1,1,1);
@@ -1118,12 +1114,13 @@ CanvasItem::CanvasItem() : xform_change(this) {
first_draw=false;
drawing=false;
behind=false;
- block_transform_notify=false;
-// viewport=NULL;
+ block_transform_notify=false;
+ //viewport=NULL;
canvas_layer=NULL;
use_parent_material=false;
global_invalid=true;
notify_local_transform=false;
+ notify_transform=false;
light_mask=1;
C=NULL;