diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-08 15:02:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-08 17:06:36 +0300 |
commit | b930f7f858b0ad91206939ed1b6d5695bc10f9cc (patch) | |
tree | 2b6d2be95b1f387399709e99ffedf050866f534a /src/gui/widgets/listbox.cpp | |
parent | 4c404e75a4e36d2d3151200e09990a9b6e82dacf (diff) | |
download | mv-b930f7f858b0ad91206939ed1b6d5695bc10f9cc.tar.gz mv-b930f7f858b0ad91206939ed1b6d5695bc10f9cc.tar.bz2 mv-b930f7f858b0ad91206939ed1b6d5695bc10f9cc.tar.xz mv-b930f7f858b0ad91206939ed1b6d5695bc10f9cc.zip |
use different item padding in listbox and extendedlistbox depend on DPI.
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index a31947e39..5010d3206 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -49,6 +49,8 @@ ListBox::ListBox(const Widget2 *const widget, mOldSelected(-1), mPadding(0), mPressedIndex(-2), + mRowHeight(0), + mItemPadding(1), mSkin(nullptr), mDistributeMousePressed(true), mCenterText(false) @@ -61,7 +63,16 @@ ListBox::ListBox(const Widget2 *const widget, mSkin = theme->load(skin, "listbox.xml"); if (mSkin) + { mPadding = mSkin->getPadding(); + mItemPadding = mSkin->getOption("itemPadding"); + } + + const gcn::Font *font = getFont(); + if (font) + mRowHeight = font->getHeight() + 2 * mItemPadding; + else + mRowHeight = 13; adjustSize(); } @@ -113,12 +124,13 @@ void ListBox::draw(gcn::Graphics *graphics) const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, (width - font->getWidth(str)) / 2, - mSelected * rowHeight + mPadding); + mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements g->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); - for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight) + for (int i = 0, y = mPadding + mItemPadding; + i < sz; ++i, y += rowHeight) { if (i != mSelected) { @@ -141,12 +153,13 @@ void ListBox::draw(gcn::Graphics *graphics) mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, mPadding, - mSelected * rowHeight + mPadding); + mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements g->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); - for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight) + for (int i = 0, y = mPadding + mItemPadding; i < sz; + ++i, y += rowHeight) { if (i != mSelected) { |