Moved the diaglog title bar widgets into the Widget::GraphicsSubgraph map to avoid them poluting the Dialog's children list and to prevent them from being serialized.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14441 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <osgGA/EventVisitor>
|
||||
|
||||
#include <osgUI/Export>
|
||||
#include <osgUI/Widget>
|
||||
|
||||
namespace osgUI
|
||||
{
|
||||
@@ -26,14 +27,19 @@ namespace osgUI
|
||||
class OSGUI_EXPORT CloseCallback : public osg::CallbackObject
|
||||
{
|
||||
public:
|
||||
CloseCallback(const std::string& callbackName=std::string("close"));
|
||||
CloseCallback(const std::string& callbackName=std::string("close"), osgUI::Widget* closeWidget=0);
|
||||
CloseCallback(const CloseCallback& hc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
META_Object(osgUI, CloseCallback);
|
||||
|
||||
void setCloseWidget(osgUI::Widget* widget) { _closeWidget = widget; }
|
||||
osgUI::Widget* getCloseWidget() { return _closeWidget.get(); }
|
||||
const osgUI::Widget* getCloseWidget() const { return _closeWidget.get(); }
|
||||
|
||||
virtual bool run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const;
|
||||
|
||||
protected:
|
||||
virtual ~CloseCallback() {}
|
||||
osg::observer_ptr<osgUI::Widget> _closeWidget;
|
||||
};
|
||||
|
||||
class OSGUI_EXPORT HandleCallback : public osg::CallbackObject
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
using namespace osgUI;
|
||||
|
||||
CloseCallback::CloseCallback(const std::string& callbackName)
|
||||
CloseCallback::CloseCallback(const std::string& callbackName, osgUI::Widget* closeWidget):
|
||||
_closeWidget(closeWidget)
|
||||
{
|
||||
setName(callbackName);
|
||||
}
|
||||
@@ -32,6 +33,11 @@ CloseCallback::CloseCallback(const CloseCallback& hc, const osg::CopyOp& copyop)
|
||||
|
||||
bool CloseCallback::run(osg::Object* object, osg::Parameters&, osg::Parameters&) const
|
||||
{
|
||||
if (_closeWidget.valid())
|
||||
{
|
||||
_closeWidget->setVisible(false);
|
||||
}
|
||||
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
if (node)
|
||||
{
|
||||
|
||||
@@ -102,8 +102,7 @@ void Dialog::createGraphicsImplementation()
|
||||
closeButton->setAlignmentSettings(getAlignmentSettings());
|
||||
closeButton->setTextSettings(getTextSettings());
|
||||
//closeButton->setFrameSettings(getFrameSettings());
|
||||
closeButton->getOrCreateUserDataContainer()->addUserObject(new osgUI::CloseCallback("released"));
|
||||
addChild(closeButton.get());
|
||||
closeButton->getOrCreateUserDataContainer()->addUserObject(new osgUI::CloseCallback("released", this));
|
||||
|
||||
osg::ref_ptr<Label> titleLabel = new osgUI::Label;
|
||||
titleLabel->setExtents(titleBarExtents);
|
||||
@@ -112,7 +111,19 @@ void Dialog::createGraphicsImplementation()
|
||||
titleLabel->setTextSettings(getTextSettings());
|
||||
titleLabel->setFrameSettings(getFrameSettings());
|
||||
titleLabel->getOrCreateUserDataContainer()->addUserObject(new osgUI::DragCallback);
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
_group->addChild(closeButton.get());
|
||||
_group->addChild(titleLabel.get());
|
||||
#else
|
||||
setGraphicsSubgraph(-3, closeButton.get());
|
||||
setGraphicsSubgraph(-2, titleLabel.get());
|
||||
#endif
|
||||
#else
|
||||
addChild(closeButton.get());
|
||||
addChild(titleLabel.get());
|
||||
#endif
|
||||
|
||||
style->setupDialogStateSet(getOrCreateWidgetStateSet(), 5);
|
||||
style->setupClipStateSet(dialogWithTitleExtents, getOrCreateWidgetStateSet());
|
||||
|
||||
@@ -235,7 +235,21 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin();
|
||||
while(itr!= _graphicsSubgraphMap.end() && itr->first<=0)
|
||||
{
|
||||
itr->second->accept(nv);
|
||||
++itr;
|
||||
}
|
||||
|
||||
osg::Group::traverse(nv);
|
||||
|
||||
while(itr!= _graphicsSubgraphMap.end())
|
||||
{
|
||||
itr->second->accept(nv);
|
||||
++itr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (_visible ||
|
||||
|
||||
Reference in New Issue
Block a user