ui,internal/ops,internal/opconst: move OpsReader to internal ops package

To avoid import cycles, move the op constants to its own package,
internal/opconst.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-07 14:55:20 +02:00
parent fe20cde393
commit b3517a365e
14 changed files with 295 additions and 270 deletions
+6 -6
View File
@@ -5,7 +5,7 @@ package key
import (
"gioui.org/ui"
"gioui.org/ui/input"
"gioui.org/ui/internal/ops"
"gioui.org/ui/internal/opconst"
)
type HandlerOp struct {
@@ -56,8 +56,8 @@ func (m Modifiers) Contain(m2 Modifiers) bool {
}
func (h HandlerOp) Add(o *ui.Ops) {
data := make([]byte, ops.TypeKeyHandlerLen)
data[0] = byte(ops.TypeKeyHandler)
data := make([]byte, opconst.TypeKeyHandlerLen)
data[0] = byte(opconst.TypeKeyHandler)
if h.Focus {
data[1] = 1
}
@@ -65,7 +65,7 @@ func (h HandlerOp) Add(o *ui.Ops) {
}
func (h *HandlerOp) Decode(d []byte, refs []interface{}) {
if ops.OpType(d[0]) != ops.TypeKeyHandler {
if opconst.OpType(d[0]) != opconst.TypeKeyHandler {
panic("invalid op")
}
*h = HandlerOp{
@@ -75,8 +75,8 @@ func (h *HandlerOp) Decode(d []byte, refs []interface{}) {
}
func (h HideInputOp) Add(o *ui.Ops) {
data := make([]byte, ops.TypeHideInputLen)
data[0] = byte(ops.TypeHideInput)
data := make([]byte, opconst.TypeHideInputLen)
data[0] = byte(opconst.TypeHideInput)
o.Write(data)
}