Commit Graph

78 Commits

Author SHA1 Message Date
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 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 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 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 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
Elias Naur a35118d522 ui: add package input for merged input
To avoid passing a queue type for each kind of input (pointer, key),
introduce package input for mapping a handler key to all input events.

Future input sources can be added without changes to programs, and
as an added bonus, event ordering is preserved across input sources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-08 10:58:57 +02:00
Elias Naur 86f6765e64 ui/app/internal/gl: avoid allocations when passing handles to C
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:51:33 +02:00
Elias Naur 659a85aae0 ui/app/internal/gpu: add specialized path cache to avoid key allocations
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:45:44 +02:00
Elias Naur 1e38eec0ab ui: build paths as ops
Instead of allocating and constructing a clip path, store path data
directly in op lists. Use separate op lists for cached text layout
paths.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 22:18:04 +02:00
Elias Naur 0d2cffe196 ui: let OpsReader keep track of references
Instead of exposing the entire reference slice, return the relevant
references from Next.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +02:00
Elias Naur 5966aab77e ui: move ops reader to ui package
To prepare support for cached OpBlock to refer to other Ops lists.

The exposure of OpsReader is alleviated by the removal of the Refs
and Data accessors for Ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-02 19:17:53 +02:00
Elias Naur 7ae8fdaae7 ui/app/internal/gpu: track image and color in a state stack
Just like the other drawing state, the current image or color must
be tracked in a stack.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 18:43:51 +02:00
Elias Naur 00a87f542d ui: introduce OpColor, a specialized OpImage for uniform colors
To avoid allocating an image.Image for OpImage.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 13:01:51 +02:00
Elias Naur 0061c73a89 ui: split OpImage into OpImage and OpDraw
In preparation for an OpColor (and future OpGradient and similar).

Label and Editor no longer take an explicit source image. They
draw with the current image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 12:44:49 +02:00
Elias Naur 5cc9906eb8 ui/app: (windows) use the new golang.org/x/sys/windows.MessageBox function
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-27 11:37:33 +02:00
Elias Naur e5ddb0b903 ui/app: (macOS) use CFTypeRef for the view factory
The os and gl packages were separate in the past, which required
uintptr for cross-package CFTypeRefs. That's no longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 14:05:30 +02:00
Elias Naur a1c0693eeb ui/app: add Lock/Unlock to Context for macOS
Without locking, asynchronous OpenGL rendering crashes on macOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 14:01:26 +02:00
Elias Naur c3ea85801c ui/app: (wasm) replace TypedArrayOf with the CopyBytes* API
syscall/js.TypedArrayOf is going away in Go 1.13 and is replaced by
the CopyBytesToGo, CopyBytesToJS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 12:30:34 +02:00
Elias Naur edec032ae6 ui/app: (wasm) re-use javascript buffer
Now that syscall/js.TypedArrayOf is going away in Go 1.13 (sse
https://golang.org/issue/31980), copying byte slices to JS before
use is necessary. To avoid garbage, re-use a single buffer for all
transfers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur 7b13da7299 ui/app: (wasm) use JS allocated buffer for invalidateFramebuffer
syscall/js.TypedArrayOf is going away in Go 1.13. Avoid it for
invalidateFramebuffer by using a buffer managed by JS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur bc481ea784 ui/app: serialize event handling
The frame callback for macOS comes in from a different thread than
the UI thread. Serialize event handling to maintain the invariant
that only one event is processed at a time.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-21 15:56:56 +02:00
Elias Naur da598663f7 ui/app: add GL buffer caches
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:47:30 +02:00
Elias Naur 642318842c ui/app/internal/gpu: add pathOp cache
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:16:36 +02:00
Elias Naur 00cb158247 ui: add Config.Sp and Config.Dp convenience methods
And rename Pixels to Val.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:32:47 +02:00
Elias Naur 25ba53ea51 ui/app: (macOS) suppress key shortcuts beeps
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 09:59:20 +02:00
Elias Naur a6fc2b6d45 ui/app: round total and cpu times
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 21:41:28 +02:00
Elias Naur 3c9c38947d ui/app: (wasm) don't focus input field on mouse down or touch start
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 21:30:26 +02:00
Elias Naur 32c525f7fd ui/app/internal/gpu: check for GL_EXT_disjoint_timer_query_webgl2
GL_EXT_disjoint_timer_query_webgl2 is the WebGL 2 counterpart to
the WebGL 1 GL_EXT_disjoint_timer_query extension.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 19:50:26 +02:00
Elias Naur 90d2174090 ui/app: take input focus when initializing the HTML canvas element
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 12:49:43 +02:00
Elias Naur 18c74f00af ui/app/internal/gpu: check floating point FBO support
Some devices don't support floating point FBOs even though they
support OpenGL ES 3. Check support by creating a FBO and fail early
if no support is found.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 12:44:47 +02:00
Elias Naur 8f3384ffe4 ui/app/internal/gl: add RENDERER enum value
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 09:52:39 +02:00
Elias Naur c342054dbc ui/app: apply monitorScale to browser DPI
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 20:23:07 +02:00
Elias Naur 530b9b09b2 ui/app/internal/gpu: drop useless timing
It is almost always 0.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 18:00:25 +02:00
Elias Naur 07a5a6547e ui/app: add CPU draw timings
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 17:51:15 +02:00
Elias Naur e2a1f07b84 ui/app: rename StageVisible and StageInvisible
StageRunning and StagePaused better reflect their use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 14:59:07 +02:00
Elias Naur 4441a3e13e Revert "ui/app,apps: unexport ChangeStage and Stage"
I found a convincing use case: stopping asynchronous activities
while paused. A follow up change will rename the stages and add
an example.

This reverts commit f9840b0963.
2019-05-12 14:47:38 +02:00
Elias Naur f9840b0963 ui/app,apps: unexport ChangeStage and Stage
I'm not convinced the API is right. For exmaple, an event that
notifies a program when to save its state is both smaller and
might be sufficient.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:50:18 +02:00