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
+4 -3
View File
@@ -162,7 +162,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.
saved := op.Save(gtx.Ops)
pointer.PassOp{Pass: true}.Add(gtx.Ops)
pointerArea.PassThrough = true
pointerArea.Add(gtx.Ops)
s.Scrollbar.AddTrack(gtx.Ops)
saved.Load()
@@ -208,8 +208,9 @@ func (s ScrollbarStyle) layout(gtx layout.Context, axis layout.Axis, viewportSta
}.Op(gtx.Ops))
// Add the indicator pointer hit area.
pointer.PassOp{Pass: true}.Add(gtx.Ops)
pointer.Rect(image.Rectangle{Max: indicatorDims}).Add(gtx.Ops)
area := pointer.Rect(image.Rectangle{Max: indicatorDims})
area.PassThrough = true
area.Add(gtx.Ops)
s.Scrollbar.AddIndicator(gtx.Ops)
return layout.Dimensions{Size: axis.Convert(gtx.Constraints.Min)}