Browse Source

Add disabled theme icons for CheckBox

(cherry picked from commit 3a40c268a60bff45bb123625b261345c28259441)
Tomasz Chabora 5 years ago
parent
commit
44e84c61a6

+ 8 - 0
doc/classes/CheckBox.xml

@@ -24,6 +24,8 @@
 		<theme_item name="checked" type="Texture">
 		<theme_item name="checked" type="Texture">
 			The check icon to display when the [CheckBox] is checked.
 			The check icon to display when the [CheckBox] is checked.
 		</theme_item>
 		</theme_item>
+		<theme_item name="checked_disabled" type="Texture">
+		</theme_item>
 		<theme_item name="disabled" type="StyleBox">
 		<theme_item name="disabled" type="StyleBox">
 			The [StyleBox] to display as a background when the [CheckBox] is disabled.
 			The [StyleBox] to display as a background when the [CheckBox] is disabled.
 		</theme_item>
 		</theme_item>
@@ -66,11 +68,17 @@
 		<theme_item name="radio_checked" type="Texture">
 		<theme_item name="radio_checked" type="Texture">
 			If the [CheckBox] is configured as a radio button, the icon to display when the [CheckBox] is checked.
 			If the [CheckBox] is configured as a radio button, the icon to display when the [CheckBox] is checked.
 		</theme_item>
 		</theme_item>
+		<theme_item name="radio_checked_disabled" type="Texture">
+		</theme_item>
 		<theme_item name="radio_unchecked" type="Texture">
 		<theme_item name="radio_unchecked" type="Texture">
 			If the [CheckBox] is configured as a radio button, the icon to display when the [CheckBox] is unchecked.
 			If the [CheckBox] is configured as a radio button, the icon to display when the [CheckBox] is unchecked.
 		</theme_item>
 		</theme_item>
+		<theme_item name="radio_unchecked_disabled" type="Texture">
+		</theme_item>
 		<theme_item name="unchecked" type="Texture">
 		<theme_item name="unchecked" type="Texture">
 			The check icon to display when the [CheckBox] is unchecked.
 			The check icon to display when the [CheckBox] is unchecked.
 		</theme_item>
 		</theme_item>
+		<theme_item name="unchecked_disabled" type="Texture">
+		</theme_item>
 	</theme_items>
 	</theme_items>
 </class>
 </class>

+ 4 - 2
scene/gui/check_box.cpp

@@ -34,7 +34,9 @@
 
 
 Size2 CheckBox::get_icon_size() const {
 Size2 CheckBox::get_icon_size() const {
 	Ref<Texture> checked = Control::get_icon("checked");
 	Ref<Texture> checked = Control::get_icon("checked");
+	Ref<Texture> checked_disabled = Control::get_icon("checked_disabled");
 	Ref<Texture> unchecked = Control::get_icon("unchecked");
 	Ref<Texture> unchecked = Control::get_icon("unchecked");
+	Ref<Texture> unchecked_disabled = Control::get_icon("unchecked_disabled");
 	Ref<Texture> radio_checked = Control::get_icon("radio_checked");
 	Ref<Texture> radio_checked = Control::get_icon("radio_checked");
 	Ref<Texture> radio_unchecked = Control::get_icon("radio_unchecked");
 	Ref<Texture> radio_unchecked = Control::get_icon("radio_unchecked");
 
 
@@ -73,8 +75,8 @@ void CheckBox::_notification(int p_what) {
 
 
 		RID ci = get_canvas_item();
 		RID ci = get_canvas_item();
 
 
-		Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked");
-		Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
+		Ref<Texture> on = Control::get_icon(vformat("%s%s", is_radio() ? "radio_checked" : "checked", is_disabled() ? "_disabled" : ""));
+		Ref<Texture> off = Control::get_icon(vformat("%s%s", is_radio() ? "radio_unchecked" : "unchecked", is_disabled() ? "_disabled" : ""));
 		Ref<StyleBox> sb = get_stylebox("normal");
 		Ref<StyleBox> sb = get_stylebox("normal");
 
 
 		Vector2 ofs;
 		Vector2 ofs;

BIN
scene/resources/default_theme/checked_disabled.png


+ 4 - 0
scene/resources/default_theme/default_theme.cpp

@@ -359,9 +359,13 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
 	theme->set_stylebox("focus", "CheckBox", cbx_focus);
 	theme->set_stylebox("focus", "CheckBox", cbx_focus);
 
 
 	theme->set_icon("checked", "CheckBox", make_icon(checked_png));
 	theme->set_icon("checked", "CheckBox", make_icon(checked_png));
+	theme->set_icon("checked_disabled", "CheckBox", make_icon(checked_disabled_png));
 	theme->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
 	theme->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
+	theme->set_icon("unchecked_disabled", "CheckBox", make_icon(unchecked_disabled_png));
 	theme->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
 	theme->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
+	theme->set_icon("radio_checked_disabled", "CheckBox", make_icon(radio_checked_disabled_png));
 	theme->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
 	theme->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
+	theme->set_icon("radio_unchecked_disabled", "CheckBox", make_icon(radio_unchecked_disabled_png));
 
 
 	theme->set_font("font", "CheckBox", default_font);
 	theme->set_font("font", "CheckBox", default_font);
 
 

BIN
scene/resources/default_theme/radio_checked_disabled.png


BIN
scene/resources/default_theme/radio_unchecked_disabled.png


File diff suppressed because it is too large
+ 0 - 0
scene/resources/default_theme/theme_data.h


BIN
scene/resources/default_theme/unchecked_disabled.png


Some files were not shown because too many files changed in this diff