widget/material: Make checkbox/radio buttons icon modifiable

Signed-off-by: songpv <pvsong10@icloud.com>
This commit is contained in:
Elias Naur
2020-08-10 21:33:20 +02:00
parent a063febed9
commit c3574cdabd
3 changed files with 15 additions and 13 deletions
+2 -2
View File
@@ -23,8 +23,8 @@ func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle {
TextSize: th.TextSize.Scale(14.0 / 16.0), TextSize: th.TextSize.Scale(14.0 / 16.0),
Size: unit.Dp(26), Size: unit.Dp(26),
shaper: th.Shaper, shaper: th.Shaper,
checkedStateIcon: th.checkBoxCheckedIcon, checkedStateIcon: th.Icon.CheckBoxChecked,
uncheckedStateIcon: th.checkBoxUncheckedIcon, uncheckedStateIcon: th.Icon.CheckBoxUnchecked,
}, },
} }
} }
+2 -2
View File
@@ -27,8 +27,8 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt
TextSize: th.TextSize.Scale(14.0 / 16.0), TextSize: th.TextSize.Scale(14.0 / 16.0),
Size: unit.Dp(26), Size: unit.Dp(26),
shaper: th.Shaper, shaper: th.Shaper,
checkedStateIcon: th.radioCheckedIcon, checkedStateIcon: th.Icon.RadioChecked,
uncheckedStateIcon: th.radioUncheckedIcon, uncheckedStateIcon: th.Icon.RadioUnchecked,
}, },
Key: key, Key: key,
} }
+11 -9
View File
@@ -22,11 +22,13 @@ type Theme struct {
Hint color.RGBA Hint color.RGBA
InvText color.RGBA InvText color.RGBA
} }
TextSize unit.Value TextSize unit.Value
checkBoxCheckedIcon *widget.Icon Icon struct {
checkBoxUncheckedIcon *widget.Icon CheckBoxChecked *widget.Icon
radioCheckedIcon *widget.Icon CheckBoxUnchecked *widget.Icon
radioUncheckedIcon *widget.Icon RadioChecked *widget.Icon
RadioUnchecked *widget.Icon
}
} }
func NewTheme(fontCollection []text.FontFace) *Theme { func NewTheme(fontCollection []text.FontFace) *Theme {
@@ -39,10 +41,10 @@ func NewTheme(fontCollection []text.FontFace) *Theme {
t.Color.InvText = rgb(0xffffff) t.Color.InvText = rgb(0xffffff)
t.TextSize = unit.Sp(16) t.TextSize = unit.Sp(16)
t.checkBoxCheckedIcon = mustIcon(widget.NewIcon(icons.ToggleCheckBox)) t.Icon.CheckBoxChecked = mustIcon(widget.NewIcon(icons.ToggleCheckBox))
t.checkBoxUncheckedIcon = mustIcon(widget.NewIcon(icons.ToggleCheckBoxOutlineBlank)) t.Icon.CheckBoxUnchecked = mustIcon(widget.NewIcon(icons.ToggleCheckBoxOutlineBlank))
t.radioCheckedIcon = mustIcon(widget.NewIcon(icons.ToggleRadioButtonChecked)) t.Icon.RadioChecked = mustIcon(widget.NewIcon(icons.ToggleRadioButtonChecked))
t.radioUncheckedIcon = mustIcon(widget.NewIcon(icons.ToggleRadioButtonUnchecked)) t.Icon.RadioUnchecked = mustIcon(widget.NewIcon(icons.ToggleRadioButtonUnchecked))
return t return t
} }