Introduced Widget::WidgetStateSet to help localize the StateSet set up by Widget implementations from being serialized or

affecting what end users apply via the standard Node::s/getStateSet().

Further work on TabWidget.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14440 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-09-09 13:37:33 +00:00
parent 0db0bcdd5e
commit e93e7ca1f2
13 changed files with 107 additions and 20 deletions

View File

@@ -25,12 +25,10 @@ class OSGUI_EXPORT Tab : public osg::Object
{
public:
Tab() : _color(1.0f,1.0f,1.0f,0.0f) {}
Tab(const std::string& str) : _text(str), _color(1.0f,1.0f,1.0f,0.0f) {}
Tab(const std::string& str, const osg::Vec4& col) : _text(str), _color(col) {}
Tab(const osg::Vec4& col) : _color(col) {}
Tab() {}
Tab(const std::string& str) : _text(str) {}
Tab(const Tab& item, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(item,copyop), _text(item._text), _color(item._color) {}
Tab(const Tab& item, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(item,copyop), _text(item._text) {}
META_Object(osgUI, Tab);
@@ -38,10 +36,6 @@ public:
std::string& getText() { return _text; }
const std::string& getText() const { return _text; }
void setColor(const osg::Vec4f& color) { _color = color; }
osg::Vec4f& getColor() { return _color; }
const osg::Vec4f& getColor() const { return _color; }
void setWidget(osgUI::Widget* widget) { _widget = widget; }
osgUI::Widget* getWidget() { return _widget.get(); }
const osgUI::Widget* getWidget() const { return _widget.get(); }
@@ -50,7 +44,6 @@ protected:
virtual ~Tab() {}
std::string _text;
osg::Vec4 _color;
osg::ref_ptr<osgUI::Widget> _widget;
};
@@ -92,8 +85,14 @@ public:
protected:
virtual ~TabWidget() {}
void _activateWidgets();
Tabs _tabs;
unsigned int _currentIndex;
osg::ref_ptr<osg::Switch> _unselectedHeaderSwitch;
osg::ref_ptr<osg::Switch> _selectedHeaderSwitch;
osg::ref_ptr<osg::Switch> _tabWidgetSwitch;
};
}

View File

@@ -58,6 +58,14 @@ public:
GraphicsSubgraphMap& getGraphicsSubgraphMap() { return _graphicsSubgraphMap; }
const GraphicsSubgraphMap& getGraphicsSubgraphMap() const { return _graphicsSubgraphMap; }
/** Set the WidgetStateSet is used internally by Widgets to manage state that decorates the subgraph.
* WidgetStateSet is not serialized and is typically populated by teh Widget::createGraphics() implementation,
* end users will not normally touoch the WidgetStateSet, use the normal Node::setStateSet() if you want to apply
* your own state to the Widget and it's subgraphs.*/
void setWidgetStateSet(osg::StateSet* stateset) { _widgetStateSet = stateset; }
osg::StateSet* getWidgetStateSet() { return _widgetStateSet.get(); }
const osg::StateSet* getWidgetStateSet() const { return _widgetStateSet.get(); }
osg::StateSet* getOrCreateWidgetStateSet() { if (!_widgetStateSet) _widgetStateSet = new osg::StateSet; return _widgetStateSet.get(); }
/** createGraphics entry method, calls either callback object named "createGraphics" or the createGraphicsImplementation() method.*/
@@ -152,6 +160,7 @@ protected:
bool _graphicsInitialized;
GraphicsSubgraphMap _graphicsSubgraphMap;
osg::ref_ptr<osg::StateSet> _widgetStateSet;
osg::BoundingBoxf _extents;