Commit Graph

1664 Commits

Author SHA1 Message Date
pierre 59720a8a58 router: removed unnecessary checks.
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-06 21:58:04 +01:00
Inkeliz 2739547c12 internal/glimpl: [wasm] fix WebGL 1 support v2
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-06 21:57:14 +01:00
Inkeliz fb5e2ee9ec app/internal/window: [wasm] add support for StageEvent
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-06 09:12:22 +01:00
Elias Naur 53e0733d20 .builds: test iOS/Android builds of the gioui.org module, not just the example
The kitchen example may not yet refer to the newest version of the gioui.org
module.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-05 14:32:13 +01:00
Elias Naur 2230accd34 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-05 10:22:59 +01:00
Inkeliz 828f19304b app: move system.ClipboardEvent to its own package
API change. Update your code with gofmt rule and goimports:

gofmt -r "system.ClipboardEvent -> clipboard.Event"
goimports

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-05 10:20:55 +01:00
Walter Werner SCHNEIDER feb93baee0 app/internal/window: use unsafe pointer to array
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2020-12-05 09:46:12 +01:00
Elias Naur e9a75cc22a example/glfw: delete GLFW => Gio OpenGL bridge
It's no longer needed.

Update gophers to latest gio while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 20:52:33 +01:00
Elias Naur ffe5ab51a2 gpu/gl: remove OpenGL functions parameter from NewBackend
As a consequence, most API is gone from gpu/gl, and embedding Gio in
foreign frameworks don't need to provide an OpenGL implementation.

The next change simplifies the GLFW embedding example accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 20:50:22 +01:00
Elias Naur b8e33bb420 app/internal/glimpl: derive version parameter in Functions.Init
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 20:41:34 +01:00
Elias Naur 85a06223a6 example/gophers: update to latest Gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 20:41:13 +01:00
Elias Naur 8c9466e03e app/internal/window: [iOS] disable cursor support
Building an iOS results in errors about missing NSCursor:

$ gogio -target ios -o app.app ./kitchen
gogio: go build -ldflags=-s -w -X gioui.org/app/internal/log.appID=org.gioui.kitchen -buildmode=c-archive -o /var/folders/_7/lnt35k555hl2bs7fjygkhgx00000gp/T/gogio-770783182/gio-amd64 -tags  ./kitchen failed: # gioui.org/app/internal/window
os_darwin.m:26:10: error: use of undeclared identifier 'NSCursor'
os_darwin.m:32:10: error: use of undeclared identifier 'NSCursor'
os_darwin.m:40:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:43:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:46:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:49:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:52:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:55:14: error: use of undeclared identifier 'NSCursor'
os_darwin.m:58:14: error: use of undeclared identifier 'NSCursor'

NSCursor is supported under mac catalyst; disable NSCursor support while
figuring out how.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 20:38:53 +01:00
Elias Naur eb91b2c517 .builds: install chrome dependency just before needing it
Reduces the time it takes for core and example tests to complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 19:06:08 +01:00
Elias Naur 7ef591d0ec app/internal/window: [Android] ignore setCursor when not supported
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 12:13:07 +01:00
Elias Naur 003bcc7995 widget: don't ignore Editor key events after submit
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 10:14:41 +01:00
Elias Naur d29cf52595 app/internal/window: fix missing Windows cursor
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-04 10:08:37 +01:00
Inkeliz cd3b4561cf io/key: improve InputOp focus and blur
The existing implementation cannot remove the focus of some widget,
doesn't have an option to focus without display the on-screen keyboard
and it automatically focuses the first InputOp, aggressively.

That change aims to make possible: remove focus from any widget. Add
focus without displaying the on-screen-keyboard/soft keyboard. Don't
automatically focus any widget. Don't recover focus when the widget is
visible again.

Fixes gio#180.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-03 16:46:48 +01:00
pierre e9cd8958de layout: fixed divisions by zero in Flex.Layout
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-03 16:45:33 +01:00
pierre 69cc2c795c app: add support for system cursors
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-03 16:45:17 +01:00
Elias Naur 951d45a2c6 op/clip: fix incirrent mention of even-odd fill rule
It's the non-zero winding rule.

Noticed by Richard Wilkes.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-03 10:03:51 +01:00
Elias Naur 3a792dd555 example/kitchen: gofmt -s -w .
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-02 13:57:21 +01:00
Inkeliz b9846b48b8 app/internal/glimpl: [wasm] remove slow getError calls
The removal of getError significantly improves performance on js/wasm:

Opera 72 (w/ AMD Ryzen 3900X): ~12.29ms per frame to ~8.09ms;
Chrome 87 (w/ Snapdragon 435): ~156.34ms per frame to ~94.31ms;

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-01 08:19:45 +01:00
Pierre Curto 4c3de5f5d2 app: support horizontal scrolling on Windows and Linux
Fixes #181.

Signed-off-by: pierre <pierre.curto@gmail.com>
2020-11-27 09:24:48 +01:00
Walter Werner SCHNEIDER 4f8150cd59 cmd/gogio: add gogio test for go import path
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2020-11-27 09:16:56 +01:00
Elias Naur 9b54892cc4 cmd/gogio: restore package path handling
A previous change converted the package argument to gogio to an absolute path.
However, gogio supports all package paths that may appear in Go import statements.
For example, the path "gioui.org/cmd/example/kitchen" should not be converted.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-26 11:17:40 +01:00
Egon Elbre 39787cb5b7 example/kitchen: add benchmark
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-25 23:12:27 +01:00
pierre dce035fec4 f32: added Point.In(Rectangle)
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-11-24 19:53:58 +01:00
Inkeliz eaaffa1f3e cmd/gogio: force GOARM=7 to avoid softfloat on Android
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-24 19:53:04 +01:00
Egon Elbre 7bad76ad75 op/clip: handle zero Cube
Currently this comes up with RRect/Border that has zero corners. It
improves them from ~250ns to ~170ns. While it's possible to check this
in RRect implementation, however it'll slow down calls with non-zero
corners.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-24 14:38:14 +01:00
Egon Elbre 21dc27b115 internal/ops: remove some bounds checks
Currently BCE is unable to understand that the accesses in the code are
safe. Added an explicit slice to make the length bounds obvious.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-24 14:14:26 +01:00
Egon Elbre 918a5da308 Many operations do not pass refs to Write. Similarly adding
...interface{} requires constructing a slice, which is slow.

