ref: 5c3dcc6f9a07dc22a26319616adc2c63e33da966 gio/ui/layout/list.go -rw-r--r-- 5.2 KiB
ui/gesture: add Scroll.State method

And move Click.State to a method.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/layout: document List, Stack

Tweak Flex documentation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/layout: rename List.Elem to End to match Stack and Flex

Add more documentation while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/layout: rename and sanitize enums

Rename MainAxisAlignment to Spacing and CrossAxisAlignment to just

Drop the untyped Start, End, Center values and add them as Spacing
and Direction values. Center is both a Direction and Alignment, so
use the synonym "Middle" for the alignment.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/paint: rename the draw package

The draw package name clashes with the standard library draw package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: change area ops to use rectangles, not sizes

And then use the more general rectangles to add a buffer around
text.Editor click and scroll area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: get rid of Inf

It's not worth the special cases. Use a large value where needed
(layout.List, text.Editor...) instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui: merge Transform into TransformOp

The separate Transform type is not worth its weight.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/text,ui/layout: move ui.Config and input.Queue to parameters

I too often forget to initialize widgets' config and queue. Moving
them from fields to parameters fix that. The change results in a
little more verbosity but cleaner code.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
ui: rename block to macro

It is a more precise name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ui/input: rename Queue to Router and Events to Queue

Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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

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

Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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

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>
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.
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>
ui/gesture: rename Scroller.Update to Scroller.Scroll

Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>