summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}