ui/pointer: introduce OpArea for pointer hit testing

Split out OpArea from OpHandler to allow stacked areas in a followup.

Replace hit closures with static shapes (rectangles and ellipses) to
avoid allocations. If needed, generic hit functions can be introduced
again later.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-03 13:09:07 +02:00
parent 559db02035
commit 40856a244e
6 changed files with 108 additions and 58 deletions
+3 -3
View File
@@ -201,9 +201,9 @@ func (e *Editor) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
}
baseline := e.padTop + e.dims.Baseline
area := &gesture.Rect{e.viewSize}
e.scroller.Op(ops, area)
e.clicker.Op(ops, area)
pointer.AreaRect(e.viewSize).Add(ops)
e.scroller.Add(ops)
e.clicker.Add(ops)
return layout.Dimens{Size: e.viewSize, Baseline: baseline}
}