mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
ui: let OpsReader keep track of references
Instead of exposing the entire reference slice, return the relevant references from Next. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+3
-10
@@ -3,7 +3,6 @@
|
||||
package pointer
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"time"
|
||||
|
||||
"gioui.org/ui"
|
||||
@@ -72,26 +71,20 @@ const (
|
||||
func (h OpHandler) Add(o *ui.Ops) {
|
||||
data := make([]byte, ops.TypePointerHandlerLen)
|
||||
data[0] = byte(ops.TypePointerHandler)
|
||||
bo := binary.LittleEndian
|
||||
if h.Grab {
|
||||
data[1] = 1
|
||||
}
|
||||
bo.PutUint32(data[2:], uint32(o.Ref(h.Key)))
|
||||
bo.PutUint32(data[6:], uint32(o.Ref(h.Area)))
|
||||
o.Write(data)
|
||||
o.Write(data, []interface{}{h.Key, h.Area})
|
||||
}
|
||||
|
||||
func (h *OpHandler) Decode(d []byte, refs []interface{}) {
|
||||
bo := binary.LittleEndian
|
||||
if ops.OpType(d[0]) != ops.TypePointerHandler {
|
||||
panic("invalid op")
|
||||
}
|
||||
key := int(bo.Uint32(d[2:]))
|
||||
area := int(bo.Uint32(d[6:]))
|
||||
*h = OpHandler{
|
||||
Grab: d[1] != 0,
|
||||
Key: refs[key].(Key),
|
||||
Area: refs[area].(Area),
|
||||
Key: refs[0].(Key),
|
||||
Area: refs[1].(Area),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user