diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-03 21:19:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-03 22:14:57 +0300 |
commit | 8841fd5b0627d878a50c04dd11bdbc4835930dca (patch) | |
tree | db225733a053470b87d58efbf7f9d44fb50b1993 /src | |
parent | 4cd59b0f9f30b7104197fa96851b616fb9981caa (diff) | |
download | manaplus-8841fd5b0627d878a50c04dd11bdbc4835930dca.tar.gz manaplus-8841fd5b0627d878a50c04dd11bdbc4835930dca.tar.bz2 manaplus-8841fd5b0627d878a50c04dd11bdbc4835930dca.tar.xz manaplus-8841fd5b0627d878a50c04dd11bdbc4835930dca.zip |
Add ability to scroll menu popups.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/popupmenu.cpp | 20 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 2c25cceaf..6bd384132 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -56,6 +56,7 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/chattab.h" #include "gui/widgets/progressbar.h" +#include "gui/widgets/scrollarea.h" #include "gui/widgets/textfield.h" #include "gui/widgets/whispertab.h" @@ -110,8 +111,10 @@ PopupMenu::PopupMenu(): mPlayerListener.setNick(""); mPlayerListener.setDialog(nullptr); mPlayerListener.setType(static_cast<int>(Being::UNKNOWN)); + mScrollArea = new ScrollArea(mBrowserBox, false); + mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); - add(mBrowserBox); + add(mScrollArea); } void PopupMenu::showPopup(const int x, const int y, const Being *const being) @@ -2140,14 +2143,27 @@ void PopupMenu::showPopup(int x, int y) const int pad2 = 2 * getPadding(); const int bPad2 = 2 * mBrowserBox->getPadding(); mBrowserBox->setPosition(mPadding, mPadding); + mScrollArea->setPosition(mPadding, mPadding); // add padding to initial size before draw browserbox mBrowserBox->setWidth(mBrowserBox->getWidth() + bPad2); + int height = mBrowserBox->getHeight(); + if (height + pad2 >= mainGraphics->getHeight()) + { + height = mainGraphics->getHeight() - pad2; + mBrowserBox->setWidth(mBrowserBox->getWidth() + bPad2 + 10); + } + else + { + mBrowserBox->setWidth(mBrowserBox->getWidth() + bPad2); + } setContentSize(mBrowserBox->getWidth() + pad2, - mBrowserBox->getHeight() + pad2); + height + pad2); if (mainGraphics->mWidth < (x + getWidth() + 5)) x = mainGraphics->mWidth - getWidth(); if (mainGraphics->mHeight < (y + getHeight() + 5)) y = mainGraphics->mHeight - getHeight(); + mScrollArea->setWidth(mBrowserBox->getWidth() + pad2); + mScrollArea->setHeight(height + pad2); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 7266b4d29..d3682f68e 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -41,6 +41,7 @@ class FloorItem; class Item; class ItemShortcut; class MapItem; +class ScrollArea; class TextCommand; class TextDialog; class TextField; @@ -198,7 +199,8 @@ class PopupMenu final : public Popup, public LinkHandler void addPickupFilter(const std::string &name); - BrowserBox* mBrowserBox; + BrowserBox *mBrowserBox; + ScrollArea *mScrollArea; int mBeingId; int mFloorItemId; |