summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-04 13:55:47 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-04 13:55:47 +0300
commit9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe (patch)
treec90e52de0c648bc00b604a1d29b27b23d74963b1 /src
parent923a8cd8c44ebe4402f03b71701274b8f0a4ef80 (diff)
downloadplus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.gz
plus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.bz2
plus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.xz
plus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.zip
improve icon class.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/icon.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 61b2611cf..9232aea0d 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -33,7 +33,10 @@ Icon::Icon(const Widget2 *const widget, const std::string &file) :
mImage(ResourceManager::getInstance()->getImage(file))
{
if (mImage)
- setSize(mImage->mBounds.w, mImage->mBounds.h);
+ {
+ const SDL_Rect &bounds = mImage->mBounds;
+ setSize(bounds.w, bounds.h);
+ }
}
Icon::Icon(const Widget2 *const widget, Image *const image) :
@@ -42,7 +45,10 @@ Icon::Icon(const Widget2 *const widget, Image *const image) :
mImage(image)
{
if (mImage)
- setSize(mImage->mBounds.w, mImage->mBounds.h);
+ {
+ const SDL_Rect &bounds = mImage->mBounds;
+ setSize(bounds.w, bounds.h);
+ }
}
Icon::~Icon()
@@ -55,7 +61,10 @@ void Icon::setImage(Image *const image)
{
mImage = image;
if (mImage)
- setSize(mImage->mBounds.w, mImage->mBounds.h);
+ {
+ const SDL_Rect &bounds = mImage->mBounds;
+ setSize(bounds.w, bounds.h);
+ }
}
void Icon::draw(gcn::Graphics *g)
@@ -64,8 +73,8 @@ void Icon::draw(gcn::Graphics *g)
if (mImage)
{
Graphics *const graphics = static_cast<Graphics*>(g);
- graphics->drawImage(mImage, (getWidth() - mImage->mBounds.w) / 2,
- (getHeight() - mImage->mBounds.h) / 2);
+ graphics->drawImage(mImage, (mDimension.width - mImage->mBounds.w) / 2,
+ (mDimension.height - mImage->mBounds.h) / 2);
}
BLOCK_END("Icon::draw")
}