Commit Graph

141 Commits

Author SHA1 Message Date
Elias Naur 31418eefbe ui/key: rename TextInputClosed to TextInputClose
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-07 15:52:09 +02:00
Elias Naur 2c5b7496d2 ui/text: apply correct material for cursor
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-07 00:48:00 +02:00
Elias Naur f56e082cc7 ui/app: introduce DataDir for application-specific data files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-07 00:39:13 +02:00
Elias Naur 2d89a914e9 ui/app: tweak comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-06 16:09:01 +02:00
Elias Naur 38ec6a8831 ui/draw: rename ColorOp.Col to Color 2019-07-05 17:14:57 +02:00
Elias Naur 0f576cf625 ui/text: use default colors to guard against empty materials
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-05 17:11:17 +02:00
Elias Naur 86bc3e612d ui/text: use BlockOp as materials
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>
2019-07-05 16:52:13 +02:00
Elias Naur 30a558d10d ui/app: fix race condition between Window.Redraw and Draw
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>
2019-07-04 16:31:48 +02:00
Elias Naur f1dffa155c ui/text: add ChangeEvent and rename Submit to SubmitEvent
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-04 15:06:50 +02:00
Elias Naur 252514af9d all: update dependencies
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-03 20:26:19 +02:00
Elias Naur 475bccb722 ui: add checks for unmatched Ops.Begin/End
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-02 20:12:06 +02:00
Elias Naur e862761e17 ui/input: keep default focus on earliest focusable
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-02 19:36:45 +02:00
Elias Naur 33fc35f58d ui/draw: switch to color.RGBA for colors
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-02 14:56:48 +02:00
Elias Naur 683df6345b ui/layout: fix Flex spacing
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-01 19:22:06 +02:00
Elias Naur d720fa6233 ui/text: add Hint and HintImage to Editor
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-01 13:36:54 +02:00
Elias Naur 0546683720 ui/text: add LayoutOptions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-30 23:58:05 +02:00
Elias Naur 28f53d8708 ui/text: add Label.MaxLines
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-30 23:51:11 +02:00
Elias Naur ef9384ceee ui/layout: allow one-line initialization of Flex and Stack
Returning itself from the Init methods allows the client to
initialize the layout instance on one line.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-27 12:44:15 +02:00
Elias Naur 4f94f1078a ui/gesture: rename Scroller.Update to Scroller.Scroll
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-22 17:36:57 +02:00
Elias Naur bebfd822d8 ui/gesture: convert Click to single step events for symmetry
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-22 17:33:29 +02:00
Elias Naur 0b6dd4efd9 ui: change events to have "Event" suffixed, not prefixed
Match the Go error naming convention (FooError).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 17:14:16 +02:00
Elias Naur 7aa7bb3be4 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>
2019-06-21 17:01:45 +02:00
Elias Naur b981ccf9ed ui/input: support single stepping through events
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>
2019-06-21 16:30:20 +02:00
Elias Naur 898c3c5d7d ui/layout: unexport List.Update and move its parameters to state
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 16:17:29 +02:00
Elias Naur d4eb86a9b5 ui/text: replace Editor.Update with Next for stepping through events
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>
2019-06-21 16:17:29 +02:00
Elias Naur 98d4d926f6 ui/text: move input.Events parameter from Update to Editor state
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 15:35:45 +02:00
Elias Naur dda9e3486d ui/text: move Config parameter from Editor.Update to Editor state
Assume the user will set a Config pointer once at init.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 15:27:57 +02:00
Elias Naur a695a115ce ui/measure: rename Faces.Cfg to Config
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 15:22:30 +02:00
Elias Naur 47c5859d87 ui/app: make Draw.Config a value, not a pointer
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>
2019-06-21 15:02:37 +02:00
Elias Naur b10a6938cd ui/app: update comment and fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-21 14:54:34 +02:00
Elias Naur 173d56a67a ui/app: (ios) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 19:05:06 +02:00
Elias Naur b9205d9965 uis/app: (macos) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 18:45:46 +02:00
Elias Naur a9199c6d23 ui/app: (android) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 16:07:19 +02:00
Elias Naur a92b97e236 ui/app: (js) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 15:55:49 +02:00
Elias Naur 659419738c ui/app: (windows) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 15:53:04 +02:00
Elias Naur c73d3b59e6 ui/app: (wayland) relay system focus events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-20 15:49:29 +02:00
Elias Naur c1e129a87d ui/layout: implement List.Invert for end aligned lists
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-19 19:46:11 +02:00
Elias Naur f474282a31 ui/app: (wayland) avoid excessive key repeats
Wayland requires its clients to handle key repeating themselves.
Our strategy is simple: start a timer on key down and fire key
events at regular intervals until another key event arrives.

However, if the program blocks the event loop while processing a
synchronous event, key repeats might pile up before the stopping
key event is processed.

This change use the timestamp of the stopping key event to only
dispatch the repeats queued up before the stop time.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-19 12:46:59 +02:00
Elias Naur 7354874bb5 ui/text: add submit events to Editor
Add Editor.Text() and fix a reset while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-18 21:30:19 +02:00
Elias Naur 474b1e8e17 ui/key: add Modifiers.Contain
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-18 21:10:01 +02:00
Elias Naur 3d1e16c4d2 ui/text: unexport Editor.Command
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-18 20:26:52 +02:00
Elias Naur e24f19ecba ui/key,ui/app: introduce ModShift modifier
And add desktop implementations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-18 20:20:57 +02:00
Elias Naur c511858d30 ui/layout: add sanity checks to Insets/Align Begin/End
Would have caught the invalid layout re-use fixed by a recent commit.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-17 17:36:47 +02:00
Elias Naur d67b7eca6c ui/draw,ui/layout: export OpClip
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-17 16:45:49 +02:00
Elias Naur 503c417544 ui/app: (android) enable IME dummy mode
We don't have full IME-aware editor yet. Fortunately, the BaseInputConnection
has a "dummy mode" setting to allow us to receive input from the fancier keyboards
without implementing the full IME interface.

Fixes gio#7 (I hope; I tested with SwiftKey that had the same symptoms)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-11 16:35:43 +02:00
Elias Naur 1f809234b8 ui/app/internal/gpu: replace look up texture with calculation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-10 01:18:23 +02:00
Elias Naur eddc0c948e ui/app/internal/gpu: fix stenciling on the iOS simulator
It seems that the iOS simulator can return NaN from texture2D, so
even though width == 0, the resulting cover is not.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-09 22:21:25 +02:00
Elias Naur 0138544242 ui/app/internal/gl: fix GetProgramInfoLog and GetShaderInfoLog
I should read the manual more carefully.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-09 21:19:50 +02:00
Elias Naur 1931582683 ui/app: (wasm) switch from <textarea> to <input> to avoid double newline
With a <textarea> DOM element pressing the enter key will result in
a "Enter" key down event and a "\n" input event. We're only
interested in the key event, so switching to a single line <input>
avoids the extra "\n".

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-09 15:11:02 +02:00
Elias Naur bd005a09e3 ui/app/internal/gpu: upload path data to GPU before re-use
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-08 18:30:04 +02:00