Commit Graph

1175 Commits

Author SHA1 Message Date
Fabian Geiselhart 08dfd2943b ui: fix wrong method name in documentation
Signed-off-by: Fabian Geiselhart <me@f4814n.de>
2020-04-23 15:55:51 +02:00
Elias Naur 925f5af930 example/go.mod: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-23 00:32:59 +02:00
Elias Naur 02d4316c56 gpu: reset to the default framebuffer on reset
The macOS backend doesn't re-create contexts, holding on to the first
created instead. Make sure the GPU leaves the default framebuffer bound,
in case the context is re-used.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-23 00:27:04 +02:00
Elias Naur aefc6f3625 app/internal/window: [Android] use correct JNI Call variant for registerFragment
While we're here,

- replace the registerFragment trampoline with a general variadic
CallVoidMethod trampoline.
- Use UTF-16 for passing strings to Java. Java's modified UTF-8 encoding differ
from Go's in corner cases.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-20 20:54:50 +02:00
Elias Naur ae77377f7b app: [Android] replace PlatformHandle with JavaVM, AppContext methods
Clearer and fewer types.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-20 20:21:39 +02:00
Elias Naur 10f932137c app: fix NewWindow comment
Window options are a list now, not a struct.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-20 20:08:01 +02:00
Elias Naur 30b46ded6b internal/window: [Android] remove unused C function
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-20 19:11:04 +02:00
Elias Naur 2b1935d657 cmd/gogio: include Android themes in .aar outputs
Not strictly necessary, but makes embedding a Gio Android Activity
easier; adding

	<activity android:name="org.gioui.GioActivity"
		android:theme="@style/Theme.GioApp"
		android:configChanges="orientation|keyboardHidden"
		android:windowSoftInputMode="adjustResize">
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />
			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>

should be enough.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-18 20:24:42 +02:00
Elias Naur 0cfc914d8b example/tabs: add example for tabbed content
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-17 10:50:50 +02:00
Elias Naur b1aed3eae0 Revert "widget/material: propagate ButtonLayout minimum constraints to content"
This reverts commit 52ccc183b5.

Reason for revert:

This doesn't seem like a good idea after all. The reason for the change was to
propagate the minimum constraints to the button content. But in the simplest case,
a label, stretching the button will make the label stretch as well, leaving the label
top-aligned.

We'll revisit this issue if a real use-case comes up.
2020-04-16 19:57:19 +02:00
Elias Naur b8cbc1e99d widget: improve Click description
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-16 19:15:10 +02:00
metaclips efce78d414 example/kitchen: add ProgressBar example
Updates the kitchen example codebase showing ProgressBar functionality.

Signed-off-by: metaclips <utimichael9@gmail.com>
2020-04-03 10:49:47 +02:00
metaclips da01fbdea7 widget/material: add ProgressBar
Add progress indicator support to material widget

Signed-off-by: metaclips <utimichael9@gmail.com>
2020-04-02 21:05:13 +02:00
Elias Naur 221ce02328 LICENSE: merge UNLICENSE and LICENSE-MIT
The pleasing of automatic license detectors continues.

No license change, merely a merging of LICENSE-MIT and UNLICENSE and the
license blurp from README.md.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-02 10:45:37 +02:00
Elias Naur 0542796463 .builds: add webassembly build test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:32:18 +02:00
Elias Naur 97538991d2 example/glfw: fix build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:21:55 +02:00
Elias Naur 1a3bbd5d92 example,cmd: update gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:21:55 +02:00
Elias Naur 1ad891ff67 app/internal: fix Android build
pkg-config doesn't exist for Android.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:04:40 +02:00
Elias Naur 27d81b8c7e widget/material: re-center Button label
A previous change propagated the minimum layout constraints to Button's
content, which made Button no longer center its label when stretched.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-27 16:40:13 +01:00
Elias Naur 52ccc183b5 widget/material: propagate ButtonLayout minimum constraints to content
The previous change fixed a regression where minimum constraints larger than 0
would not affect the button. This change moves the minimum constraints one
level lower so the content widget will see them as well. The wrapping
layout.Center ensures that any misbehaving widgets still end up centered.

