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>
This commit is contained in:
Elias Naur
2020-05-04 14:28:33 +02:00
parent 13941c9f1b
commit 6b4eb710b3
3 changed files with 28 additions and 28 deletions
+26
View File
@@ -0,0 +1,26 @@
package widget
import (
"gioui.org/gesture"
"gioui.org/layout"
)
type Bool struct {
Value bool
click gesture.Click
}
// Update the checked state according to incoming events.
func (b *Bool) Update(gtx *layout.Context) {
for _, e := range b.click.Events(gtx) {
switch e.Type {
case gesture.TypeClick:
b.Value = !b.Value
}
}
}
func (b *Bool) Layout(gtx *layout.Context) {
b.click.Add(gtx.Ops)
}