diff options
Diffstat (limited to 'scene/gui/check_box.cpp')
-rw-r--r-- | scene/gui/check_box.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 470450e3ed..df6f38f65d 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -39,19 +39,22 @@ Size2 CheckBox::get_icon_size() const { Ref<Texture2D> radio_unchecked = Control::get_theme_icon("radio_unchecked"); Size2 tex_size = Size2(0, 0); - if (!checked.is_null()) + if (!checked.is_null()) { tex_size = Size2(checked->get_width(), checked->get_height()); - if (!unchecked.is_null()) + } + if (!unchecked.is_null()) { tex_size = Size2(MAX(tex_size.width, unchecked->get_width()), MAX(tex_size.height, unchecked->get_height())); - if (!radio_checked.is_null()) + } + if (!radio_checked.is_null()) { tex_size = Size2(MAX(tex_size.width, radio_checked->get_width()), MAX(tex_size.height, radio_checked->get_height())); - if (!radio_unchecked.is_null()) + } + if (!radio_unchecked.is_null()) { tex_size = Size2(MAX(tex_size.width, radio_unchecked->get_width()), MAX(tex_size.height, radio_unchecked->get_height())); + } return tex_size; } Size2 CheckBox::get_minimum_size() const { - Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; @@ -65,12 +68,9 @@ Size2 CheckBox::get_minimum_size() const { } void CheckBox::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED) { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); } else if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); Ref<Texture2D> on = Control::get_theme_icon(is_radio() ? "radio_checked" : "checked"); @@ -81,15 +81,15 @@ void CheckBox::_notification(int p_what) { ofs.x = sb->get_margin(MARGIN_LEFT); ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant("check_vadjust"); - if (is_pressed()) + if (is_pressed()) { on->draw(ci, ofs); - else + } else { off->draw(ci, ofs); + } } } bool CheckBox::is_radio() { - return get_button_group().is_valid(); } |