Commit Graph

252 Commits

Author SHA1 Message Date
Elias Naur eee497f22a ui/app: (wasm) create and add container div if one is not provided
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-02 09:04:00 +02:00
Elias Naur 28bd97f877 ui/app: delete unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-02 08:59:54 +02:00
Elias Naur 0be3492e07 ui/app: (wasm) avoid deadlock from focus changes
showTextInput is called from the window loop in window.go, but
could result in an immediate event which then deadlocks waiting for
the window loop to handle it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-02 08:54:21 +02:00
Elias Naur 73b1e64209 ui/input: change Queue to return Events one at a time
By returning all events, widgets that might return early from its
event loop might throw away subsequent events. Instead of requiring
those widgets to store the event list, convert input.Queue to step
through the available events one at a time.

Functional revert of 1735d5ced8.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 18:56:49 +02:00
Elias Naur b15a32065f ui/app: (wasm) fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 17:48:53 +02:00
Elias Naur cb312c8d32 ui/app: drop Event
input.Event is enough if we stretch "input" to mean both input
devices and other events such as profiling events and system
commands.

The pointer and key packages are separate already, so I don't
expanding the meaning is unreasonable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 15:27:14 +02:00
Elias Naur 69bba3aa4b ui,ui/draw: fix decoding of negative integers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 10:43:17 +02:00
Elias Naur bfece0beba ui: change area ops to use rectangles, not sizes
And then use the more general rectangles to add a buffer around
text.Editor click and scroll area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-01 10:06:19 +02:00
Elias Naur 46b9e7b9ab ui/app: (macOS, iOS) ignore SIGPIPE
Work around golang.org/issue/33384

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-31 22:53:30 +02:00
Elias Naur 3d9861011e ui/layout: restore Flex.Rigid behaviour
Broken by 5f2adf9b2f.

Clamp to 0 while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-30 15:25:23 +02:00
Elias Naur 5f2adf9b2f ui: get rid of Inf
It's not worth the special cases. Use a large value where needed
(layout.List, text.Editor...) instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-29 12:12:51 +02:00
Elias Naur 5e1f078b12 ui: merge Transform into TransformOp
The separate Transform type is not worth its weight.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-29 02:50:55 -07:00
Elias Naur d178167c3b ui/app/internal/gpu: add workaround for render corruption
Fixes gio#13

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-29 02:50:50 -07:00
Elias Naur a0d1d93ccf ui/app: (linux) don't deadlock when failing to create window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-25 17:27:10 -07:00
Elias Naur c1128e7f8a ui/app/internal/gpu: only apply clear optimization for rect clips
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-24 20:16:38 -07:00
Elias Naur c080a54038 ui/app: call main from Android and iOS
Android can only run c-shared libraries which means that every
Gio program must create its window and event loop from an init
function.

The same applies to iOS but for a more benign reason: the gio tool
builds programs in c-archive mode for iOS and links the binary with
a Objective-C driver.

Allow Gio programs to run off its main function by linking to and
invoking main even from Android libraries and iOS ditto.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-22 11:33:09 +02:00
Elias Naur 4e0d820a5b ui/app: (android) block until DataDir is ready
The app data dir is not set until after Go's init functions have
run, which means that DataDir is inherently racy. Avoid that race
by blocking in DataDir until it is set from Java.
In other words, trade a race condition with a deadlock.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-22 09:37:48 +02:00
Elias Naur 1ee8c08f3b ui/app: make the default window title "Gio", not "Gio program"
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 22:02:30 +02:00
Elias Naur dd081c78b9 ui/app: make DrawEvent optional
It is never a good idea not to draw in response to a DrawEvent, but
let's not hang the program if it doesn't call Window.Draw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 21:58:54 +02:00
Elias Naur 2f9e29d878 ui/app: (macOS) avoid double-drawing in NSOpenGLView update
Instead of drwaing twice when updated, schedule a redraw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 19:19:34 +02:00
Elias Naur 21ad48b7de ui/app: (macOS) use consistent scale for pointer events
Instead of querying the backing store scale for every pointer event,
use the scale from the last window draw. It might not make any visible
difference because we redraw on scale changes, but it is more correct.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 17:34:12 +02:00
Elias Naur 71f6df9352 ui/app: (macOS) redraw when NSOpenGLView update is called
When moving a window to another monitor, update is called when the
opengl backing store updates its internal size.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 17:20:44 +02:00
Elias Naur 8eea6b80f3 ui/app: (macOS) use a consistent and constant backing store constant
Compute and keep constant the pixel density, to avoid window content
changes when moving to another monitor with a different density.

Use backing store scale, not content scale for input events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 16:59:29 +02:00
Elias Naur cb59594b5b Revert "ui/app: make window event queue buffered"
Breaks the ack mechanism of sending a dummy ack event to ensure
the previous event has been processed.

