summaryrefslogtreecommitdiff
path: root/src/gui/widgets/button.cpp
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/gui/widgets/button.cpp
parentb2f23e4a4f57a88ee4872d1f5af4cf97ed0d9bed (diff)
downloadplus-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.gz
plus-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.bz2
plus-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.tar.xz
plus-06ace6f3b67757e09dde16da0f28c0169ed6bc0e.zip
Improve performance in button drawing.
Diffstat (limited to 'src/gui/widgets/button.cpp')
-rw-r--r--src/gui/widgets/button.cpp23
1 files changed, 15 insertions, 8 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);