Commit Graph

26 Commits

Author SHA1 Message Date
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 6e26c92c75 all: remove exported Decode methods on operations
Add decode functions to the packages that need them instead. For
TransformOp that is used in multiple packages, add the decode
function to the internal ops package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:34 +02:00
Elias Naur b3517a365e ui,internal/ops,internal/opconst: move OpsReader to internal ops package
To avoid import cycles, move the op constants to its own package,
internal/opconst.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:26 +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 bfece0beba ui: change area ops to use rectangles, not sizes
And then use the more general rectangles to add a buffer around
text.Editor click and scroll area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 10:06:19 +02:00
Elias Naur c7eb9be9f3 ui/key,ui/pointer: replace Key types with input.Key
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:53:45 +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 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 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 a78f9c6eaa ui/pointer: don't drop handlers that whose events haven't been read
We're about to merge the pointer and key event streams in a single
input queue. To do that, we need to simplify Queue.For to just returning
events for the given handler.

First step is the handler active flag.

Dropping handlers that haven't had their events read doesn't seem
worth it. Drop that special case and only determine a handler's activeness
from its presence in the ops list.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-07 20:25:32 +02:00
Elias Naur 56bfc6e348 ui/pointer: unexport HitResult enum
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-05 10:53:25 +02:00
Elias Naur f2679b2024 ui/pointer: add Transparent to OpArea to allow events to pass through
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-05 10:51:45 +02:00
Elias Naur b12430bab3 ui/pointer: unexport OpArea.Hit
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-05 10:46:23 +02:00
Elias Naur 955fe1bc77 ui: make the reference list argument to Ops.Write variadic
Makes the code nicer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 15:22:11 +02:00
Elias Naur 402837bbfa ui/pointer/queue: intersect hit areas of stacked OpAreas
Instead of using the most recent area for hit testing a pointer handler,
use the intersection of the areas up until the handler.

Fixes a bug where layout.List children received pointer events in their
clipped areas.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 15:21:12 +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 1e38eec0ab ui: build paths as ops
Instead of allocating and constructing a clip path, store path data
directly in op lists. Use separate op lists for cached text layout
paths.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:18:04 +02:00
Elias Naur 0d2cffe196 ui: let OpsReader keep track of references
Instead of exposing the entire reference slice, return the relevant
references from Next.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +02:00
Elias Naur 5966aab77e ui: move ops reader to ui package
To prepare support for cached OpBlock to refer to other Ops lists.

The exposure of OpsReader is alleviated by the removal of the Refs
and Data accessors for Ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +02:00
Elias Naur 20f55a4ad7 all: delete the ui.Op type
It's no longer used.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-27 22:27:50 +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 7b6e1ce35a ui/pointer: simplify hit testing
Serialize the implied tree of layers and handlers into a list
that can be traversed from the end to collect handlers.

This change will make it easier to switch op representation in
a follow-up change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-26 19:26:59 +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