diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/popups/speechbubble.cpp | 17 | ||||
-rw-r--r-- | src/gui/popups/speechbubble.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/browserbox.h | 3 |
4 files changed, 22 insertions, 9 deletions
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index ad043b9bf..3033b7923 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -25,6 +25,7 @@ #include "gui/sdlfont.h" +#include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" #include "gui/widgets/textbox.h" @@ -36,14 +37,15 @@ SpeechBubble::SpeechBubble() : Popup("Speech", "speechbubble.xml"), mText(), mCaption(new Label(this)), - mSpeechBox(new TextBox(this)) + mSpeechBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, + "browserbox.xml")) { setContentSize(140, 46); setMinWidth(29); setMinHeight(29); mCaption->setFont(boldFont); - mSpeechBox->setEditable(false); +// mSpeechBox->setEditable(false); mSpeechBox->setOpaque(false); mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT), getThemeColor(Theme::BUBBLE_TEXT_OUTLINE)); @@ -66,7 +68,7 @@ void SpeechBubble::setCaption(const std::string &name, void SpeechBubble::setText(const std::string &text, const bool showName) { - if (text == mText && (mCaption->getWidth() <= mSpeechBox->getMinWidth())) + if (text == mText && (mCaption->getWidth() <= mSpeechBox->getWidth())) return; mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT), @@ -75,13 +77,14 @@ void SpeechBubble::setText(const std::string &text, const bool showName) 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() + pad2; + mSpeechBox->clearRows(); + mSpeechBox->addRow(text); + const int speechWidth = mSpeechBox->getWidth() + pad2; const int fontHeight = getFont()->getHeight(); const int nameHeight = showName ? mCaption->getHeight() + pad / 2 : 0; - const int numRows = mSpeechBox->getNumberOfRows(); - const int height = (numRows * fontHeight) + nameHeight + pad; + const int numRows = 1; + const int height = fontHeight + nameHeight + pad; if (width < speechWidth) width = speechWidth; diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h index 6b7c705bb..496b3d71c 100644 --- a/src/gui/popups/speechbubble.h +++ b/src/gui/popups/speechbubble.h @@ -29,7 +29,7 @@ #include "gui/widgets/popup.h" class Label; -class TextBox; +class BrowserBox; class SpeechBubble final : public Popup { @@ -60,7 +60,7 @@ class SpeechBubble final : public Popup private: std::string mText; Label *mCaption; - TextBox *mSpeechBox; + BrowserBox *mSpeechBox; }; #endif // GUI_POPUPS_SPEECHBUBBLE_H diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 0dafe8e24..014e4cf58 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -889,6 +889,13 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const return str; } +void BrowserBox::setForegroundColorAll(const gcn::Color &color1, + const gcn::Color &color2) +{ + mForegroundColor = color1; + mForegroundColor2 = color2; +} + LinePart::~LinePart() { if (mImage) diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index e06ca3f48..fd037506b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -231,6 +231,9 @@ class BrowserBox final : public gcn::Widget, int getPadding() const A_WARN_UNUSED { return mPadding; } + void setForegroundColorAll(const gcn::Color &color1, + const gcn::Color &color2); + private: int calcHeight() A_WARN_UNUSED; |