mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
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),
|
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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user