summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-16 19:51:22 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-16 20:05:42 +0300
commit7f7ac0e998506fb2b19b03ae4f2ef6ef04b87b13 (patch)
treeff445411d6b69e6f65f7f83bf7ff634974f472c6
parentbf3205aafa71fad7138e7be8a4b641907ec056ce (diff)
downloadplus-7f7ac0e998506fb2b19b03ae4f2ef6ef04b87b13.tar.gz
plus-7f7ac0e998506fb2b19b03ae4f2ef6ef04b87b13.tar.bz2
plus-7f7ac0e998506fb2b19b03ae4f2ef6ef04b87b13.tar.xz
plus-7f7ac0e998506fb2b19b03ae4f2ef6ef04b87b13.zip
fix speechbubble size.
-rw-r--r--data/graphics/gui/CMakeLists.txt1
-rw-r--r--data/graphics/gui/Makefile.am1
-rw-r--r--data/graphics/gui/speechbrowserbox.xml10
-rw-r--r--data/graphics/gui/speechbubble.xml3
-rw-r--r--src/gui/popups/speechbubble.cpp29
-rw-r--r--src/gui/popups/speechbubble.h1
-rw-r--r--src/gui/widgets/browserbox.cpp8
-rw-r--r--src/gui/widgets/browserbox.h4
8 files changed, 39 insertions, 18 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index 45e615244..870b86b60 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -66,6 +66,7 @@ SET (FILES
shop.xml
slider.xml
slider_highlighted.xml
+ speechbrowserbox.xml
speechbubble.xml
tab.xml
tab_highlighted.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index dbe1498ac..50ea62178 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -69,6 +69,7 @@ gui_DATA = \
shop.xml \
slider.xml \
slider_highlighted.xml \
+ speechbrowserbox.xml \
speechbubble.xml \
tab.xml \
tab_highlighted.xml \
diff --git a/data/graphics/gui/speechbrowserbox.xml b/data/graphics/gui/speechbrowserbox.xml
new file mode 100644
index 000000000..281683021
--- /dev/null
+++ b/data/graphics/gui/speechbrowserbox.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <option name="padding" value="0" />
+ <option name="newLinePadding" value="0" />
+ <option name="itemPadding" value="0" />
+ <option name="highlightBackground" value="1" />
+ <option name="highlightUnderline" value="1" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/speechbubble.xml b/data/graphics/gui/speechbubble.xml
index 6b79718b3..5ca5b1e69 100644
--- a/data/graphics/gui/speechbubble.xml
+++ b/data/graphics/gui/speechbubble.xml
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<skinset name="SpeechBubble" image="bubble.png">
<widget type="Window">
+ <option name="padding" value="4" />
+ <option name="spacing" value="2" />
+
<!-- Top Row -->
<part type="top-left-corner" xpos="0" ypos="0" width="5" height="5" />
<part type="top-edge" xpos="5" ypos="0" width="5" height="5" />
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
index 3033b7923..7febfdf4c 100644
--- a/src/gui/popups/speechbubble.cpp
+++ b/src/gui/popups/speechbubble.cpp
@@ -36,16 +36,16 @@
SpeechBubble::SpeechBubble() :
Popup("Speech", "speechbubble.xml"),
mText(),
+ mSpacing(mSkin ? mSkin->getOption("spacing") : 2),
mCaption(new Label(this)),
mSpeechBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
- "browserbox.xml"))
+ "speechbrowserbox.xml"))
{
setContentSize(140, 46);
- setMinWidth(29);
- setMinHeight(29);
+ setMinWidth(8);
+ setMinHeight(8);
mCaption->setFont(boldFont);
-// mSpeechBox->setEditable(false);
mSpeechBox->setOpaque(false);
mSpeechBox->setForegroundColorAll(getThemeColor(Theme::BUBBLE_TEXT),
getThemeColor(Theme::BUBBLE_TEXT_OUTLINE));
@@ -75,28 +75,21 @@ void SpeechBubble::setText(const std::string &text, const bool showName)
getThemeColor(Theme::BUBBLE_TEXT_OUTLINE));
const int pad = mPadding;
- const int pad2 = 2 * pad;
- int width = mCaption->getWidth() + pad2;
+ int width = mCaption->getWidth();
mSpeechBox->clearRows();
mSpeechBox->addRow(text);
- const int speechWidth = mSpeechBox->getWidth() + pad2;
+ mSpeechBox->setWidth(mSpeechBox->getDataWidth());
+ const int speechWidth = mSpeechBox->getWidth();
const int fontHeight = getFont()->getHeight();
- const int nameHeight = showName ? mCaption->getHeight() + pad / 2 : 0;
- const int numRows = 1;
- const int height = fontHeight + nameHeight + pad;
+ const int nameHeight = showName ? mCaption->getHeight() + mSpacing : 0;
+ int height = fontHeight + nameHeight;
if (width < speechWidth)
width = speechWidth;
- width += pad2;
-
setContentSize(width, height);
- const gcn::Rectangle &rect = mDimension;
- const int xPos = ((rect.width - width) / 2);
- const int yPos = ((rect.height - height) / 2) + nameHeight;
-
- mCaption->setPosition(xPos, pad);
- mSpeechBox->setPosition(xPos, yPos);
+ mCaption->setPosition(0, 0);
+ mSpeechBox->setPosition(0, nameHeight);
}
diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h
index 496b3d71c..41c210eab 100644
--- a/src/gui/popups/speechbubble.h
+++ b/src/gui/popups/speechbubble.h
@@ -59,6 +59,7 @@ class SpeechBubble final : public Popup
private:
std::string mText;
+ int mSpacing;
Label *mCaption;
BrowserBox *mSpeechBox;
};
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 014e4cf58..d3e2efc67 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -72,6 +72,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mPadding(0),
mNewLinePadding(15),
mItemPadding(0),
+ mDataWidth(0),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
mHyperLinkColor(getThemeColor(Theme::HYPERLINK)),
mOpaque(opaque),
@@ -403,6 +404,7 @@ void BrowserBox::clearRows()
setHeight(0);
mSelectedLink = -1;
mUpdateTime = 0;
+ mDataWidth = 0;
updateHeight();
}
@@ -751,7 +753,11 @@ int BrowserBox::calcHeight()
start += 3;
if (start == row.size())
+ {
+ if (x > mDataWidth)
+ mDataWidth = x;
break;
+ }
}
}
const size_t len = (end == std::string::npos) ? end : end - start;
@@ -832,6 +838,8 @@ int BrowserBox::calcHeight()
break;
x += width;
+ if (x > mDataWidth)
+ mDataWidth = x;
}
y += fontHeight;
}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index fd037506b..5a09f60d6 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -234,6 +234,9 @@ class BrowserBox final : public gcn::Widget,
void setForegroundColorAll(const gcn::Color &color1,
const gcn::Color &color2);
+ int getDataWidth() const
+ { return mDataWidth; }
+
private:
int calcHeight() A_WARN_UNUSED;
@@ -264,6 +267,7 @@ class BrowserBox final : public gcn::Widget,
int mPadding;
int mNewLinePadding;
int mItemPadding;
+ unsigned int mDataWidth;
gcn::Color mHighlightColor;
gcn::Color mHyperLinkColor;