io/input,io/router: [API] rename package io/router to io/input

The input name better matches its purpose, in particular when we
introduce input.Source.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-10-08 17:45:39 -05:00
parent 99399184ac
commit d5a0d2cf60
19 changed files with 74 additions and 72 deletions
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"gioui.org/font"
"gioui.org/font/gofont"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/router"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/text"
@@ -33,7 +33,7 @@ func FuzzIME(f *testing.F) {
e := new(widget.Editor)
e.Focus()
var r router.Router
var r input.Router
gtx := layout.Context{Ops: new(op.Ops), Queue: &r}
// Layout once to register focus.
e.Layout(gtx, cache, font.Font{}, unit.Sp(10), op.CallOp{}, op.CallOp{})
+10 -10
View File
@@ -138,9 +138,9 @@ import (
"gioui.org/f32"
"gioui.org/io/clipboard"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/semantic"
"gioui.org/io/system"
"gioui.org/unit"
@@ -164,10 +164,10 @@ type window struct {
config Config
semantic struct {
hoverID router.SemanticID
rootID router.SemanticID
focusID router.SemanticID
diffs []router.SemanticID
hoverID input.SemanticID
rootID input.SemanticID
focusID input.SemanticID
diffs []input.SemanticID
}
}
@@ -661,7 +661,7 @@ func Java_org_gioui_GioView_onClearA11yFocus(env *C.JNIEnv, class C.jclass, view
}
}
func (w *window) initAccessibilityNodeInfo(env *C.JNIEnv, sem router.SemanticNode, off image.Point, info C.jobject) error {
func (w *window) initAccessibilityNodeInfo(env *C.JNIEnv, sem input.SemanticNode, off image.Point, info C.jobject) error {
for _, ch := range sem.Children {
err := callVoidMethod(env, info, android.accessibilityNodeInfo.addChild, jvalue(w.view), jvalue(w.virtualIDFor(ch.ID)))
if err != nil {
@@ -704,7 +704,7 @@ func (w *window) initAccessibilityNodeInfo(env *C.JNIEnv, sem router.SemanticNod
panic(err)
}
}
if d.Gestures&router.ClickGesture != 0 {
if d.Gestures&input.ClickGesture != 0 {
addAction(ACTION_CLICK)
}
clsName := android.strings.androidViewView
@@ -749,18 +749,18 @@ func (w *window) initAccessibilityNodeInfo(env *C.JNIEnv, sem router.SemanticNod
return nil
}
func (w *window) virtualIDFor(id router.SemanticID) C.jint {
func (w *window) virtualIDFor(id input.SemanticID) C.jint {
if id == w.semantic.rootID {
return HOST_VIEW_ID
}
return C.jint(id)
}
func (w *window) semIDFor(virtID C.jint) router.SemanticID {
func (w *window) semIDFor(virtID C.jint) input.SemanticID {
if virtID == HOST_VIEW_ID {
return w.semantic.rootID
}
return router.SemanticID(virtID)
return input.SemanticID(virtID)
}
func (w *window) detach(env *C.JNIEnv) {
+26 -26
View File
@@ -19,9 +19,9 @@ import (
"gioui.org/internal/debug"
"gioui.org/internal/ops"
"gioui.org/io/event"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
@@ -76,7 +76,7 @@ type Window struct {
// metric is the metric from the most recent frame.
metric unit.Metric
queue router.Router
queue input.Router
cursor pointer.Cursor
decorations struct {
op.Ops
@@ -101,10 +101,10 @@ type Window struct {
semantic struct {
// uptodate tracks whether the fields below are up to date.
uptodate bool
root router.SemanticID
prevTree []router.SemanticNode
tree []router.SemanticNode
ids map[router.SemanticID]router.SemanticNode
root input.SemanticID
prevTree []input.SemanticNode
tree []input.SemanticNode
ids map[input.SemanticID]input.SemanticNode
}
imeState editorState
@@ -121,7 +121,7 @@ type Window struct {
}
type editorState struct {
router.EditorState
input.EditorState
compose key.Range
}
@@ -188,7 +188,7 @@ func NewWindow(options ...Option) *Window {
w.decorations.enabled = cnf.Decorated
w.decorations.height = decoHeight
w.imeState.compose = key.Range{Start: -1, End: -1}
w.semantic.ids = make(map[router.SemanticID]router.SemanticNode)
w.semantic.ids = make(map[input.SemanticID]input.SemanticNode)
w.callbacks.w = w
w.eventState.initialOpts = options
return w
@@ -308,9 +308,9 @@ func (w *Window) processFrame(d driver) {
w.semantic.uptodate = false
q := &w.queue
switch q.TextInputState() {
case router.TextInputOpen:
case input.TextInputOpen:
d.ShowTextInput(true)
case router.TextInputClose:
case input.TextInputClose:
d.ShowTextInput(false)
}
if hint, ok := q.TextInputHint(); ok {
@@ -501,19 +501,19 @@ func (c *callbacks) Event(e event.Event) bool {
}
// SemanticRoot returns the ID of the semantic root.
func (c *callbacks) SemanticRoot() router.SemanticID {
func (c *callbacks) SemanticRoot() input.SemanticID {
c.w.updateSemantics()
return c.w.semantic.root
}
// LookupSemantic looks up a semantic node from an ID. The zero ID denotes the root.
func (c *callbacks) LookupSemantic(semID router.SemanticID) (router.SemanticNode, bool) {
func (c *callbacks) LookupSemantic(semID input.SemanticID) (input.SemanticNode, bool) {
c.w.updateSemantics()
n, found := c.w.semantic.ids[semID]
return n, found
}
func (c *callbacks) AppendSemanticDiffs(diffs []router.SemanticID) []router.SemanticID {
func (c *callbacks) AppendSemanticDiffs(diffs []input.SemanticID) []input.SemanticID {
c.w.updateSemantics()
if tree := c.w.semantic.prevTree; len(tree) > 0 {
c.w.collectSemanticDiffs(&diffs, c.w.semantic.prevTree[0])
@@ -521,7 +521,7 @@ func (c *callbacks) AppendSemanticDiffs(diffs []router.SemanticID) []router.Sema
return diffs
}
func (c *callbacks) SemanticAt(pos f32.Point) (router.SemanticID, bool) {
func (c *callbacks) SemanticAt(pos f32.Point) (input.SemanticID, bool) {
c.w.updateSemantics()
return c.w.queue.SemanticAt(pos)
}
@@ -565,19 +565,19 @@ func (c *callbacks) SetEditorSnippet(r key.Range) {
c.Event(key.SnippetEvent(r))
}
func (w *Window) moveFocus(dir router.FocusDirection, d driver) {
func (w *Window) moveFocus(dir input.FocusDirection, d driver) {
if w.queue.MoveFocus(dir) {
w.queue.RevealFocus(w.viewport)
} else {
var v image.Point
switch dir {
case router.FocusRight:
case input.FocusRight:
v = image.Pt(+1, 0)
case router.FocusLeft:
case input.FocusLeft:
v = image.Pt(-1, 0)
case router.FocusDown:
case input.FocusDown:
v = image.Pt(0, +1)
case router.FocusUp:
case input.FocusUp:
v = image.Pt(0, -1)
default:
return
@@ -767,7 +767,7 @@ func (w *Window) updateSemantics() {
}
// collectSemanticDiffs traverses the previous semantic tree, noting changed nodes.
func (w *Window) collectSemanticDiffs(diffs *[]router.SemanticID, n router.SemanticNode) {
func (w *Window) collectSemanticDiffs(diffs *[]input.SemanticID, n input.SemanticNode) {
newNode, exists := w.semantic.ids[n.ID]
// Ignore deleted nodes, as their disappearance will be reported through an
// ancestor node.
@@ -895,17 +895,17 @@ func (w *Window) processEvent(d driver, e event.Event) bool {
isMobile := runtime.GOOS == "ios" || runtime.GOOS == "android"
switch {
case e.Name == key.NameTab && e.Modifiers == 0:
w.moveFocus(router.FocusForward, d)
w.moveFocus(input.FocusForward, d)
case e.Name == key.NameTab && e.Modifiers == key.ModShift:
w.moveFocus(router.FocusBackward, d)
w.moveFocus(input.FocusBackward, d)
case e.Name == key.NameUpArrow && e.Modifiers == 0 && isMobile:
w.moveFocus(router.FocusUp, d)
w.moveFocus(input.FocusUp, d)
case e.Name == key.NameDownArrow && e.Modifiers == 0 && isMobile:
w.moveFocus(router.FocusDown, d)
w.moveFocus(input.FocusDown, d)
case e.Name == key.NameLeftArrow && e.Modifiers == 0 && isMobile:
w.moveFocus(router.FocusLeft, d)
w.moveFocus(input.FocusLeft, d)
case e.Name == key.NameRightArrow && e.Modifiers == 0 && isMobile:
w.moveFocus(router.FocusRight, d)
w.moveFocus(input.FocusRight, d)
default:
handled = false
}
+3 -3
View File
@@ -9,8 +9,8 @@ import (
"gioui.org/f32"
"gioui.org/io/event"
"gioui.org/io/input"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/op"
"gioui.org/op/clip"
)
@@ -22,7 +22,7 @@ func TestHover(t *testing.T) {
stack := clip.Rect(rect).Push(ops)
h.Add(ops)
stack.Pop()
r := new(router.Router)
r := new(input.Router)
r.Frame(ops)
r.Queue(
@@ -71,7 +71,7 @@ func TestMouseClicks(t *testing.T) {
var ops op.Ops
click.Add(&ops)
var r router.Router
var r input.Router
r.Frame(&ops)
r.Queue(tc.events...)
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"gioui.org/io/event"
@@ -1,4 +1,6 @@
package router
// SPDX-License-Identifier: Unlicense OR MIT
package input
import (
"testing"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"image"
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"image"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"image"
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"fmt"
+3 -3
View File
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: Unlicense OR MIT
/*
Package router implements Router, a event.Queue implementation
that that disambiguates and routes events to handlers declared
Package input implements Router, an event.Queue implementation
that disambiguates and routes events to handlers declared
in operation lists.
Router is used by app.Window and is otherwise only useful for
using Gio with external window implementations.
*/
package router
package input
import (
"encoding/binary"
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Unlicense OR MIT
package router
package input
import (
"fmt"
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"gioui.org/f32"
"gioui.org/io/event"
"gioui.org/io/input"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/op"
)
@@ -64,7 +64,7 @@ func TestListScrollToEnd(t *testing.T) {
func TestListPosition(t *testing.T) {
_s := func(e ...event.Event) []event.Event { return e }
r := new(router.Router)
r := new(input.Router)
gtx := Context{
Ops: new(op.Ops),
Constraints: Constraints{
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"testing"
"gioui.org/app"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/router"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget"
@@ -17,7 +17,7 @@ import (
func TestClickable(t *testing.T) {
var (
ops op.Ops
r router.Router
r input.Router
b1 widget.Clickable
b2 widget.Clickable
)
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"testing"
"gioui.org/f32"
"gioui.org/io/input"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/transfer"
"gioui.org/layout"
"gioui.org/op"
@@ -14,7 +14,7 @@ import (
)
func TestDraggable(t *testing.T) {
var r router.Router
var r input.Router
gtx := layout.Context{
Constraints: layout.Exact(image.Pt(100, 100)),
Queue: &r,
+8 -8
View File
@@ -20,9 +20,9 @@ import (
"gioui.org/font"
"gioui.org/font/gofont"
"gioui.org/font/opentype"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
@@ -96,7 +96,7 @@ func assertContents(t *testing.T, e *Editor, contents string, selectionStart, se
// TestEditorReadOnly ensures that mouse and keyboard interactions with readonly
// editors do nothing but manipulate the text selection.
func TestEditorReadOnly(t *testing.T) {
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Constraints{
@@ -501,7 +501,7 @@ func TestEditorLigature(t *testing.T) {
func TestEditorDimensions(t *testing.T) {
e := new(Editor)
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Constraints{Max: image.Pt(100, 100)},
@@ -887,7 +887,7 @@ f 2 4 6 8 f
g 2 4 6 8 g
`)
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Locale: english,
@@ -987,7 +987,7 @@ func TestSelectMove(t *testing.T) {
e := new(Editor)
e.SetText(`0123456789`)
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Locale: english,
@@ -1076,7 +1076,7 @@ func TestEditor_MaxLen(t *testing.T) {
}
e.SetText("2345678")
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
@@ -1112,7 +1112,7 @@ func TestEditor_Filter(t *testing.T) {
}
e.SetText("2345678")
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
@@ -1142,7 +1142,7 @@ func TestEditor_Submit(t *testing.T) {
e := new(Editor)
e.Submit = true
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
+3 -3
View File
@@ -7,8 +7,8 @@ import (
"image"
"gioui.org/f32"
"gioui.org/io/input"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/transfer"
"gioui.org/layout"
"gioui.org/op"
@@ -21,7 +21,7 @@ func ExampleClickable_passthrough() {
// pointer events can be passed down for the underlying
// widgets to pick them up.
var button1, button2 widget.Clickable
var r router.Router
var r input.Router
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
@@ -71,7 +71,7 @@ func ExampleClickable_passthrough() {
}
func ExampleDraggable_Layout() {
var r router.Router
var r input.Router
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"gioui.org/font"
"gioui.org/font/gofont"
"gioui.org/io/input"
"gioui.org/io/key"
"gioui.org/io/router"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/text"
@@ -34,7 +34,7 @@ func TestSelectableZeroValue(t *testing.T) {
// Verify that an existing selection is dismissed when you press arrow keys.
func TestSelectableMove(t *testing.T) {
r := new(router.Router)
r := new(input.Router)
gtx := layout.Context{
Ops: new(op.Ops),
Locale: english,
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"gioui.org/app"
"gioui.org/f32"
"gioui.org/io/input"
"gioui.org/io/pointer"
"gioui.org/io/router"
"gioui.org/io/semantic"
"gioui.org/layout"
"gioui.org/op"
@@ -19,7 +19,7 @@ import (
func TestBool(t *testing.T) {
var (
ops op.Ops
r router.Router
r input.Router
b widget.Bool
)
gtx := app.NewContext(&ops, app.FrameEvent{Queue: &r})