From 77a5341118e27572c9b9db90d42120c84d204d77 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 12 Jun 2013 22:20:53 +0300 Subject: improve popuplist. --- src/gui/widgets/popuplist.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/gui/widgets/popuplist.cpp') 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) -- cgit v1.2.3-70-g09d2