summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/canvas_item.cpp49
-rw-r--r--scene/2d/canvas_item.h8
-rw-r--r--scene/2d/canvas_modulate.cpp8
-rw-r--r--scene/2d/collision_object_2d.cpp2
-rw-r--r--scene/2d/light_2d.cpp2
-rw-r--r--scene/2d/light_occluder_2d.cpp4
-rw-r--r--scene/2d/navigation_polygon.cpp2
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/screen_button.cpp2
9 files changed, 29 insertions, 50 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index d48cfb1b15..0a3e06602b 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;
@@ -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;
}
@@ -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);
@@ -1010,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") );
@@ -1125,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);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 9865ad04a0..9688b873c0 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -109,7 +109,7 @@ private:
int light_mask;
bool first_draw;
- bool hidden;
+ bool visible;
bool pending_update;
bool toplevel;
bool drawing;
@@ -129,8 +129,6 @@ private:
void _propagate_visibility_changed(bool p_visible);
- void _set_visible_(bool p_visible);
- bool _is_visible_() const;
void _update_callback();
@@ -174,11 +172,11 @@ public:
/* VISIBILITY */
+ void set_visible(bool p_visible);
bool is_visible() const;
- bool is_hidden() const;
+ bool is_visible_in_tree() const;
void show();
void hide();
- void set_hidden(bool p_hidden);
void update();
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 583f03eab1..138589651c 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -33,7 +33,7 @@ void CanvasModulate::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
@@ -42,13 +42,13 @@ void CanvasModulate::_notification(int p_what) {
} else if (p_what==NOTIFICATION_EXIT_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
} else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
} else {
@@ -83,7 +83,7 @@ Color CanvasModulate::get_color() const {
String CanvasModulate::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
List<Node*> nodes;
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index af070dc825..e90bf8b96e 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -212,7 +212,7 @@ void CollisionObject2D::_mouse_exit() {
void CollisionObject2D::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = this->pickable && is_inside_tree() && is_visible();
+ bool pickable = this->pickable && is_inside_tree() && is_visible_in_tree();
if (area)
Physics2DServer::get_singleton()->area_set_pickable(rid,pickable);
else
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 07fce58fc0..2935f6b9f7 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -83,7 +83,7 @@ void Light2D::_update_light_visibility() {
}
#endif
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok);
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible_in_tree() && editor_ok);
}
void Light2D::set_enabled( bool p_enabled) {
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index a9e654e699..77c9b8184a 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -123,7 +123,7 @@ void LightOccluder2D::_notification(int p_what) {
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
@@ -132,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) {
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_DRAW) {
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 26047a7426..b91b2d4f56 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -459,7 +459,7 @@ void NavigationPolygonInstance::_navpoly_changed() {
String NavigationPolygonInstance::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!navpoly.is_valid()) {
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 0508a715eb..e1d1920cc5 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -239,7 +239,7 @@ void PathFollow2D::_get_property_list( List<PropertyInfo> *p_list) const{
String PathFollow2D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!get_parent() || !get_parent()->cast_to<Path2D>()) {
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 3aacd7091a..99147b0a39 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -236,7 +236,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (p_event.screen_touch.pressed) {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if (finger_pressed!=-1)