diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-05-03 14:55:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 14:55:32 +0200 |
commit | 7b64a24eb3fcec41c5e90b18ab2f61b895efb659 (patch) | |
tree | bcf51d556dcc6a753dff0b85abbe18c8dec4b227 /scene/gui/check_button.cpp | |
parent | 7e4cb80d4c1aca0aa4707977d77ed1058f4803ca (diff) | |
parent | 3eb5d1b52587b5608f7b3f73a30cb86ec592fdbe (diff) |
Merge pull request #28548 from YeldhamDev/check_button_disabled_icon
Add "disabled" icon for 'CheckButton'
Diffstat (limited to 'scene/gui/check_button.cpp')
-rw-r--r-- | scene/gui/check_button.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 35e3119473..a2d0f388c4 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -34,13 +34,15 @@ #include "servers/visual_server.h" Size2 CheckButton::get_icon_size() const { - Ref<Texture> on = Control::get_icon("on"); - Ref<Texture> off = Control::get_icon("off"); + + Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Size2 tex_size = Size2(0, 0); if (!on.is_null()) tex_size = Size2(on->get_width(), on->get_height()); if (!off.is_null()) tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height())); + return tex_size; } @@ -49,9 +51,8 @@ Size2 CheckButton::get_minimum_size() const { Size2 minsize = Button::get_minimum_size(); Size2 tex_size = get_icon_size(); minsize.width += tex_size.width; - if (get_text().length() > 0) { + if (get_text().length() > 0) minsize.width += get_constant("hseparation"); - } Ref<StyleBox> sb = get_stylebox("normal"); minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM)); @@ -67,8 +68,8 @@ void CheckButton::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> on = Control::get_icon("on"); - Ref<Texture> off = Control::get_icon("off"); + Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; |