diff options
author | romulox_x <romulox_x@yahoo.com> | 2015-11-26 13:44:06 -0800 |
---|---|---|
committer | romulox_x <romulox_x@yahoo.com> | 2015-11-26 13:44:06 -0800 |
commit | 0b4830f3bebaaec75cecf48253068d35bb344859 (patch) | |
tree | 3cedd3d30289913a9a6292c787c8ea9b7f3d1592 /scene | |
parent | a1059e3e3e54e9921c0426c8a5c9faf595175cf0 (diff) |
Added set_hidden method to Spatial and CanvasItem
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/canvas_item.cpp | 10 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 1 | ||||
-rw-r--r-- | scene/3d/spatial.cpp | 10 | ||||
-rw-r--r-- | scene/3d/spatial.h | 1 |
4 files changed, 22 insertions, 0 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 357aaa225b..abd532c156 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -309,6 +309,15 @@ 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 { @@ -1043,6 +1052,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden); ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show); ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden); ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 4885256c64..667fedc956 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -190,6 +190,7 @@ public: bool is_hidden() const; void show(); void hide(); + void set_hidden(bool p_hidden); void update(); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index a65f68ed2c..7d48420a83 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -594,6 +594,15 @@ bool Spatial::is_hidden() const{ return !data.visible; } +void Spatial::set_hidden(bool p_hidden) { + + if (data.visible != p_hidden) { + return; + } + + _set_visible_(!p_hidden); +} + void Spatial::_set_visible_(bool p_visible) { if (p_visible) @@ -742,6 +751,7 @@ void Spatial::_bind_methods() { ObjectTypeDB::bind_method(_MD("hide"), &Spatial::hide); ObjectTypeDB::bind_method(_MD("is_visible"), &Spatial::is_visible); ObjectTypeDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden); ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_); ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 7fa6099d7a..b1e3a82868 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -191,6 +191,7 @@ public: void hide(); bool is_visible() const; bool is_hidden() const; + void set_hidden(bool p_hidden); #ifdef TOOLS_ENABLED void set_import_transform(const Transform& p_transform) ; |