diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-04 13:55:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-04 13:55:47 +0300 |
commit | 9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe (patch) | |
tree | c90e52de0c648bc00b604a1d29b27b23d74963b1 /src/gui/widgets | |
parent | 923a8cd8c44ebe4402f03b71701274b8f0a4ef80 (diff) | |
download | manaplus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.gz manaplus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.bz2 manaplus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.tar.xz manaplus-9c7446cc89957b46c7a41671cc0f7fb2f5f2f4fe.zip |
improve icon class.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/icon.cpp | 19 |
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") } |