~eliasnaur/gio

ref: 69dfd2e3a55419167975adc316f8126bc4737443 gio/widget/material/checkbox.go -rw-r--r-- 724 bytes View raw
69dfd2e3Elias Naur op/paint: add support for efficient ImageOp subimages 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: Unlicense OR MIT

package material

import (
	"gioui.org/layout"
	"gioui.org/unit"
	"gioui.org/widget"
)

type CheckBox struct {
	checkable
}

func (t *Theme) CheckBox(label string) CheckBox {
	return CheckBox{
		checkable{
			Label:              label,
			Color:              t.Color.Text,
			IconColor:          t.Color.Primary,
			TextSize:           t.TextSize.Scale(14.0 / 16.0),
			Size:               unit.Dp(26),
			shaper:             t.Shaper,
			checkedStateIcon:   t.checkBoxCheckedIcon,
			uncheckedStateIcon: t.checkBoxUncheckedIcon,
		},
	}
}

func (c CheckBox) Layout(gtx *layout.Context, checkBox *widget.CheckBox) {
	c.layout(gtx, checkBox.Checked(gtx))
	checkBox.Layout(gtx)
}