forked from joejulian/gio
widget/material: Make checkbox/radio buttons icon modifiable
Signed-off-by: songpv <pvsong10@icloud.com>
This commit is contained in:
@@ -23,8 +23,8 @@ func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle {
|
||||
TextSize: th.TextSize.Scale(14.0 / 16.0),
|
||||
Size: unit.Dp(26),
|
||||
shaper: th.Shaper,
|
||||
checkedStateIcon: th.checkBoxCheckedIcon,
|
||||
uncheckedStateIcon: th.checkBoxUncheckedIcon,
|
||||
checkedStateIcon: th.Icon.CheckBoxChecked,
|
||||
uncheckedStateIcon: th.Icon.CheckBoxUnchecked,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt
|
||||
TextSize: th.TextSize.Scale(14.0 / 16.0),
|
||||
Size: unit.Dp(26),
|
||||
shaper: th.Shaper,
|
||||
checkedStateIcon: th.radioCheckedIcon,
|
||||
uncheckedStateIcon: th.radioUncheckedIcon,
|
||||
checkedStateIcon: th.Icon.RadioChecked,
|
||||
uncheckedStateIcon: th.Icon.RadioUnchecked,
|
||||
},
|
||||
Key: key,
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ type Theme struct {
|
||||
Hint color.RGBA
|
||||
InvText color.RGBA
|
||||
}
|
||||
TextSize unit.Value
|
||||
checkBoxCheckedIcon *widget.Icon
|
||||
checkBoxUncheckedIcon *widget.Icon
|
||||
radioCheckedIcon *widget.Icon
|
||||
radioUncheckedIcon *widget.Icon
|
||||
TextSize unit.Value
|
||||
Icon struct {
|
||||
CheckBoxChecked *widget.Icon
|
||||
CheckBoxUnchecked *widget.Icon
|
||||
RadioChecked *widget.Icon
|
||||
RadioUnchecked *widget.Icon
|
||||
}
|
||||
}
|
||||
|
||||
func NewTheme(fontCollection []text.FontFace) *Theme {
|
||||
@@ -39,10 +41,10 @@ func NewTheme(fontCollection []text.FontFace) *Theme {
|
||||
t.Color.InvText = rgb(0xffffff)
|
||||
t.TextSize = unit.Sp(16)
|
||||
|
||||
t.checkBoxCheckedIcon = mustIcon(widget.NewIcon(icons.ToggleCheckBox))
|
||||
t.checkBoxUncheckedIcon = mustIcon(widget.NewIcon(icons.ToggleCheckBoxOutlineBlank))
|
||||
t.radioCheckedIcon = mustIcon(widget.NewIcon(icons.ToggleRadioButtonChecked))
|
||||
t.radioUncheckedIcon = mustIcon(widget.NewIcon(icons.ToggleRadioButtonUnchecked))
|
||||
t.Icon.CheckBoxChecked = mustIcon(widget.NewIcon(icons.ToggleCheckBox))
|
||||
t.Icon.CheckBoxUnchecked = mustIcon(widget.NewIcon(icons.ToggleCheckBoxOutlineBlank))
|
||||
t.Icon.RadioChecked = mustIcon(widget.NewIcon(icons.ToggleRadioButtonChecked))
|
||||
t.Icon.RadioUnchecked = mustIcon(widget.NewIcon(icons.ToggleRadioButtonUnchecked))
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user