diff --git a/include/osgUI/LineEdit b/include/osgUI/LineEdit index 5b79f3a2e..616803ad2 100644 --- a/include/osgUI/LineEdit +++ b/include/osgUI/LineEdit @@ -27,12 +27,14 @@ public: LineEdit(const LineEdit& label, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); META_Node(osgUI, LineEdit); - virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event); - void setText(const std::string& text); const std::string& getText() const { return _text; } + virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event); virtual void createGraphicsImplementation(); + virtual void enterImplementation(); + virtual void leaveImplementation(); + protected: virtual ~LineEdit() {} @@ -40,6 +42,7 @@ protected: std::string _text; // implementation detail + osg::ref_ptr _backgroundSwitch; osg::ref_ptr _textDrawable; }; diff --git a/src/osgUI/LineEdit.cpp b/src/osgUI/LineEdit.cpp index 5dd0637dc..4fac0893c 100644 --- a/src/osgUI/LineEdit.cpp +++ b/src/osgUI/LineEdit.cpp @@ -72,6 +72,18 @@ void LineEdit::setText(const std::string& text) if (_textDrawable) _textDrawable->setText(_text); } +void LineEdit::enterImplementation() +{ + OSG_NOTICE<<"PushButton enter"<setSingleChildOn(1); +} + + +void LineEdit::leaveImplementation() +{ + OSG_NOTICE<<"PushButton leave"<setSingleChildOn(0); +} void LineEdit::createGraphicsImplementation() @@ -81,7 +93,11 @@ void LineEdit::createGraphicsImplementation() osg::ref_ptr group = new osg::Group; osg::BoundingBox extents(_extents); - osg::Vec4 frameColor(1.0f,1.0f,1.0f,1.0f); + float unFocused = 0.92; + float withFocus = 0.97; + float pressed = 0.75; + + osg::Vec4 frameColor(unFocused,unFocused,unFocused,1.0f); bool requiresFrame = (getFrameSettings() && getFrameSettings()->getShape()!=osgUI::FrameSettings::NO_FRAME); if (requiresFrame) @@ -94,7 +110,12 @@ void LineEdit::createGraphicsImplementation() } // clear background of edit region - group->addChild(style->createPanel(extents, frameColor)); + _backgroundSwitch = new osg::Switch; + _backgroundSwitch->addChild(style->createPanel(extents, osg::Vec4(unFocused, unFocused,unFocused, 1.0))); + _backgroundSwitch->addChild(style->createPanel(extents, osg::Vec4(withFocus,withFocus,withFocus,1.0))); + _backgroundSwitch->addChild(style->createPanel(extents, osg::Vec4(pressed,pressed,pressed,1.0))); + _backgroundSwitch->setSingleChildOn(0); + group->addChild(_backgroundSwitch.get()); osg::ref_ptr node = style->createText(extents, getAlignmentSettings(), getTextSettings(), _text); _textDrawable = dynamic_cast(node.get()); diff --git a/src/osgUI/PushButton.cpp b/src/osgUI/PushButton.cpp index 43060c53e..b346e7482 100644 --- a/src/osgUI/PushButton.cpp +++ b/src/osgUI/PushButton.cpp @@ -75,11 +75,9 @@ void PushButton::createGraphicsImplementation() Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get(); - _buttonSwitch = new osg::Switch; float unFocused = 0.92; float withFocus = 0.97; - float pressed = 0.75; osg::Vec4 frameColor(unFocused,unFocused,unFocused,1.0f); @@ -95,9 +93,9 @@ void PushButton::createGraphicsImplementation() extents.yMax() -= getFrameSettings()->getLineWidth(); } + _buttonSwitch = new osg::Switch; _buttonSwitch->addChild(style->createPanel(extents, osg::Vec4(unFocused, unFocused,unFocused, 1.0))); _buttonSwitch->addChild(style->createPanel(extents, osg::Vec4(withFocus,withFocus,withFocus,1.0))); - _buttonSwitch->addChild(style->createPanel(extents, osg::Vec4(pressed,pressed,pressed,1.0))); _buttonSwitch->setSingleChildOn(0); group->addChild(_buttonSwitch.get());