diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/characterdisplay.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/label.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/label.h | 2 | ||||
-rw-r--r-- | src/gui/windows/charcreatedialog.cpp | 9 |
4 files changed, 17 insertions, 13 deletions
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index d88334973..9d409a6bb 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -102,6 +102,8 @@ void CharacterDisplay::update() mName->setCaption(mCharacter->dummy->getName()); else mName->setCaption(""); + const int width = mPlayerBox->getWidth(); + mName->resizeTo(width, width); distributeResizedEvent(); } diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index d57268bdd..50bd3ad41 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -128,18 +128,18 @@ void Label::setForegroundColorAll(const gcn::Color &color1, mForegroundColor2 = color2; } -void Label::resizeTo(const int sz) +void Label::resizeTo(const int maxSize, const int minSize) { const gcn::Font *const font = getFont(); const int pad2 = 2 * mPadding; setHeight(font->getHeight() + pad2); - if (font->getWidth(mCaption) + pad2 > sz) + if (font->getWidth(mCaption) + pad2 > maxSize) { const int dots = font->getWidth("..."); - if (dots > sz) + if (dots > maxSize) { - setWidth(sz); + setWidth(maxSize); return; } const size_t szChars = mCaption.size(); @@ -147,17 +147,20 @@ void Label::resizeTo(const int sz) { const std::string text = mCaption.substr(0, szChars - f); const int width = font->getWidth(text) + dots + pad2; - if (width <= sz) + if (width <= maxSize) { setCaption(text + "..."); setWidth(width); return; } } - setWidth(sz); + setWidth(maxSize); } else { - setWidth(font->getWidth(mCaption) + pad2); + int sz = font->getWidth(mCaption) + pad2; + if (sz < minSize) + sz = minSize; + setWidth(sz); } } diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 42f07d1c2..049e7bae9 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -68,7 +68,7 @@ class Label final : public gcn::Label, public Widget2 void setForegroundColorAll(const gcn::Color &color1, const gcn::Color &color2); - void resizeTo(const int sz); + void resizeTo(const int maxSize, const int minSize); static Skin *mSkin; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index f6cd22720..a61a6f8fd 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -587,7 +587,7 @@ void CharCreateDialog::updateHair() } const ItemInfo &item = ItemDB::get(-mHairStyle); mHairStyleNameLabel->setCaption(item.getName()); - mHairStyleNameLabel->resizeTo(150); + mHairStyleNameLabel->resizeTo(150, 150); if (ColorDB::getHairSize()) mHairColor %= ColorDB::getHairSize(); @@ -601,8 +601,7 @@ void CharCreateDialog::updateHair() mHairColor = minHairColor; } mHairColorNameLabel->setCaption(ColorDB::getHairColorName(mHairColor)); - mHairColorNameLabel->adjustSize(); - mHairColorNameLabel->resizeTo(150); + mHairColorNameLabel->resizeTo(150, 150); mPlayer->setSprite(Net::getCharServerHandler()->hairSprite(), mHairStyle * -1, item.getDyeColorsString(mHairColor)); @@ -639,12 +638,12 @@ void CharCreateDialog::updateLook() if (mRaceNameLabel) { mRaceNameLabel->setCaption(item.getName()); - mRaceNameLabel->resizeTo(150); + mRaceNameLabel->resizeTo(150, 150); } if (mLookNameLabel) { mLookNameLabel->setCaption(item.getColorName(mLook)); - mLookNameLabel->resizeTo(150); + mLookNameLabel->resizeTo(150, 150); } } |