Commit Graph

1251 Commits

Author SHA1 Message Date
Elias Naur db0af521d0 app/internal/window: move Wayland callback structs into function scope
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-15 12:14:17 +02:00
Elias Naur 31acd5451e op/paint: further clarify PaintOp documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:44:36 +02:00
Elias Naur 29c9b06dab op/paint: document ImageOp gotcha
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:31:21 +02:00
Elias Naur b7ba809517 op/paint: rename material to brush
The "material" name clashes with the theme of the same name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:19:15 +02:00
Elias Naur 81f474f5d7 op/paint,io/system: document ImageOp lifetime
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:15:05 +02:00
Elias Naur 391b89d11d example/glfw: add package documentation and link to installation
Fixes #114

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 11:12:39 +02:00
Elias Naur f16e8fd122 app: update package documentation
Reflect the move of Queue from Window to FrameEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 10:11:18 +02:00
Elias Naur 2e25a28a54 app: fix typo in Main documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 10:08:28 +02:00
Elias Naur 05dfceb7e7 app/clipboard: implement clipboard for Android
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 17:14:58 +02:00
Elias Naur a6dd70b2dc app: add license header to app_android.go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 15:18:07 +02:00
Wagner Riffel 390949790e f32: implement fmt.Stringer to Point and Rectangle
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2020-05-13 12:59:39 +02:00
Wagner Riffel 4bbc6379ed doc: rewrite references to preivous api to current
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2020-05-13 12:59:33 +02:00
Egon Elbre f29964fee1 example/tabs: animated switching
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-05-13 12:59:29 +02:00
Elias Naur d682e92606 example/tabs: use material.Clickable
Replace the hacked material.Buttons with Clickables for the tab areas.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 10:31:40 +02:00
Elias Naur 062e2bc54b gesture: only report TypePress for Click gestures if pointer is grabbed
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:50:07 +02:00
Elias Naur ca0af08ff2 gesture: use Enter/Leave events instead of Moves
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:32:37 +02:00
Elias Naur a0df8ba59b example: bump gio version and add flat button example to kitchen
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 13:20:17 +02:00
Elias Naur 23baeff18d widget/button,widget/material: introduce Clickable for generic click areas
material.Clickable is useful for adding a click response to any widget
or area.

Rename widget.Button to widget.Clickable to reflect the wider use
spectrum.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 13:17:14 +02:00
Elias Naur 47ce4b8cb8 widget: export Button.Update method for accessing raw gesture events
Document Button while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:56:56 +02:00
Elias Naur 43c2b90716 widget: simplify popping an element from a slice
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:47:27 +02:00
Elias Naur fd2cb4a7a1 widget,widget/material: use constraints for setting up hit area
Before this change, the widget.Button.Layout method assumed the caller had set
up the pointer hit area before. Further, the very common rectangular hit
areas needed both an AreaOp and a widget.Button.Layout call.

Make widget.Button less subtle and more useful by setting up a
pointer hit area given by the incoming minimum constraints.

Drop a pointer.AreaOp made redundant by the change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:37:08 +02:00
Elias Naur 4e20ea83a1 widget/material: use cosntraints for setting pointer hit areas
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:23:18 +02:00
Elias Naur 3fd1ccbbed io/router: fix ellipse hit function
The previous formula was simply wrong.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:15:54 +02:00
Elias Naur a046f15156 io/router: return boolean expressions directly
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:57:37 +02:00
Elias Naur 73475270fe example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:32:45 +02:00
Elias Naur c32b3fe43a widget/material: drop Color from ButtonLayoutStyle
Setting a ColorOp before calling a widget function is too subtle.
Let the widget manage its color instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:31:48 +02:00
Daniel Martí 669e4cc96a cmd/gogio: speed up the wine e2e test
First, use wineboot instead of winecfg to set up the WINEPREFIX. It's
the right tool for it.

