io/pointer,io/router: [API] make pass-through a property of AreaOp

We're about to make operation scopes explicit, which would result in
both AreaOp and PassOp be scoped. However, PassOp seems to light to have
its separate stack, so this change instead makes pass-through a property
of an area. We're assuming that clients that want pass-through are also
aware of the affected hit area.

API change: replace PassOps with the AreaOp.PassThrough field.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-10-03 18:23:55 +02:00
parent 62daadb37c
commit 6f80b94b4a
6 changed files with 51 additions and 56 deletions
+5 -4
View File
@@ -28,11 +28,12 @@ func ExampleClickable_passthrough() {
// widget lays out two buttons on top of each other.
widget := func() {
// button2 completely covers button1, but PassOp allows pointer
// events to pass through to button1.
button1.Layout(gtx)
// PassOp is applied to the area defined by button1.
pointer.PassOp{Pass: true}.Add(gtx.Ops)
area := pointer.Rect(image.Rectangle{Max: gtx.Constraints.Max})
// button2 completely covers button1, but pass-through allows pointer
// events to pass through to button1.
area.PassThrough = true
area.Add(gtx.Ops)
button2.Layout(gtx)
}