~eliasnaur/giouiorg

38905d0843ccd4a11dbcbd0a4ac145db1975627f — Egon Elbre 5 months ago b87e915
content,site,template: add Newsletters

This is initial template for newsletters and the four
most recent newsletters by Chris Waldon.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
M content/index.md => content/index.md +1 -0
@@ 3,6 3,7 @@ title: Gio UI
subtitle: Cross-Platform GUI for Go
childrennolink: true
children:
    - news
    - doc/install
    - doc/learn
    - doc/showcase

A content/news/2022-02.md => content/news/2022-02.md +241 -0
@@ 0,0 1,241 @@
---
title: Newsletter, February 2022
shorttitle: February 2022
subtitle: pointer.CursorNameOp renamed to pointer.Cursor
---

## core gio

Elias implemented focus traversal for Gio interfaces this month. This
enables users to navigate between focusable widgets (buttons, editors,
etc) with actions like pressing tab. This single feature has a huge
impact on the ease of using Gio for entering data into form fields and
general keyboard navigation.

There were 47 commits to core since the last newsletter.

Breaking API changes by author:

Egon Elbre:

- app,io/pointer: [API] remove CursorNameOp and rename CursorName ->
Cursor.  (cdb288d1)
- io/pointer: [API] make cursor name into a byte. Add most of the
common cursors defined by different systems. (4172566a)

Non-breaking changes by author:

Elias Naur:

