3111 Commits

Author SHA1 Message Date
Elias Naur 28dd25736f ui/key: make the computed text input state available as a method
When merging the key and pointers input sources, we can't return
the text input state as a side effect of the Frame method.

Expose it as a method in the key event queue instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-07 20:59:20 +02:00
Elias Naur bb6ee05d95 ui/key: don't drop handlers that haven't had their events read
Similar to the previous change for pointers, only determine the
activeness of a handler from its presence in the ops list.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-07 20:27:22 +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 13f69a28ac apps/gophers: upgrade to simpler layout API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 16:12:43 +02:00
Elias Naur df791f2e9b ui: remove ui.Ops parameters from layouts and path builder structs
Layouts and path builders are transient and need an ops list for
operation. However, instead of passing the ops list to every method,
pass the list in an init method and store it for subsequent methods.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 16:08:38 +02:00
Elias Naur 60fd129fda apps/gophers: upgrade to OpArea API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-03 15:24:00 +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 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 86f6765e64 ui/app/internal/gl: avoid allocations when passing handles to C
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:51:33 +02:00
Elias Naur 659a85aae0 ui/app/internal/gpu: add specialized path cache to avoid key allocations
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:45:44 +02:00
Elias Naur 34fe872635 apps/gophers: upgrade to latest path clipping API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:36:29 +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 a4ccc861ac apps/gophers: switch to explicit drawing state stack
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:37:34 +02:00
Elias Naur 9142345fd4 ui: make OpPush and OpPop explicit
We're about to allow OpBlock for invoking ops from multiple (cached)
Ops containers. To allow for drawing state changes to stick after
invoking such a cached block, we can't let OpBlock perform an implicit
save and restore of drawing state.

Instead, introduce OpPush and OpPop for explicit drawing state stack
management.

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 9d661277da ui: encapsulate encoded ops in a new type, opsData
Used for making OpBlock refer to other Ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +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 528a588f2e apps/hello: update to explicit API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +02:00
Elias Naur 1c880f2b9d ui/layout: activate sanity checks for Stack
Added by an earlier change, but not activated.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 15:14:46 +02:00
Elias Naur b55a02f597 apps: go get gioui.org/ui@latest
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 18:45:35 +02:00
Elias Naur 7ae8fdaae7 ui/app/internal/gpu: track image and color in a state stack
Just like the other drawing state, the current image or color must
be tracked in a stack.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 18:43:51 +02:00
Elias Naur d752040f17 ui/draw: typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 18:21:58 +02:00
Elias Naur 16a55850cb apps/gophers: switch to new OpImage, OpColor, OpDraw API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 13:05:32 +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 29993af408 apps/gophers: add per-frame mallocs to profiling status line
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-31 14:41:05 +02:00
Elias Naur bb0f80902f apps/gophers: update event method names
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:57:43 +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 67bfa38e02 apps/gophers: switch to explicit layout methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:52:19 +02:00
Elias Naur 9b3429d6da ui: switch to (more) explicit layout
The layout package switched from interfaces to functions for
composing layouts. The switch made sure that no garbage is
generated for transient layouts such as Align, Inset, Stack, Flex.

Unfortunately, that left the stateful widgets and layouts: as soon
as their layout methods are embedded in a transient layout, a
closure is generated that escapes to the heap.

To avoid garbage for both transient as well as stateful widgets,
replace the functional approach with explicit begin/end methods.

A begin method generally starts an op block and returns the adjusted
constraints. An end method takes computed dimensions, ends its op
block and returns adjusted dimensions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:39:00 +02:00
Elias Naur 5cc9906eb8 ui/app: (windows) use the new golang.org/x/sys/windows.MessageBox function
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-27 11:37:33 +02:00
Elias Naur e5ddb0b903 ui/app: (macOS) use CFTypeRef for the view factory
The os and gl packages were separate in the past, which required
uintptr for cross-package CFTypeRefs. That's no longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 14:05:30 +02:00
Elias Naur a1c0693eeb ui/app: add Lock/Unlock to Context for macOS
Without locking, asynchronous OpenGL rendering crashes on macOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 14:01:26 +02:00
Elias Naur c3ea85801c ui/app: (wasm) replace TypedArrayOf with the CopyBytes* API
syscall/js.TypedArrayOf is going away in Go 1.13 and is replaced by
the CopyBytesToGo, CopyBytesToJS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 12:30:34 +02:00
Elias Naur edec032ae6 ui/app: (wasm) re-use javascript buffer
Now that syscall/js.TypedArrayOf is going away in Go 1.13 (sse
https://golang.org/issue/31980), copying byte slices to JS before
use is necessary. To avoid garbage, re-use a single buffer for all
transfers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur 7b13da7299 ui/app: (wasm) use JS allocated buffer for invalidateFramebuffer
syscall/js.TypedArrayOf is going away in Go 1.13. Avoid it for
invalidateFramebuffer by using a buffer managed by JS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur bc481ea784 ui/app: serialize event handling
The frame callback for macOS comes in from a different thread than
the UI thread. Serialize event handling to maintain the invariant
that only one event is processed at a time.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-21 15:56:56 +02:00
Elias Naur da598663f7 ui/app: add GL buffer caches
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:47:30 +02:00
Elias Naur 642318842c ui/app/internal/gpu: add pathOp cache
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:16:36 +02:00
Elias Naur 4513d109b1 apps/hello: fix build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:35:02 +02:00
Elias Naur 51d1c32c07 apps/gopers: update to new Config convenience methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:34:06 +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 acf345a0f8 apps/gophers: use shorter layout method names
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 15:43:41 +02:00