From 82cc576b7896f39bcf71aa85c8c4b3ef786c065b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Oct 2012 03:22:50 +0300 Subject: Add listbox padding. New theme file: listbox.xml Theme option: padding --- src/gui/widgets/extendedlistbox.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/gui/widgets/extendedlistbox.cpp') diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 610b4360c..249254cde 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -61,7 +61,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) graphics->setFont(getFont()); const int height = getRowHeight(); - int textPos = (height - getFont()->getHeight()) / 2; + int textPos = (height - getFont()->getHeight()) / 2 + mPadding; if (textPos < 0) textPos = 0; @@ -70,8 +70,9 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) { mHighlightColor.a = static_cast(mAlpha * 255.0f); graphics->setColor(mHighlightColor); - graphics->fillRectangle(gcn::Rectangle(0, height * mSelected, - getWidth(), height)); + graphics->fillRectangle(gcn::Rectangle(mPadding, + height * mSelected + mPadding, + getWidth() - 2 * mPadding, height)); } // Draw the list elements @@ -82,13 +83,14 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(i); if (!image) { - graphics->drawText(mListModel->getElementAt(i), 1, y + textPos); + graphics->drawText(mListModel->getElementAt(i), mPadding, y + textPos); } else { - g->drawImage(image, 1, y + (height - image->getHeight()) / 2); + g->drawImage(image, mPadding, y + (height - image->getHeight()) + / 2 + mPadding); graphics->drawText(mListModel->getElementAt(i), - image->getWidth() + 2, y + textPos); + image->getWidth() + mPadding, y + textPos); } } } -- cgit v1.2.3-60-g2f50