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
Daniel Martí 2542c55e9d all: fix some issues spotted by static analysis
First, vet was upset by two incorrect fmt verbs. One was an extra %x,
when there was just one argument, so remove it. Another was a %p with a
non-pointer. It's a struct, so for now simply use %#v.

Second, staticcheck found some unused or unnecessary bits of code;
remove the obvious ones.

Finally, staticcheck also complained about some error strings which were
capitalized or had periods. Adjust those, which also makes all error
messages more consistent.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-08-25 22:41:05 +01:00
Elias Naur a6c262c1e1 ui: expose internal Ops fields as methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-08 15:20:58 +02:00
Elias Naur dd35a48a61 ui/paint: rename the draw package
The draw package name clashes with the standard library draw package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 20:11:53 +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 eaa4efe5af all: add missing licence headers
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 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 3b5fcfe2bb ui: rename block to macro
It is a more precise name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 20:36:17 +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 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 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 559db02035 ui: simplify op size and reference count code
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 13:30:18 +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 9f58ed0fea ui: add version to OpBlock to track invalidated blocks
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:37:34 +02:00
Elias Naur bf5d083b8a ui,ui/internal/ops: store owner Ops in OpBlock
Allows users to refer to other (cached) Ops from a main Ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:37:34 +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 00a87f542d ui: introduce OpColor, a specialized OpImage for uniform colors
To avoid allocating an image.Image for OpImage.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 13:01:51 +02:00
Elias Naur 0061c73a89 ui: split OpImage into OpImage and OpDraw
In preparation for an OpColor (and future OpGradient and similar).

Label and Editor no longer take an explicit source image. They
draw with the current image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 12:44:49 +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 0f05231c35 all: initial import
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-03-31 10:47:22 +02:00