- cmd/gogio: bump Android target SDK to 31.  (9b2bdf6c)
- io/router: replace cursor stack with area field.  (3e18a310)
- io/router: always choose the topmost cursor among candidates. See
#373  (99bb5429)
- io/router: ensure root pointer area in deferred calls. See #372  (68544111)
- .builds: upgrade Android builds tools and SDK.  (2b0898fc)
- app: replace C-to-Go handle maps with cgo.Handle.  (c0c25b77)
- app/internal/windows,app: [Windows] generalize
windows.GetPointerLong.  (95365d58)
- app: [iOS] disable fallback decorations. Before this change, the iOS
backend would not report decoration support at window creation.
(b9e8a177)
- all: replace unsafe slice operations with unsafe.Slice.  (fea2f888)
- go.*: upgrade to Go 1.17.  (af8ca964)
- .builds: upgrade to Go 1.17.7.  (09309d33)
- app: [Android] avoid a null pointer exception at initialization.
GioView.onCreateView may call methods on the imm field of GioView.
Make sure it is initialized before use. (b0838bf6)
- app: [macOS] redraw when window moves to a different monitor. The
monitor may have a different backing store scale, yet the system
doesn't redraw automatically when that happens (1fa9dd0f)
- Revert "app: [macOS] pace display link". This reverts commit
11f39582b84703c33d3aae4c1b703698a1bb4ea6 that introduced pacing of
display link callbacks. Blocking the display link callback introduced
deadlocks with code that updates the display link display. (34f10d9c)
- widget: reset focused states when disabled.  (79bfd3ad)
- widget/material: add focus and hover indicators to Clickable.  (50e35c9c)
- app: ensure Window.Invalidate redraws after delivering events.
Events such as system.CommandEvent may result in Invalidate being
called. Ensure animation state is properly updated. (f711e7ea)
- widget: treat enter and space as clicks on release, not press.  (aaf457d6)
- app,io/router: map Androids' DPAD_CENTER to a click. Mapping it to
key.NameReturn confuses widgets such as Editor that treats clicks
separate from return key presses. (21431975)
- internal/f32color: add support for light widgets to Hovered.  (2bea9a37)
- internal/f32color: extract color mixing into separate function.  (b74c9f96)
- io/router,app: add support for directional focus moves. Implement
support for up/down/right/left directional focus moves and map Android
directional pad keys to focus moves. (73eabb35)
- io/router: move focus on tab and shift+tab. See #195  (2e9df04a)
- widget,widget/material: make Clickable widgets focusable. This
change adds focus and keyboard control to Clickable widgets. They now
consider a press of the enter or return key equivalent to a click. To
keep the change simple, the focus indication is the same as the hover
indication. (cd2ade05)
- app: [Android] map numpad enter to key.NameReturn.  (eb48b459)
- widget: only ask for software keyboard once per click.  (8ff10a20)
- app: [macOS] pass key events to system before handling them. This
change solves an issue where an editor key press such as backspace
would apply before the IME had a chance to process it. (7f90f04c)
- app: [Wayland] always refresh frame pacing notification. Apparently,
a Wayland server such as Sway and River may not issue a frame pacing
callback created before a top level configure event. This change
ensures the frame pacing callback is always refreshed when animating,
regardless of the reason for the frame. (2e91edaf)
- op/clip: don't panic when stroking empty path. See #367  (773a7e48)
- widget: remove pointer area padding from Editor. Pointer padding was
introduced in bfece0bebacb5cec4fdf5682b886333e03b6549b. I don't
remember why, and its commit message doesn't say. Regardless, adding
padding outside a widget's reported dimensions doesn't seem like a
good idea (see #365), and this change removes it. (bed59024)
- widget: replace segmentIterator with simpler functions.  (41489fb7)
- widget: extract seeking logic from Editor.closestPosition. We'd like
to re-use the Editor.closestPosition seeking for segmentIterator.Next;
this change extracts the state-less logic into functions. (b7341672)
- widget: fix moveLines residual x offset calculation.  (2df3db36)
- io/key: update stale comment.  (845d35dd)

Egon Elbre:

- app: [macos] add missing cursors.  (e9e00994)
- app: [windows] add missing cursors.  (b7a42da3)

Lucas Rodrigues:

- app: [windows] fix maximized window size. Previously, the window
size was equal to the screen size. That doesn't consider the size of
the taskbar, causing the height to be bigger than the real height.
Now, the maximized state has the same behavior as windowed, since both
of them must include decorations and taskbar. (b82427d4)
- io/pointer: rename cursors to match the JavaScript DOM.  (730e0463)
- internal/gl: [js] replace Call to Bind/Invoke. Before that patch,
the Call function was used to call each JS function related to WebGL.
The Call function contains strings, which is slow on most browsers.
Now, it uses Bind on the initialization and re-use the same function,
avoiding the usage of strings. (182e7010)

Chris Waldon:

- widget: test caret coordinates. This commit adds a check that caret
coordinates never exceed the max constraints of the editor. (9b692339)
- widget: fix Editor.CaretCoords when scrolled. This commit fixes the
position returned by Editor.CaretCoords to account for the scroll
position of the editor. Without this change, the returned coordinates
can easily overflow the boundaries of the editor widget when it has
been scrolled on either axis. (a401d7aa)
- widget: fix editor's io.Seeker implementation. For some reason,
widget.Editor had a Seek method that ignored the supplied offset and
always seeked to offset zero. This made it impossible to use it like
any other io.Seeker. This commit simply honors the requested offset.
(a7afa4d6)

Pierre Curto:

- app: remove defer op in window decorate. See #361  (20d4bc21)
- widget: adjust Draggable.Pos to be relative. When dragging objects
around an area, it is easier to reason with the relative movement of
the dragged item. (42ea56ac)

Aman Karmani:
- app: [Android] handle DPAD_CENTER keycode.  (27762fdd)

## gio-x

There have been 4 commits to gio-x since the last newsletter.

Non-breaking changes:

Chris Waldon:

- component: defer modal layout. This commit alters the ModalStyle to
defer laying out the scrim and modal widget. This was always the
intended behavior, and I'm frankly unsure why I didn't do it before. I
guess I always laid out the modal layer last, and therefore didn't
notice. (729e3a0)
- explorer: allow no extensions on linux. This commit fixes a bug in
the linux backend that would fail to present a file selector if no
extensions were provided as a parameter. (d5cf750)
- component: expand ContextArea's positioning options. This commit
allows users to position a ContextArea's contextual widget at a fixed
location instead of at the location of the triggering pointer
interaction. It also allows users to provide a hint to the ContextArea
about where it is positioned within a larger layout, enabling the
ContextArea to avoid positioning its contextual widget off-screen.
(22cb65b)

Egon Elbre:

- component,richtext: update pointer.Cursor usages.  (8b9099e)

## gio-example

A couple of small changes went into the examples repository this month:

Elias Naur:

- opengl: render on app thread, not window event loop thread. Binding
a GPU context to a window surface must happen on the event thread, but
rendering doesn't. (e49702a)

Egon Elbre:

- mod: bump gioui.org and gioui.org/x.  (e051ef6)

## gioui.org

Last month, I accidentally failed to include updates to our website in
the newsletter, so here I'll detail changes to the site since the
start of the year.
At a high level, Egon has been hard at work modernizing the website
layout, and I've been updating inaccurate documentation as I find it.

Egon Elbre:

- content/doc/architecture: use ops.Reset instead of recreating.  (57881f1)
- go.mod: bump gioui dependencies.  (6556fa2)
- content/architecture/drawing: add info about clip.Stroke.  (7e2a7b1)
- content: fix toc on home.  (1a0d2c6)
- content/showcase: add example applications. This adds a showcase
section for the site. There are other modifications to support this.
(a4bf3c3)
- style: dark-mode.  (5da0fe5)
- style: add repeating bg to examples.  (2bb2345)
- content/home: simplify the content.  (ea6d728)
- files/sponsors: remove 2x size.  (1ece1b5)
- content/doc/faq: add closure information.  (3c4839b)
- content/doc/contribute: organize information.  (4d9cbcc)
- content/doc/community: page for finding help.  (f3ae1d6)
- content: use triple-quote for code. Triple-quote makes it more
consistent and easier to manage. Additionally add annotations for the
languages. (838ca06)
- template: use more common triangle.  (3ded86f)

Chris Waldon:

- content/doc/architecture: remove obsolete text about Add. The
content referred to clip.Op.Add, which is removed in favor of
Push/Pop. (308259a)
- include/files/architecture: balance ops in helpers. This commit
balances the push/pop of clip and offset operations in the helper
functions for the drawing examples. This prevents a panic when the
unbalanced operations are used in a macro. (8b0179a)
- content: add note about Java 1.8 to Android docs. Added a note to
the Android docs about having OpenJDK 1.8 installed, as gogio cannot
build APKs with more recent versions of Java. (1262ca4)
- content: fix Android SDK variable name. This commit updates the
Android install documentation to refer to ANDROID_SDK_ROOT instead of
the obsolete ANDROID_HOME. Thanks to \~u542620 for pointing this out!
(c16d2f8)

Elias Naur:

- content/doc: fix issue linking format examples.  (191f2e7)

## go-text

I'm still hard at work revising the patches that I posted last month.
Elias has considerably simplified the editor in response to seeing the
sprawling mess I wrote to integrate with it, and I think the result is
a considerably cleaner codebase all around. I'm sorry that these
changes are taking so long, but very happy with the clarity and
quality of the new code.
\ No newline at end of file

A content/news/2022-03.md => content/news/2022-03.md +263 -0
@@ 0,0 1,263 @@
---
title: Newsletter, March 2022
shorttitle: March 2022
subtitle: Complex script support
---

## core gio

Elias spent the last month reviewing my text work, improving widget
focus traversal, and improving many small details about core. In
particular, there is now a nix-based development environment for gio
available in core's flake.nix file. For details on nix, see:

https://nixos.org/

I revised my text patches, and they were accepted! Gio can now render
complex scripts, and can properly handle right-to-left text.

For the time being, applications seeking to leverage the new text
shaping should do the following:

- use fonts supporting the languages they want to display.
- populate layout.Context.Locale with the information for the language in use.

I hope to automate font selection and populating the locale in future
work, but those steps are manual for the time being.

There were 49 commits to core since the last newsletter.

Breaking API changes by author:

Elias Naur:

- io/router: [API] don't emit Enter and Leave events for touch input.
Enter/Leave events make sense for mouse pointers, to track hover
status. It doesn't make sense to track hover for touch input, so this
change stops pointer.Enter and pointer.Leave from being emitted for
pointer.Touch sources. (cd0c9dab)

Chris Waldon:

- deps,text,widget,font/opentype: [API] add harfbuzz-powered text
shaper. This commit introduces a new text shaping infrastructure
powered by Benoit Kugler's Go source-port of harfbuzz. This shaper can
properly display complex scripts and RTL text. This commit changes the
signature of the text.Shaper function, which is a breaking API change.
(1e5a3696)
- widget{,/material}: [API] update editor to support complex scripts.
This commit updates material.Editor and material.Label to support the
new text shaper. This requires breaking their assumption that glyphs
of font data map 1:1 to runes of text data. (42c99a5c)
- font/opentype: [API] replace old font type with harfbuzz. This
commit replaces the previous opentype.Font with an implementation that
uses the new text shaper. In order to keep the implementation simple,
support for opentype font collections was dropped. It should be
possible to re-add this support after some changes to the text
shaper's line wrapping algorithm. (01276238)
- text: [API] remove Text and Advances from Layout. These fields are
no longer needed with the new text shaper. Advances is redundant to
the glyph information, and Text should never be used during layout, as
you should traverse the cluster list instead. This commit also removed
the now-unused string field from the path LRU cache key. (9576b659)
- font/gofont: [API] use new opentype impl for Collection(). This
commit switches gofont.Collection from returning a collection of fonts
using the old text shaper to using the new harfbuzz-based shaper. The
underlying type of gofont.Collection() has changed, which may break
users who dug into the font data. (e14bbee2)
- widget: [API] make text.Alignment direction-sensitive. This commit
ensures that text.Alignment is intuitive for the direction of the text
being aligned. RTL text with Alignment Start will be aligned to the
right edge of the area, whereas LTR text with Alignment Start will
continue to be aligned to the left edge. Vice versa for the End
alignment. (7daab97f)

Non-breaking changes by author:

Elias Naur:

- app: [macOS] ensure only one redraw request is in flight at any
time. After 34f10d9cbb3a45da2ecb8a9fab60b0a5995c1a31, the display link
callback will never block. However, if the main thread is blocked for
another reason, say a bug in the user program, callback requests will
pile up as blocked goroutines. (083d407b)
- .builds: disable Vulkan on FreeBSD.  (317635b1)
- gpu,app: don't call time.Now when not profiling. runtime.nanotime1
shows up in profiles on Android, so avoid calling time.Now when we
can. (f19b16fe)
- app: [Android] re-introduce Choreographer for frame pacing.
According to #375, change b86928ceecf6800069cfd5a92e5b6f2216367fe5
increased frame pacing jitter. This change effectively reverts it by
re-introducing Choreographer for pacing. (b48b1270)
- gpu/internal/vulkan: resize descriptor set pool correctly. Before
this change, the resized descriptor set pool would never increase,
defeating the purpose of re-using pools. (c244b7c3)
- gpu/internal/vulkan: [Vulkan] replace Device/QueueWaitIdle with
fences. vkDeviceWaitIdle and vkQueueWaitIdle are expensive; a vkFence
is cheaper and the usual way to ensure a previous frame has completed
before starting another. (e8aa881d)
- gpu/internal/vulkan,internal/vk: allocate descriptor sets in
batches. We know exactly the configuration and number of sets in each
pool, so we may as well allocate them all up front. (7785310e)
- gpu: minimize FBO resizes in current renderer. References: #375  (eeb2febf)
- cmd/gogio: [Android] export GioActivity to please Android 32 and
later. Fixes: #378  (99f6224e)
- .builds: use Android SDK for 32-bit build test. With GOARCH=386, we
can't readily build packages that use Cgo. However, we already have
the Android SDK available, so use that to test for 32-bit issues such
as #384. (4a061a7d)
- flake.*: add Nix development environment. This change adds a Nix
flake capable of setting up an environment for building Gio programs
for Linux and Android, on top of the platforms that only needs Go
(Windows, WASM). (a3f14754)
- cmd: update Gio version.  (75d487fa)
- flake.nix: remove emulator from environment. The emulator needs
android system images to run, each of which takes up a lot of space.
Remove emulator from the Nix flake environment and let something else
provide emulator support, maybe even a custom Nix devShell. (b6ee0264)
- flake.nix: enable Vulkan support.  (01757791)
- io/router,app: move Tab-to-focus conversion to app.Window. This is a
refactor to make it easier to add higher level logic to focus moves. A
follow-up will add automatic scrolling to bring focused widgets into
view. (920e6dd0)
- f32,gpu,op/clip: add f32.Rectangle method for converting to
image.Rectangle. Creating an image.Rectangle from a f32.Rectangle is
used by two packages in Gio and about to be used for a third. Add a
Round method to f32.Rectangle to avoid duplicating the implementation.
(1f11a5a1)
- io/router: use integer coordinates for bounds. There is no need for
floating point coordinates, except for transforming bounds and hit
testing. (e72c46f1)
- widget: include the Editor key handler in the editor clip area. A
meaningful clip area for a key handler will matter when we start
auto-scrolling to move focused handlers into view. (b2d10c2f)
- io/router: add ScrollGesture.  (6389b1a3)
- gesture: don't rely on Enter events to determine validity of click.
We're about to not emit Enter and Leave events for touch input, and
this change changes the Click gesture to no longer rely on those
events to determine whether a Release is inside its bounds. (2069d5cb)
- app,io/router: scroll focused widgets into view. A focused widget
may be partially or completely off-screen in which case the user will
have difficulty interacting with it. This change attempts to scroll
the focused widget into view by issuing synthetic scroll events.
(4326fee7)
- io/router: use areas to determine targets for synthetic clicks.
Before this change, semantic clicks would be delivered according to
the center of the targeted widget, which could result in a different
widget receiving the click. Or in worst case, no widget in case the
center is not visible because of clipping. (e8603ba5)
- io/router: merge pointerQueue.deliverScrollEvents and deliverEvent.
(d34544cc)
- layout: default List scroll bounds to infinity. Before, List would
only report the remaining scrollable area of the visible children when
positioned close to either end. Now, List always report infinite
scroll bounds *unless* it is positioned at an extremum. (a699fb89)
- layout: layout one invisible child at each end of a List. A recent
change added automatic scrolling to move focused widgets into view.
This change modifies List to layout an extra child at each of its
ends, to enable focus to move to them and trigger automatic scrolling
of the list. (508330e8)
- layout: compute Position.Offset correctly for ScrollToEnd Lists.  (afd39a6b)
- io/router,app: scroll a bit when reaching the end in a focus
direction. List was recently changed to include an extra child at each
end, to automatically scroll when reaching the end of a focus
direction. However, if List includes unfocusable children that
strategy may fail. This change adds another fallback where app.Window
will scroll a constant amount in the focus direction, to reveal more
children. (a1b5ff05)
- layout: don't clip List children. Clipping all children once to the
entire List area is enough. The change was motivated by #389 where
individual child clips would make it harder for focus scroll
heuristics to work. (36919ef7)
- io/router: account for parent clip areas when scrolling focus into
view. Fixes: #389  (bd7f5043)
- app: clip client area. On Wayland, app.Window provides fallback
window decorations but clients are not prohibited from drawing over
the decorations or capturing events. This change adds a clip operation
to ensure no unwanted interaction between client content and
decorations. (f0753733)
- io/router: don't panic on focus moves when there is nothing to
focus.  (69f982e2)

Chris Waldon:

- widget/material: make clickable respect constraints. This change
makes material.Clickable propagate the constraints it is invoked with
to the widget being made clickable. Without this, the internal use of
layout.Stack resets the minimum constraints to zero. This has the
confusing effect of breaking a working layout when you decide to wrap
one element in a Clickable, which I think is sufficiently surprising
that we should eliminate the footgun. (cf787a1a)
- widget: optimize painting editor selection. This commit introduces
logic to skip painting the selection rectangle on lines prior to the
line containing the beginning of the selection. (1ad78565)
- widget: remove unneeded editor flicker logic. We cannot find a way
to trigger this flickering condition anymore, and so we're removing
the logic guarding against it. (b0ab5ae0)
- system: define new Locale type. This commit adds a Locale struct
that captures language and layout flow direction for the system. This
information can be leveraged by text shaping and layout code to make
better choices. (512900c9)
- layout: add Locale to Context. This commit adds a system.Locale to
the layout.Context, providing an easy means to plumb language
information throughout an application. (db82d123)
- font/gofont: add font collection using the new shaper. This commit
adds a font collection that uses the new text shaper so that
constructing material.Themes atop it is equally simple to using the
old shaper. (938179d2)
- widget: drop debug prints from tests. This commit removes some
lingering editor debug prints from the test code. (8833a673)
- ci: test non-cgo packages in 32-bit mode. This commit runs Gio's
test harness in 32-bit mode as well as 64-bit. This helps catch bugs
in Gio and its dependencies where integer overflow causes build or
runtime problems. (3fb522ca)
- deps,font/opentype: update dependencies to fix 32-bit build. This
commit updates to a newer version of textlayout and switches to a fork
of the UAX library that builds properly on 32-bit machines. This
should fix 32-bit Gio compilation for the time being. I hope to switch
back to npillmayer's UAX as soon as he has time to review the pending
pull requests. (3406a6da)

Inkeliz:

- gpu: prevent texture to be larger than MaxTextureSize. Change
eeb2febfea01cda47bd46e76f08b3f80347fce46 added extra space to FBO
sizes to avoid re-creating them often. However, the size could end up
higher than the GPU supports. This change caps the size. (eec78223)

Egon Elbre:

- internal/stroke: optimize arc drawing. Arc with a small angle
doesn't need many segments. (3fd23136)

## gio-x

There have been 1 commits to gio-x since the last newsletter.

Non-breaking changes:

Chris Waldon:

- deps,richtext: update gio and adapt richtext to new shaper. This
commit tweaks the richtext package to match the new text shaper API in
Gio core. (bc7801f)

## gio-example

A couple of small changes went into the examples repository this month:

Elias Naur:

- go.\*: bump Gio version. (bc47932)

Chris Waldon:

- deps: update gio and gio-x. These updates pick up support for RTL
languages and complex scripts. (b6b2f1a)

## gioui.org

Elias Naur:

- cmd/giouiorg: return 404 for unknown vainity import paths.  (437538b)
- content/doc/install: add Nix setup instructions.  (65d74fc)
\ No newline at end of file

A content/news/2022-04.md => content/news/2022-04.md +217 -0
@@ 0,0 1,217 @@
---
title: Newsletter, April 2022
shorttitle: April 2022
subtitle: io/key changes
---

## GUI survey

As many of you know, Fyne and Gio together ran a "Go GUI Developer
Survey" recently, and Andy from Fyne has published the results here:

https://fynelabs.com/2022/05/03/go-gui-developer-survey-results/

Gio and Fyne both have growing communities that are supplanting more
entrenched options like binding to GTK or Qt. It's really encouraging
to see so much interest and adoption.

## core gio

This month, Elias focused on keyboard input and frame lifecycle.
Applications can now register multiple layers of global keyboard
shortcut handlers, the window no longer emits all key and pointer
events as window events, and the system.FrameEvent.Frame was changed
to give applications as much time as possible to execute other tasks
on their primary event loop between frames. Additionally,
gioui.org/cmd was moved to a new repository.

Elias has also posted an RFC to convert Gio's handling of units (Dp,
Sp, and Px) to a new API. Please try out the `units` branch of core in
your applications and respond to this email thread with your thoughts:

