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>
A Window.Redraw called after the client has completed building a
frame and before Window.Draw resets the redraw flag is effectively
ignored. Move the flag reset earlier to just before the client is
asked to build the frame, to ensure that no state updates are lost.
Tighten and simplify the locking while we're here.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Change input.Events interface to return one event at a time until
the queue is empty.
Change text.Editor and gestures to match.
Re-add Editor.Submit while we're here; we don't want to enable
submit mode always.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, the Editor cleared its content after each
Submission event. If it didn't multiple submits for a frame would
not result in the cleared text for clients that wants to clear the
Editor between submits.
However, for clients that do not want to clear the content or that
wants to validate the text before accepting it were not supported.
Instead, switch to a event stepping model, where the client can
call Next to receive each EditorEvent (that is, Submit event) in
turn.
We can then delete the Submit flag on Editor and always report Submit
events.
We can also make Layout flush the pending events now that Editor
always has access to its Config and input queue.
Signed-off-by: Elias Naur <mail@eliasnaur.com>