Files
gio/widget/material/checkbox.go
T
Elias Naur 52d8a8867d widget,widget/material: export CheckBox.Checked
Similar to the previous change to Enum, expose the current state of
the CheckBox. Rename the Checked method to just Update and get rid
of the SetChecked method.

Fixes gio#100

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-03 21:28:33 +02:00

36 lines
815 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.CheckBox) {
checkBox.Update(gtx)
c.layout(gtx, checkBox.Checked)
checkBox.Layout(gtx)
}