Commit Graph

1021 Commits

Author SHA1 Message Date
Elias Naur 1cf8fee73f example/gophers: update Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-02 17:19:27 +01:00
Elias Naur fb7337f794 layout: replace Align with a Layout method on Direction
It's one less type (Align) and shorter:

Before:

	layout.Align(layout.Center).Layout(...)

After

	layout.Center.Layout(...)

It is also safer: since `layout.Align(...)` was a casting operation,
the Go compiler would not complain about an incompatible constant.

For example, the widget/material package contained a wrong cast:

	layout.Align(layout.Start)

which should have been

	layout.Align(layout.W)

After this change, attempting `layout.Start.Layout(...)` result
in a compile error.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-02 17:13:02 +01:00
Elias Naur 359839ad07 README.md: add OpenBSD to list of supported platforms
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-01 15:56:50 +01:00
Elias Naur f640b798ee example: update gio version to fix OpenBSD build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-29 18:16:18 +01:00
Greg Pomerantz 72cb36c5f9 app/internal/gpu: make the zero value of paint.ImageOp useful
Do not panic when drawing the zero value of paint.ImageOp.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2020-01-29 15:58:45 +01:00
Daniel Martí 8d1e53cfa9 cmd/gogio: add the first Android end-to-end test
It passes the whole e2e test flow on my real device, a OnePlus 5 running
LineageOS 16.0 (Android 9).

I was also successful at running it against an x86-64 Android 8.0
emulator, but I'm not including any of that just yet. A patch later this
week will include a piece of code to set up and start an emulator, which
CI can then use to run the test.

Also stop requiring the screen dimensions to be enforced when running in
non-headless mode. An Android emulator can run at an arbitrary
resolution, and even in headless mode, but a real Android device will
have its own predefined resolution. Forcing the test user to set the
-headless=false flag to not get annoying "unexpected dimensions" errors
would be annoying.

That check doesn't really mean much, as our test app doesn't care about
the screen resolution. And we were only doing the check sometimes. Drop
it entirely, making the resolution parameters merely a hint so that we
can keep the drivers a bit more consistent.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-29 14:50:42 +01:00
Aaron Bieber ff6c798a28 app: Extend CI to build on OpenBSD now that golang.org/x/sys is updated.
I was able to get the Pipe2 syscall added for OpenBSD:
https://go.googlesource.com/sys/+/9fbb57f87de9ccfe3a99d4e3270ce8a926ebba4f

This also updates the dependencies to include the latest sys and gio.

I submitted a patch to the builder environment to include the xshare sets on
OpenBSD. Once that is in it will mean the "install_deps" block can be removed.

  https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/9640

Here is a link to a successful build: https://builds.sr.ht/~qbit/job/143004

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-28 17:21:01 +01:00
Daniel Martí 6819dea21c cmd/gogio: attempt to fix timeout failures on CI
I've seen a couple of "timed out waiting for a frame to be ready" errors
on CI in the past week. I think two seconds is a bit low, if the machine
in question is not very powerful or under stress - which is common for
CI environments.

Raise the timeout to 5s.

While at it, add some log lines to each e2e test, and mark waitForFrame
as a helper func, so that its errors show up at the caller's location.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-28 15:27:50 +01:00
Elias Naur 761ab68868 cmd/gogio: support newer NDKs
Newer Windows NDKs add the "x86_64" platform suffix like other
OS'es. Remove the special case.

Newer NDKs are also installed in "ndk/x.y.z" versioned directories
instead of in "ndk-bundle". Support that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-27 17:34:43 +00:00
Daniel Martí 54ed198cb0 app: don't discard android touch events of unknown tool type
This is the kind of event one gets when using 'adb shell input tap x y',
which I am trying to use for the end-to-end tests.

Right now, we only have two pointer source types: mouse and touch.
On Android, emulated touch events tend to simulate the touchscreen, not
a mouse, so let's go with that as a fallback.

Perhaps in the future we will have another special pointer source for
this kind of event, such as "unknown" or "virtual".

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-27 11:17:47 +01:00
Elias Naur fb07ad6593 .builds: add missing dependency
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-24 15:00:46 +01:00
Aaron Bieber fdaf891732 app: Enable building on OpenBSD
Currently the golang.org/x/sys package is missing the Pipe2 call for OpenBSD.
The call exists on OpenBSD, it just isn't exposed.

