From 8841fd5b0627d878a50c04dd11bdbc4835930dca Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 3 Feb 2013 21:19:34 +0300 Subject: Add ability to scroll menu popups. --- src/gui/popupmenu.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/gui/popupmenu.cpp') 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(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(); -- cgit v1.2.3-60-g2f50