gesture,widget,f32: [API] use integer coordinates for gesture coordinates

Most widget code operate in integer coordinates. This change makes
gesture pointer coordinates integer, to lessen the number of float32
to int conversions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-26 10:36:41 +02:00
parent 87be31cbec
commit 14805af367
4 changed files with 13 additions and 6 deletions
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"image"
"time"
"gioui.org/f32"
"gioui.org/gesture"
"gioui.org/io/key"
"gioui.org/io/pointer"
@@ -39,7 +38,7 @@ type Click struct {
// Press represents a past pointer press.
type Press struct {
// Position of the press.
Position f32.Point
Position image.Point
// Start is when the press began.
Start time.Time
// End is when the press was ended by a release or cancel.
+1 -1
View File
@@ -297,7 +297,7 @@ func drawInk(gtx layout.Context, c widget.Press) {
ink := paint.ColorOp{Color: rgba}
ink.Add(gtx.Ops)
rr := size * .5
defer op.Offset(c.Position.Add(f32.Point{
defer op.Offset(layout.FPt(c.Position).Add(f32.Point{
X: -rr,
Y: -rr,
})).Push(gtx.Ops).Pop()