This reverts commit 7582b835bc.
2019-07-21 15:36:02 +02:00
Elias Naur 9e0e4af8c6 ui/app,ui/key: move TextInputState from key to internal package
Clients have no need for the TextInputState type.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 13:12:24 +02:00
Elias Naur b46bad09bd ui/app: remove redundant redraw check
Now that the input router triggers a redraw when a focus event is
added, it is no longer necessary to check for that condition in
Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 12:53:28 +02:00
Elias Naur 3f7735ccdf ui/app/internal/input: redraw if focus events was added
The key queue might generate focus events. Schedule a redraw if so.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 12:50:53 +02:00
Elias Naur 7582b835bc ui/app: make window event queue buffered
Input events are asynchronous, so add buffered to the event queue
so that a slow client does not stall the native window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 12:43:42 +02:00
Elias Naur b6290990ad ui/text,ui/layout: move ui.Config and input.Queue to parameters
I too often forget to initialize widgets' config and queue. Moving
them from fields to parameters fix that. The change results in a
little more verbosity but cleaner code.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 11:44:48 +02:00
Elias Naur cd244f21ab ui/app: (macOS) don't release opengl context
I haven't found a reliable way to re-create the context and redraw
after deminiaturization or app unhide.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-20 16:22:41 +02:00
Elias Naur 05f0c3e22a ui/app: (macOS) destroy the GL context correctly
The NSOpenGLView owns the NSOpenGLContext so we can't just CFRelease
the context. Use [NSOpenGLView releaseGLContext] instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-20 16:11:27 +02:00
Elias Naur 0b6e6c58dd ui/app: return a concrete Queue from Window.Queue
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-20 14:20:59 +02:00
Elias Naur 6b5714d15d ui/app: (macOS) ignore asynchronous redraws to deleted windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 13:19:35 +02:00
Elias Naur a140527b08 ui/app: (macOS) serialize access to the views map
The CVDisplayLink used for synchronizing rendering to the display
refresh rate runs on a separate thread from the main thread.
View callbacks must therefore be serialized. Implement that by
introducing a singleton goroutine that owns the view map and runs
incoming commands.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 01:18:48 +02:00
Elias Naur c94315119b ui/app/internal/input: only drop handlers completely when inactive
Delete a redundant loop; dropHandlers already does the required work.

Fixes pointer event issues found after pointer events with no side
effects no longer trigger redraws.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 21:06:06 +02:00
Elias Naur d9d8df989d ui/app: rename Window.Redraw to Invalidate to match ui.InvalidateOp
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 18:45:46 +02:00
Elias Naur 84fb7279eb ui/draw: rename ImageOp.Img to Src
To match widget.Image.Src field name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 15:58:11 +02:00
Elias Naur fd096e8838 ui/input,ui/layout: update comments
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 14:30:59 +02:00
Elias Naur b4441a8728 ui: reset StackOp in Pop
To enable re-use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:53:57 +02:00
Elias Naur 586d33c26e ui: replace PushOp, PopOp with a StackOp
Before this change, there was no guarantee that a PopOp matched
the intended PushOp. With a single stack operation, the client is
forced to match pop with the right push.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:49:32 +02:00
Elias Naur 94a913a371 ui: move macro recording from Ops to MacroOp
Move the Record and Stop methods from Ops to MacroOp itself.

Before this change, Ops.Stop stopped the recording of the most
recent macro, which could be a different macro than intended.
After this change, there is no such confusion.

As a bonus, the Ops API becomes less cluttered.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:21:51 +02:00
Elias Naur ba9ffe846e ui: merge opsData type with Ops
opsData wasn't worth the complexity.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 12:44:23 +02:00
Elias Naur 6947ed9312 ui/app: go fmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 12:32:39 +02:00
Elias Naur eb9c2896cd ui/layout: round, not truncate, flex sizes in Flex.Flexible
Without proper rounding, a pixel could be left uncovered at the end
of the flex layout.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 21:43:53 +02:00
Elias Naur 00b9ff603f ui/layout: rename Insets to Inset and EqualInsets to UniformInset
Rename Insets to the verb Inset for consistency with Align.

Uniform is a better description than Equal for the result of
UniformInset.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 21:10:43 +02:00
Elias Naur 3b5fcfe2bb ui: rename block to macro
It is a more precise name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 20:36:17 +02:00
Elias Naur f36070f716 ui/layout: delete Constraints.Expand and Constraints.Loose
They're not (yet) shown their use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 19:29:42 +02:00
Elias Naur 667670f9c6 ui/layout: delete Constraints.Exact and rename ExactConstraints
Exact was too special and can be expressed with RigidConstraints.

RigidConstraints is a better name ("rigid" was in the comment!)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 19:16:11 +02:00
Elias Naur 8eb58ff2eb ui: support Window.Draw(nil) in OpsReader
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 11:42:47 +02:00
Elias Naur 5b3090b128 ui: don't keep references alive in Ops.Reset
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 09:09:30 +02:00