Commit Graph

131 Commits

Author SHA1 Message Date
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 29993af408 apps/gophers: add per-frame mallocs to profiling status line
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-31 14:41:05 +02:00
Elias Naur bb0f80902f apps/gophers: update event method names
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:57:43 +02:00
Elias Naur a7874d70ef ui: rename event methods to Update
For uniformity.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:55:52 +02:00
Elias Naur 67bfa38e02 apps/gophers: switch to explicit layout methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:52:19 +02:00
Elias Naur 9b3429d6da ui: switch to (more) explicit layout
The layout package switched from interfaces to functions for
composing layouts. The switch made sure that no garbage is
generated for transient layouts such as Align, Inset, Stack, Flex.

Unfortunately, that left the stateful widgets and layouts: as soon
as their layout methods are embedded in a transient layout, a
closure is generated that escapes to the heap.

To avoid garbage for both transient as well as stateful widgets,
replace the functional approach with explicit begin/end methods.

A begin method generally starts an op block and returns the adjusted
constraints. An end method takes computed dimensions, ends its op
block and returns adjusted dimensions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-30 21:39:00 +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 4513d109b1 apps/hello: fix build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:35:02 +02:00
Elias Naur 51d1c32c07 apps/gopers: update to new Config convenience methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 19:34:06 +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 acf345a0f8 apps/gophers: use shorter layout method names
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 15:43:41 +02:00
Elias Naur 2d96e760d3 ui/layout,ui/text,ui/widget: shorten Widget function names to W
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 15:41:43 +02:00
Elias Naur 3e5e9b2df2 apps/gophers: convert to new explicit layout API
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 12:58:02 +02:00
Elias Naur e436dce0e7 ui/layout: make layout API explicit
With layout.Widget a function instead of an interface, the amount
of per-frame garbage can be drastically reduced.

The layout code ends up slightly more explicit.

As a side benefit, the awkward ordering indexing for Flex and Stack
fit nicely into their new explicit Layout methods.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 11:44:17 +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 44e02786c6 README.md: note that todos can now be filed through email
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-15 22:48:05 +02:00
Elias Naur d98f579048 ui/layout: remove unused layout.Interface
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-14 16:02:24 +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 379cab92c4 apps: go get gioui.org/ui@latest
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 20:24:20 +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 1e14540a6f apps: go get gioui.org/ui@latest
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 18:07:57 +02:00
Elias Naur 701ceda4d0 ui/gesture,ui/editor: don't focus and show keyboard on touch press
Wait until click for touches.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 18:06:18 +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 84f80711dc apps/gophers: correct inverted logic
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 17:43:23 +02:00
Elias Naur 31bec932d1 apps: go get gioui.org/ui@latest
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 17:33:14 +02:00
Elias Naur 1d91555ace apps/gophers: add context cancellation on StagePaused
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 15:11:44 +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 af7a0ad293 REEADME.md: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 14:49:37 +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
Elias Naur 314c79a725 ui/app: fix iOS build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:49:47 +02:00
Elias Naur 6d690fd343 README.md: add note about webassembly support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:36:24 +02:00
Elias Naur 1b6a0580a7 apps: go get gioui.org/ui@latest
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:22:13 +02:00
Elias Naur 801ce944f2 apps/gophers/web: add driver files for WebAssembly builds
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:17:57 +02:00
Elias Naur 0397cbb599 ui/app: add basic webassembly/webgl support
It is still slow. And crashy: https://github.com/golang/go/issues/31980.

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