~eliasnaur/gio

a22bcfc88c893452b8308e4cdc92afd3b291658d — Elias Naur 1 year, 4 months ago 6a4ba30
ui/input: rename Queue to Router and Events to Queue

Signed-off-by: Elias Naur <mail@eliasnaur.com>
5 files changed, 14 insertions(+), 14 deletions(-)

M ui/gesture/gestures.go
M ui/input/input.go
R ui/input/{queue.go => router.go}
M ui/layout/list.go
M ui/text/editor.go
M ui/gesture/gestures.go => ui/gesture/gestures.go +2 -2
@@ 81,7 81,7 @@ func (c *Click) Add(ops *ui.Ops) {
	op.Add(ops)
}

func (c *Click) Events(q input.Events) []ClickEvent {
func (c *Click) Events(q input.Queue) []ClickEvent {
	var events []ClickEvent
	for _, evt := range q.Events(c) {
		e, ok := evt.(pointer.Event)


@@ 130,7 130,7 @@ func (s *Scroll) Dragging() bool {
	return s.dragging
}

func (s *Scroll) Scroll(cfg ui.Config, q input.Events, axis Axis) int {
func (s *Scroll) Scroll(cfg ui.Config, q input.Queue, axis Axis) int {
	if s.axis != axis {
		s.axis = axis
		return 0

M ui/input/input.go => ui/input/input.go +2 -2
@@ 4,9 4,9 @@
// such as pointer and key provide the interfaces for specific input types.
package input

// Events maps an event handler key to the events
// Queue maps an event handler key to the events
// available to the handler.
type Events interface {
type Queue interface {
	Events(k Key) []Event
}


R ui/input/queue.go => ui/input/router.go +8 -8
@@ 8,9 8,9 @@ import (
	"gioui.org/ui/pointer"
)

// Queue is an Events implementation that merges events from
// all available input sources.
type Queue struct {
// Router is a Queue implementation that routes events from
// all available input sources to registered handlers.
type Router struct {
	pqueue pointerQueue
	kqueue keyQueue



@@ 19,13 19,13 @@ type Queue struct {

type handlerEvents map[Key][]Event

func (q *Queue) Events(k Key) []Event {
func (q *Router) Events(k Key) []Event {
	events := q.handlers[k]
	delete(q.handlers, k)
	return events
}

func (q *Queue) Frame(ops *ui.Ops) {
func (q *Router) Frame(ops *ui.Ops) {
	q.init()
	for k := range q.handlers {
		delete(q.handlers, k)


@@ 34,7 34,7 @@ func (q *Queue) Frame(ops *ui.Ops) {
	q.kqueue.Frame(ops, q.handlers)
}

func (q *Queue) Add(e Event) {
func (q *Router) Add(e Event) {
	q.init()
	switch e := e.(type) {
	case pointer.Event:


@@ 44,11 44,11 @@ func (q *Queue) Add(e Event) {
	}
}

func (q *Queue) InputState() key.TextInputState {
func (q *Router) InputState() key.TextInputState {
	return q.kqueue.InputState()
}

func (q *Queue) init() {
func (q *Router) init() {
	if q.handlers == nil {
		q.handlers = make(handlerEvents)
	}

M ui/layout/list.go => ui/layout/list.go +1 -1
@@ 19,7 19,7 @@ type scrollChild struct {

type List struct {
	Config             ui.Config
	Inputs             input.Events
	Inputs             input.Queue
	Axis               Axis
	Invert             bool
	CrossAxisAlignment CrossAxisAlignment

M ui/text/editor.go => ui/text/editor.go +1 -1
@@ 22,7 22,7 @@ import (

type Editor struct {
	Config     ui.Config
	Inputs     input.Events
	Inputs     input.Queue
	Face       Face
	Alignment  Alignment
	SingleLine bool