https://lists.sr.ht/~eliasnaur/gio/%3CCAMAFT9XLLdmRBfSz%3D7v9Hnr0NBcNFygABVfd3V7kt57wp%3D9pJA%40mail.gmail.com%3E

There were 33 commits to core since the last newsletter.

Breaking API changes by author:

Elias Naur:

- io/key: [API] rename tab and modifier keys, introduce NameCommand.
We already have precedence for word-named keys ("Space") and the new
names are less obscure and matches Modifiers.String. (ed8d3e85)
- io/key: [API] implement key event propagation. Before this change,
every Event would be passed to the focused InputOp tag, making it
impossible to implement, say, program-wide shortcuts. This change
implements key.Event routing similar to how pointer.Events are routed:
every InputOp describes the set of keys it can handle, and the router
use that information to deliver an Event to the matching handler.
(380f96b3)
- app,io/key,io/system: [API] replace system.CommandEvent with
key.Event. It's much simpler to map the Android back button to a
key.Event and let the usual key filtering determine whether to block
its default behaviour. (6c76fa6d)

Jack Mordaunt:

- app: [API] don't relay raw input events from app.Window. Avoid
sending raw input events over the window channel. (4e488f4c)

Non-breaking changes by author:

Elias Naur:

- app: [macOS] fix caret position calculation after IME text insert.
Fixes: #385  (49bd5787)
- app: don't delay FrameEvent.Frame by v-sync latency. We should
return as soon as possible from FrameEvent.Frame to allow the main
goroutine to continue processing other tasks. Whereas GPU.Frame may
touch the frame ops, GPU.Present will not, so this change moves
Present to after returning from FrameEvent.Frame. (38ff78df)
- gpu/headless: return error if NewTexture fails.  (6e662038)
- Revert "app: don't delay FrameEvent.Frame by v-sync latency". This
reverts commit 38ff78df5dbeb8fcb13fa743a891237afd9ff573, because it
broke OpenGL by moving eglSwapBuffers outside the MakeCurrent context
scope. (405215f8)
- app: don't delay FrameEvent.Frame by v-sync latency. We should
return as soon as possible from FrameEvent.Frame to allow the main
goroutine to continue processing other tasks.  Whereas GPU.Frame may
touch the frame ops, GPU.Present will not, so this change moves
Present to after returning from FrameEvent.Frame. (43865dda)
- gpu/internal/opengl: add fallback for sparse OpenGL ES 2.0
ReadPixels. OpenGL ES 2.0 doesn't support GL_PACK_ROW_LENGTH, so this
change implements a fallback using a temporary buffer. (6a142696)
- app: don't panic when the client doesn't call FrameEvent.Frame.
Fixes: #396  (dc25afda)
- io/key: change Modifiers.String separator to "-". We're about to
express sets of key combinations as <modifiers>-<keys> where modifiers
are separated by dashes as well. To make Modifers.String useful for
expressing key sets, change its separator to "-". (9c59612e)
- io/router: deliver synthetic events to sibling pointer handlers.
Before this change, synthetic events such as scrolling caused by focus
movement would use semantic information to determine potential
receivers. However, there can only be one handler per area so sibling
handlers would not be considered. This change makes the event delivery
traverse the entire tree of handlers, including siblings. (bec0283e)
- app: give key handlers a chance to process Tab and Shift-Tab. Before
this change, Tab and Shift-Tab would always result in focus movement.
With this change, a key.InputOp with a matching Keys set will block
focus movement and deliver the events to it. (d37197f4)
- app,io/key: introduce keys for directional navigation. This change
adds key.NameUp/Down/Left/Right and maps the Android TV remote
directional keys to them. As a side-effect a key.InputOp can now
receive directional keys (and block their focus movement). (ad7c1eb7)
- io/system: describe FrameEvent.Insets more precisely.  (3a4b8b81)
- widget/material: remove redundant offset op.  (76298742)
- widget: fix Editor key set. Arrow and delete/backspace shortcuts use
ShortcutAlt, not Shortcut. (6ddc13ce)
- io/router: send key events to root handlers if nothing else wants
them. Fixes: #403  (30fa85f5)
- app: [Android] take snippet offset into account for
getCursorCapsMode. References: #404  (f3265e56)
- app,io/router: expand IME snippets if a new range overlaps the old.
Instead of completely replacing the IME snippet for every update,
expand the old range if there is overlap. This change avoids
never-ending restarts of the IME on Android where snippets are
expanded in two calls, one for expanding before the selection and one
for expanding after the selection. (02732037)
- io/router,widget: give every key.InputOp a chance to process events.
If the currently focused handler doesn't want the key event, try every
other handler, from top to bottom. This change requires widgets to
only react when focused. (2381c5ad)
- widget: don't draw Editor selection when not focused.  (3c45a6d4)
- io/pointer: remove unused functions.  (8630fee6)
- app: [Android] avoid out-of-bounds access in getCursorCapsMode.
Fixes: #404  (6ede60d8)
- app: replace driver.Raise with Perform(ActionRaise).  (1a833ab0)
- app: replace Config.center with Perform(ActionCenter).  (d22ec125)
- app: only perform actions and apply options on wakeups. In
particular, avoid a race between the setup of the platform window
returned by NewWindow and Window.Perform. (1071f561)
- cmd: delete tools module.  (4e6a9c09)
- io/router: remove unused frect function.  (aa140563)
- go.\*: upgrade github.com/benoitkugler/textlayout to v0.1.0.  (a9a9a7c0)

