summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-10 16:16:40 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-10 16:16:40 +0300
commit06ace6f3b67757e09dde16da0f28c0169ed6bc0e (patch)
tree4e8fb1e1bdfaee00beed090b58954177b3878894 /src
parentb2f23e4a4f57a88ee4872d1f5af4cf97ed0d9bed (diff)
downloadmv-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.gz
mv-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.bz2
mv-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.xz
mv-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.zip
Improve performance in button drawing.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/button.cpp23
-rw-r--r--src/gui/widgets/button.h2
2 files changed, 16 insertions, 9 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 6fe3e9bc2..3d05584d9 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -119,7 +119,7 @@ Button::Button(const Widget2 *const widget) :
mImageSet(nullptr),
mAlignment(Graphics::CENTER),
mClickCount(0),
- mSpacing(4),
+ mSpacing(),
mTag(0),
mMode(0),
mXOffset(0),
@@ -160,7 +160,7 @@ Button::Button(const Widget2 *const widget,
mImageSet(nullptr),
mAlignment(Graphics::CENTER),
mClickCount(0),
- mSpacing(4),
+ mSpacing(),
mTag(0),
mMode(0),
mXOffset(0),
@@ -207,7 +207,7 @@ Button::Button(const Widget2 *const widget,
mImageSet(nullptr),
mAlignment(Graphics::CENTER),
mClickCount(0),
- mSpacing(4),
+ mSpacing(),
mTag(0),
mMode(0),
mXOffset(0),
@@ -254,7 +254,7 @@ Button::Button(const Widget2 *const widget,
mImageSet(nullptr),
mAlignment(Graphics::CENTER),
mClickCount(0),
- mSpacing(4),
+ mSpacing(),
mTag(0),
mMode(0),
mXOffset(0),
@@ -301,7 +301,7 @@ Button::Button(const Widget2 *const widget,
mImageSet(nullptr),
mAlignment(Graphics::CENTER),
mClickCount(0),
- mSpacing(4),
+ mSpacing(),
mTag(0),
mMode(0),
mXOffset(0),
@@ -339,7 +339,14 @@ void Button::init()
if (theme)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- button[mode] = theme->load(data[mode], "button.xml");
+ {
+ Skin *const skin = theme->load(data[mode], "button.xml");
+ if (skin)
+ {
+ button[mode] = skin;
+ mSpacing[mode] = skin->getOption("spacing");
+ }
+ }
}
updateAlpha();
@@ -487,7 +494,7 @@ void Button::draw(Graphics *graphics)
}
const int padding = skin->getPadding();
- const int spacing = skin->getOption("spacing");
+ const int spacing = mSpacing[mode];
switch (mode)
{
@@ -653,7 +660,7 @@ void Button::adjustSize()
if (mImages)
{
- const int spacing = skin->getOption("spacing");
+ const int spacing = mSpacing[BUTTON_STANDARD];
const int width = font->getWidth(mCaption);
if (width)
setWidth(width + mImageWidth + spacing + 2 * padding);
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index 9c9dce3cc..e568f8131 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -295,7 +295,7 @@ class Button final : public Widget,
/**
* Holds the spacing between the border and the caption.
*/
- unsigned int mSpacing;
+ int mSpacing[BUTTON_COUNT];
int mTag;
int mMode;