Implemented Widger::Visible and Enabled usage
This commit is contained in:
parent
b04a4813ba
commit
5d635287c0
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -198,34 +198,46 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
if (ev)
|
||||
{
|
||||
|
||||
updateFocus(nv);
|
||||
|
||||
// OSG_NOTICE<<"EventTraversal getHasEventFocus()="<<getHasEventFocus()<<std::endl;
|
||||
|
||||
if (getHasEventFocus())
|
||||
if (_visible && _enabled)
|
||||
{
|
||||
// signify that event has been taken by widget with focus
|
||||
ev->setEventHandled(true);
|
||||
|
||||
osgGA::EventQueue::Events& events = ev->getEvents();
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
updateFocus(nv);
|
||||
|
||||
// OSG_NOTICE<<"EventTraversal getHasEventFocus()="<<getHasEventFocus()<<std::endl;
|
||||
|
||||
if (getHasEventFocus())
|
||||
{
|
||||
if (handle(ev, itr->get()))
|
||||
// signify that event has been taken by widget with focus
|
||||
ev->setEventHandled(true);
|
||||
|
||||
osgGA::EventQueue::Events& events = ev->getEvents();
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setHandled(true);
|
||||
if (handle(ev, itr->get()))
|
||||
{
|
||||
(*itr)->setHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
osg::Group::traverse(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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user