Add a test to lock in the new behaviour and the previous fix.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-25 17:52:02 +01:00
metaclips f7a23ad46a widget/material: draw button to max width with ButtonLayout
This patch allows support to draw button to maximum width using ButtonLayout.
2020-03-25 17:41:01 +01:00
metaclips 43df9f2677 example/kitchen: add ButtonLayout example
Updates the kitchen example codebase showing ButtonLayout functionality.
2020-03-24 15:12:44 +01:00
Elias Naur 38ed6d1569 app/internal: use pkg-config for finding system headers and libraries
I've resisted relying on pkg-config in the hope that hard-coded include and
library paths would suffice. However, apart from having to work around some
distro-specific differences, building with hardcoded include paths fails when
building on a buildroot:

	x86_64-buildroot-linux-gnu-gcc: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/include/wayland'

(see #91)

Andri mentions a workaround (prefixing paths with "="), but that doesn't seem
to work on the BSDs.

Let's see how pkg-config fares. It's an extra dependency, but it promises to keep
us isolated from the varying paths on Linux distrobutions.

Updates #91

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-23 12:03:38 +01:00
metaclips 5d7fbd761f widget/material: add ButtonLayout
Add ButtonLayout for adding button behaviour and style to arbitrary content such
as a combined icon-and-text button.
Fixes #43

Signed-off-by: metaclips <utimichael9@gmail.com>
2020-03-22 13:20:32 +01:00
Elias Naur a3101c9454 app/internal/window,app/internal/egl: avoid X11 dependency in EGL
EGL is window system agnostic, but its egl.h header includex X11
headers by default. Use the MESA_EGL_NO_X11_HEADERS define to avoid
it, fixing the "nox11" build for systems without X11 headers installed.

Fixes #91

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-20 20:58:17 +01:00
Elias Naur 56c3edef82 gpu/gl: remove unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-19 20:28:09 +01:00
Egon Elbre acd32c31a2 app/internal/d3d11: enable VSync
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-03-15 20:58:30 +01:00
Elias Naur 7fba3bb8fe gpu/backend: remove clear color and depth state
Specifying the clear color and depth at the time of clearing is
less error prone and a better for modern GPU APIs. As a bonus, we
can get rid of the BufferAttachment type.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-15 12:25:56 +01:00
Chris Waldon daecdcaabf ci: add skeleton for sourcehut annotations
This commit adds the necessary task to the CI job to generate sourcehut
annotations as documented here:

https://man.sr.ht/git.sr.ht/annotations.md

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-03-15 09:30:37 +01:00
Elias Naur 5180bb0e1a gpu/gl: don't panic if no input layout is bound
Rendering will probably not be correct, but a panic is overreacting.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-13 17:33:06 +01:00
Elias Naur af68e17dd3 op/paint: set subimage Rect when converting image
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-12 18:42:20 +01:00
Egon Elbre 7c1a21ce56 add f32color.RGBA
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-03-12 13:21:34 +01:00
Elias Naur 7024a0e691 gpu: fix depth buffer on direct3d and headless opengl
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-11 17:45:16 +01:00
Elias Naur 61529c2cb6 gpu: fix clip intersection with the D3D backend
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-03-11 16:23:35 +01:00
Daniel Martí acfe91ec3e CI: add wine on Linux for the Windows e2e test
Installing it on Debian was enough, with the only wrinkle that
propagating -race won't work when we're cross-compiling, since
cross-compilation disables CGo by default.

For now, just skip the test in that edge case. If we want to use the
race detector on Windows in the future, we need to get a Windows CI
builder somehow.

Tested on my fork; see https://builds.sr.ht/~mvdan/job/164899.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-08 10:52:08 +01:00
Daniel Martí 49000ae4a3 cmd/gogio: add the first Windows e2e test via Wine
Since Wine is heavily tied to X11, we build its end-to-end test driver
on top of X11's. We use the same mechanism to start an X server, take
screenshots, and issue clicks.

Its only quirk is that it was difficult to get the screenshots to line
up with Gio's window. The comments cover what we ended up with. The
display dimensions are now part of driverBase, so that methods other
than Start can also use them - this is necessary for the wine driver to
crop screenshots.

We also use a sleep for now; a comment explains why, and a TODO is left
for future Dan to deal with. What we have now works, and I've spent
enough hours on this patch as it is.

Adding Wine to CI, and ensuring that the test passes there, is left for
a follow-up patch.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-05 09:49:02 +01:00
Daniel Martí 9bbeb92b61 cmd/gogio: reuse the test binary to call gogio in the e2e tests
We were using 'go run . <args>' before, which works fine, but does mean
re-linking a new binary and throwing it away at each invocation. Given
that the end-to-end tests don't do all that much work besides building
the tiny red.go app, this amount of extra work was noticeable.

We can obtain statistics for the JS sub-test, which used 'go run', via
the perflock and benchcmd tools:

	$ go test -c
	$ perflock -governorp% benchcmd EndToEnd/JS ./gogio.test -test.run=EndToEnd/JS

After capturing those numbers before and after the change, we can then
compare them with benchstat. The CPU cost of the subtest is halved:

	name         old time/op         new time/op         delta
	EndToEnd/JS          1.42s ± 2%          1.07s ± 3%  -25.04%  (p=0.008 n=5+5)

	name         old user-time/op    new user-time/op    delta
	EndToEnd/JS          1.46s ± 3%          0.75s ± 5%  -48.34%  (p=0.008 n=5+5)

	name         old sys-time/op     new sys-time/op     delta
	EndToEnd/JS          366ms ±13%          224ms ± 7%  -38.79%  (p=0.008 n=5+5)

An alternative here would have been to refactor main.go to allow being
called directly. However, that would have required a non-trivial
refactor, since flag parsing is done via globals. Given that the
TestMain method is asy and keeps the main function simple, we've
decided to avoid a refactor.

While at it, remove the sleep in the Android driver to wait for the app
to come up on screen. Since we retry screenshots now, we no longer need
a static sleep. On average, we still need one retry for the initial
screenshot, but that's just 100ms versus the old 500ms. The maximum wait
time is also 2s here, which should scale better for slower devices.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 17:34:59 +01:00
Daniel Martí b064899967 cmd/gogio: groundwork for Windows e2e tests on Wine
First, move from debian unstable to testing, since sway was promoted to
testing as of earlier this week.

Second, use the --sync option when using xdotool to move an X11 mouse.
This makes the command block until the mouse has finished moving to the
specified location, removing a potential race with the following
'xdotool click' command.

Third, deduplicate some logic into driverBase: tempDir to create a
temporary directory within a test, and needPrograms to skip a test if
the required programs aren't available.

Lastly, split the code that starts the X11 server into a method, so that
the future Wine e2e driver can reuse it. Since Wine is tightly coupled
with X11, we can reuse a good part of the code, including the X11 server
and the xdotool mechanisms.

We also add a TODO to perhaps improve the handling of the app's output
under each of the e2e test cases.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 10:29:17 +01:00
Elias Naur 48eb5c666c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:17:27 +01:00
Elias Naur bd7c7a108a app/internal/window: (Windows) don't send zero-sized draw requests
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:15:55 +01:00
Elias Naur 3738aa43a8 example,cmd: bump gio version 2020-02-29 15:57:27 +01:00
Elias Naur 62a2f3b8c8 README.md: link to Larry's GitHub mirror
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 15:42:01 +01:00
Elias Naur 22e15da67c app/internal/window: (Windows) return all errors from NewContext
Instead of just returning the first error (from Direct3D), return
the errors from all attempts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 15:39:04 +01:00
Elias Naur 8405bf0e47 gpu/shaders: be more robust against floating point inaccuracies
We're forced by compatibility to encode an integer state into a
floating point. Make the implicit conversion from floating point to
integer more robust against GPUs with low precision floats.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 14:27:50 +00:00
Elias Naur 148a2828e7 layout: don't force Expanded Stack children larger than their minimum
Instead, honor the constraints after laying out both Stacked and
Expanded children.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 14:06:25 +01:00
Elias Naur c1048a3a54 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:03:20 +01:00
Elias Naur 0ceccf3c93 app/internal/d3d11: try more floating point formats
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:01:48 +01:00
Elias Naur 0160bba020 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:53:20 +01:00
Elias Naur b3a3c34088 app/internal/d3d11: detect hardware floating point support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:52:04 +01:00
Elias Naur 050f43d60a io/router: add pointer drag-and-move test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:11:23 +01:00