diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-27 15:54:25 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-28 09:34:21 +0100 |
commit | 474442f1a49d29d85de769c4fbb3aa8636877b49 (patch) | |
tree | 2d8218d3648f370d31009831c86fc4c6b9f30033 /src/gui/textpopup.cpp | |
parent | dac3832265fa17de8d3b9d3ea8d930b83efe9c17 (diff) | |
download | mana-474442f1a49d29d85de769c4fbb3aa8636877b49.tar.gz mana-474442f1a49d29d85de769c4fbb3aa8636877b49.tar.bz2 mana-474442f1a49d29d85de769c4fbb3aa8636877b49.tar.xz mana-474442f1a49d29d85de769c4fbb3aa8636877b49.zip |
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.
Diffstat (limited to 'src/gui/textpopup.cpp')
-rw-r--r-- | src/gui/textpopup.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 4e8272d6..dbb5bc1f 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -35,37 +35,37 @@ TextPopup::TextPopup(): Popup("TextPopup") { + setMinWidth(0); + setMinHeight(0); + const int fontHeight = getFont()->getHeight(); mText1 = new Label; - mText1->setPosition(getPadding(), getPadding()); + mText1->setPosition(0, 0); mText2 = new Label; - mText2->setPosition(getPadding(), fontHeight + getPadding()); + mText2->setPosition(0, fontHeight); add(mText1); add(mText2); addMouseListener(this); } -void TextPopup::show(int x, int y, const std::string &str1, const std::string &str2) +void TextPopup::show(int x, int y, + const std::string &str1, + const std::string &str2) { mText1->setCaption(str1); mText1->adjustSize(); mText2->setCaption(str2); mText2->adjustSize(); - int minWidth = mText1->getWidth(); - if (mText2->getWidth() > minWidth) - minWidth = mText2->getWidth(); - - minWidth += 4 * getPadding(); - setWidth(minWidth); - + int width = std::max(mText1->getWidth(), mText2->getWidth()); + int height = mText1->getHeight(); if (!str2.empty()) - setHeight((getPadding() + mText1->getFont()->getHeight()) * 2); - else - setHeight(2 * getPadding() + mText1->getFont()->getHeight()); + height += mText2->getHeight(); + + setContentSize(width, height); const int distance = 20; |