mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
io/pointer,io/router: replace AreaOp with clip.Op
Pointer hit areas and paint clip areas are separate concepts, but similar enough to warrant merging. This change replaces pointer hit areas with clip areas, so Gio is left with just one area concept (in package op/clip). The reason for separating the concepts in the original Gio release was because of my being unsure general path/stroke hit areas would ever be implemented, let alone efficient. This change represents a change of mind, in the sense that it's better to have an incomplete API than two separate area concepts. Leave the deprecated pointer.Rect, pointer.Ellipse for temporary backwards compatibility. This is an API change. Most existing programs should continue to build with this change, but may have to adjust to having all clip.Ops participate in InputOp hit areas. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+11
-12
@@ -29,6 +29,8 @@ type Ops struct {
|
||||
|
||||
type OpType byte
|
||||
|
||||
type Shape byte
|
||||
|
||||
// Start at a high number for easier debugging.
|
||||
const firstOpIndex = 200
|
||||
|
||||
@@ -44,8 +46,6 @@ const (
|
||||
TypePaint
|
||||
TypeColor
|
||||
TypeLinearGradient
|
||||
TypeArea
|
||||
TypePopArea
|
||||
TypePass
|
||||
TypePopPass
|
||||
TypePointerInput
|
||||
@@ -91,15 +91,21 @@ type StackKind uint8
|
||||
type ClipOp struct {
|
||||
Bounds image.Rectangle
|
||||
Outline bool
|
||||
Shape Shape
|
||||
}
|
||||
|
||||
const (
|
||||
ClipStack StackKind = iota
|
||||
AreaStack
|
||||
TransStack
|
||||
PassStack
|
||||
)
|
||||
|
||||
const (
|
||||
Path Shape = iota
|
||||
Ellipse
|
||||
Rect
|
||||
)
|
||||
|
||||
const (
|
||||
TypeMacroLen = 1 + 4 + 4
|
||||
TypeCallLen = 1 + 4 + 4
|
||||
@@ -112,8 +118,6 @@ const (
|
||||
TypePaintLen = 1
|
||||
TypeColorLen = 1 + 4
|
||||
TypeLinearGradientLen = 1 + 8*2 + 4*2
|
||||
TypeAreaLen = 1 + 1 + 4*4
|
||||
TypePopAreaLen = 1
|
||||
TypePassLen = 1
|
||||
TypePopPassLen = 1
|
||||
TypePointerInputLen = 1 + 1 + 1*2 + 2*4 + 2*4
|
||||
@@ -125,7 +129,7 @@ const (
|
||||
TypeSaveLen = 1 + 4
|
||||
TypeLoadLen = 1 + 4
|
||||
TypeAuxLen = 1
|
||||
TypeClipLen = 1 + 4*4 + 1
|
||||
TypeClipLen = 1 + 4*4 + 1 + 1
|
||||
TypePopClipLen = 1
|
||||
TypeProfileLen = 1
|
||||
TypeCursorLen = 1 + 1
|
||||
@@ -151,6 +155,7 @@ func (op *ClipOp) Decode(data []byte) {
|
||||
*op = ClipOp{
|
||||
Bounds: r,
|
||||
Outline: data[17] == 1,
|
||||
Shape: Shape(data[18]),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,8 +337,6 @@ func (t OpType) Size() int {
|
||||
TypePaintLen,
|
||||
TypeColorLen,
|
||||
TypeLinearGradientLen,
|
||||
TypeAreaLen,
|
||||
TypePopAreaLen,
|
||||
TypePassLen,
|
||||
TypePopPassLen,
|
||||
TypePointerInputLen,
|
||||
@@ -389,10 +392,6 @@ func (t OpType) String() string {
|
||||
return "Color"
|
||||
case TypeLinearGradient:
|
||||
return "LinearGradient"
|
||||
case TypeArea:
|
||||
return "Area"
|
||||
case TypePopArea:
|
||||
return "PopArea"
|
||||
case TypePass:
|
||||
return "Pass"
|
||||
case TypePopPass:
|
||||
|
||||
Reference in New Issue
Block a user