From a0248fbd9a859ac66771565e6d0cefb61179e833 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 22 May 2013 13:45:44 +0300 Subject: improve speechbubble. --- src/gui/speechbubble.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 9bd85ad43..cd0a08694 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -70,26 +70,28 @@ void SpeechBubble::setText(const std::string &text, const bool showName) mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT), getThemeColor(Theme::BUBBLE_TEXT_OUTLINE)); - int width = mCaption->getWidth() + 2 * getPadding(); + const int pad = mPadding; + const int pad2 = 2 * pad; + int width = mCaption->getWidth() + pad2; mSpeechBox->setTextWrapped(text, 130 > width ? 130 : width); - const int speechWidth = mSpeechBox->getMinWidth() + 2 * getPadding(); + const int speechWidth = mSpeechBox->getMinWidth() + pad2; const int fontHeight = getFont()->getHeight(); - const int nameHeight = showName ? mCaption->getHeight() + - (getPadding() / 2) : 0; + const int nameHeight = showName ? mCaption->getHeight() + pad / 2 : 0; const int numRows = mSpeechBox->getNumberOfRows(); - const int height = (numRows * fontHeight) + nameHeight + getPadding(); + const int height = (numRows * fontHeight) + nameHeight + pad; if (width < speechWidth) width = speechWidth; - width += 2 * getPadding(); + width += pad2; setContentSize(width, height); - const int xPos = ((getWidth() - width) / 2); - const int yPos = ((getHeight() - height) / 2) + nameHeight; + const gcn::Rectangle &rect = mDimension; + const int xPos = ((rect.width - width) / 2); + const int yPos = ((rect.height - height) / 2) + nameHeight; - mCaption->setPosition(xPos, getPadding()); + mCaption->setPosition(xPos, pad); mSpeechBox->setPosition(xPos, yPos); } -- cgit v1.2.3-60-g2f50