Improved positioning of combo box popup items

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14253 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-06-12 14:12:30 +00:00
parent 63d101b653
commit 410f7d27ed

View File

@ -190,15 +190,15 @@ void ComboBox::createGraphicsImplementation()
{ {
float margin = (extents.yMax()-extents.yMin())*0.1f; float margin = (extents.yMax()-extents.yMin())*0.1f;
float itemWidth = (_extents.xMax()-_extents.xMin()) - 2.0f*margin - 2.0f*frameWidth; float itemWidth = (_extents.xMax()-_extents.xMin()) - 2.0f*frameWidth;
float itemHeight = (_extents.yMax()-_extents.yMin()) - margin - 2.0f*frameWidth; float itemHeight = (_extents.yMax()-_extents.yMin()) - 2.0f*frameWidth;
float popupHeight = (itemHeight +margin)* _items.size() + margin + 2.0f*frameWidth; float popupHeight = (itemHeight)* _items.size() + margin*static_cast<float>(_items.size()-1) + 2.0f*frameWidth;
float popupTop = _extents.yMin()-margin; float popupTop = _extents.yMin()-frameWidth;
osg::BoundingBox popupExtents(_extents.xMin(), popupTop-popupHeight, _extents.zMin(), _extents.xMax(), popupTop, _extents.zMax()); osg::BoundingBox popupExtents(_extents.xMin(), popupTop-popupHeight, _extents.zMin(), _extents.xMax(), popupTop, _extents.zMax());
_popup->setExtents(popupExtents); _popup->setExtents(popupExtents);
osg::BoundingBox popupItemExtents(_extents.xMin()+margin, popupTop-margin-itemHeight, _extents.zMin(), _extents.xMax()-margin, popupTop-margin, _extents.zMax()); osg::BoundingBox popupItemExtents(popupExtents.xMin()+frameWidth, popupTop-frameWidth-itemHeight, popupExtents.zMin(), popupExtents.xMax()-frameWidth, popupTop-frameWidth, popupExtents.zMax());
unsigned int index = 0; unsigned int index = 0;
for(Items::iterator itr = _items.begin(); for(Items::iterator itr = _items.begin();