mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +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
-9
@@ -3,8 +3,6 @@
|
||||
package key
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"gioui.org/ui"
|
||||
"gioui.org/ui/internal/ops"
|
||||
)
|
||||
@@ -73,30 +71,26 @@ const (
|
||||
func (h OpHandler) Add(o *ui.Ops) {
|
||||
data := make([]byte, ops.TypeKeyHandlerLen)
|
||||
data[0] = byte(ops.TypeKeyHandler)
|
||||
bo := binary.LittleEndian
|
||||
if h.Focus {
|
||||
data[1] = 1
|
||||
}
|
||||
bo.PutUint32(data[2:], uint32(o.Ref(h.Key)))
|
||||
o.Write(data)
|
||||
o.Write(data, []interface{}{h.Key})
|
||||
}
|
||||
|
||||
func (h *OpHandler) Decode(d []byte, refs []interface{}) {
|
||||
bo := binary.LittleEndian
|
||||
if ops.OpType(d[0]) != ops.TypeKeyHandler {
|
||||
panic("invalid op")
|
||||
}
|
||||
key := int(bo.Uint32(d[2:]))
|
||||
*h = OpHandler{
|
||||
Focus: d[1] != 0,
|
||||
Key: refs[key].(Key),
|
||||
Key: refs[0].(Key),
|
||||
}
|
||||
}
|
||||
|
||||
func (h OpHideInput) Add(o *ui.Ops) {
|
||||
data := make([]byte, ops.TypeHideInputLen)
|
||||
data[0] = byte(ops.TypeHideInput)
|
||||
o.Write(data)
|
||||
o.Write(data, nil)
|
||||
}
|
||||
|
||||
func (Edit) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user