diff --git a/app/ime_test.go b/app/ime_test.go index 13abf902..cdab9950 100644 --- a/app/ime_test.go +++ b/app/ime_test.go @@ -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{}) diff --git a/app/os_android.go b/app/os_android.go index 1c80ec03..9e790b52 100644 --- a/app/os_android.go +++ b/app/os_android.go @@ -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) { diff --git a/app/window.go b/app/window.go index 1fd0d9e9..e21f48f2 100644 --- a/app/window.go +++ b/app/window.go @@ -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 } diff --git a/gesture/gesture_test.go b/gesture/gesture_test.go index 6e0ffa11..27b95f9e 100644 --- a/gesture/gesture_test.go +++ b/gesture/gesture_test.go @@ -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...) diff --git a/io/router/clipboard.go b/io/input/clipboard.go similarity index 98% rename from io/router/clipboard.go rename to io/input/clipboard.go index 5f1623ca..1f9cbb27 100644 --- a/io/router/clipboard.go +++ b/io/input/clipboard.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "gioui.org/io/event" diff --git a/io/router/clipboard_test.go b/io/input/clipboard_test.go similarity index 98% rename from io/router/clipboard_test.go rename to io/input/clipboard_test.go index 9a010f42..673f1fc7 100644 --- a/io/router/clipboard_test.go +++ b/io/input/clipboard_test.go @@ -1,4 +1,6 @@ -package router +// SPDX-License-Identifier: Unlicense OR MIT + +package input import ( "testing" diff --git a/io/router/key.go b/io/input/key.go similarity index 99% rename from io/router/key.go rename to io/input/key.go index add86f81..45bcc15d 100644 --- a/io/router/key.go +++ b/io/input/key.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "image" diff --git a/io/router/key_test.go b/io/input/key_test.go similarity index 99% rename from io/router/key_test.go rename to io/input/key_test.go index d91d1386..a2174b0f 100644 --- a/io/router/key_test.go +++ b/io/input/key_test.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "image" diff --git a/io/router/pointer.go b/io/input/pointer.go similarity index 99% rename from io/router/pointer.go rename to io/input/pointer.go index 2cc17ce3..1e87d823 100644 --- a/io/router/pointer.go +++ b/io/input/pointer.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "image" diff --git a/io/router/pointer_test.go b/io/input/pointer_test.go similarity index 99% rename from io/router/pointer_test.go rename to io/input/pointer_test.go index c83a85f8..f93ecfc1 100644 --- a/io/router/pointer_test.go +++ b/io/input/pointer_test.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "fmt" diff --git a/io/router/router.go b/io/input/router.go similarity index 99% rename from io/router/router.go rename to io/input/router.go index 224e442d..fb8fcf3f 100644 --- a/io/router/router.go +++ b/io/input/router.go @@ -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" diff --git a/io/router/semantic_test.go b/io/input/semantic_test.go similarity index 99% rename from io/router/semantic_test.go rename to io/input/semantic_test.go index 46982fc0..004bc609 100644 --- a/io/router/semantic_test.go +++ b/io/input/semantic_test.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Unlicense OR MIT -package router +package input import ( "fmt" diff --git a/layout/list_test.go b/layout/list_test.go index b48f396f..f5019dbd 100644 --- a/layout/list_test.go +++ b/layout/list_test.go @@ -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{ diff --git a/widget/button_test.go b/widget/button_test.go index 0a00f1c8..eb8a15c2 100644 --- a/widget/button_test.go +++ b/widget/button_test.go @@ -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 ) diff --git a/widget/dnd_test.go b/widget/dnd_test.go index ea26de09..ce57f481 100644 --- a/widget/dnd_test.go +++ b/widget/dnd_test.go @@ -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, diff --git a/widget/editor_test.go b/widget/editor_test.go index ca368b0c..7642951f 100644 --- a/widget/editor_test.go +++ b/widget/editor_test.go @@ -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)), diff --git a/widget/example_test.go b/widget/example_test.go index b04cf25f..ee99dc09 100644 --- a/widget/example_test.go +++ b/widget/example_test.go @@ -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)), diff --git a/widget/selectable_test.go b/widget/selectable_test.go index bd8b8542..fdec9829 100644 --- a/widget/selectable_test.go +++ b/widget/selectable_test.go @@ -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, diff --git a/widget/widget_test.go b/widget/widget_test.go index cd10d8c5..db82d854 100644 --- a/widget/widget_test.go +++ b/widget/widget_test.go @@ -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})