summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-22 13:45:44 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-22 13:45:44 +0300
commita0248fbd9a859ac66771565e6d0cefb61179e833 (patch)
tree3545c697ae6e1b09eb871803149eae7c939a9248
parent16e0c6518c2f407675293a77cd2f626f65489992 (diff)
downloadmv-a0248fbd9a859ac66771565e6d0cefb61179e833.tar.gz
mv-a0248fbd9a859ac66771565e6d0cefb61179e833.tar.bz2
mv-a0248fbd9a859ac66771565e6d0cefb61179e833.tar.xz
mv-a0248fbd9a859ac66771565e6d0cefb61179e833.zip
improve speechbubble.
-rw-r--r--src/gui/speechbubble.cpp20
1 files 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);
}