Implemented clipping of widget to the widgets extents.

This commit is contained in:
Robert Osfield
2014-05-23 18:59:16 +00:00
parent cca18e82e8
commit f50ec0fe8e
7 changed files with 78 additions and 49 deletions

View File

@@ -69,28 +69,33 @@ void Dialog::open()
void Dialog::createGraphicsImplementation()
{
OSG_NOTICE<<"Dialog::createGraphicsImplementation()"<<std::endl;
_transform = new osg::PositionAttitudeTransform;
Style* style = (getStyle()!=0) ? getStyle() : Style::instance().get();
float titleHeight = 1.0;
float titleHeight = 10.0;
osg::BoundingBox titleBarExents(_extents.xMin(), _extents.yMax(), _extents.zMin(), _extents.xMax(), _extents.yMax()+titleHeight, _extents.zMin());
osg::Vec4 dialogBackgroundColor(0.8,0.8,0.8,1.0);
osg::Vec4 dialogTitleBackgroundColor(0.5,0.5,1.0,1.0);
_transform->addChild( style->createPanel(_extents, dialogBackgroundColor) );
_transform->addChild( style->createPanel(titleBarExents, dialogTitleBackgroundColor) );
osg::BoundingBox dialogWithTileExtents(_extents);
dialogWithTileExtents.expandBy(titleBarExents);
OSG_NOTICE<<"Dialog::_extents ("<<_extents.xMin()<<", "<<_extents.yMin()<<", "<<_extents.zMin()<<"), ("<<_extents.xMax()<<", "<<_extents.yMax()<<", "<<_extents.zMax()<<")"<<std::endl;
OSG_NOTICE<<"Dialog::titleBarExents ("<<titleBarExents.xMin()<<", "<<titleBarExents.yMin()<<", "<<titleBarExents.zMin()<<"), ("<<titleBarExents.xMax()<<", "<<titleBarExents.yMax()<<", "<<titleBarExents.zMax()<<")"<<std::endl;
OSG_NOTICE<<"Dialog::dialogWithTileExtents ("<<dialogWithTileExtents.xMin()<<", "<<dialogWithTileExtents.yMin()<<", "<<dialogWithTileExtents.zMin()<<"), ("<<dialogWithTileExtents.xMax()<<", "<<dialogWithTileExtents.yMax()<<", "<<dialogWithTileExtents.zMax()<<")"<<std::endl;
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());
style->setupClipStateSet(dialogWithTileExtents, getOrCreateStateSet());
setGraphicsSubgraph(_transform.get());
}