Implemented scheme for making sure nested widgest overdraw parent widgets graphics

This commit is contained in:
Robert Osfield 2014-05-23 15:00:49 +00:00
parent 55c2041d4d
commit cca18e82e8
6 changed files with 30 additions and 14 deletions

View File

@ -467,7 +467,8 @@ TypoCorrection typoCorrections[] =
{"Kristoger","Kristofer"},
{"Blessing","Blissing"},
{"Dannahuer","Dannhauer"},
{"Chebeav", "Chebaev"}
{"Chebeav", "Chebaev"},
{"Messershmidt","Messerschmidt"}
};
@ -634,7 +635,9 @@ NameCorrection nameCorrections[] =
{"Tyge", "",
"Tyge", "Løvset"},
{"Ricard", "Schmidt",
"Richard", "Schmidt"}
"Richard", "Schmidt"},
{"Matthias", "Helsing",
"Mattias", "Helsing"}
};

View File

@ -47,7 +47,8 @@ public:
virtual osg::Node* createFrame(const osg::BoundingBox& extents, const FrameSettings* frameSettings);
virtual osg::Node* createText(const osg::BoundingBox& extents, const AlignmentSettings* as, const TextSettings* textSettings, const std::string& text);
virtual osg::Node* createIcon(const osg::BoundingBox& extents, const std::string& filename);
virtual void setupDialogStateSet(osg::StateSet* stateset);
protected:
virtual ~Style() {}

View File

@ -32,8 +32,6 @@ Dialog::Dialog(const osgUI::Dialog& dialog, const osg::CopyOp& copyop):
bool Dialog::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
{
OSG_NOTICE<<"Dialog::handleImplementation"<<std::endl;
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
if (!ea) return false;
@ -80,10 +78,6 @@ void Dialog::createGraphicsImplementation()
float titleHeight = 1.0;
osg::BoundingBox titleBarExents(_extents.xMin(), _extents.yMax(), _extents.zMin(), _extents.xMax(), _extents.yMax()+titleHeight, _extents.zMin());
osg::ref_ptr<Node> node = style->createText(titleBarExents, getAlignmentSettings(), getTextSettings(), _title);
_titleDrawable = dynamic_cast<osgText::Text*>(node.get());
_titleDrawable->setDataVariance(osg::Object::DYNAMIC);
_transform->addChild(_titleDrawable.get());
osg::Vec4 dialogBackgroundColor(0.8,0.8,0.8,1.0);
osg::Vec4 dialogTitleBackgroundColor(0.5,0.5,1.0,1.0);
@ -91,5 +85,12 @@ void Dialog::createGraphicsImplementation()
_transform->addChild( style->createPanel(_extents, dialogBackgroundColor) );
_transform->addChild( style->createPanel(titleBarExents, dialogTitleBackgroundColor) );
osg::ref_ptr<Node> node = style->createText(titleBarExents, getAlignmentSettings(), getTextSettings(), _title);
_titleDrawable = dynamic_cast<osgText::Text*>(node.get());
_titleDrawable->setDataVariance(osg::Object::DYNAMIC);
_transform->addChild(_titleDrawable.get());
style->setupDialogStateSet(getOrCreateStateSet());
setGraphicsSubgraph(_transform.get());
}

View File

@ -86,5 +86,7 @@ void Popup::createGraphicsImplementation()
_transform->addChild( style->createPanel(_extents, dialogBackgroundColor) );
style->setupDialogStateSet(getOrCreateStateSet());
setGraphicsSubgraph(_transform.get());
}

View File

@ -76,11 +76,6 @@ void PushButton::createGraphicsImplementation()
osg::ref_ptr<osg::Group> group = new osg::Group;
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
osg::ref_ptr<Node> node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text);
_textDrawable = dynamic_cast<osgText::Text*>(node.get());
_textDrawable->setDataVariance(osg::Object::DYNAMIC);
group->addChild(_textDrawable.get());
_buttonSwitch = new osg::Switch;
@ -95,6 +90,13 @@ void PushButton::createGraphicsImplementation()
group->addChild(_buttonSwitch.get());
// create label.
osg::ref_ptr<Node> node = style->createText(_extents, getAlignmentSettings(), getTextSettings(), _text);
_textDrawable = dynamic_cast<osgText::Text*>(node.get());
_textDrawable->setDataVariance(osg::Object::DYNAMIC);
group->addChild(_textDrawable.get());
setGraphicsSubgraph(group.get());
}

View File

@ -13,6 +13,7 @@
#include <osgUI/Style>
#include <osg/Geode>
#include <osg/Depth>
#include <osgText/Text>
using namespace osgUI;
@ -89,3 +90,9 @@ osg::Node* Style::createIcon(const osg::BoundingBox& extents, const std::string&
return 0;
}
void Style::setupDialogStateSet(osg::StateSet* stateset)
{
stateset->setRenderBinDetails(5, "TraversalOrderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
stateset->setAttributeAndModes( new osg::Depth(osg::Depth::LESS,0.0, 1.0,false), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE );
stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
}