diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-12 22:20:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-12 22:20:53 +0300 |
commit | 77a5341118e27572c9b9db90d42120c84d204d77 (patch) | |
tree | 6547ae368b498044657126fc55a8f0234afefe9a | |
parent | 77e2fc7f22393fba02e650a196093e1af9a824ac (diff) | |
download | manaplus-77a5341118e27572c9b9db90d42120c84d204d77.tar.gz manaplus-77a5341118e27572c9b9db90d42120c84d204d77.tar.bz2 manaplus-77a5341118e27572c9b9db90d42120c84d204d77.tar.xz manaplus-77a5341118e27572c9b9db90d42120c84d204d77.zip |
improve popuplist.
-rw-r--r-- | src/gui/widgets/popuplist.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/popuplist.h | 6 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index a0d8b558a..8cea612ab 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -49,8 +49,6 @@ PopupList::PopupList(DropDown *const widget, mScrollArea->setPosition(mPadding, mPadding); add(mScrollArea); -// if (getParent()) -// getParent()->addFocusListener(this); if (gui) gui->addGlobalFocusListener(this); @@ -74,10 +72,12 @@ void PopupList::show(int x, int y) if (len > 250) len = 250; setContentSize(mListBox->getWidth() + 8, len); - if (mainGraphics->mWidth < (x + getWidth() + 5)) - x = mainGraphics->mWidth - getWidth(); - if (mainGraphics->mHeight < (y + getHeight() + 5)) - y = mainGraphics->mHeight - getHeight(); + const int width = mDimension.width; + const int height = mDimension.height; + if (mainGraphics->mWidth < (x + width + 5)) + x = mainGraphics->mWidth - width; + if (mainGraphics->mHeight < (y + height + 5)) + y = mainGraphics->mHeight - height; setPosition(x, y); setVisible(true); requestMoveToTop(); @@ -117,10 +117,11 @@ void PopupList::setListModel(gcn::ListModel *model) void PopupList::adjustSize() { const int pad2 = 2 * mPadding; - mScrollArea->setWidth(getWidth() - pad2); - mScrollArea->setHeight(getHeight() - pad2); + const int width = mDimension.width - pad2; + mScrollArea->setWidth(width); + mScrollArea->setHeight(mDimension.height - pad2); mListBox->adjustSize(); - mListBox->setWidth(getWidth() - pad2); + mListBox->setWidth(width); } void PopupList::mousePressed(gcn::MouseEvent& mouseEvent) diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index a9d2c7593..f3786c192 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -61,11 +61,11 @@ class PopupList final : public Popup, void adjustSize(); - void focusGained(const gcn::Event& event A_UNUSED); + void focusGained(const gcn::Event& event A_UNUSED) override; - void focusLost(const gcn::Event& event A_UNUSED); + void focusLost(const gcn::Event& event A_UNUSED) override; - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; private: gcn::ListModel *mListModel; |