Files
gio/ui/internal/ops/ops.go
T
Elias Naur f44ccec043 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.
2019-07-10 22:43:03 +02:00

78 lines
1.4 KiB
Go

package ops
type OpType byte
// Start at a high number for easier debugging.
const firstOpIndex = 200
const (
TypeBlockDef OpType = iota + firstOpIndex
TypeBlock
TypeTransform
TypeLayer
TypeInvalidate
TypeImage
TypeDraw
TypeColor
TypeArea
TypePointerHandler
TypePass
TypeKeyHandler
TypeHideInput
TypePush
TypePop
TypeAux
TypeClip
)
const (
TypeBlockDefLen = 1 + 4 + 4
TypeBlockLen = 1 + 4 + 4 + 4
TypeTransformLen = 1 + 4*2
TypeLayerLen = 1
TypeRedrawLen = 1 + 8
TypeImageLen = 1 + 4*4
TypeDrawLen = 1 + 4*4
TypeColorLen = 1 + 4
TypeAreaLen = 1 + 1 + 2*4
TypePointerHandlerLen = 1 + 1
TypePassLen = 1 + 1
TypeKeyHandlerLen = 1 + 1
TypeHideInputLen = 1
TypePushLen = 1
TypePopLen = 1
TypeAuxLen = 1 + 4
TypeClipLen = 1 + 4*4
)
func (t OpType) Size() int {
return [...]int{
TypeBlockDefLen,
TypeBlockLen,
TypeTransformLen,
TypeLayerLen,
TypeRedrawLen,
TypeImageLen,
TypeDrawLen,
TypeColorLen,
TypeAreaLen,
TypePointerHandlerLen,
TypePassLen,
TypeKeyHandlerLen,
TypeHideInputLen,
TypePushLen,
TypePopLen,
TypeAuxLen,
TypeClipLen,
}[t-firstOpIndex]
}
func (t OpType) NumRefs() int {
switch t {
case TypeBlock, TypeImage, TypeKeyHandler, TypePointerHandler:
return 1
default:
return 0
}
}