mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
ui/pointer: simplify pointer pass through
Get rid of the confused LayerOp and the transparent property from AreaOp. Add an explicit PassOp to specify whether pointer events pass-through the current area. Let AreaOp swallow events even when no handlers are active for the area. That behaviour is less surprising and allow clients to disable a widget by keeping its areas but leave out its handlers. Simplify the pointer.HitResult enum to just a bool: hit or no hit. Finally, simplify the pointer queue by tracking parent areas and node with indices.
This commit is contained in:
@@ -20,10 +20,6 @@ type Config interface {
|
||||
Px(v Value) int
|
||||
}
|
||||
|
||||
// LayerOp represents a semantic layer of UI.
|
||||
type LayerOp struct {
|
||||
}
|
||||
|
||||
// InvalidateOp requests a redraw at the given time. Use
|
||||
// the zero value to request an immediate redraw.
|
||||
type InvalidateOp struct {
|
||||
@@ -40,6 +36,9 @@ type Transform struct {
|
||||
offset f32.Point
|
||||
}
|
||||
|
||||
// Inf is the int value that represents an unbounded maximum constraint.
|
||||
const Inf = int(^uint(0) >> 1)
|
||||
|
||||
func (r InvalidateOp) Add(o *Ops) {
|
||||
data := make([]byte, ops.TypeRedrawLen)
|
||||
data[0] = byte(ops.TypeInvalidate)
|
||||
@@ -100,22 +99,6 @@ func (t *TransformOp) Decode(d []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l LayerOp) Add(o *Ops) {
|
||||
data := make([]byte, ops.TypeLayerLen)
|
||||
data[0] = byte(ops.TypeLayer)
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (l *LayerOp) Decode(d []byte) {
|
||||
if ops.OpType(d[0]) != ops.TypeLayer {
|
||||
panic("invalid op")
|
||||
}
|
||||
*l = LayerOp{}
|
||||
}
|
||||
|
||||
func Offset(o f32.Point) Transform {
|
||||
return Transform{o}
|
||||
}
|
||||
|
||||
// Inf is the int value that represents an unbounded maximum constraint.
|
||||
const Inf = int(^uint(0) >> 1)
|
||||
|
||||
Reference in New Issue
Block a user