Files
gio/widget/material/checkbox.go
T
Elias Naur 6b4eb710b3 widget: rename CheckBox to Bool
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>
2020-05-04 17:13:50 +02:00

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)
}