Commit Graph

280 Commits

Author SHA1 Message Date
Elias Naur 4ce8f4ea51 ui/layout: add Inset example
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 18:18:18 +02:00
Elias Naur 3c941e938f ui/layout: expand package documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 17:56:16 +02:00
Elias Naur 8f37a565b9 ui/layout: document layout types and helpers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 17:09:35 +02:00
Elias Naur ba3a952af2 ui/layout: document List, Stack
Tweak Flex documentation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 16:49:02 +02:00
Elias Naur 8f17163a13 ui/layout: rename List.Elem to End to match Stack and Flex
Add more documentation while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 16:26:39 +02:00
Elias Naur 6d1339733a apps: update gioui.org/ui
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 12:34:58 +02:00
Elias Naur 1a15d7241a ui/layout: rename and sanitize enums
Rename MainAxisAlignment to Spacing and CrossAxisAlignment to just
Alignment.

Drop the untyped Start, End, Center values and add them as Spacing
and Direction values. Center is both a Direction and Alignment, so
use the synonym "Middle" for the alignment.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 12:29:17 +02:00
Elias Naur 2a0b0077da ui/app: (wasm) add checks for required extensions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-10 00:49:28 +02:00
Elias Naur 7bc18c0139 ui/app: more documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 22:27:33 +02:00
Elias Naur a8f42cd567 ui/app: expand package documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 22:16:52 +02:00
Elias Naur 657c40e4bb ui/app: support 0 for window width and height
The zero value means that the client don't care and a sensible
default is chosen.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 22:01:25 +02:00
Elias Naur e5738481f8 ui/app: add package documentation and document Main
Split Main into the common Main function and platform specific
main functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 21:34:29 +02:00
Elias Naur 87f8fd4152 ui/app: update documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 21:17:33 +02:00
Elias Naur a2baffdbfd ui: expand package documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-09 20:35:04 +02:00
Elias Naur a6c262c1e1 ui: expose internal Ops fields as methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-08 15:20:58 +02:00
Elias Naur 3c924e2a18 ui: document types and methods
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-08 14:54:51 +02:00
Elias Naur aa703dfc3e apps/gophers: update to latest gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 20:40:01 +02:00
Elias Naur 4e005f2bfa ui/app: rename DrawEvent to UpdateEvent and Window.Draw to Window.Update
Window.Draw is not the right name for a method that does more than
just drawing. Rename to Update instead, and rename the DrawEvent
accordingly for symmetry.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 20:35:37 +02:00
Elias Naur dd35a48a61 ui/paint: rename the draw package
The draw package name clashes with the standard library draw package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 20:11:53 +02:00
Elias Naur 6e26c92c75 all: remove exported Decode methods on operations
Add decode functions to the packages that need them instead. For
TransformOp that is used in multiple packages, add the decode
function to the internal ops package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:34 +02:00
Elias Naur 4d66669a9e app/internal/gpu: rename opClip to clipOp
To better match ClipOp, which was renamed from OpClip.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:34 +02:00
Elias Naur eaa4efe5af all: add missing licence headers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:34 +02:00
Elias Naur b3517a365e ui,internal/ops,internal/opconst: move OpsReader to internal ops package
To avoid import cycles, move the op constants to its own package,
internal/opconst.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 17:21:26 +02:00
Elias Naur fe20cde393 ui: rename TransformOp.Mul to Multiply and split InvTransform
Multiply is a bit longer but more clear. InvTransform was really
two operations: Invert and Transform.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 14:47:14 +02:00
Elias Naur 9be695cc24 ui: fix TransformOp.Offset
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-07 14:20:40 +02:00
Larry Clapp a14e818299 draw: Fix spelling of Bezier
Sometimes it was "bezier", sometimes "beziér".  Capitalize and put
accent on first e.  https://en.wikipedia.org/wiki/Bézier_curve

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-08-05 19:18:10 +02:00
Elias Naur 8472bbc78b ui/app,cmd/gio: move running of main from driver to GioAppDelegate
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-05 15:38:34 +02:00
Elias Naur 15dc714d40 ui/app: add darwin build tag to ios files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-08-03 21:25:34 +02:00
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