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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
With layout.Widget a function instead of an interface, the amount
of per-frame garbage can be drastically reduced.
The layout code ends up slightly more explicit.
As a side benefit, the awkward ordering indexing for Flex and Stack
fit nicely into their new explicit Layout methods.
Signed-off-by: Elias Naur <mail@eliasnaur.com>