This diff was tested buy adding the Pipe2 call and setting:

   go mod edit -replace=golang.org/x/sys=/pat/to/modified/sys

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-24 14:32:54 +01:00
Elias Naur 18cddc0300 layout: include Expanded sizes in Stack size calculation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-16 13:20:50 +01:00
mural a7dc7c01c0 app/internal/log: add logger for Windows DebugView
Signed-off-by: mural <mural@ctli.io>
2020-01-13 21:48:13 +01:00
Elias Naur b331407e81 text: add io.Reader Layout method to Shaper
use them for Editor, which is no longer required to construct a string
for laying out its content.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 21:38:54 +01:00
Elias Naur 16d2a3ac0a text: remove String, Layout and add Glyph
In preparation for using Shaper with an io.Reader, rework the API to not refer
to strings. In particular, introduce Glyph for holding the rune in addition to
the advance. For fast traversing of the underlying text, add Len to Line with
the UTF8 length.

Layout is a useless wrapper around []Line; remove it while we're
here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 19:54:11 +01:00
Elias Naur e25b1639b9 text: make Shaper an interface
And rename out the caching implementation to FontRegistry.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 14:48:31 +01:00
Elias Naur 3f6a1c34d3 text: correct Shaper comment about the default face
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 13:52:33 +01:00
Daniel Martí 170e86142c cmd/gogio: don't hang on some e2e test errors
For example, if the test app fails to start on wayland, we'd block
~forever (ten minutes) waiting for it to render its first frame.

We don't have a good solution right now. But at least we can use a
relatively short timeout, to help out the human who rightfully expects
a result within ten seconds.

While at it, remove a sway "get_seats" command, which was a leftover
from my debugging of what input devices are available when running
headless.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-13 13:36:51 +01:00
Elias Naur 08b840f114 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-11 23:23:11 +01:00
Elias Naur f176cbfe88 app/internal/egl: try EGL_DEFAULT_DISPLAY is eglGetDisplay fails
Fixes #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-11 23:21:27 +01:00
Elias Naur bc30683588 Revert "app/internal/egl: accept zero EGLDisplay values as valid"
This reverts commit 66138e7890.

Reason: According to #77, it didn't work and the proposed fix
(retry when EGL_NO_DISPLAY is returned) is correct.
2020-01-11 23:15:23 +01:00
axel paulander 2e66c90aee op/paint: correct image loading
Corrected the use of draw.Draw in paint.NewImageOp as the old use only works for images starting at the origin

Signed-off-by: Axel Paulander <axel.paulander@gmail.com>
2020-01-10 17:52:33 +01:00
Elias Naur 631c3b0e02 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-08 13:31:16 +01:00
Elias Naur 66138e7890 app/internal/egl: accept zero EGLDisplay values as valid
Issue #77 seems to be caused by eglGetDisplay returning a zero
EGLDisplay, yet eglGetError returns EGL_SUCCESS. Since EGLDisplay
is not necessary a pointer type, the zero value may be valid.

Updates #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-08 13:28:12 +01:00
Elias Naur ccbcbdbfbd example/go.*: update Gio version
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:31:12 +01:00
Elias Naur 95903aafda app/internal/window: add errno to wl_display_connect errors
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:28:53 +01:00
Greg Pomerantz 3dd7c8121c font/opentype: add Collection type and methods
The Collection type wraps sfnt.Collection and allows lazy-loading
of fonts from SFNT collections.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-12-18 19:07:54 +01:00
Elias Naur 19acf05820 COPYING: extract licensing information into COPYING
This is hopefully clear enough for license detectors and lawyers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-18 09:58:21 +01:00
Elias Naur c9f1f59c40 font/opentype: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-16 20:06:33 +01:00
Larry Clapp 2b4e9ad426 widget: add some rudimentary exported editing methods
Editor.Delete
Editor.Move
Editor.Insert

Move the Editor.command method up above all the functions it calls.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-12-16 19:06:09 +01:00
Greg Pomerantz 8a4d0007f3 app: clarify documentation of app.Main()
Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-12-16 19:06:05 +01:00
Werner Laurensse e76726d4f7 text/shaper: Add Metrics method to Shaper struct.
Signed-off-by: Werner Laurensse <werner@alman.ax>
2019-12-15 20:23:13 +01:00
Elias Naur 0bfcac9734 cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:48:31 +01:00
Elias Naur 7814da47a0 layout: simplify Stack API
Similar to what a previous commit did for Flex, this change simplifies
Stack to just one Layout call:

	layout.Stack{}.Layout(gtx,
		layout.Stacked(func() {...}),
		layout.Expanded(func() {...}),
	)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur f60a5c7ac3 layout: simplify Flex API to a single Layout call
