//----------------------------------------------------------------------------
void Element::update(double dt)
{
- if( !_transform->getNodeMask() )
- // Don't do anything if element is hidden
+ if( !isVisible() )
return;
// Trigger matrix update
return _transform->getBound().contains(osg::Vec3f(pos, 0));
}
+ //----------------------------------------------------------------------------
+ void Element::setVisible(bool visible)
+ {
+ if( _transform.valid() )
+ // TODO check if we need another nodemask
+ _transform->setNodeMask(visible ? 0xffffffff : 0);
+ }
+
//----------------------------------------------------------------------------
bool Element::isVisible() const
{
}
else if( name == "update" )
return update(0);
- else if( name == "visible" )
- // TODO check if we need another nodemask
- return _transform->setNodeMask( child->getBoolValue() ? 0xffffffff : 0 );
else if( boost::starts_with(name, "blend-") )
return (void)(_attributes_dirty |= BLEND_FUNC);
}
addStyle("clip", "", &Element::setClip, false);
addStyle("clip-frame", "", &Element::setClipFrame, false);
+ addStyle("visible", "", &Element::setVisible, false);
}
//----------------------------------------------------------------------------
const osg::Vec2f& local_pos ) const;
/**
- * Get whether the element is visible or hidden (Can be changed with
- * setting property "visible" accordingly).
+ * Set visibility of the element.
+ */
+ void setVisible(bool visible);
+
+ /**
+ * Get whether the element is visible or hidden.
*/
bool isVisible() const;