Vec2f Button::getContentRequestedSize(void) const { Vec2f Result(0.0f,0.0f); UIDrawObjectCanvasRefPtr DrawnDrawObject = getDrawnDrawObject(); if(getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_LEFT_OF_TEXT || getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT) { if(getFont() != NULL) { Pnt2f TextTopLeft(0.0f,0.0f), TextBottomRight(0.0f,0.0f); getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); Result[0] += (TextBottomRight - TextTopLeft).x(); Result[1] = osgMax(Result[1],(TextBottomRight - TextTopLeft).y()); } if(DrawnDrawObject != NULL) { Pnt2f DrawObjectTopLeft, DrawObjectBottomRight; DrawnDrawObject->getDrawObjectBounds(DrawObjectTopLeft, DrawObjectBottomRight); Result[0] += (DrawObjectBottomRight - DrawObjectTopLeft).x(); Result[1] = osgMax(Result[1],(DrawObjectBottomRight - DrawObjectTopLeft).y()); } if(getFont() != NULL && DrawnDrawObject != NULL) { Result[0] += getDrawObjectToTextPadding(); } } else if(getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_ABOVE_TEXT || getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_BELOW_TEXT) { if(getFont() != NULL) { Pnt2f TextTopLeft(0.0f,0.0f), TextBottomRight(0.0f,0.0f); getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); Result[1] += (TextBottomRight - TextTopLeft).y(); Result[0] = osgMax(Result[0],(TextBottomRight - TextTopLeft).x()); } if(DrawnDrawObject != NULL) { Pnt2f DrawObjectTopLeft, DrawObjectBottomRight; DrawnDrawObject->getDrawObjectBounds(DrawObjectTopLeft, DrawObjectBottomRight); Result[1] += (DrawObjectBottomRight - DrawObjectTopLeft).y(); Result[0] = osgMax(Result[0],(DrawObjectBottomRight - DrawObjectTopLeft).x()); } if(getFont() != NULL && DrawnDrawObject != NULL) { Result[1] += getDrawObjectToTextPadding(); } } return Result + Vec2f(2.0,2.0); }
Vec2f Label::getContentRequestedSize(void) const { Pnt2f TextTopLeft(0.0f,0.0f), TextBottomRight(0.0f,0.0f); if(getFont() != NULL) { getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); } return (TextBottomRight - TextTopLeft) + Vec2f(2.0,2.0); }