Commit Graph

20 Commits

Author SHA1 Message Date
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 37ac75f3bb ui/gesture: switch Click to return all events
Simpler and more ergonomic for clients.

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 32aae18293 ui,ui/app: convert Config to an interface
To keep the interface slim, remove the helper methods and shorten
the essential method, Pixels, to Px.

Add and use unexported Config implementation in the app package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 17:20:55 +02:00
Elias Naur 320579814f ui: rename Config.Val to Pixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 14:00:44 +02:00
Elias Naur ad4215a7eb ui: use ints for unit conversions to pixels
The dp and sp units are approximate and mostly used for layout
dimensions that operate in whole pixels. This change alters the
Config methods to return pixels in ints instead of floats, which
results in smoother use for layout and emphasize the inexactness of
the device independent units.

Clients can still access to raw PxPrDp and PxPrSp factors from
Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 13:31:06 +02:00
Elias Naur 84cd3fcdca ui/text: handle stop and scroll immediately
In case an event is returned, don't aggregate state changes in Next.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-08 00:07:51 +02:00
Elias Naur 4f94f1078a ui/gesture: rename Scroller.Update to Scroller.Scroll
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-22 17:36:57 +02:00
Elias Naur bebfd822d8 ui/gesture: convert Click to single step events for symmetry
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-22 17:33:29 +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
Elias Naur 40856a244e ui/pointer: introduce OpArea for pointer hit testing
Split out OpArea from OpHandler to allow stacked areas in a followup.

Replace hit closures with static shapes (rectangles and ellipses) to
avoid allocations. If needed, generic hit functions can be introduced
again later.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 14:54:26 +02:00
Elias Naur a7874d70ef ui: rename event methods to Update
For uniformity.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:55:52 +02:00
Elias Naur 00cb158247 ui: add Config.Sp and Config.Dp convenience methods
And rename Pixels to Val.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:32:47 +02:00
Elias Naur 701ceda4d0 ui/gesture,ui/editor: don't focus and show keyboard on touch press
Wait until click for touches.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 18:06:18 +02:00
Elias Naur 252e058766 all: serialize ops
Pros:
- Much less per-frame garbage
- Allow future preprocessing of ops while building it
- Much fewer interface calls and pointer chasing
- Allow future serialization of ops for remote rendering

Cons:
- Slightly clumsier API

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-27 22:19:34 +02:00
Elias Naur a8bb3c2f14 all: make pointer.Area an interface
With an interface instead of anonymous functions, amending an
area's parameters can be done even after adding it to an OpHandler.

This will be useful when we switch to serialized op lists.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-25 10:02:14 +02:00
Elias Naur 48b6a73753 all: run goimports
gioui.org/ui was renamed from gioui.org/ui/ui before the release,
but the import order wasn't changed accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-02 17:09:06 +02:00
Elias Naur 0f05231c35 all: initial import
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-03-31 10:47:22 +02:00