Thomas Mathews:

- layout: improve layout.List documentation. Updated the documentation
for layout.List to include the details about how drawing is performed
for items in it. This gives the user an understanding about how so
many items can be drawn with good performance. (45e8c781)

Chris Waldon:

- deps: update golang.org/x/text and go-text. Fixes a panic parsing
language tags. (25fae8de)

## gio-x

There have been 4 commits to gio-x since the last newsletter.

Non-breaking changes:

Mearaj Bhagad:

- notify/android: update sendNotification to support Android 12(SDK
31) or higher. As per android official docs, it is required to provide
the mutability flag for PendingIntent, which should be either
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_IMMUTABLE. Docs
recommends using PendingIntent.FLAG_IMMUTABLE, and hence for
simplification we are using PendingIntent.FLAG_IMMUTABLE. Allowing the
api user to select the flag requires little more changes, hence left
for later (9f76c90)
- explorer: update ChooseFile WASM documentation.  (f9e5afd)

Chris Waldon:

- richtext: fix byte/rune offset mixup. This commit correctly converts
a subslice operation to use byte offsets instead of rune offsets,
fixing the output for non- ASCII data. Thanks to \~fabien for
identifying the problem and suggesting a good fix! (1135178)

Andy Balholm:

- stroke: use github.com/andybalholm/stroke. I had to adjust test
thresholds to make the tests pass, because the output isn't
pixel-perfect identical to the old implementation, but there is no
visible difference between the two (other than for
TesttDashedPathFlatCapZNoPath, which I deleted because the new
implementation has different behavior for invalid dash patterns).
(f419638)

