diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 26 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.h | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 603827130..accb52ddc 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -39,7 +39,7 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget, gcn::ListModel *const listModel, const std::string &skin, - int rowHeight) : + const int rowHeight) : ListBox(widget, listModel, skin), mRowHeight(rowHeight), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), @@ -74,7 +74,8 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) gcn::Font *const font = getFont(); const int height = getRowHeight(); - int textPos = (height - font->getHeight()) / 2 + mPadding; + const int pad2 = 2 + mPadding; + int textPos = (height - font->getHeight()) / pad2; if (textPos < 0) textPos = 0; @@ -85,13 +86,24 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) graphics->setColor(mHighlightColor); graphics->fillRectangle(gcn::Rectangle(mPadding, height * mSelected + mPadding, - getWidth() - 2 * mPadding, height)); + getWidth() - pad2, height)); } - // Draw the list elements + const int sz = mListModel->getNumberOfElements(); + for (int i = 0, y = 0; i < sz; ++i, y += height) + { + if (i != mSelected) + { + const Image *const image = model->getImageAt(i); + if (image) + { + g->drawImage(image, mImagePadding, y + (height + - image->getHeight()) / 2 + mPadding); + } + } + } g->setColorAll(mForegroundColor, mForegroundColor2); - for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); - ++i, y += height) + for (int i = 0, y = 0; i < sz; ++i, y += height) { if (i != mSelected) { @@ -103,8 +115,6 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) } else { - g->drawImage(image, mImagePadding, y + (height - - image->getHeight()) / 2 + mPadding); font->drawString(graphics, mListModel->getElementAt(i), image->getWidth() + mImagePadding + mSpacing, y + textPos); } diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 1ac942a54..9d3394dd4 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -32,7 +32,7 @@ class ExtendedListBox final : public ListBox ExtendedListBox(const Widget2 *const widget, gcn::ListModel *const listModel, const std::string &skin, - int rowHeight = 13); + const int rowHeight = 13); A_DELETE_COPY(ExtendedListBox) |