Second, when initialising WINEPREFIX, use output pipes instead of
CombinedOutput. The latter will wait for *all* output to be copied to a
buffer, including the output from grandchildren processes. Since wine
starts wineserver automatically, and wineserver lingers for three
seconds by default, this is bad. We would waste three seconds waiting
for wineserver doing nothing, and then the next wine call (to start the
app) would need to start wineserver all over.

Instead, with pipes we can get cmd.Run to only wait for the parent
process to finish. wineserver stays running but we don't care. And, when
we start the gio app, we very likely reuse the same wineserver process.

Third, disable wine-gecko and wine-mono. This ensures we don't get stuck
if they're not installed, and speeds up wineboot by avoiding work we
don't need.

The time to set up WINEPREFIX goes down form ~6s to ~1s, and the overall
subtest run-time goes down from ~10s to ~3s.

Finally, copiously document all of the precious data I've gathered above
after hours of debugging.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 21:51:30 +02:00
Daniel Martí 023e022255 cmd/gogio: make e2e test output consistent
Fix a long-standing TODO: instead of each sub-test handling its own
output separately, just make each expose its output via an io.Reader.
Then, the shared driverBase code can tell if any of the lines contain
the magic "gio frame ready" string.

Reduces the amount of code a bit, but most importantly, it keeps the "is
a frame ready?" logic in a single place.

In the future, this also enables us to do more with all the e2e test app
output consistently. For example, we might want to add a -debug flag to
always log output lines as they happen.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:57 +02:00
Daniel Martí 9ad412ea0b cmd: bump gioui.org dependency, use -modfile properly on CI
A simple 'go test -modfile=<path>' won't work properly for the
end-to-end tests, since they run 'go build' under the hood as well.

To properly propagate the flag, we need to use GOFLAGS. Since -modfile
is always relative to the current directory, we can't use it to test
many packages at once, nor can we use it via 'go test ./gogio'.

While at it, document this distinction in go.local.mod to prevent others
getting confused like I did.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:53 +02:00
Daniel Martí c2cbcee78d cmd/gogio: use a standalone WINEPREFIX for the wine e2e test
This way, if the user has a custom winecfg, it can't possibly affect the
tests. I was encountering this as DXVK does not work on virtual Xorg
servers (which we use), and Gio thus failed to render on such a
combination.

>From the numbers below, it can be seen that setting up a new WINEPREFIX
takes roughly five seconds:

	$ rm -rf ~/.cache/gio-e2e-wine
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	16.369s
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	11.810s

A repeated run still has a slow "wine winecfg /?", for some reason. Add
a TODO since I can see it taking a third of the time on my terminal. I
haven't been able to properly investigate why, unfortunately. As far as
I can tell, winecfg is just faster when run with a terminal instead of
an output buffer. They might use isatty on stdout/stderr.

The overall time to run the wine sub-test is increased from ~5s to ~11s,
but it's worth it to make it run everywhere. It looks like there is
plenty of room as per the TODO above, as winecfg seems to mostly do
nothing. We're also not too worried, as all e2e subtests run in
parallel.

Fixes #106.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 08:40:36 +02:00
Chris Waldon 29a9e5bc27 io/router: fix Enter/Leave during press events
This commit updates the implementation of the Enter/Leave pointer
events so that it no longer shares any state with the processing
of pointer presses and grabs. This simplifies the implementation,
though it does leave a certain amount of structural redundancy.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:47:01 +02:00
Chris Waldon c1f0f9b5c7 io/router: improve benchmark by trying multiple sizes
This commit improves the usefulness of the benchmark by automatically
measuring event processing times with a range of values for the complexity
of the UI.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:56 +02:00
Chris Waldon b2f1776670 io/router: fix enter/leave event tests and add more
This commit fixes a bug which concealed test failures when
the actual event sequence was empty but the expected events
were not.

Additionally, this commit adds the following tests:

