mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user