Commit Graph

216 Commits

Author SHA1 Message Date
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
Elias Naur fe4a61ec89 ui/layout: make List more friendly to for loops
With this change, a List l can be iterated with

    for l.Init(...); l.More(); l.Next() {
        l.Elem(..., l.Constraints(), l.Index())
    }

instead of

   l.Init(...)
   for {
       i, cs, ok := l.Next()
       if !ok {
               break
       }
       l.End(..., cs, i))
    }

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 18:07:16 +02:00
Elias Naur f4461721e3 ui/app: tweak monitor scale
Don't apply monitor scale to wayland font sizes, since it detects
the user scale itself.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 15:08:25 +02:00
Elias Naur 478d56102a ui/app: introduce Insets for system decoration insets
Insets is like image.Rectangle, but with properly named fields
and ui.Value instead of raw ints to make use with the layout
package easier.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 14:33:38 +02:00
Elias Naur 15c4ce9e22 ui/app,cmd/gio: support edge-to-edge layout on Android
Implement recomendations from
https://developer.android.com/preview/features/gesturalnav#java

While here, give up on providing translucent top and bottom bars on
Android 4.4 and below. It's simpler to use the app drawn system
backgrounds from 5.0 and newer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 13:05:29 +02:00
Elias Naur 896f5a77dd ui/layout: don't stretch Align child
Let the caller decide whether the constraints should be stretched.

Also unexport Constraint (not Constraints) methods, they weren't
pulling their weight.

Finally, don't force cross axis constraint minimum to 0 in List.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 09:18:56 +02:00