- a test for when the active input
area disappears while it is still being "hovered".
- a test for when there are two nested input areas that are
being hovered

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:53 +02:00
Elias Naur 0ad8f85c05 cmd/gogio: add -linkmode flags
For experimenting with https://github.com/golang/go/issues/38918.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:31:26 +02:00
Elias Naur bcbea7e653 cmd/gogio: fix ldflags overwriting
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:27:42 +02:00
Elias Naur 630e0b494d app/internal/windows: remove extra empty line
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-07 16:03:22 +02:00
Elias Naur 681bafce08 cmd/gogio: use filepath for Windows compatibility
Fixes gio#112

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-07 15:52:13 +02:00
Elias Naur 3957be37c8 app: [Android] tweak environment for os.UserHomeDir and os.UserConfigDir
Set the fallback environment variables XDG_CONFIG_HOME and HOME to
make os.UserConfigDir and os.UserHomeDir report useful paths.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-06 16:54:55 +02:00
Elias Naur 2395659be3 app: [Android] set XDG_CACHE_HOME to make os.UserCacheDir work
os.UserCacheDir can't work on Android because it doesn't have
access to the Java app context. Gio programs do have access, so set
up UserCacheDir's fallback, the XDG_CACHE_HOME environment variable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-06 16:39:21 +02:00
Daniel Martí e97adeedd9 app/internal/log: use the app ID as the Android log tag
This way, a Gio app's logs can be filtered uniquely, which wasn't
possible before since the tag "gio" would be the same between gio apps.

Since the app ID is supplied at build time, inject it via a variable
with the linker's help. The variable is only used on Android for now,
but that's OK. It might be useful for other platforms or other internal
packages in the future.

Fixes #84.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-06 08:41:04 +02:00
Daniel Martí ec34eb4919 cmd: add a go.local.mod for development
It's essentially a copy of go.mod, but with the gioui.org module replaed
with the parent directory. Useful when wanting to try a change in the
root module as part of a gogio invocation or end-to-end test, such as
either of the following:

	$ cd cmd; go test -modfile=go.local.mod ./...
	$ cd cmd/gogio; go build -modfile=../go.local.mod

Since go.sum can essentially be shared, and since it seems to work with
the go tool, use a symlink. The way the -modfile flag works, if given
foo.mod, it will use the sum file at foo.sum. The only caveat is that
'go mod tidy -modfile=go.mod.local' will try to remove gioui.org lines,
since that module is replaced. So tidy shouldn't be used with -modfile.

In the future, the only upkeep needed for go.local.mod is to update the
external dependencies to mirror changes in go.mod. This is not automated
nor checked by CI, but it could be in the future if it becomes
repetitive or error-prone.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-06 08:41:00 +02:00
Elias Naur 33493501a6 app/internal/headless: [Android] expose Java initialization method
Android apps may want to run Go code independent of the Gio Android Activity.
Expose a Gio.init Java method public for early loading and initialization of
the Go library.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 19:22:11 +02:00
Elias Naur cde651db60 app/internal/window: [Android] remove JNI_OnLoad JNI callback
There can only be one JNI_OnLoad callback per JNI library, and the
Gio program may need it for its own purposes.

Gio only used JNI_OnLoad for explicitly registering native methods. Switch
to implicit name based registration and get rid of JNI_OnLoad.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 19:01:12 +02:00
Elias Naur 0c0a22bee7 app/internal/window: don't rely on JNI_OnCreate for getting the JavaVM
We're about to remove the global JNI_OnLoad constructor, and the
JavaVM singleton is just as easily fetched from a Java JNI callback.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 18:55:14 +02:00
Elias Naur c7c5b87264 app/internal/window: remove unused #includes
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 18:29:25 +02:00
Elias Naur 7301ebe0ef app/internal/window: removed unused function
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 18:23:31 +02:00
Elias Naur f08568a6df widget: report whether Value changed after Enum.Update and Bool.Update
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 11:33:41 +02:00
Elias Naur 05efb9b5f4 example/kitchen: add Switch widget
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 10:41:10 +02:00
Elias Naur 26da49e145 widget/material: add Switch widget
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-05 10:38:31 +02:00
Elias Naur 6b4eb710b3 widget: rename CheckBox to Bool
We're about to introduce the Switch widget that re-uses the same
state type as CheckBox. The Bool name covers both uses.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-04 17:13:50 +02:00