diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-13 21:41:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-13 21:41:49 +0300 |
commit | 34a5f3077937317febd9fa3fc2dc6f2a2473521c (patch) | |
tree | 5326dc8b545c8d80b430d98bef7b3d246d194af8 | |
parent | 97e43ea4bb98f3fae87ac8dc8f4335bfaeff5876 (diff) | |
download | ManaVerse-34a5f3077937317febd9fa3fc2dc6f2a2473521c.tar.gz ManaVerse-34a5f3077937317febd9fa3fc2dc6f2a2473521c.tar.bz2 ManaVerse-34a5f3077937317febd9fa3fc2dc6f2a2473521c.tar.xz ManaVerse-34a5f3077937317febd9fa3fc2dc6f2a2473521c.zip |
improve radiobutton.
-rw-r--r-- | src/gui/widgets/radiobutton.cpp | 20 | ||||
-rw-r--r-- | src/gui/widgets/radiobutton.h | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 13f3fb237..08561d56c 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -42,19 +42,20 @@ RadioButton::RadioButton(const Widget2 *const widget, const bool marked): gcn::RadioButton(caption, group, marked), Widget2(widget), - mHasMouse(false), mPadding(0), mImagePadding(0), mImageSize(9), mSpacing(2), - mForegroundColor2(getThemeColor(Theme::RADIOBUTTON_OUTLINE)) + mForegroundColor2(getThemeColor(Theme::RADIOBUTTON_OUTLINE)), + mHasMouse(false) { mForegroundColor = getThemeColor(Theme::RADIOBUTTON); if (instances == 0) { - if (Theme::instance()) + Theme *const theme = Theme::instance(); + if (theme) { - mSkin = Theme::instance()->load("radio.xml", ""); + mSkin = theme->load("radio.xml", ""); updateAlpha(); } } @@ -81,8 +82,9 @@ RadioButton::~RadioButton() if (instances == 0) { - if (Theme::instance()) - Theme::instance()->unload(mSkin); + Theme *const theme = Theme::instance(); + if (theme) + theme->unload(mSkin); } } @@ -178,7 +180,6 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) void RadioButton::keyPressed(gcn::KeyEvent& keyEvent) { const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); - if (action == Input::KEY_GUI_SELECT) { setSelected(true); @@ -189,7 +190,8 @@ void RadioButton::keyPressed(gcn::KeyEvent& keyEvent) void RadioButton::adjustSize() { - setHeight(getFont()->getHeight() + 2 * mPadding); + gcn::Font *const font = getFont(); + setHeight(font->getHeight() + 2 * mPadding); setWidth(mImagePadding + mImageSize + mSpacing - + getFont()->getWidth(mCaption) + mPadding); + + font->getWidth(mCaption) + mPadding); } diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 01bbb438e..fad8309ea 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -83,12 +83,12 @@ class RadioButton final : public gcn::RadioButton, static int instances; static Skin *mSkin; static float mAlpha; - bool mHasMouse; int mPadding; int mImagePadding; int mImageSize; int mSpacing; gcn::Color mForegroundColor2; + bool mHasMouse; }; #endif // GUI_WIDGETS_RADIOBUTTON_H |