From 474442f1a49d29d85de769c4fbb3aa8636877b49 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 27 Mar 2024 15:54:25 +0100 Subject: Fixed size and child positions for various popups Most prominently, fixes the tooltips on the window buttons being clipped due to their position being slightly outside of the clipping children area. And fixes NPC tooltips from having a lot of empty space below the NPC name. Also reduced the space between texts in the item tooltip to match the padding rather than being an entire empty line. --- src/gui/itempopup.cpp | 49 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'src/gui/itempopup.cpp') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 7790a3c0..f552a570 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -83,6 +83,8 @@ static const gcn::Color &getColorFromItemType(ItemType type) ItemPopup::ItemPopup(): Popup("ItemPopup") { + setMinHeight(boldFont->getHeight()); + // Item Name mItemName = new Label; mItemName->setFont(boldFont); @@ -141,12 +143,12 @@ void ItemPopup::setNoItem() mItemName->adjustSize(); mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC)); - mItemName->setPosition(getPadding(), getPadding()); + mItemName->setPosition(0, 0); mItemDesc->setText(std::string()); mItemEffect->setText(std::string()); - setContentSize(mItemName->getWidth() + 2 * getPadding(), 0); + setContentSize(mItemName->getWidth(), mItemName->getHeight()); } void ItemPopup::setItem(const ItemInfo &item, bool showImage) @@ -170,9 +172,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) mIcon->setImage(image); if (image) { - int x = getPadding(); - int y = getPadding(); - mIcon->setPosition(x, y); + mIcon->setPosition(0, 0); space = mIcon->getWidth(); } } @@ -190,7 +190,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) mItemName->setCaption(caption); mItemName->adjustSize(); mItemName->setForegroundColor(getColorFromItemType(mItemType)); - mItemName->setPosition(getPadding() + space, getPadding()); + mItemName->setPosition(space, 0); mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH); mItemEffect->setTextWrapped(join(item.getEffect(), "\n"), ITEMPOPUP_WRAP_WIDTH); @@ -207,40 +207,30 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) if (mItemWeight->getMinWidth() > minWidth) minWidth = mItemWeight->getMinWidth(); - minWidth += 8; - setWidth(minWidth); + const int descHeight = mItemDesc->getHeight(); + const int effectHeight = mItemEffect->getHeight(); + const int weightHeight = mItemWeight->getHeight(); - const int numRowsDesc = mItemDesc->getNumberOfRows(); - const int numRowsEffect = mItemEffect->getNumberOfRows(); - const int numRowsWeight = mItemWeight->getNumberOfRows(); - const int fontHeight = getFont()->getHeight(); - - int nameHeight; - if (mIcon->getHeight() > 2 * fontHeight) - nameHeight = mIcon->getHeight(); - else - nameHeight = 2 * fontHeight; + int nameHeight = std::max(mItemName->getHeight(), mIcon->getHeight()); + nameHeight += getPadding(); if (item.getEffect().empty()) { - setContentSize(minWidth, nameHeight + - (numRowsDesc + numRowsWeight + 1) * fontHeight); + setContentSize(minWidth, nameHeight + descHeight + weightHeight + getPadding()); - mItemWeight->setPosition(getPadding(), - nameHeight + (numRowsDesc + 1) * fontHeight); + mItemWeight->setPosition(0, nameHeight + descHeight + getPadding()); } else { - setContentSize(minWidth, nameHeight + (numRowsDesc + numRowsEffect + - numRowsWeight + 1) * fontHeight); + setContentSize(minWidth, nameHeight + descHeight + effectHeight + + weightHeight + getPadding()); - mItemWeight->setPosition(getPadding(), nameHeight + (numRowsDesc + - numRowsEffect + 1) * fontHeight); + mItemWeight->setPosition(0, nameHeight + descHeight + effectHeight + + getPadding()); } - mItemDesc->setPosition(getPadding(), nameHeight); - mItemEffect->setPosition(getPadding(), nameHeight + - (numRowsDesc + 1) * fontHeight); + mItemDesc->setPosition(0, nameHeight); + mItemEffect->setPosition(0, nameHeight + descHeight + getPadding()); } void ItemPopup::mouseMoved(gcn::MouseEvent &event) @@ -251,4 +241,3 @@ void ItemPopup::mouseMoved(gcn::MouseEvent &event) setVisible(false); mItemEquipSlot.clear(); } - -- cgit v1.2.3-70-g09d2