mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
665e23693f
To make the semantic relation between the clickable area and its content clear, it will be important for the clickable clip operation to cover all of the clickable content. API change: users of widget.Clickable must now pass the clickable content to Layout. Signed-off-by: Elias Naur <mail@eliasnaur.com>
38 lines
957 B
Go
38 lines
957 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package material
|
|
|
|
import (
|
|
"gioui.org/layout"
|
|
"gioui.org/unit"
|
|
"gioui.org/widget"
|
|
)
|
|
|
|
type CheckBoxStyle struct {
|
|
checkable
|
|
CheckBox *widget.Bool
|
|
}
|
|
|
|
func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle {
|
|
return CheckBoxStyle{
|
|
CheckBox: checkBox,
|
|
checkable: checkable{
|
|
Label: label,
|
|
Color: th.Palette.Fg,
|
|
IconColor: th.Palette.ContrastBg,
|
|
TextSize: th.TextSize.Scale(14.0 / 16.0),
|
|
Size: unit.Dp(26),
|
|
shaper: th.Shaper,
|
|
checkedStateIcon: th.Icon.CheckBoxChecked,
|
|
uncheckedStateIcon: th.Icon.CheckBoxUnchecked,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Layout updates the checkBox and displays it.
|
|
func (c CheckBoxStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|
return c.CheckBox.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
|
return c.layout(gtx, c.CheckBox.Value, c.CheckBox.Hovered())
|
|
})
|
|
}
|