From 34a5f3077937317febd9fa3fc2dc6f2a2473521c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 13 Jun 2013 21:41:49 +0300 Subject: improve radiobutton. --- src/gui/widgets/radiobutton.cpp | 20 +++++++++++--------- src/gui/widgets/radiobutton.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') 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)->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 -- cgit v1.2.3-70-g09d2