io/pointer: added CursorNameOp

The cursor can now be customized for a given area.

Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
pierre
2020-12-08 18:54:50 +01:00
committed by Elias Naur
parent 675e86b8e8
commit 7c5bcd3db8
6 changed files with 57 additions and 3 deletions
+10
View File
@@ -49,6 +49,11 @@ type AreaOp struct {
rect image.Rectangle
}
// CursorNameOp sets the cursor for the current area.
type CursorNameOp struct {
Name CursorName
}
// InputOp declares an input handler ready for pointer
// events.
type InputOp struct {
@@ -178,6 +183,11 @@ func (op AreaOp) Add(o *op.Ops) {
bo.PutUint32(data[14:], uint32(op.rect.Max.Y))
}
func (op CursorNameOp) Add(o *op.Ops) {
data := o.Write1(opconst.TypeCursorLen, op.Name)
data[0] = byte(opconst.TypeCursor)
}
func (h InputOp) Add(o *op.Ops) {
data := o.Write1(opconst.TypePointerInputLen, h.Tag)
data[0] = byte(opconst.TypePointerInput)