This cuts about 100ns from RRect and Border benchmark.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-23 23:43:17 +01:00
Egon Elbre 1899104536 op/clip: expose LineTo and QuadTo
Using delta position with Line and Quad can drift over successive calls.
Also, in some cases it's much more convenient to use absolute
coordinates rather than relative.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-21 22:46:03 +01:00
Inkeliz 689b317de9 app/internal/window: add support for system.CommandBack on wasm
To get the `popstate` we need to create a new entry into
the browser history. Then, Gio will handle the "back" and
"forward" of the page.

In some browsers (Chrome 87/Edge 87): The user must
click inside the window/page at least one time. It will not
work if the user leaves the page  (clicking back button)
without interaction with Gio.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-21 16:52:48 +01:00
Raffaele Sena 8a3ff4abcb app/internal/window: implement key.Press and key.Release on macOS
Update key.State documentation and add State.String while here. Also
update Event.String to include State.

Signed-off-by: Raffaele Sena <raff367@gmail.com>
2020-11-21 09:10:14 +01:00
Inkeliz e195309d55 app/internal/window: mitigate keyboard issue on WASM iOS
That change mitigates the issue gio#150 and gio#166. The
iOS can only `focus()` as a response to touchstart/click
events. We can't `focus()` at random, without user interaction.

The `w.requestFocus` will try to focus on the next `touchstart`,
which may need some "double click" in some cases. That mitigates
the issue, but doesn't fixes completely, but open the keyboard. (:

I didn't notice any side-effect of that change on Android and on
Windows.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-21 09:09:47 +01:00
Inkeliz fb15547b7a app/internal/window: remove context-menu (right-click) for wasm
The context-menu seems useless. The only action available, on the
context-menu is to "Save image": which gives a black image.

I think it's better to remove it. The right-click still work and still
provide `pointer.Event`.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-21 09:09:35 +01:00
Inkeliz 7ca00d5d34 app/internal/window: fix enter-key for android
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-19 20:54:19 +01:00
Elias Naur e2f9ebe87e .builds: add check for missing sign-offs
As suggested by Chris Waldon, this will catch pushes to master and
also during automatic testing of patches sent to the mailing list.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-19 18:56:47 +01:00
Elias Naur 8886f9de56 .builds: add SPDX license header
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-19 18:44:57 +01:00
Elias Naur fe9c11dfe3 .builds: move go fmt check last
The check is important, but shouldn't block the other tests from running.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-19 18:11:55 +01:00
Egon Elbre 2affb6eaa4 cmd,example: fix uses of color.NRGBA
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-19 11:35:26 +01:00
Egon Elbre 21ef492cc9 all: use color.NRGBA in public API
color.RGBA has two problems with regards to using it.

First the color values need to be premultiplied, whereas most APIs
have non-premultiplied values. This is mainly to preserve color components
with low alpha values.

Second there are two ways to premultiply with sRGB. One is to premultiply
after sRGB conversion, the other is before. This makes using the API more
confusing.

Using color.NRGBA in sRGB makes it align with CSS.e

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-19 11:30:11 +01:00
Inkeliz 9469d18907 widget/material: fix hint when Editor is single-line
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-11-18 11:42:41 +01:00
Elias Naur 01e8308a83 app/internal/window: add missing period after sentence
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 16:51:12 +01:00
Elias Naur aee87baefe text: represent laid out text as strings to facilitate caching of layouts
Commit https://gioui.org/commit/b331407e81456 added text layout and shaping
based on io.Reader and changed Editor to use it. Unfortunately, as ~inkeliz
discovered, caching of shapes were also lost.

~inkeliz suggested fix,

https://lists.sr.ht/~eliasnaur/gio-patches/patches/15059

adds caching of shapes to Editor to regain lost performance.

This change repairs the cache to work on io.Reader API, in hope that the
already complicated Editor won't need additional caching.

Before this change, text layouts were represented as a slice of (rune, advance)
pairs. Unfortunately, this representation doesn't lend itself to caching of
shaping results, so change the representation of a line of text to be a pair
of text and advances:

	package text

	type Layout {
		Text string
		Advances []fixed.Int26_6
	}

The Text field can then be used in a cache key, assuming Advances is
consistent with it.

The end result is that the two shaper variants of text.Shaper is reduced to
just one, and the Len field field of text.Line is no longer needed.

The changed representation adds a bit of extra work to package opentype.
Cleaning that up is left as a future TODO.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 16:02:30 +01:00
Elias Naur 67594636e7 text: offset Weight constants so the zero value is normal text weight
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 14:54:44 +01:00
Elias Naur 23fa3480c6 op/paint: update documentation to match the removal of PaintOp.Rect
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-16 12:54:58 +01:00
Sebastien Binet c15415b0d9 app/permission/camera: fix documentation typo
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-13 15:06:51 +01:00
Walter Werner SCHNEIDER 3c739323cb cmd/gogio: group buildInfo related code
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2020-11-12 15:52:35 +01:00
Sebastien Binet 7eb32360e5 gpu,op/clip: implement stroked paths with miter joins
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-11-11 16:14:49 +01:00