From 9f89a15fbcaf3f24f4c941b7061979e424d6384a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 18 Oct 2012 12:38:47 +0300 Subject: Extend theming listbox with image. New theme options: imagePadding - padding for image from left spacing - space between image and text --- data/graphics/gui/listbox.xml | 2 ++ src/gui/widgets/extendedlistbox.cpp | 10 ++++++---- src/gui/widgets/extendedlistbox.h | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/data/graphics/gui/listbox.xml b/data/graphics/gui/listbox.xml index 406213a2a..c1de64f2e 100644 --- a/data/graphics/gui/listbox.xml +++ b/data/graphics/gui/listbox.xml @@ -1,5 +1,7 @@ diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 0acf66a65..eb1e93303 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -40,7 +40,9 @@ ExtendedListBox::ExtendedListBox(gcn::ListModel *const listModel): ListBox(listModel), - mRowHeight(13) + mRowHeight(13), + mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), + mSpacing(mSkin ? mSkin->getOption("spacing") : 0) { } @@ -88,10 +90,10 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) } else { - g->drawImage(image, mPadding, y + (height - image->getHeight()) - / 2 + mPadding); + g->drawImage(image, mImagePadding, y + (height + - image->getHeight()) / 2 + mPadding); graphics->drawText(mListModel->getElementAt(i), - image->getWidth() + mPadding, y + textPos); + image->getWidth() + mImagePadding + mSpacing, y + textPos); } } } diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 87e4ffde0..f9563c6c4 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -48,6 +48,8 @@ class ExtendedListBox final : public ListBox protected: unsigned int mRowHeight; + int mImagePadding; + int mSpacing; }; #endif -- cgit v1.2.3-70-g09d2