Commit Graph

22 Commits

Author SHA1 Message Date
Elias Naur b4441a8728 ui: reset StackOp in Pop
To enable re-use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:53:57 +02:00
Elias Naur 586d33c26e ui: replace PushOp, PopOp with a StackOp
Before this change, there was no guarantee that a PopOp matched
the intended PushOp. With a single stack operation, the client is
forced to match pop with the right push.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:49:32 +02:00
Elias Naur 94a913a371 ui: move macro recording from Ops to MacroOp
Move the Record and Stop methods from Ops to MacroOp itself.

Before this change, Ops.Stop stopped the recording of the most
recent macro, which could be a different macro than intended.
After this change, there is no such confusion.

As a bonus, the Ops API becomes less cluttered.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:21:51 +02:00
Elias Naur ba9ffe846e ui: merge opsData type with Ops
opsData wasn't worth the complexity.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 12:44:23 +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 8eb58ff2eb ui: support Window.Draw(nil) in OpsReader
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 11:42:47 +02:00
Elias Naur 5b3090b128 ui: don't keep references alive in Ops.Reset
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 09:09:30 +02:00
Elias Naur 86bc3e612d ui/text: use BlockOp as materials
Before this change, clients were expected to set up the current
material (color or image) before laying out Labels and Editors.
This was done to avoid garbage from a hypothetical material
interface covering both colors and images.

However, some widgets need more than one material: the Editor had
HintImage for the hint text material.

This change implements generalized materials through blocks:
anywhere a material is expected, a ui.BlockOp is is assumed to
contain the operation(s) needed for setting the desired material.

This way we avoid allocations (interfaces) and keep the
abstraction over material types.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-05 16:52:13 +02:00
Elias Naur 475bccb722 ui: add checks for unmatched Ops.Begin/End
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-02 20:12:06 +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 52cea80bd4 ui: update doc comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-08 11:00:59 +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 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 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 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