diff --git a/include/osgUI/Dialog b/include/osgUI/Dialog index cfd5aab26..a4dee645f 100644 --- a/include/osgUI/Dialog +++ b/include/osgUI/Dialog @@ -16,7 +16,6 @@ #include #include -#include namespace osgUI { @@ -44,7 +43,7 @@ protected: std::string _title; - osg::ref_ptr _transform; + osg::ref_ptr _group; // implementation detail osg::ref_ptr _titleDrawable; diff --git a/src/osgUI/Dialog.cpp b/src/osgUI/Dialog.cpp index f9348bfab..d3d61d227 100644 --- a/src/osgUI/Dialog.cpp +++ b/src/osgUI/Dialog.cpp @@ -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 = style->createText(titleBarExents, getAlignmentSettings(), getTextSettings(), _title); _titleDrawable = dynamic_cast(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()); } diff --git a/src/osgUI/Popup.cpp b/src/osgUI/Popup.cpp index 4c6f64739..6533691c4 100644 --- a/src/osgUI/Popup.cpp +++ b/src/osgUI/Popup.cpp @@ -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() diff --git a/src/osgUI/Widget.cpp b/src/osgUI/Widget.cpp index a4dabc95f..86986bbf8 100644 --- a/src/osgUI/Widget.cpp +++ b/src/osgUI/Widget.cpp @@ -198,34 +198,46 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv) osgGA::EventVisitor* ev = dynamic_cast(&nv); if (ev) { - - updateFocus(nv); - - // OSG_NOTICE<<"EventTraversal getHasEventFocus()="<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()="<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); } }