mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
52d8a8867d
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>
36 lines
815 B
Go
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)
|
|
}
|