Added Visible and Enalbed properties to Widget

This commit is contained in:
Robert Osfield 2014-05-26 16:15:33 +00:00
parent 5d234ba021
commit b04a4813ba
3 changed files with 20 additions and 2 deletions

View File

@ -76,6 +76,15 @@ public:
TextSettings* getTextSettings() { return _textSettings.get(); }
const TextSettings* getTextSettings() const { return _textSettings.get(); }
/** set the visibility of the widget.*/
virtual void setVisible(bool visible) { _visible = visible; }
/** get the visibility of the widget.*/
virtual bool getVisible() const { return _visible; }
/** set whether the widget is enabled for user interaction.*/
virtual void setEnabled(bool enabled) { _enabled = enabled; }
/** get whether the widget is enabled for user interaction.*/
virtual bool getEnabled() const { return _enabled; }
enum FocusBehaviour
{
@ -136,6 +145,9 @@ protected:
osg::ref_ptr<AlignmentSettings> _alignmentSettings;
osg::ref_ptr<FrameSettings> _frameSettings;
osg::ref_ptr<TextSettings> _textSettings;
bool _visible;
bool _enabled;
};
}

View File

@ -28,7 +28,9 @@ using namespace osgUI;
Widget::Widget():
_focusBehaviour(FOCUS_FOLLOWS_POINTER),
_hasEventFocus(false),
_graphicsInitialized(false)
_graphicsInitialized(false),
_visible(true),
_enabled(true)
{
setNumChildrenRequiringEventTraversal(1);
}
@ -40,7 +42,9 @@ Widget::Widget(const Widget& widget, const osg::CopyOp& copyop):
_graphicsInitialized(false),
_alignmentSettings(osg::clone(widget._alignmentSettings.get(), copyop)),
_frameSettings(osg::clone(widget._frameSettings.get(), copyop)),
_textSettings(osg::clone(widget._textSettings.get(), copyop))
_textSettings(osg::clone(widget._textSettings.get(), copyop)),
_visible(widget._visible),
_enabled(widget._enabled)
{
setNumChildrenRequiringEventTraversal(1);
}

View File

@ -77,6 +77,8 @@ REGISTER_OBJECT_WRAPPER( Widget,
ADD_OBJECT_SERIALIZER( AlignmentSettings, osgUI::AlignmentSettings, NULL );
ADD_OBJECT_SERIALIZER( TextSettings, osgUI::TextSettings, NULL );
ADD_BOOL_SERIALIZER(Visible, true);
ADD_BOOL_SERIALIZER(Enabled, true);
ADD_METHOD( createGraphics );
ADD_METHOD( createGraphicsImplementation );