io/pointer: re-introduce PassOp

A previous change merged PassOp with AreaOp under the assumption that
the pass mode would be set on a particular area. That assumption turns
out not to hold, so this change brings back PassOp as an independent
stack operation.

This is an API change: replace AreaOp{Pass: true} with a separate
pointer.PassOp operation.

Fixes gio#288

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-10-09 16:27:24 +02:00
parent 61a3395879
commit 960f3068a1
5 changed files with 58 additions and 29 deletions
+1 -3
View File
@@ -29,11 +29,9 @@ func ExampleClickable_passthrough() {
// widget lays out two buttons on top of each other.
widget := func() {
button1.Layout(gtx)
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
defer area.Push(gtx.Ops).Pop()
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
button2.Layout(gtx)
}
+2 -2
View File
@@ -161,7 +161,7 @@ func (s ScrollbarStyle) layout(gtx layout.Context, axis layout.Axis, viewportSta
// Stack a normal clickable area on top of the draggable area
// to capture non-dragging clicks.
pointerArea.PassThrough = true
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
defer pointerArea.Push(gtx.Ops).Pop()
s.Scrollbar.AddTrack(gtx.Ops)
@@ -206,7 +206,7 @@ func (s ScrollbarStyle) layout(gtx layout.Context, axis layout.Axis, viewportSta
// Add the indicator pointer hit area.
area := pointer.Rect(image.Rectangle{Max: indicatorDims})
area.PassThrough = true
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
defer area.Push(gtx.Ops).Pop()
s.Scrollbar.AddIndicator(gtx.Ops)