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>
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>
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.
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>
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>
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>
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>
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.
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>
The dp and sp units are approximate and mostly used for layout
dimensions that operate in whole pixels. This change alters the
Config methods to return pixels in ints instead of floats, which
results in smoother use for layout and emphasize the inexactness of
the device independent units.
Clients can still access to raw PxPrDp and PxPrSp factors from
Config.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
And use a constant 72 DPI for the default scale, to ensure consistent
image sizes across display densities.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Layout objects are usually ephemereal, but when saved and re-used
between frames their measurements are not updated with varying pixel
density and font scaling.
Go back to storing unconverted ui.Values instead of raw pixels,
and convert them at each use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The data dir string is returned to Go as a byte array of the UTF-8
encoded string, but it is not NUL terminated.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
IsAlive races with the StageDead event: if the client checks IsAlive
after the stage is updated to StageDead but before having received
the StageDead it will exit the event loop, blocking the StageDead
to ever arrive.
Remove IsAlive and let the client rely only on the StageDead to exit
its event loop.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>