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>
We are going to encourage a model where pointers to a central
(program global) Configs are passed to widgets at setup time, and
not pass Configs at every frame.
That way, the global Gonfig can change, but the pointers won't need
updating.
This change only switches the Draw event's Config pointer to a value
to avoid tempting programs to use the event Config instead of
updating their own central Configs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>