## gio-example

A couple of small changes went into the examples repository this month:

Chris Waldon:

- deps,7gui/*,life,gophers: update gio and global keyboard shortcut
example. This commit updates to the latest gio and adapts all of the
global keyboard shortcut handling examples to the recent changes in
Gio's keyboard event processing. (3f0fb59)
- deps: require gogio using tools.go. This ensures gogio is available
to build examples, and it helps lock the version of gogio used to be
compatible with the version of Gio used. (b74c795)

## gioui.org

We had a handful of small updates to the website as well:

Chris Waldon:

- architecture: document how list handles large input.  (28a0089)
- content: document minimum supported android sdk version.  (bf788e0)

Elias Naur:

- cmd/giouiorg: add new gioui.org/cmd reference.  (aa5d39c)

## gio-cmd

The cmd repository is all-new:

https://git.sr.ht/~eliasnaur/gio-cmd

Elias Naur:

- all: initial import from gio main repository.  (6826ef0)
\ No newline at end of file

A content/news/2022-05.md => content/news/2022-05.md +276 -0
@@ 0,0 1,276 @@
---
title: Newsletter, May 2022
shorttitle: May 2022
subtitle: Material Data Table added and unit.Value removed
---

## material data table

I'm sure you're all wondering "what happened to the material data
table?" Well, good news! This month, Jan's work was merged into gio-x
and the bounty payout is processing right now!

The basic grid type is available in gioui.org/x/outlay.Grid. It
provides a two-dimensional surface of cells that can be populated with
elements much like layout.List. All rows must currently be the same
height, though columns may vary in width.

The material styling is available in gioui.org/x/component.GridStyle
and gioui.org/x/component.TableStyle. These add scrollbars, and the
Table version provides a simple way to add persistent headers to your
table.

For examples of the use of these new types, see
gioui.org/example/fps-table and gioui.org/examle/color-grid.

## core gio

Elias and I spent a lot of time away from Gio this month, but that
doesn't mean that nothing happened. Elias merged an important change
to how Gio handles units that considerably simplifies how they work
and dramatically reduces the number of casts required to change units.

At a high level, the unit.Value type is gone, replaced by concrete
types unit.Dp and unit.Sp. These unit types are now accepted
explicitly by the APIs that consume them, which prevents accidentally
using an inappropriate unit. As these new values are simply float32
under the hood, you can now do math directly on them instead of
invoking methods like unit.Add. The new units can each be converted
into pixels using unit.Metric.Dp and unit.Metric.Sp respectively. As a
unit.Metric is embedded in the layout.Context, the following is
sufficient to resolve Dp into pixels:

    gtx.Dp(8)

The clip package API has been updated to use integer coordinates for
most common operations as well. Usually, rectangles and other shapes
should be pixel-aligned, so the loss of precision won't matter for
most use-cases. If you need floating point precision, the clip.Path
API still provides it so that complex shapes can be drawn with
sub-pixel precision.

I mostly focused on bugfixes. I tackled several visual bugs, a memory
leak, and a problem with the semantics of key event propagation.

There were 27 commits to core since the last newsletter.

Breaking API changes by author:

Elias Naur:

- gesture,widget,f32: [API] use integer coordinates for gesture
coordinates. Most widget code operate in integer coordinates. This
change makes gesture pointer coordinates integer, to lessen the number
of float32 to int conversions. (14805af3)
- all: [API] change op.Offset to take integer coordinates. op.Offset
is a convenience function most often used by layouts. Layouts usually
operate in integer coordinates, and the float32 version of op.Offset
needlessly force conversions from int to float32. This change makes
op.Offset take integer coordinates, to better match its intended use.
(a63e0cb4)
- all: [API] change clip.RRect and UniformRRect to take integer
coordinates. Like the change to op.Offset before this, clip.RRect and
UniformRRect is usually used with integer coordinates. Change to
integer coordinates to eliminate many useless conversions to float32.
(48a8540a)
- all: [API] replace unit.Value with separate unit.Dp, unit.Sp types.
The unit.Value is a struct and thus more inconvenient to use than its
underlying float32 type. In addition, most uses don't need a general
value, but rather a specific unit given by the context. This change
replaces unit.Value with two float32 units, Dp and Sp. It also changes
variables and parameters of unit.Value to a specific unit type
matching the context. That is, unit.Dp everywhere except for text
sizes which are in Sp. (3d374913)
- layout: [API] remove FRect. We're about to unexport f32.Rectangle,
this change removes the only public API for it. (fc79ec5c)
- f32: [API] unexport Rectangle. There are no public API that uses
f32.Rectangle anymore. Move Rectangle to an internal package for
internal use. (b5f12c5f)

Non-breaking changes by author:

Elias Naur:

- go.\*: upgrade github.com/benoitkugler/textlayout to v0.1.1. The
v0.1.1 release is much smaller because the module no longer contains
test data. See (c68417aa)
- io/key: remove key.NameUp/Down/Left/Right. They're no longer used
now that Android directional keys are mapped to key.Name\*Arrow.
(7fc594fa)
- app: don't lock up when using custom renderers. A recent change
broke custom rendering by not allowing the client to continue after
calling FrameEvent.Frame. This change makes sure the client is allowed
to continue regardless of rendering mode. (0e2e02a6)
- app: lock GPU context during present. The OpenGL backend needs it,
but I keep forgetting to test it when rearranging the window rendering
code. The gogio X11 end-to-end test tests this issue, but
unfortunately it is disabled because of flakiness. (79f037f9)
- app: don't deadlock if Window.validateAndProcess fails. Fixes: #417
(2a0a196d)
- flake.lock: run `nix flake update`. Otherwise, running Gio programs
fails with an error because of GPU driver mismatch. (9bf68963)
- all: apply suggestions from staticcheck.io.  (916efb46)
- gpu: re-align coverUniforms struct. Direct3D requires GPU vertex
attribute structs sizes be a multiple 16. A cleanup commit removed an
unused field, and broke that assumption. (44416833)
- app: restore IME snippet after an EditorReplace. Commit
02732037436f547717ec53073ce8b295329c9bd8 removed the snippet restore
event, which broke IME on macOS and Windows. (5cf916c0)

Chris Waldon:

- widget: ensure empty editor makes space for caret. Prior to this
change an editor with no content and a zero minimum constraint would
return itself has having width zero. This prevented users from being
able to see the editor when they moved focus to it, as it could not
display its caret. This simple change ensures that, at minimum, the
editor returns its dimensions to include the width of a caret.
(4996337d)
- text: fix doc typos.  (28acb79b)
- widget/material: prevent invalid list item constraints. Previously,
a bug in the ListStyle could result in items being passed a negative
value in the minimum constraints. (99d03320)
- widget/material: ensure scrollbar within dimensions. This commit
fixes a visual-only bug in the ListStyle that could make the scrollbar
float at the edge of the maximum constraints when the list did not
occupy the full constraints. The list would still reserve layout space
for the scrollbar in the correct position, but the scrollbar would not
be displayed there. (87be31cb)
- io/router: fix focused key event propagation. When a key.InputOp is
focused, keypresses that it does not explicitly include in its key set
should check for ancestor clip areas that are interested in them.
Previously this check only included ancestors of the final clip area
in the hit tree, and could fail to find ancestors of the focused
key.InputOp because they were in a different branch. (44ec48d3)
- text: eliminate path cache memory leak. This commit alters the
method we use to check for valid cache hits in the text path cache.
Previously we stored the entire text.Layout that was provided when the
cache entry was set so that we could ensure only identical
text.Layouts would produce hits (guarding against hash collisions).
This commit instead pulls the glyph IDs for every glyph in the
text.Layout and stores them in the cache. This uses far less memory
and seems to allow cache entries to be GCed after eviction. (11192a51)

Mearaj:

- app,widget: use arrow keys for Android navigation. Android doesn't
distinguish between the arrow keys on a keyboard and the directional
keys on a remote control, so there's no way to move the caret in an
Editor with arrow keys. This change updates the Android port to map
Android's DPAD_* key codes to the arrow key names, fixing caret
movement. The change also updates Editor to only request arrow keys
that actually move the caret, to keep directional focus movement
working. (7ced0d29)

Inkeliz:

- app: [Android] improve keyboard hints. This patch adds support for
the following KeyboardHint: Text, Email, Telephone and URL. (c97f976e)

Egon Elbre:

- app/internal/windows: fix WS_CLIPCHILDREN value. Fixes:
https://todo.sr.ht/~eliasnaur/gio/419  (cbbb5865)

## gio-x

The biggest change in x was the merge of the material data table, but
there were also some bugfixes and new features.

There have been 7 commits to gio-x since the last newsletter.

Breaking API changes by author:

Chris Waldon:

- all: [API] convert to unit API. This change updates all packages to
be compatible with the new unit package exposed by Gio core. (48c6fc7)
- outlay: drop previous table and rename grid to flow. This commit
removes the outlay.Table type that is obsolete now that we have a more
general two dimensional grid type available. (d3f24a3)

Non-breaking changes:

Chris Waldon:

- outlay: make gridwrap return correct baseline. The GridWrap type
previously returned a zero baseline unconditionally, which made it
impossible to align content outside of the grid to the first line of
text within the grid. Now the baseline is set to the baseline of the
first widget laid out within the grid. (1b330a1)
- component: simplify text field border clipping. This commit alters
the way in which the decorative border around the text field is drawn.
It was previously drawn in three clipped segments, but now is drawn
all at once with a single clip mask. (1978dde)

Jan Kåre Vatne:

- component: implement grid and table layouts. This commit adds
support for material themed grid and table widgets with appropriate
scorllbars and headings. (8732bd3)
- outlay: implement grid layout. This patch implements a two
dimensional grid that functions much like layout.List. The API accepts
a closure to provide the dimensions of each row and column, and a
separate closure to supply the contents of each cell. (df70009)

er:

- component: adding a way to remove selected item.  (25f67b5)

## gio-example

A couple of small changes went into the examples repository this month:

Chris Waldon:

- deps,all: update to latest gio{,-x} and fix all examples. This
commit updates all examples to use the latest units API. It also drops
the outlay/table example, as outlay no longer provides that layout.
(b5ffb1e)
- color-grid,fps-table: add simple demos exploring grid/table usage.
This commit adds two demonstrations of the new grid and table types
available in gioui.org/x/component. (caaef92)

Elias Naur:

- go.\*: upgrade to latest Gio, bump go.mod to 1.17.  (b8e926b)

## gioui.org

Elias updated the website to the latest API as well.

Elias Naur:

- go.\*,include/files/architecture: upgrade to latest Gio.  (f1940f3)

## gio-cmd

Lucas updated gogio to refuse compilation if the flags are malformed.

Inkeliz:

- gogio: refuse compilation with additional arguments. Previously, it
was possible to misuse gigio with arguments after the package, such as
`gogio -target android . -o foo.apk`. That cause an undesired effect,
since `-o` is silently ignored by gogio. (35e56c5)

## chipalee

Turns out my daughter really likes music, so to entertain her I wrote
a chiptune pipe organ in Gio. It's very simple, but was a fun little
project. There's (currently) a web demo of it available here:

https://whereswaldon.srht.site/

After it loads, type to play notes. Hold shift to play chords.

You can find the source here:

https://git.sr.ht/~whereswaldon/chipalee

You can try it locally by running:

    go run git.sr.ht/~whereswaldon/chipalee@latest

The desktop version provides additional features when using the
control and alt modifiers.
\ No newline at end of file

A content/news/index.tmpl => content/news/index.tmpl +19 -0
@@ 0,0 1,19 @@
---
title: Newsletter
subtitle: Gioverse news
hidechildren: true
children:
    - "./2022-05"
    - "./2022-04"
    - "./2022-03"
    - "./2022-02"
---

{{ define "content" }}
	<ul>
	{{- range $item := .Children -}}
		<li><a href="{{$item.URL}}">{{or $item.ShortTitle $item.Title}}{{with $item.Subtitle}} - {{.}}{{end}}</a></li>
	</article>
	{{- end -}}
	</ul>
{{ end }}
\ No newline at end of file

M site/front.go => site/front.go +5 -3
@@ 14,13 14,15 @@ import (

// FrontMatter is used to define properties for the page.
type FrontMatter struct {
	Slug     string `yaml:"url"`
	Title    string `yaml:"title"`
	Subtitle string `yaml:"subtitle"`
	Slug       string `yaml:"url"`
	Title      string `yaml:"title"`
	Subtitle   string `yaml:"subtitle"`
	ShortTitle string `yaml:"shorttitle"`

	After  string `yaml:"after"`
	Before string `yaml:"before"`

	HideChildren   bool     `yaml:"hidechildren"`
	ChildrenNoLink bool     `yaml:"childrennolink"`
	Children       []string `yaml:"children"`


M template/nav.tmpl => template/nav.tmpl +3 -2
@@ 9,7 9,8 @@

	<nav id="menu">
		<ul>
			<li><a href="/" {{if .Nav.Active}}aria-describedby="current"{{end}}>Home</a></li>
			<li><a href="/" {{if .Nav.Active}}aria-describedby="current"{{end}}>Home</a>
			</li>
			{{ template "nav-children" .Nav }}
		</ul>
	</nav>


@@ 20,7 21,7 @@
{{ range $item := .Children }}
<li>
	<a href="{{$item.Page.URL}}" {{if .Active}}aria-describedby="current"{{end}}>{{$item.Page.Title}}</a>
	{{if $item.Children}}
	{{ if and $item.Children (not $item.Page.HideChildren) }}
	<input class="nav-toggle" id="{{$item.Page.Slug}}" type="checkbox" {{if .Active}}checked{{end}}>
	<label for="{{$item.Page.Slug}}"><span class="font-size:small">▼</span></label>
	<ul>{{ template "nav-children" $item }}</ul>

M template/root.tmpl => template/root.tmpl +2 -2
@@ 30,7 30,7 @@
						{{ if .Page.Before }}
						<a class="before" href="{{.Page.Before.URL}}">
							<div>Prev</div>
							<div>{{.Page.Before.Title}}</div>
							<div>{{or .Page.Before.ShortTitle .Page.Before.Title}}</div>
						</a>
						{{ else }}
						<span class="before"></span>


@@ 38,7 38,7 @@
						{{ if .Page.After }}
						<a class="after" href="{{.Page.After.URL}}">
							<div>Next</div>
							<div>{{.Page.After.Title}}</div>
							<div>{{or .Page.After.ShortTitle .Page.After.Title}}</div>
						</a>
						{{ else }}
						<span class="after"></span>