Commit Graph

398 Commits

Author SHA1 Message Date
Elias Naur a2e485b56d README.md: add link to Gophercon 2019 talk
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-25 13:10:49 -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 b45222b457 apps: drop init funcs
Now that Gio runs main functions everywhere, init func are no longer
necessary.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-22 11:40:13 +02: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 f47a38844b apps: update to newest gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 22:01:29 +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 4724666ba0 apps/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 20:04:59 +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 2cb3832c16 apps/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 17:39:14 +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 2cf2f211cb apps/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 13:14:57 +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 5f0047567e apps: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-21 11:50:43 +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 6c0850ce60 apps/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-20 16:26:47 +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 4a9b6f3007 apps/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 13:20:54 +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 7f5393f9be apps: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-19 01:22:50 +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 a36372a243 apps: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 21:14:22 +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 75891f024c apps/gophers: update to rename Window.Invalidate method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 18:46:34 +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 8fc7a316cc apps/gophers: update to renamed ImageOp.Src field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-18 16:00:24 +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 934aa4fe8d README.md: add shameless plug to Scatter
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 18:57:38 +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 8f0d741d9f apps/gophers: update to StackOp
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:51:20 +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 f9fda47d25 apps: update to newest macro api
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-16 13:24:41 +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 f32b5fef43 apps/gophers: update to renamed layout.Inset and layout.UniformInset
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 21:12: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 5b7b1eb001 apps: upgrade to the block to macro rename
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-07-15 20:39:15 +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