diff options
Diffstat (limited to 'src/gui/widgets/button.cpp')
-rw-r--r-- | src/gui/widgets/button.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index b2fa9e89..6770c180 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -83,15 +83,14 @@ Button::Button(const std::string &caption, const std::string &actionEventId, adjustSize(); } -void Button::setButtonIcon(const std::string& iconFile, int frameHeight, - int frameWidth) +void Button::setButtonIcon(const std::string& iconFile) { // We clean up possible older references. if (mButtonIcon) removeButtonIcon(); // If nothing relevant was set, we can quit now. - if (iconFile.empty() || !frameWidth || !frameHeight) + if (iconFile.empty()) return; // Load the icon frames. @@ -99,6 +98,10 @@ void Button::setButtonIcon(const std::string& iconFile, int frameHeight, if (!btnIcons) return; + // Compute the sub images size. + int frameWidth = btnIcons->getWidth() / 4; + int frameHeight = btnIcons->getHeight(); + if (btnIcons->getWidth() > 0 && btnIcons->getHeight() > 0) { mButtonIcon = new Image*[BUTTON_COUNT]; |