With the simplification of MacroOp, it is now possible to simplify
the Flex API to just a single Layout method, similar to List:

	layout.Flex{}.Layout(gtx,
		layout.Rigid(func() { ... }),
		layout.Flexed(0.5, func() { ... }),
	)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur edc81ea0bb op: remove operation list argument from MacroOp.Add
The ability to invoke other operation lists belongs in the new CallOp.

While we're here, make MacroOp.Add use a pointer receiver to match the
other methods.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 0768fbe590 text: convert clip.Ops to op.CallOp
MacroOp is about to lose the ability to run a different operation list
than the one it was recorded on. Text shape caches rely on that property,
and must use the new CallOp operation added for purpose.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 06217c5320 op: introduce CallOp
We'd like to improve the API of Flex, Stack and similar layouts
that use MacroOps internall. Unfortunately, the

  func (m MacroOp) Add(o *Ops)

method causes the MacroOp to be allocated on the heap, ruining the
nice garbage-free property of layouts.

Fortunately, layouts don't need the feature that caused the heap
allocation: invoking operation lists different than the current.

CallOp separates the invoke-different-list semantic from MacroOp,
in preparation for removing the feature from MacroOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 9114dbe759 app/internal/gl: gofmt -w -s
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 4a628d1c2c app/internal/gpu: re-add check for GL_EXT_color_buffer_half_float
As noted in #49, GL_EXT_color_buffer_half_float is required for
GL_OES_texture_half_float to be useful for FBOs.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 15:12:57 +01:00
Elias Naur 8a44ac11d8 app/internal/gpu: use single channel floating point FBO if possible
Remove dependency on EXT_color_buffer_half_float, it's not clear it's
necessary. In any case the following FBO sanity check will catch invalid
FBO format combinations.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 13:54:24 +01:00
Elias Naur 7164c557f9 Revert "LICENSE: merge UNLICENSE and LICENSE-MIT to please license identifiers"
This reverts commit b74f2d2d1c.

Reason: the merging was done to please the license detection library
underlying pkg.go.dev. Since pkg.go.dev treats dual licensed projects
as the intersection ("AND") of the licenses, and because the UNLICENSE
is not supported per

	https://pkg.go.dev/license-policy

revert to the usual once-license-per-file.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-05 10:40:25 +01:00
Elias Naur 31ebd9e811 cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:32:36 +01:00
Elias Naur 86d69859b9 app/internal/gpu: query GL_EXTENSIONS correctly on macOS
macOS supports the OpenGL core profiles where glGetString(GL_EXTENSIONS)
is not supported. Use glGetStringi(GL_EXTENSIONS, <index>) instead.

The wrong query didn't make any practical difference because Gio doesn't
need any extensions on OpenGL 3 and better.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur d9212263aa app/headless: prepare OpenGL context on macOS
The macOS backend uses a desktop OpenGL context, not a OpenGL ES
context. The main difference is that sRGB have to be enabled and
a vertex buffer must be bound.

Do that and fix Window.Screenshot for scenes more complex than a
glClear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur fddb0af6f6 app/internal/gpu: default to color material
Before this change the default material were a texture, which leads
to a crash when no texture is current.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-03 16:48:48 +01:00
Elias Naur 96a4e510f9 .gitattributes: disable Windows line ending conversion
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-03 13:36:31 +01:00
Elias Naur 65dc6797eb layout: don't allow overlapping Flex and Stack layouts
Overlapping layouts such as

	outer := layout.Flex{}
	inner := layout.Stack{}
	child := inner.Rigid(gtx, ...)
	outerChild := outer.Rigid(gtx, func() {
		inner.Layout(gtx, child)
	})
	outer.Layout(gtx, outerChild)

runs but result in a wrong layout.

This change use empty StackOps to ensure that the Stack and Flex
child layout methods are called in the same scope as their Layout
methods:

	outer := layout.Flex{}
	inner := layout.Stack{}
	outerChild := outer.Rigid(gtx, func() {
		child := inner.Rigid(gtx, ...)
		inner.Layout(gtx, child)
	})
	outer.Layout(gtx, outerChild)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 18:54:35 +01:00
Elias Naur 8102f63114 op: tighten stack checks
Assign (per-frame) unique ids to each MacroOp and StackOp operations
and ensure that the pairwise Push/Pop and Record/End match.

In a follow-up change the Flex and Stack layouts will rely on those
checks to avoid being overlapped.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 18:52:29 +01:00