Commit Graph

23 Commits

Author SHA1 Message Date
Elias Naur 8700a8ffc3 ui/key,ui/pointer: rename HandlerOp to InputOp
"Input" is more specific and reads better than "handler".

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-26 18:07:48 +01:00
Elias Naur 842d29373f ui: documentation tweaks
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-11 19:36:46 +02:00
Elias Naur 9cc6757da9 ui/pointer: expand documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-11 16:46:03 +02:00
Elias Naur b68c9c23c8 ui/input: expand package documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-11 12:31:39 +02:00
Elias Naur 73b1e64209 ui/input: change Queue to return Events one at a time
By returning all events, widgets that might return early from its
event loop might throw away subsequent events. Instead of requiring
those widgets to store the event list, convert input.Queue to step
through the available events one at a time.

Functional revert of 1735d5ced8.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 18:56:49 +02:00
Elias Naur cb312c8d32 ui/app: drop Event
input.Event is enough if we stretch "input" to mean both input
devices and other events such as profiling events and system
commands.

The pointer and key packages are separate already, so I don't
expanding the meaning is unreasonable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 15:27:14 +02:00
Elias Naur fd096e8838 ui/input,ui/layout: update comments
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 14:30:59 +02:00
Elias Naur 2296393471 ui/system: move package ui/input/system
Just like the pointer and key packages.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:54:41 +02:00
Elias Naur 86533ae683 ui/input/system: introduce package for system events
And add ProfileOp and ProfileEvent for registering and receiving
profile data.

Remove the Profiling field and Timings method from app.Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:31:29 +02:00
Elias Naur cbdda4e9c5 ui/input: move Router and input queues to internal package
Now that only app.Window needs the Router, make it unavailable for
clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 13:51:00 +02:00
Elias Naur fb9e5ca902 ui/pointer: ignore hits to dropped handlers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 12:24:31 +02:00
Elias Naur 3a6fda129a ui: shorten OpReader.Decode for loops
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 11:44:50 +02:00
Elias Naur a22bcfc88c ui/input: rename Queue to Router and Events to Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:56 +02:00
Elias Naur 1735d5ced8 ui/input: change Events to return all events at once
Single stepping events only makes sense for widgets with complex
state, e.g. the text.Editor. For the input.Events source, returning
all events in a single Events call is sufficient and more natural
for clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:46 +02:00
Elias Naur 4fadf71992 ui/pointer: split AreaOp into RectAreaOp and EllipseAreaOp
Now that the pass through mode is moved into its own PassOp op,
it doesn't make sense to collect all area types into one exported
type.

Add RectAreaOp and EllipseAreaOp for clients; the internal
representation is still a single op. It can be changed later without
breaking clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 22:55:16 +02:00
Elias Naur f44ccec043 ui/pointer: simplify pointer pass through
Get rid of the confused LayerOp and the transparent property from
AreaOp. Add an explicit PassOp to specify whether pointer events
pass-through the current area.

Let AreaOp swallow events even when no handlers are active for the
area. That behaviour is less surprising and allow clients to disable
a widget by keeping its areas but leave out its handlers.

Simplify the pointer.HitResult enum to just a bool: hit or no hit.

Finally, simplify the pointer queue by tracking parent areas and
node with indices.
2019-07-10 22:43:03 +02:00
Elias Naur f110c26e3f ui/input: hide soft keyboard when focus is lost
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-07 15:52:09 +02:00
Elias Naur 31418eefbe ui/key: rename TextInputClosed to TextInputClose
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-07 15:52:09 +02:00
Elias Naur e862761e17 ui/input: keep default focus on earliest focusable
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-02 19:36:45 +02:00
Elias Naur 0b6dd4efd9 ui: change events to have "Event" suffixed, not prefixed
Match the Go error naming convention (FooError).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 17:14:16 +02:00
Elias Naur 7aa7bb3be4 ui: rename ops to have Op suffixed, not prefixed
Match Go's FooError name pattern.

While we're here, rename RedrawOp to InvalidateOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 17:01:45 +02:00
Elias Naur b981ccf9ed ui/input: support single stepping through events
Change input.Events interface to return one event at a time until
the queue is empty.

Change text.Editor and gestures to match.

Re-add Editor.Submit while we're here; we don't want to enable
submit mode always.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 16:30:20 +02:00
Elias Naur a35118d522 ui: add package input for merged input
To avoid passing a queue type for each kind of input (pointer, key),
introduce package input for mapping a handler key to all input events.

Future input sources can be added without changes to programs, and
as an added bonus, event ordering is preserved across input sources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-08 10:58:57 +02:00