diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml index 5b2c93f7b33f..4dd3724a7413 100644 --- a/doc/classes/CheckBox.xml +++ b/doc/classes/CheckBox.xml @@ -15,6 +15,12 @@ + + The color of the checked icon when the checkbox is pressed. + + + The color of the unchecked icon when the checkbox is not pressed. + The vertical offset used when rendering the check icons (in pixels). diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml index c2da6cfe3e33..bdcb049b6c4b 100644 --- a/doc/classes/CheckButton.xml +++ b/doc/classes/CheckButton.xml @@ -14,6 +14,12 @@ + + The color of the checked icon when the checkbox is pressed. + + + The color of the unchecked icon when the checkbox is not pressed. + The vertical offset used when rendering the toggle icons (in pixels). diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 99937aaf41f0..b151b285cb95 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -127,9 +127,9 @@ void CheckBox::_notification(int p_what) { ofs.y = int((get_size().height - get_icon_size().height) / 2) + theme_cache.check_v_offset; if (is_pressed()) { - on_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(on_tex->get_size()))); + on_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(on_tex->get_size())), false, theme_cache.checkbox_checked_color); } else { - off_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(off_tex->get_size()))); + off_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(off_tex->get_size())), false, theme_cache.checkbox_unchecked_color); } } break; } @@ -152,6 +152,9 @@ void CheckBox::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckBox, unchecked_disabled); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckBox, radio_checked_disabled); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckBox, radio_unchecked_disabled); + + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CheckBox, checkbox_checked_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CheckBox, checkbox_unchecked_color); } CheckBox::CheckBox(const String &p_text) : diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h index 87261816311c..a8af55a2f5a1 100644 --- a/scene/gui/check_box.h +++ b/scene/gui/check_box.h @@ -49,6 +49,9 @@ class CheckBox : public Button { Ref unchecked_disabled; Ref radio_checked_disabled; Ref radio_unchecked_disabled; + + Color checkbox_checked_color; + Color checkbox_unchecked_color; } theme_cache; protected: diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 29b9504776fb..63d239857d31 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -134,9 +134,9 @@ void CheckButton::_notification(int p_what) { ofs.y = (get_size().height - tex_size.height) / 2 + theme_cache.check_v_offset; if (is_pressed()) { - on_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(on_tex->get_size()))); + on_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(on_tex->get_size())), false, theme_cache.button_checked_color); } else { - off_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(off_tex->get_size()))); + off_tex->draw_rect(ci, Rect2(ofs, _fit_icon_size(off_tex->get_size())), false, theme_cache.button_unchecked_color); } } break; } @@ -155,6 +155,9 @@ void CheckButton::_bind_methods() { BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckButton, unchecked_mirrored); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckButton, checked_disabled_mirrored); BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, CheckButton, unchecked_disabled_mirrored); + + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CheckButton, button_checked_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CheckButton, button_unchecked_color); } CheckButton::CheckButton(const String &p_text) : diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index 84f77b2e8340..6cc33e232b27 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -49,6 +49,9 @@ class CheckButton : public Button { Ref unchecked_mirrored; Ref checked_disabled_mirrored; Ref unchecked_disabled_mirrored; + + Color button_checked_color; + Color button_unchecked_color; } theme_cache; protected: diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index 4c7efabe0615..992b14a44da4 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -325,6 +325,9 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_constant("check_v_offset", "CheckBox", 0); theme->set_constant("outline_size", "CheckBox", 0); + theme->set_color("checkbox_checked_color", "CheckBox", Color(1, 1, 1)); + theme->set_color("checkbox_unchecked_color", "CheckBox", Color(1, 1, 1)); + // CheckButton Ref cb_empty = memnew(StyleBoxEmpty); @@ -362,6 +365,9 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_constant("check_v_offset", "CheckButton", 0); theme->set_constant("outline_size", "CheckButton", 0); + theme->set_color("button_checked_color", "CheckButton", Color(1, 1, 1)); + theme->set_color("button_unchecked_color", "CheckButton", Color(1, 1, 1)); + // Button variations theme->set_type_variation("FlatButton", "Button");