Commit Graph

1823 Commits

Author SHA1 Message Date
Elias Naur b456e987f7 .builds: prepare for splitting out examples in separate repository
The example module is moving to git.sr.ht/~eliasnaur/gio-example.
We still need some main package for testing gogio, so update reference
to use the module path (gioui.org/example).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-08 19:40:57 +01:00
Chris Waldon acc3f704e4 example/{kitchen,tabs,gophers}: update to use material.Palette
Update gioui.org/cmd while here.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-06 23:04:52 +01:00
Chris Waldon a87a520ae8 widget/material: manage widget colors with Palette type
This introduces a new material.Palette type that captures the color information
necessary to render a widget. This type is embedded in the material.Theme to
make it easier to swap to a different palette for part of the UI by reassinging
the Palette field.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-06 23:02:30 +01:00
Elias Naur 47ba975899 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-06 22:59:51 +01:00
Elias Naur ede632b265 widget: fix Editor and Label clipping
Commit gioui.org/commit/94d242d18c9245 broke Editor and Label clipping,
most visible for single-line Editors. Restore the correct clipping.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-06 22:57:11 +01:00
Elias Naur 9b8e847a05 example,cmd: update gio version
Remove copy/paste from kitchen now that Editor supports it natively.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-06 22:31:43 +01:00
Inkeliz a4d0c3e702 widget: add support for copy/paste in the Editor
The Editor will handle CTRL+C and CTRL+V. The CTRL+V will paste the
content on the Editor, and CTRL+C will copy all the Editor content.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-06 22:21:18 +01:00
Inkeliz a76f816ae9 io/clipboard,app: add WriteOp, ReadOp
Previously, the only way to manipulate the clipboard (read or write) is
using the `app.Window`.

The new `clipboard.ReadOp` and `clipboard.WriteOp`makes possible to
read/write from the widget.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-06 22:15:16 +01:00
Elias Naur 4e2d08c0a6 widget: replace newline with space in single-line Editors; cover SetText
Move the replacing to Editor.prepend to fix SetText, and replace with
space instead of nothing to keep lines separated even in single-line
Editors.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-06 22:15:16 +01:00
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