mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
widget: [API] add child widget argument to Clickable.Layout
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>
This commit is contained in:
@@ -3,10 +3,7 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
)
|
||||
@@ -34,9 +31,7 @@ func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle {
|
||||
|
||||
// Layout updates the checkBox and displays it.
|
||||
func (c CheckBoxStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
dims := c.layout(gtx, c.CheckBox.Value, c.CheckBox.Hovered())
|
||||
defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
|
||||
gtx.Constraints.Min = dims.Size
|
||||
c.CheckBox.Layout(gtx)
|
||||
return dims
|
||||
return c.CheckBox.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
return c.layout(gtx, c.CheckBox.Value, c.CheckBox.Hovered())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user