Commit Graph

221 Commits

Author SHA1 Message Date
Elias Naur 0b6e6c58dd ui/app: return a concrete Queue from Window.Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-20 14:20:59 +02:00
Elias Naur 6b5714d15d ui/app: (macOS) ignore asynchronous redraws to deleted windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 13:19:35 +02:00
Elias Naur a140527b08 ui/app: (macOS) serialize access to the views map
The CVDisplayLink used for synchronizing rendering to the display
refresh rate runs on a separate thread from the main thread.
View callbacks must therefore be serialized. Implement that by
introducing a singleton goroutine that owns the view map and runs
incoming commands.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 01:18:48 +02:00
Elias Naur c94315119b ui/app/internal/input: only drop handlers completely when inactive
Delete a redundant loop; dropHandlers already does the required work.

Fixes pointer event issues found after pointer events with no side
effects no longer trigger redraws.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 21:06:06 +02:00
Elias Naur d9d8df989d ui/app: rename Window.Redraw to Invalidate to match ui.InvalidateOp
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 18:45:46 +02:00
Elias Naur 84fb7279eb ui/draw: rename ImageOp.Img to Src
To match widget.Image.Src field name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 15:58:11 +02:00
Elias Naur fd096e8838 ui/input,ui/layout: update comments
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 14:30:59 +02:00
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 6947ed9312 ui/app: go fmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 12:32:39 +02:00
Elias Naur eb9c2896cd ui/layout: round, not truncate, flex sizes in Flex.Flexible
Without proper rounding, a pixel could be left uncovered at the end
of the flex layout.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 21:43:53 +02:00
Elias Naur 00b9ff603f ui/layout: rename Insets to Inset and EqualInsets to UniformInset
Rename Insets to the verb Inset for consistency with Align.

Uniform is a better description than Equal for the result of
UniformInset.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 21:10:43 +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 f36070f716 ui/layout: delete Constraints.Expand and Constraints.Loose
They're not (yet) shown their use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 19:29:42 +02:00
Elias Naur 667670f9c6 ui/layout: delete Constraints.Exact and rename ExactConstraints
Exact was too special and can be expressed with RigidConstraints.

RigidConstraints is a better name ("rigid" was in the comment!)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 19:16:11 +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 09b5752659 ui/app: use the delayed redraw timer directly in the Window run loop
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-14 21:58:44 +02:00
Elias Naur 07622a295c ui/app: replace locking with channels in Window implementation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-14 21:58:43 +02:00
Elias Naur 587b88d346 ui/app: don't draw or handle events if window is dead
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-14 19:33:31 +02:00
Elias Naur 6e97d65af1 ui/app: delete Window.Size method
Clients should use the size from DrawEvent instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-14 13:08:34 +02:00
Elias Naur 112368a2e3 ui/app: add a DataDir fallback to Go 1.12
o.UserConfigDir is introduced in Go 1.13, which is not released yet.
Add a Go 1.12 stopgab until then.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-13 13:28:58 +02:00
Elias Naur 4cde5d57d7 ui/app: remove two redundant assignments
StagePaused is the zero value now that StateDead is gone.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-13 13:14:30 +02:00
Elias Naur 59e92e8233 ui/app: introduce DestroyEvent for ending the event loop
Replace the StageDead stage with DestroyEvent dedicated to ending
the event loop and, for premature window closes, the error.

Drop the error return from NewWindow; any errors in window creation
will appear as an immediate DestroyEvent with its Err field set.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-13 13:09:51 +02:00
Elias Naur a3b9c7818f ui/app: create windows directly
Replace CreateWindow with NewWindow that immediately creates a Window
ready to use.

Drop the Windows channel of windows created by the system. For iOS
and Android where the system creates the windows, let them rendezvous
with the window created in the first NewWindow call.

Android is further changed so that destroying and re-creating the
Java Activity simply reconnects with the original Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 20:47:29 +02:00
Elias Naur 46cee54dd6 io/app/internal/input: go fmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 20:47:29 +02:00
Elias Naur 2296393471 ui/system: move package ui/input/system
Just like the pointer and key packages.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:54:41 +02:00
Elias Naur 93368253ac ui/app: delete unused Input type
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:44:19 +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 032e9a380e ui/app,ui/internal/input: move InvalidateOp summary to Router
In preparation for extracting more op types in Router.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:11:20 +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 25a20af284 ui/app: only schedule a redraw when events are available
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:37:30 +02:00
Elias Naur ba18817400 ui/app/internal/input: add tracking up updates to handlerEvents
In preparation for only redrawing when new events are available.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:34:24 +02:00
Elias Naur 326f78c341 ui/app: don't implicitly redraw for each CommandEvent
Redrawing should only be scheduled when some UI state has changed.

Window has no way to know whether a CommandEvent was ignored by
the client, so push the onus to the client to schedule a redraw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:05:18 +02:00
Elias Naur 46850653ef ui/app: unexport Window.SetTextInput
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 13:58:27 +02:00
Elias Naur cbdda4e9c5 ui/input: move Router and input queues to internal package
Now that only app.Window needs the Router, make it unavailable for
clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 13:51:00 +02:00
Elias Naur 0d924a1950 ui/app: add input queue to Window
I see no point in forcing the client to manage input events. Let's
put it on Window for now.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 13:39:56 +02:00
Elias Naur b8eca39277 ui/app: comment fix
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 13:32:16 +02:00
Elias Naur fb9e5ca902 ui/pointer: ignore hits to dropped handlers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 12:24:31 +02:00
Elias Naur 3a6fda129a ui: shorten OpReader.Decode for loops
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 11:44:50 +02:00
Elias Naur a22bcfc88c ui/input: rename Queue to Router and Events to Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:56 +02:00
Elias Naur 6a4ba30c96 ui/text: shorten event loop in Editor.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:56 +02:00
Elias Naur 37ac75f3bb ui/gesture: switch Click to return all events
Simpler and more ergonomic for clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:56 +02:00
Elias Naur 1735d5ced8 ui/input: change Events to return all events at once
Single stepping events only makes sense for widgets with complex
state, e.g. the text.Editor. For the input.Events source, returning
all events in a single Events call is sufficient and more natural
for clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:05:46 +02:00
Elias Naur 0d49eb3f4b ui/layout: drop CrossAxisAlignment value Stretch
It doesn't carry its own weight; client can just as easily adjust
the Constraints themselves.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 20:13:10 +02:00
Elias Naur 10ef4576e7 ui/layout: drop Flex.MainAxisSize setting and MainAxisSize type
The setting doesn't bear its own weight; it's simpler for the client
to adjust the constraints itself.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 19:15:17 +02:00
Elias Naur c7e85efc27 ui/layout: ensure that flex weights add to 1
Before this change, the weight applied to the space left, not the
total space available after rigid children.

While here, ensure that weight sums > 1 are capped to the available
space.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 19:06:27 +02:00
Elias Naur 449c2b844a ui/layout: drop FlexMode
The type and argument to Flex.Flexible does not carry its weight;
It is just as easy to expand the constraint directly.

While we're here, rename the flex argument to weight which is clearer.
2019-07-11 18:44:44 +02:00