Implemented Widger::Visible and Enabled usage

This commit is contained in:
Robert Osfield 2014-05-26 16:27:33 +00:00
parent b04a4813ba
commit 5d635287c0
4 changed files with 39 additions and 28 deletions

View File

@ -16,7 +16,6 @@
#include <osgUI/Widget>
#include <osgText/Text>
#include <osg/PositionAttitudeTransform>
namespace osgUI
{
@ -44,7 +43,7 @@ protected:
std::string _title;
osg::ref_ptr<osg::PositionAttitudeTransform> _transform;
osg::ref_ptr<osg::Group> _group;
// implementation detail
osg::ref_ptr<osgText::Text> _titleDrawable;

View File

@ -59,17 +59,17 @@ bool Dialog::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
void Dialog::close()
{
if (_transform.valid()) _transform->setNodeMask(0x0);
setVisible(false);
}
void Dialog::open()
{
if (_transform.valid()) _transform->setNodeMask(0xffffffff);
setVisible(true);
}
void Dialog::createGraphicsImplementation()
{
_transform = new osg::PositionAttitudeTransform;
_group = new osg::Group;
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
@ -79,8 +79,8 @@ void Dialog::createGraphicsImplementation()
osg::Vec4 dialogBackgroundColor(0.8,0.8,0.8,1.0);
osg::Vec4 dialogTitleBackgroundColor(0.5,0.5,1.0,1.0);
_transform->addChild( style->createPanel(_extents, dialogBackgroundColor) );
_transform->addChild( style->createPanel(titleBarExents, dialogTitleBackgroundColor) );
_group->addChild( style->createPanel(_extents, dialogBackgroundColor) );
_group->addChild( style->createPanel(titleBarExents, dialogTitleBackgroundColor) );
osg::BoundingBox dialogWithTileExtents(_extents);
dialogWithTileExtents.expandBy(titleBarExents);
@ -92,10 +92,10 @@ void Dialog::createGraphicsImplementation()
osg::ref_ptr<Node> node = style->createText(titleBarExents, getAlignmentSettings(), getTextSettings(), _title);
_titleDrawable = dynamic_cast<osgText::Text*>(node.get());
_titleDrawable->setDataVariance(osg::Object::DYNAMIC);
_transform->addChild(_titleDrawable.get());
_group->addChild(_titleDrawable.get());
style->setupDialogStateSet(getOrCreateStateSet());
style->setupClipStateSet(dialogWithTileExtents, getOrCreateStateSet());
setGraphicsSubgraph(_transform.get());
setGraphicsSubgraph(_group.get());
}

View File

@ -61,12 +61,12 @@ bool Popup::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
void Popup::close()
{
if (_transform.valid()) _transform->setNodeMask(0x0);
setVisible(false);
}
void Popup::open()
{
if (_transform.valid()) _transform->setNodeMask(0xffffffff);
setVisible(true);
}
void Popup::leaveImplementation()

View File

@ -197,6 +197,8 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
if (ev)
{
if (_visible && _enabled)
{
updateFocus(nv);
@ -222,10 +224,20 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
osg::Group::traverse(nv);
}
}
else if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR ||
nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
{
if (_visible)
{
if (_graphicsSubgraph.valid()) _graphicsSubgraph->accept(nv);
osg::Group::traverse(nv);
}
}
else
{
if (_graphicsSubgraph.valid()) _graphicsSubgraph->accept(nv);
osg::Group::traverse(nv);
}
}