Hi,

I had the same problem and ended up overriding the _calculateSize method as you 
are doing.

However, I don't think this is an error of the bounding box. What happens 
internally is that the text has a width and height according to the first text 
that we fit in, and it's only updated IF the text occupies more space, shall it 
be width or heigth.

On the other hand, I think it's not a good approach to remove completely the if 
statement, because that would imply the size of the box is always going to be 
that one of the text's. Eg. suppose you want a bigger container with a 
background color specified by user's width and height.

I went for two booleans, "_userWidth" and "_userHeight" which are set whenever 
the user wants to define a custom width or height (in the setters and adders). 
With this, the _calculateSize looks like this:


Code:
void EnhancedWidgetText::_calculateSize(const osgWidget::XYCoord& size){
        if(!_userWidth || getWidth() < size.x())
                inherited::setWidth(size.x());

        if(!_userHeight || getHeight() < size.y())
                inherited::setHeight(size.y());
}



If someone is interested I can provide the implementation.

Btw, among other things, you'll find out the padding is not supported in canvas 
widgets. An addition could be added in this direction, maybe.

Cheers,

Daniel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42132#42132





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to