mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
ui/pointer: unexport HitResult enum
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -41,12 +41,12 @@ type Events interface {
|
|||||||
For(k Key) []Event
|
For(k Key) []Event
|
||||||
}
|
}
|
||||||
|
|
||||||
type HitResult uint8
|
type hitResult uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HitNone HitResult = iota
|
hitNone hitResult = iota
|
||||||
HitTransparent
|
hitTransparent
|
||||||
HitOpaque
|
hitOpaque
|
||||||
)
|
)
|
||||||
|
|
||||||
type ID uint16
|
type ID uint16
|
||||||
@@ -118,10 +118,10 @@ func (op *OpArea) decode(d []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *OpArea) hit(pos f32.Point) HitResult {
|
func (op *OpArea) hit(pos f32.Point) hitResult {
|
||||||
res := HitOpaque
|
res := hitOpaque
|
||||||
if op.Transparent {
|
if op.Transparent {
|
||||||
res = HitTransparent
|
res = hitTransparent
|
||||||
}
|
}
|
||||||
switch op.kind {
|
switch op.kind {
|
||||||
case areaRect:
|
case areaRect:
|
||||||
@@ -129,7 +129,7 @@ func (op *OpArea) hit(pos f32.Point) HitResult {
|
|||||||
0 <= pos.Y && pos.Y < float32(op.size.Y) {
|
0 <= pos.Y && pos.Y < float32(op.size.Y) {
|
||||||
return res
|
return res
|
||||||
} else {
|
} else {
|
||||||
return HitNone
|
return hitNone
|
||||||
}
|
}
|
||||||
case areaEllipse:
|
case areaEllipse:
|
||||||
rx := float32(op.size.X) / 2
|
rx := float32(op.size.X) / 2
|
||||||
@@ -141,7 +141,7 @@ func (op *OpArea) hit(pos f32.Point) HitResult {
|
|||||||
if xh*xh*ry2+yk*yk*rx2 <= rx2*ry2 {
|
if xh*xh*ry2+yk*yk*rx2 <= rx2*ry2 {
|
||||||
return res
|
return res
|
||||||
} else {
|
} else {
|
||||||
return HitNone
|
return hitNone
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("invalid area kind")
|
panic("invalid area kind")
|
||||||
|
|||||||
+6
-6
@@ -110,8 +110,8 @@ func (q *Queue) opHit(handlers *[]Key, pos f32.Point) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
res := h.area.hit(pos)
|
res := h.area.hit(pos)
|
||||||
opaque = opaque || res == HitOpaque
|
opaque = opaque || res == hitOpaque
|
||||||
if res != HitNone {
|
if res != hitNone {
|
||||||
*handlers = append(*handlers, n.key)
|
*handlers = append(*handlers, n.key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ func (q *Queue) Push(e Event) {
|
|||||||
case i == 0:
|
case i == 0:
|
||||||
e.Priority = Foremost
|
e.Priority = Foremost
|
||||||
}
|
}
|
||||||
e.Hit = h.area.hit(e.Position) != HitNone
|
e.Hit = h.area.hit(e.Position) != hitNone
|
||||||
e.Position = h.transform.InvTransform(e.Position)
|
e.Position = h.transform.InvTransform(e.Position)
|
||||||
h.events = append(h.events, e)
|
h.events = append(h.events, e)
|
||||||
if e.Type == Release {
|
if e.Type == Release {
|
||||||
@@ -256,12 +256,12 @@ func (q *Queue) Push(e Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a areaIntersection) hit(p f32.Point) HitResult {
|
func (a areaIntersection) hit(p f32.Point) hitResult {
|
||||||
res := HitNone
|
res := hitNone
|
||||||
for _, area := range a {
|
for _, area := range a {
|
||||||
tp := area.trans.InvTransform(p)
|
tp := area.trans.InvTransform(p)
|
||||||
res = area.area.hit(tp)
|
res = area.area.hit(tp)
|
||||||
if res == HitNone {
|
if res == hitNone {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user