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:
Elias Naur
2021-11-29 16:28:19 +01:00
parent a894bd6c9c
commit 665e23693f
6 changed files with 98 additions and 91 deletions
+3 -2
View File
@@ -28,11 +28,12 @@ func ExampleClickable_passthrough() {
// widget lays out two buttons on top of each other.
widget := func() {
button1.Layout(gtx)
content := func(gtx layout.Context) layout.Dimensions { return layout.Dimensions{Size: gtx.Constraints.Min} }
button1.Layout(gtx, content)
// button2 completely covers button1, but pass-through allows pointer
// events to pass through to button1.
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
button2.Layout(gtx)
button2.Layout(gtx, content)
}
// The first layout and call to Frame declare the Clickable handlers