io: give event packages a common prefix

Packages that provide support for external events such as pointer, key and
system are only the beginning. Future packages are expected for clipboard
access, drag and drop, gps positions and so on.

To keep the number of top-level packages under control, move such I/O packages
to the new `io` directory.

The `system` package name was the previous solution to keeping the number of
top-level packages under control: I named it `system` instead of the narrower
`profile` because I expected to put all the less common events into it, turning
`system` into a "package util" smell.

With `io`, package system can be renamed to `profile`.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-30 14:50:03 +02:00
parent a175f38d19
commit 7a259e68f7
20 changed files with 68 additions and 68 deletions
+2 -2
View File
@@ -3,10 +3,10 @@
package input
import (
"gioui.org/ui"
"gioui.org/internal/opconst"
"gioui.org/internal/ops"
"gioui.org/key"
"gioui.org/io/key"
"gioui.org/ui"
)
type TextInputState uint8
+2 -2
View File
@@ -6,11 +6,11 @@ import (
"encoding/binary"
"image"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/internal/opconst"
"gioui.org/internal/ops"
"gioui.org/pointer"
"gioui.org/io/pointer"
"gioui.org/ui"
)
type pointerQueue struct {
+7 -7
View File
@@ -6,12 +6,12 @@ import (
"encoding/binary"
"time"
"gioui.org/ui"
"gioui.org/internal/opconst"
"gioui.org/internal/ops"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/system"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/io/profile"
"gioui.org/ui"
)
// Router is a Queue implementation that routes events from
@@ -98,7 +98,7 @@ func (q *Router) collect() {
}
}
func (q *Router) AddProfile(e system.ProfileEvent) {
func (q *Router) AddProfile(e profile.Event) {
for _, h := range q.profHandlers {
q.handlers.Add(h, e)
}
@@ -150,11 +150,11 @@ func (h *handlerEvents) Clear() {
}
}
func decodeProfileOp(d []byte, refs []interface{}) system.ProfileOp {
func decodeProfileOp(d []byte, refs []interface{}) profile.Op {
if opconst.OpType(d[0]) != opconst.TypeProfile {
panic("invalid op")
}
return system.ProfileOp{
return profile.Op{
Key: refs[0].(ui.Key),
}
}
+3 -3
View File
@@ -24,10 +24,10 @@ import (
"time"
"unsafe"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/ui"
)
type window struct {
+3 -3
View File
@@ -22,10 +22,10 @@ import (
"sync/atomic"
"time"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/ui"
)
type window struct {
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"time"
"gioui.org/f32"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
)
type window struct {
+2 -2
View File
@@ -20,8 +20,8 @@ import (
"unsafe"
"gioui.org/f32"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
)
func init() {
+2 -2
View File
@@ -18,8 +18,8 @@ import (
"gioui.org/f32"
"gioui.org/internal/fling"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
syscall "golang.org/x/sys/unix"
)
+2 -2
View File
@@ -15,8 +15,8 @@ import (
syscall "golang.org/x/sys/windows"
"gioui.org/f32"
"gioui.org/key"
"gioui.org/pointer"
"gioui.org/io/key"
"gioui.org/io/pointer"
)
var winMap = make(map[syscall.Handle]*window)
+3 -3
View File
@@ -8,10 +8,10 @@ import (
"image"
"time"
"gioui.org/ui"
"gioui.org/app/internal/gpu"
"gioui.org/app/internal/input"
"gioui.org/system"
"gioui.org/io/profile"
"gioui.org/ui"
)
// WindowOption configures a Window.
@@ -144,7 +144,7 @@ func (w *Window) draw(size image.Point, frame *ui.Ops) {
if w.queue.q.Profiling() {
q := 100 * time.Microsecond
timings := fmt.Sprintf("tot:%7s cpu:%7s %s", frameDur.Round(q), drawDur.Round(q), w.gpu.Timings())
w.queue.q.AddProfile(system.ProfileEvent{Timings: timings})
w.queue.q.AddProfile(profile.Event{Timings: timings})
w.setNextFrame(time.Time{})
}
if t, ok := w.queue.q.WakeupTime(); ok {
+1 -1
View File
@@ -22,7 +22,7 @@ import (
"unicode/utf8"
"unsafe"
"gioui.org/key"
"gioui.org/io/key"
)
type xkb struct {
+2 -2
View File
@@ -12,10 +12,10 @@ package gesture
import (
"math"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/internal/fling"
"gioui.org/pointer"
"gioui.org/io/pointer"
"gioui.org/ui"
)
// Click detects click gestures in the form
View File
+31
View File
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: Unlicense OR MIT
// Package profiles provides access to rendering
// profiles.
package profile
import (
"gioui.org/internal/opconst"
"gioui.org/ui"
)
// Op registers a handler for receiving
// Events.
type Op struct {
Key ui.Key
}
// Event contains profile data from a single
// rendered frame.
type Event struct {
// Timings. Very likely to change.
Timings string
}
func (p Op) Add(o *ui.Ops) {
data := make([]byte, opconst.TypeProfileLen)
data[0] = byte(opconst.TypeProfile)
o.Write(data, p.Key)
}
func (p Event) ImplementsEvent() {}
+2 -2
View File
@@ -5,10 +5,10 @@ package layout
import (
"image"
"gioui.org/ui"
"gioui.org/gesture"
"gioui.org/io/pointer"
"gioui.org/paint"
"gioui.org/pointer"
"gioui.org/ui"
)
type scrollChild struct {
-31
View File
@@ -1,31 +0,0 @@
// SPDX-License-Identifier: Unlicense OR MIT
// Package system contain ops and types for
// system events.
package system
import (
"gioui.org/ui"
"gioui.org/internal/opconst"
)
// ProfileOp registers a handler for receiving
// ProfileEvents.
type ProfileOp struct {
Key ui.Key
}
// ProfileEvent contain profile data from a single
// rendered frame.
type ProfileEvent struct {
// String with timings. Very likely to change.
Timings string
}
func (p ProfileOp) Add(o *ui.Ops) {
data := make([]byte, opconst.TypeProfileLen)
data[0] = byte(opconst.TypeProfile)
o.Write(data, p.Key)
}
func (p ProfileEvent) ImplementsEvent() {}
+3 -3
View File
@@ -9,12 +9,12 @@ import (
"time"
"unicode/utf8"
"gioui.org/ui"
"gioui.org/gesture"
"gioui.org/key"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/paint"
"gioui.org/pointer"
"gioui.org/ui"
"golang.org/x/image/math/fixed"
)
+1 -1
View File
@@ -101,7 +101,7 @@ the means for declaring handlers for specific event types.
The following example declares a handler ready for key input:
import gioui.org/key
import gioui.org/io/key
ops := new(ui.Ops)
var h *Handler = ...