diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-04 12:00:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-04 12:00:17 +0300 |
commit | 66d469fe20cff2749316afe3ba44ad74acfc1557 (patch) | |
tree | 15267204b4ab85be7b3e2ad64e7d7be6290be1bc /src/gui | |
parent | a78b3a34de86d181f845f352b3c4a58e6ff03872 (diff) | |
download | manaverse-66d469fe20cff2749316afe3ba44ad74acfc1557.tar.gz manaverse-66d469fe20cff2749316afe3ba44ad74acfc1557.tar.bz2 manaverse-66d469fe20cff2749316afe3ba44ad74acfc1557.tar.xz manaverse-66d469fe20cff2749316afe3ba44ad74acfc1557.zip |
Fix popups sizes and padding.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/beingpopup.cpp | 16 | ||||
-rw-r--r-- | src/gui/itempopup.cpp | 40 | ||||
-rw-r--r-- | src/gui/ministatuswindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/ministatuswindow.h | 2 | ||||
-rw-r--r-- | src/gui/spellpopup.cpp | 18 | ||||
-rw-r--r-- | src/gui/statuspopup.cpp | 103 | ||||
-rw-r--r-- | src/gui/textpopup.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/popup.cpp | 4 |
8 files changed, 90 insertions, 111 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 865e29abd..87db79aa6 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -49,16 +49,16 @@ BeingPopup::BeingPopup() : { // Being Name mBeingName->setFont(boldFont); - mBeingName->setPosition(getPadding(), getPadding()); + mBeingName->setPosition(0, 0); - const int fontHeight = mBeingName->getHeight() + getPadding(); + const int fontHeight = mBeingName->getHeight(); // Being's party - mBeingParty->setPosition(getPadding(), fontHeight); + mBeingParty->setPosition(0, fontHeight); // Being's party - mBeingGuild->setPosition(getPadding(), 2 * fontHeight); - mBeingRank->setPosition(getPadding(), 3 * fontHeight); - mBeingComment->setPosition(getPadding(), 4 * fontHeight); + mBeingGuild->setPosition(0, 2 * fontHeight); + mBeingRank->setPosition(0, 3 * fontHeight); + mBeingComment->setPosition(0, 4 * fontHeight); mBeingParty->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); mBeingGuild->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); @@ -190,8 +190,8 @@ void BeingPopup::show(const int x, const int y, Being *const b) if (label4) height += getFont()->getHeight(); - setContentSize(minWidth + 10, height + 10); - + const int pad = 2 * getPadding(); + setContentSize(minWidth + pad, height + pad); position(x, y); return; } diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index b1c363a67..f5de59579 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -60,23 +60,23 @@ ItemPopup::ItemPopup(): { // Item Name mItemName->setFont(boldFont); - mItemName->setPosition(getPadding(), getPadding()); + mItemName->setPosition(0, 0); const int fontHeight = getFont()->getHeight(); // Item Description mItemDesc->setEditable(false); - mItemDesc->setPosition(getPadding(), fontHeight); + mItemDesc->setPosition(0, fontHeight); mItemDesc->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); // Item Effect mItemEffect->setEditable(false); - mItemEffect->setPosition(getPadding(), 2 * fontHeight + 2 * getPadding()); + mItemEffect->setPosition(0, 2 * fontHeight); mItemEffect->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); // Item Weight mItemWeight->setEditable(false); - mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding()); + mItemWeight->setPosition(0, 3 * fontHeight); mItemWeight->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); add(mItemName); @@ -144,9 +144,6 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, if (showImage) { ResourceManager *const resman = ResourceManager::getInstance(); -// logger->log("img: " + combineDye2( -// paths.getStringValue("itemIcons") -// + item.getDisplay().image, item.getDyeColorsString(color))); Image *const image = resman->getImage(combineDye2( paths.getStringValue("itemIcons") + item.getDisplay().image, item.getDyeColorsString(color))); @@ -154,8 +151,7 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, mIcon->setImage(image); if (image) { - const int pad = getPadding(); - mIcon->setPosition(pad, pad); + mIcon->setPosition(0, 0); space = mIcon->getWidth(); } } @@ -184,7 +180,7 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, mItemName->adjustSize(); mItemName->setForegroundColor(getColor(mItemType)); - mItemName->setPosition(getPadding() + space, getPadding()); + mItemName->setPosition(space, 0); mItemEffect->setTextWrapped(item.getEffect(), 196); mItemWeight->setTextWrapped(strprintf(_("Weight: %s"), @@ -202,9 +198,6 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, if (mItemWeight->getMinWidth() > minWidth) minWidth = mItemWeight->getMinWidth(); - minWidth += 8; - setWidth(minWidth); - const int numRowsDesc = mItemDesc->getNumberOfRows(); const int numRowsEffect = mItemEffect->getNumberOfRows(); const int numRowsWeight = mItemWeight->getNumberOfRows(); @@ -212,24 +205,19 @@ void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, if (item.getEffect().empty()) { - setContentSize(minWidth, (numRowsDesc + numRowsWeight + getPadding()) * - height); - - mItemWeight->setPosition(getPadding(), (numRowsDesc + getPadding()) * - height); + setContentSize(minWidth, (numRowsDesc + 2 + numRowsWeight) * height); + mItemWeight->setPosition(0, (numRowsDesc + 2) * height); } else { - setContentSize(minWidth, (numRowsDesc + numRowsEffect + numRowsWeight + - getPadding()) * height); - - mItemWeight->setPosition(getPadding(), (numRowsDesc + numRowsEffect + - getPadding()) * height); + setContentSize(minWidth, (numRowsDesc + numRowsEffect + 2 + + numRowsWeight) * height); + mItemWeight->setPosition(0, (numRowsDesc + numRowsEffect + 2) + * height); + mItemEffect->setPosition(0, (numRowsDesc + 2) * height); } - mItemDesc->setPosition(getPadding(), 2 * height); - mItemEffect->setPosition(getPadding(), - (numRowsDesc + getPadding()) * height); + mItemDesc->setPosition(0, 2 * height); } gcn::Color ItemPopup::getColor(const ItemType type) diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 9f89ca97f..b219d23c7 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -479,3 +479,9 @@ void MiniStatusWindow::updateArrows() { StatusWindow::updateArrowsBar(mArrowsBar); } + +gcn::Rectangle MiniStatusWindow::getChildrenArea() +{ + return gcn::Rectangle(getPadding(), 0, getWidth() - getPadding() * 2, + getHeight() - getPadding() * 2); +} diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 58eabcf56..fe372c97d 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -85,6 +85,8 @@ class MiniStatusWindow final : public Popup, std::vector <ProgressBar*> &getBars() { return mBars; } + gcn::Rectangle getChildrenArea(); + private: bool isInBar(ProgressBar *bar, int x, int y) const; diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 4d9666be4..f28cc024f 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -76,23 +76,13 @@ void SpellPopup::setItem(const TextCommand *const spell) if (mItemComment->getWidth() > minWidth) minWidth = mItemComment->getWidth(); - minWidth += 8; - setWidth(minWidth + 2 * getPadding()); - - mItemName->setPosition(getPadding(), getPadding()); - mItemComment->setPosition(getPadding(), - getPadding() + mItemName->getHeight()); + mItemName->setPosition(0, 0); + mItemComment->setPosition(0, mItemName->getHeight()); if (mItemComment->getCaption() != "") - { - setContentSize(minWidth, getPadding() - + 2 * getFont()->getHeight()); - } + setContentSize(minWidth, 2 * getFont()->getHeight()); else - { - setContentSize(minWidth, getPadding() - + getFont()->getHeight()); - } + setContentSize(minWidth, getFont()->getHeight()); } void SpellPopup::view(const int x, const int y) diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 183b7c02e..0f523aa31 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -62,28 +62,21 @@ StatusPopup::StatusPopup() : { const int fontHeight = getFont()->getHeight(); - mMoveType->setPosition(getPadding(), getPadding()); - mCrazyMoveType->setPosition(getPadding(), fontHeight + getPadding()); - mMoveToTargetType->setPosition(getPadding(), - 2 * fontHeight + getPadding()); - mFollowMode->setPosition(getPadding(), 3 * fontHeight + getPadding()); - mAttackWeaponType->setPosition(getPadding(), - 4 + 4 * fontHeight + getPadding()); - mAttackType->setPosition(getPadding(), 4 + 5 * fontHeight + getPadding()); - mMagicAttackType->setPosition(getPadding(), - 4 + 6 * fontHeight + getPadding()); - mPvpAttackType->setPosition(getPadding(), - 4 + 7 * fontHeight + getPadding()); - mDropCounter->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding()); - mPickUpType->setPosition(getPadding(), 8 + 9 * fontHeight + getPadding()); - mMapType->setPosition(getPadding(), 12 + 10 * fontHeight + getPadding()); - mImitationMode->setPosition(getPadding(), - 16 + 11 * fontHeight + getPadding()); - mAwayMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding()); - mCameraMode->setPosition(getPadding(), - 16 + 13 * fontHeight + getPadding()); - mDisableGameModifiers->setPosition(getPadding(), - 20 + 14 * fontHeight + getPadding()); + mMoveType->setPosition(0, 0); + mCrazyMoveType->setPosition(0, fontHeight); + mMoveToTargetType->setPosition(0, 2 * fontHeight); + mFollowMode->setPosition(0, 3 * fontHeight); + mAttackWeaponType->setPosition(0, 4 + 4 * fontHeight); + mAttackType->setPosition(0, 4 + 5 * fontHeight); + mMagicAttackType->setPosition(0, 4 + 6 * fontHeight); + mPvpAttackType->setPosition(0, 4 + 7 * fontHeight); + mDropCounter->setPosition(0, 8 + 8 * fontHeight); + mPickUpType->setPosition(0, 8 + 9 * fontHeight); + mMapType->setPosition(0, 12 + 10 * fontHeight); + mImitationMode->setPosition(0, 16 + 11 * fontHeight); + mAwayMode->setPosition(0, 16 + 12 * fontHeight); + mCameraMode->setPosition(0, 16 + 13 * fontHeight); + mDisableGameModifiers->setPosition(0, 20 + 14 * fontHeight); mMoveType->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); mCrazyMoveType->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); @@ -129,39 +122,39 @@ void StatusPopup::update() { updateLabels(); - int minWidth = mMoveType->getWidth(); - - if (mMoveToTargetType->getWidth() > minWidth) - minWidth = mMoveToTargetType->getWidth(); - if (mFollowMode->getWidth() > minWidth) - minWidth = mFollowMode->getWidth(); - if (mCrazyMoveType->getWidth() > minWidth) - minWidth = mCrazyMoveType->getWidth(); - if (mAttackWeaponType->getWidth() > minWidth) - minWidth = mAttackWeaponType->getWidth(); - if (mAttackType->getWidth() > minWidth) - minWidth = mAttackType->getWidth(); - if (mDropCounter->getWidth() > minWidth) - minWidth = mDropCounter->getWidth(); - if (mPickUpType->getWidth() > minWidth) - minWidth = mPickUpType->getWidth(); - if (mMapType->getWidth() > minWidth) - minWidth = mMapType->getWidth(); - if (mMagicAttackType->getWidth() > minWidth) - minWidth = mMagicAttackType->getWidth(); - if (mPvpAttackType->getWidth() > minWidth) - minWidth = mPvpAttackType->getWidth(); - if (mDisableGameModifiers->getWidth() > minWidth) - minWidth = mDisableGameModifiers->getWidth(); - if (mAwayMode->getWidth() > minWidth) - minWidth = mAwayMode->getWidth(); - if (mCameraMode->getWidth() > minWidth) - minWidth = mCameraMode->getWidth(); - if (mImitationMode->getWidth() > minWidth) - minWidth = mImitationMode->getWidth(); - - minWidth += 16 + 2 * getPadding(); - setWidth(minWidth); + int maxWidth = mMoveType->getWidth(); + + if (mCrazyMoveType->getWidth() > maxWidth) + maxWidth = mCrazyMoveType->getWidth(); + if (mMoveToTargetType->getWidth() > maxWidth) + maxWidth = mMoveToTargetType->getWidth(); + if (mFollowMode->getWidth() > maxWidth) + maxWidth = mFollowMode->getWidth(); + if (mAttackWeaponType->getWidth() > maxWidth) + maxWidth = mAttackWeaponType->getWidth(); + if (mAttackType->getWidth() > maxWidth) + maxWidth = mAttackType->getWidth(); + if (mDropCounter->getWidth() > maxWidth) + maxWidth = mDropCounter->getWidth(); + if (mPickUpType->getWidth() > maxWidth) + maxWidth = mPickUpType->getWidth(); + if (mMapType->getWidth() > maxWidth) + maxWidth = mMapType->getWidth(); + if (mMagicAttackType->getWidth() > maxWidth) + maxWidth = mMagicAttackType->getWidth(); + if (mPvpAttackType->getWidth() > maxWidth) + maxWidth = mPvpAttackType->getWidth(); + if (mDisableGameModifiers->getWidth() > maxWidth) + maxWidth = mDisableGameModifiers->getWidth(); + if (mImitationMode->getWidth() > maxWidth) + maxWidth = mImitationMode->getWidth(); + if (mAwayMode->getWidth() > maxWidth) + maxWidth = mAwayMode->getWidth(); + if (mCameraMode->getWidth() > maxWidth) + maxWidth = mCameraMode->getWidth(); + + maxWidth += 2 * getPadding(); + setWidth(maxWidth); setHeight(mDisableGameModifiers->getY() + mDisableGameModifiers->getHeight() + 2 * getPadding()); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index d542bdcde..02b330b9a 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -28,6 +28,7 @@ #include "gui/theme.h" #include "gui/widgets/label.h" +#include "gui/widgets/layouthelper.h" #include "units.h" @@ -45,11 +46,11 @@ TextPopup::TextPopup(): { const int fontHeight = getFont()->getHeight(); - mText1->setPosition(getPadding(), getPadding()); + mText1->setPosition(0, 0); mText1->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); - mText2->setPosition(getPadding(), fontHeight + 2 * getPadding()); + mText2->setPosition(0, fontHeight); mText2->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); - mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding()); + mText3->setPosition(0, 2 * fontHeight); mText3->setForegroundColor(Theme::getThemeColor(Theme::POPUP)); add(mText1); @@ -78,7 +79,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, if (mText3->getWidth() > minWidth) minWidth = mText3->getWidth(); - minWidth += 4 * getPadding(); + minWidth += 2 * getPadding(); setWidth(minWidth); int cnt = 1; @@ -87,8 +88,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, if (!str3.empty()) cnt ++; - setHeight((2 * getPadding() + mText1->getFont()->getHeight()) * cnt); - + setHeight(2 * getPadding() + mText1->getFont()->getHeight() * cnt); const int distance = 20; int posX = std::max(0, x - getWidth() / 2); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index fe3b63bf2..9a16d8530 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -119,8 +119,8 @@ void Popup::draw(gcn::Graphics *graphics) gcn::Rectangle Popup::getChildrenArea() { - return gcn::Rectangle(getPadding(), 0, getWidth() - getPadding() * 2, - getHeight() - getPadding() * 2); + return gcn::Rectangle(getPadding(), getPadding(), + getWidth() - getPadding() * 2, getHeight() - getPadding() * 2); } void Popup::setContentSize(int width, int height) |