mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
6b4eb710b3
We're about to introduce the Switch widget that re-uses the same state type as CheckBox. The Bool name covers both uses. Signed-off-by: Elias Naur <mail@eliasnaur.com>
36 lines
809 B
Go
36 lines
809 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package material
|
|
|
|
import (
|
|
"gioui.org/layout"
|
|
"gioui.org/unit"
|
|
"gioui.org/widget"
|
|
)
|
|
|
|
type CheckBoxStyle struct {
|
|
checkable
|
|
}
|
|
|
|
func CheckBox(th *Theme, label string) CheckBoxStyle {
|
|
return CheckBoxStyle{
|
|
checkable{
|
|
Label: label,
|
|
Color: th.Color.Text,
|
|
IconColor: th.Color.Primary,
|
|
TextSize: th.TextSize.Scale(14.0 / 16.0),
|
|
Size: unit.Dp(26),
|
|
shaper: th.Shaper,
|
|
checkedStateIcon: th.checkBoxCheckedIcon,
|
|
uncheckedStateIcon: th.checkBoxUncheckedIcon,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Layout updates the checkBox and displays it.
|
|
func (c CheckBoxStyle) Layout(gtx *layout.Context, checkBox *widget.Bool) {
|
|
checkBox.Update(gtx)
|
|
c.layout(gtx, checkBox.Value)
|
|
checkBox.Layout(gtx)
|
|
}
|