Commit Graph

1006 Commits

Author SHA1 Message Date
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
Elias Naur 2486d46ab4 op: tighten documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 17:55:26 +01:00
Elias Naur 3701e2eb1d layout: move examples to example_test.go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 17:46:40 +01:00
Elias Naur b3c095fdcc example/kitchen: add newline after error message
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 14:35:23 +01:00
Elias Naur 16e6e2d3f7 example/kitchen: dump screenshots in 1.5 scale
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 14:33:27 +01:00
Elias Naur 9023b1b865 example/kitchen: add -screenshot flag
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 14:02:36 +01:00
Elias Naur 6fbdefa21f app/headless: compensate for OpenGL's lower left origin
The origin of image.Images is the upper left corner. Convert the
ReadPixels result by flipping the image the y-direction.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:59:34 +01:00
Elias Naur c0beeb5e77 layout: update documentation for NewContext
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:21:35 +01:00
Elias Naur 1762e0c07b cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:20:20 +01:00
Elias Naur 11506a974e layout: add NewContext, make zero value Contexts useful
While here, unexport the Queue and Config fields. The NewContext
cosntructor is shorter, and there is no reason to expose the fields
to accidental mutation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:13:15 +01:00
Elias Naur bbdedfa4a7 layout: move Context to its own file
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:43:42 +01:00
Elias Naur 75d4eaff0e layout: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:41:52 +01:00
Elias Naur 2aa6071e33 io/system: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 12:38:48 +01:00
Daniel Martí 5bddf66db7 cmd: update the chromedp version
It's a bugfix release, and we want some of the stability fixes in it.
Starting Chrome processes is more reliable now, for example.

See https://github.com/chromedp/chromedp/releases/tag/v0.5.2.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-12-02 11:01:17 +01:00
Elias Naur 41116b5cb8 app/headless: add package docs
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 00:05:30 +01:00
Elias Naur 0b84137f40 app/headless: implement headless windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:40:02 +01:00