Commit Graph

325 Commits

Author SHA1 Message Date
Elias Naur 759fdb2efe apps/gophers: simplify type switch
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:41:10 +02:00
Elias Naur 1336ca109a apps/gophers: upgrade to new profiling api
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 15:37:05 +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 c7fda6d37d apps/gophers: add explicit redraws
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:08:59 +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 343934d3de apps/gophers: replace own input router with the window's Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 14:02:54 +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
Dan Kortschak 3c2c404fa9 apps/hello: fix loop variable captured by func literal
Signed-off-by: Dan Kortschak <dan@kortschak.io>
2019-07-12 00:45:19 +02:00
Elias Naur 96b52d3493 apps/gophers: upgrade to changed input api
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-12 00:07:18 +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 a9d4186bef apps/gophers: move user list click handling earlier
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 23:33:43 +02:00
Elias Naur fc7bb79c36 apps/gophers: remove CrossAxisAlignment Stretch values
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 20:15:11 +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 5c3398f33d apps/gophers: drop MainAxisSize from Flex initializers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 19:17:16 +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 9f394109cb apps/gophers: update to simpler Flex.Flexible method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 18:46:58 +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 15505cd635 apps/gophers: upgrade to new layout.List API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 18:11:26 +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 431fa218b2 apps/gophers: larger font sizes and a layout fix
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 16:56:56 +02:00
Dan Kortschak bcd5685e78 apps/hello: use correct Config type
Signed-off-by: Dan Kortschak <dan@kortschak.io>
2019-07-11 15:31:18 +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 9d8d5da106 cmd/gio: (android) don't compress resources.arsc in apks
Compressing resources.arsc result in warnings such as

"resources.arsc in APK '...' is compressed."

in the adb logs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 13:22:42 +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 828a695086 cmd/gio: rename -v to -x and add -work
The verbose flag only triggered printing of commands, which is
traditionally named -x by other Go tools.

The -work flag will print and preserve the temporary directory.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-11 11:11:06 +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
Elias Naur dbe15b23a9 apps/gophers: update to new split area ops
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 23:00:42 +02:00
Elias Naur 4fadf71992 ui/pointer: split AreaOp into RectAreaOp and EllipseAreaOp
Now that the pass through mode is moved into its own PassOp op,
it doesn't make sense to collect all area types into one exported
type.

Add RectAreaOp and EllipseAreaOp for clients; the internal
representation is still a single op. It can be changed later without
breaking clients.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 22:55:16 +02:00
Elias Naur f44ccec043 ui/pointer: simplify pointer pass through
Get rid of the confused LayerOp and the transparent property from
AreaOp. Add an explicit PassOp to specify whether pointer events
pass-through the current area.

Let AreaOp swallow events even when no handlers are active for the
area. That behaviour is less surprising and allow clients to disable
a widget by keeping its areas but leave out its handlers.

Simplify the pointer.HitResult enum to just a bool: hit or no hit.

Finally, simplify the pointer queue by tracking parent areas and
node with indices.
2019-07-10 22:43:03 +02:00
Elias Naur f90ef91b19 ui: fix comment for TransformOp 2019-07-10 20:47:42 +02:00
Elias Naur cadfc88be2 cmd/gophers: update to ui.Config as an interface
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 17:23:31 +02:00
Elias Naur 32aae18293 ui,ui/app: convert Config to an interface
To keep the interface slim, remove the helper methods and shorten
the essential method, Pixels, to Px.

Add and use unexported Config implementation in the app package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 17:20:55 +02:00
Elias Naur 624ef78e1c apps/gophers: update to renamed Config.Pixels method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 14:03:30 +02:00
Elias Naur 320579814f ui: rename Config.Val to Pixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 14:00:44 +02:00
Elias Naur e3ba84758c cmd/gophers: use default scale for avatar images
We don't know the DPI for random images from the internet.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 13:50:41 +02:00
Elias Naur 2aac09b3b2 cmd/gophers: update to integer ui.Config pixel values
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-10 13:36:26 +02:00