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 | |
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.
-rw-r--r-- | data/themes/jewelry/CMakeLists.txt | 8 | ||||
-rw-r--r-- | data/themes/jewelry/Makefile.am | 8 | ||||
-rw-r--r-- | data/themes/jewelry/extendedlistbox.xml | 2 | ||||
-rw-r--r-- | data/themes/jewelry/extendedlistbox_high.xml | 9 | ||||
-rw-r--r-- | data/themes/jewelry/extendedlistbox_medium.xml | 9 | ||||
-rw-r--r-- | data/themes/jewelry/extendedlistbox_xhigh.xml | 9 | ||||
-rw-r--r-- | data/themes/jewelry/extendedlistbox_xxhigh.xml | 9 | ||||
-rw-r--r-- | data/themes/jewelry/listbox_high.xml | 10 | ||||
-rw-r--r-- | data/themes/jewelry/listbox_medium.xml | 10 | ||||
-rw-r--r-- | data/themes/jewelry/listbox_xhigh.xml | 10 | ||||
-rw-r--r-- | data/themes/jewelry/listbox_xxhigh.xml | 10 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 21 | ||||
-rw-r--r-- | src/gui/widgets/listbox.h | 8 |
15 files changed, 119 insertions, 24 deletions
diff --git a/data/themes/jewelry/CMakeLists.txt b/data/themes/jewelry/CMakeLists.txt index ec6cee20c..171d7b08e 100644 --- a/data/themes/jewelry/CMakeLists.txt +++ b/data/themes/jewelry/CMakeLists.txt @@ -27,6 +27,10 @@ SET (FILES equipment_background.xml equipmentbox.png extendedlistbox.xml + extendedlistbox_high.xml + extendedlistbox_medium.xml + extendedlistbox_xhigh.xml + extendedlistbox_xxhigh.xml help.xml incomplete_icon.xml info.xml @@ -42,6 +46,10 @@ SET (FILES keyboard_icon_xxhigh.xml LICENSE.txt listbox.xml + listbox_high.xml + listbox_medium.xml + listbox_xhigh.xml + listbox_xxhigh.xml login.xml map.xml ministatus.xml diff --git a/data/themes/jewelry/Makefile.am b/data/themes/jewelry/Makefile.am index 009fd6eac..0ba198b67 100644 --- a/data/themes/jewelry/Makefile.am +++ b/data/themes/jewelry/Makefile.am @@ -30,6 +30,10 @@ gui_DATA = \ equipment_background.xml \ equipmentbox.png \ extendedlistbox.xml \ + extendedlistbox_high.xml \ + extendedlistbox_medium.xml \ + extendedlistbox_xhigh.xml \ + extendedlistbox_xxhigh.xml \ help.xml \ incomplete_icon.xml \ info.xml \ @@ -45,6 +49,10 @@ gui_DATA = \ keyboard_icon_xxhigh.xml \ LICENSE.txt \ listbox.xml \ + listbox_high.xml \ + listbox_medium.xml \ + listbox_xhigh.xml \ + listbox_xxhigh.xml \ login.xml \ map.xml \ ministatus.xml \ diff --git a/data/themes/jewelry/extendedlistbox.xml b/data/themes/jewelry/extendedlistbox.xml index 82940467b..e19ed980b 100644 --- a/data/themes/jewelry/extendedlistbox.xml +++ b/data/themes/jewelry/extendedlistbox.xml @@ -1,11 +1,9 @@ <skinset name="Default" image="window.png"> <widget type="Window"> - <option name="padding" value="8" /> <option name="textPadding" value="48" /> <option name="imagePadding" value="6" /> <option name="itemPadding" value="1" /> <option name="spacing" value="8" /> - </widget> </skinset> diff --git a/data/themes/jewelry/extendedlistbox_high.xml b/data/themes/jewelry/extendedlistbox_high.xml new file mode 100644 index 000000000..f472b6fa2 --- /dev/null +++ b/data/themes/jewelry/extendedlistbox_high.xml @@ -0,0 +1,9 @@ +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="6" /> + <option name="itemPadding" value="10" /> + <option name="spacing" value="8" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/extendedlistbox_medium.xml b/data/themes/jewelry/extendedlistbox_medium.xml new file mode 100644 index 000000000..370cddc70 --- /dev/null +++ b/data/themes/jewelry/extendedlistbox_medium.xml @@ -0,0 +1,9 @@ +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="6" /> + <option name="itemPadding" value="5" /> + <option name="spacing" value="8" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/extendedlistbox_xhigh.xml b/data/themes/jewelry/extendedlistbox_xhigh.xml new file mode 100644 index 000000000..f472b6fa2 --- /dev/null +++ b/data/themes/jewelry/extendedlistbox_xhigh.xml @@ -0,0 +1,9 @@ +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="6" /> + <option name="itemPadding" value="10" /> + <option name="spacing" value="8" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/extendedlistbox_xxhigh.xml b/data/themes/jewelry/extendedlistbox_xxhigh.xml new file mode 100644 index 000000000..d940f30a9 --- /dev/null +++ b/data/themes/jewelry/extendedlistbox_xxhigh.xml @@ -0,0 +1,9 @@ +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="6" /> + <option name="itemPadding" value="15" /> + <option name="spacing" value="8" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/listbox_high.xml b/data/themes/jewelry/listbox_high.xml new file mode 100644 index 000000000..c40ff1ada --- /dev/null +++ b/data/themes/jewelry/listbox_high.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="2" /> + <option name="itemPadding" value="10" /> + <option name="spacing" value="0" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/listbox_medium.xml b/data/themes/jewelry/listbox_medium.xml new file mode 100644 index 000000000..5955166cd --- /dev/null +++ b/data/themes/jewelry/listbox_medium.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="2" /> + <option name="itemPadding" value="5" /> + <option name="spacing" value="0" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/listbox_xhigh.xml b/data/themes/jewelry/listbox_xhigh.xml new file mode 100644 index 000000000..c40ff1ada --- /dev/null +++ b/data/themes/jewelry/listbox_xhigh.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="2" /> + <option name="itemPadding" value="10" /> + <option name="spacing" value="0" /> + </widget> +</skinset> diff --git a/data/themes/jewelry/listbox_xxhigh.xml b/data/themes/jewelry/listbox_xxhigh.xml new file mode 100644 index 000000000..5f5da473b --- /dev/null +++ b/data/themes/jewelry/listbox_xxhigh.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<skinset name="Default" image="window.png"> + <widget type="Window"> + <option name="padding" value="8" /> + <option name="textPadding" value="48" /> + <option name="imagePadding" value="2" /> + <option name="itemPadding" value="15" /> + <option name="spacing" value="0" /> + </widget> +</skinset> diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 45497ae0a..68b4df766 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -33,22 +33,14 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget, const std::string &skin, const int rowHeight) : ListBox(widget, listModel, skin), - mRowHeight(rowHeight), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), mSpacing(mSkin ? mSkin->getOption("spacing") : 0), - mItemPadding(mSkin ? mSkin->getOption("itemPadding") : 1), mHeight(0), mListItems(), mSelectedItems() { - if (!mRowHeight) - { - const gcn::Font *font = getFont(); - if (font) - mRowHeight = font->getHeight() + 2 * mItemPadding; - else - mRowHeight = 13; - } + if (rowHeight) + mRowHeight = rowHeight; } ExtendedListBox::~ExtendedListBox() diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 79fef2f50..854c02f8b 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -61,21 +61,13 @@ class ExtendedListBox final : public ListBox */ void draw(gcn::Graphics *graphics) override; - unsigned int getRowHeight() const override A_WARN_UNUSED - { return mRowHeight; } - - void setRowHeight(unsigned int n) - { mRowHeight = n; } - void adjustSize() override; int getSelectionByMouse(const int y) const override; protected: - unsigned int mRowHeight; int mImagePadding; int mSpacing; - int mItemPadding; int mHeight; std::vector<ExtendedListBoxItem> mListItems; std::vector<ExtendedListBoxItem> mSelectedItems; 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) { diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 27e24a030..865a67216 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -98,6 +98,12 @@ class ListBox : public gcn::ListBox, int getPressedIndex() { return mPressedIndex; } + unsigned int getRowHeight() const override A_WARN_UNUSED + { return mRowHeight; } + + void setRowHeight(unsigned int n) + { mRowHeight = n; } + protected: gcn::Color mHighlightColor; gcn::Color mForegroundSelectedColor; @@ -105,6 +111,8 @@ class ListBox : public gcn::ListBox, int mOldSelected; int mPadding; int mPressedIndex; + unsigned int mRowHeight; + int mItemPadding; Skin *mSkin; static float mAlpha; bool mDistributeMousePressed; |