Repository navigation
Added
-
Mahjong Solitaire example (
examples/mahjong). A complete game: 144 tiles
on Turtle, Fortress and Pyramid layouts, with hints, undo, restart, a shuffle
assist when no moves remain, a clock and keyboard shortcuts. Every deal can be
cleared. The rules are in a separateenginepackage that does not import
go-gui, and layouts are data. The tile art is one SVG atlas of<symbol>
elements, built by a generator from the public-domain (CC0) FluffyStuff tiles
plus eight new flower and season faces. It shows how to draw a large stacked
board withCanvas, render SVG symbols with<use>, build a new board tile
by tile, fade removed tiles withOpacity, and celebrate a win with fireworks
drawn on aDrawCanvas. -
Locale strings for the in-window file browser (#1385).
Localehas 19 new
fields:StrFileName,StrFolder,StrFilterOrPath,StrHome,
StrSortName,StrSortDate,StrSortSize,StrSortAscending,
StrSortDescending,StrShowHidden,StrAllFiles,StrRefresh,
StrEmptyFolder,StrNoFolders,StrNoMatches,StrNoMatchingFiles,
StrReplaceFile,StrBadFileNameandStrNotAFolder. Bundles set them with
the snake-case keys (file_name,replace_file, …). The ten bundled locales
translate all of them. Before, the browser's overwrite question and its two
errors were English in every locale.StrReplaceFileandStrNotAFolderare
fmtformats with one%s. An appLocalethat leaves a browser field empty
(one built before this release) gets the en-US text for it, so the browser
never shows a blank label or a broken format. -
Hold-to-action button (
ButtonCfg.HoldDuration) (#1397). Set
HoldDurationon a button andOnClickfires only after the user presses and
holds for that long. The button fills from left to right while it is held, and
the action fires when the fill reaches the right edge. Use it for a
destructive action (delete, wipe, revoke) that a click makes too easy and a
confirm dialog makes too heavy. Releasing early, moving the pointer off the
button, or losing focus cancels the hold: nothing fires and the fill drains
back in about 150 ms. Holding Space on a focused button works the same way,
and Enter does nothing. A screen reader's press action firesOnClickat
once, because it cannot hold. The fill is the pressed color moved one
lightness step, so every variant, theme and caller color works. The click
sound plays on completion. Zero keeps today's button. ADisabledor
Loadingbutton never starts a hold. One hold runs per window. See
examples/hold_button.
Changed
-
Scrolling a long column is faster: anonymous text is cached and offscreen
children are skipped (#1389). ATextwith noIDand up to
textChunkBytesof text now keeps its shaped block between frames, keyed by
its content, width, style and mode. Before, each frame shaped every such
paragraph again, even if the text did not change or the view built a new
string each frame. Longer text keeps the key by string pointer. A block that
no view pass uses for two passes is dropped. A scroll container that clips now
skips children that are fully outside its viewport, so they no longer emit an
emptyClippair. A child is never skipped if it is a float, has a transform,
a quarter turn or a color filter, or draws over its siblings. It is also kept
if its shadow, blur or ink, or any descendant, can paint into view. A
render-only frame never skips a child, becauseAmendLayoutcan move one into
view. On a 400-row column of 600-byte wrapped paragraphs, one scroll frame
went from 60 ms and 42 MB to 0.5 ms and 142 KB. Approach by @akaenner. -
macOS: wake requests from other goroutines coalesce (#1387). The Metal
backend now sends at most one wake to the main queue at a time. Scroll and
animation wakes that come before the main thread serves the pending one do
nothing, because that one wake already starts the next frame. Before, each
call put one more dispatch on the main queue and posted one more empty event,
so fast wakes could fill the queue. A wake that comes after the pending one
runs sends a new one, so no wake is lost. Approach by @akaenner. -
The in-window file browser has breadcrumbs, places, a filter box, sorting
and file details (#1385).InWindowOpenDialog,InWindowSaveDialog,
InWindowFolderDialogand the native-picker fallback show the new browser. At
the top is a row of places: Home, Desktop, Downloads, Documents, Movies or
Videos, the volumes in/Volumeson macOS and the drives on Windows. The path
bar is now a breadcrumb trail (~for the home folder) under the list, with a
Refresh button at its end. The text field filters the folder as you type. Text
that starts with/,~,./,../or a drive goes to that path on Enter,
and in open mode a path to a file accepts it. A row of pill buttons sorts by
name, date or size (a second click on the active key flips the order), shows
dotfiles (Hidden, or Cmd/Ctrl+Shift+.). At its right end a file type select
picks one of the app's filters or "All files". The active place, sort key and
toggle take the accent fill; the others use the quieter secondary text. The
list has the theme's list fill and border, and each row is taller and shows an
icon, the size and the date. An empty list says why: empty folder, no folders
(folder mode), no matches, or no files of the filter's type. Escape clears a
typed filter before it closes the dialog, and Cmd/Ctrl+Up on the list goes to
the parent folder. The dialog is 600 px wide (was 480). The only new API is
theLocalestrings above. -
Bump go-glyph v1.30.0 to v1.31.0 and regexp2 v2.13.3 to v2.14.0 (#1398).
Text shaping and glyph rasterization come from the new go-glyph; regexp2 is
pulled in by chroma for code highlighting. The public API does not change.
Fixed
-
Date picker roller and slider wheel move one step per detent (#1396). The
wheel handler stepped one item for every scroll event. A trackpad, a
smooth-scroll mouse or a mouse utility sends many small events per notch, so
the drum ran several items. An event with no vertical delta also moved the
drum forward. Now a discrete wheel moves one item per event, and precise
deltas add up: one notch (3 lines) is one item. A change of direction drops
the carried remainder, and a momentum burst gives at most one item per event.
An event with no vertical delta does nothing.Slideruses the same rule: a
precise source no longer moves it severalSteps per notch. -
WithTooltipno longer moves or grows the view it wraps (#1381). Its
wrapper set no padding or spacing, so the theme's default container padding
applied: 14 px on each side in the default theme. A view that got a tooltip
moved and grew, and in a list with a fixed row height it was pushed down and
cut off. The wrapper now adds no room. A layout that relied on those 14 px
shrinks. To keep them, put the wrapped view in a container with that padding
insideContent. Padding on the wrapped view itself does not work for a
fixed-size view: it stays the same size, and its content gets less room. -
Smooth wheel scrolling and flings no longer judder (#1388). The background
animation tick stepped the ease on its own clock, and the next frame showed
the result. The tick's phase beat against the display's vsync, which showed as
judder on 60 Hz and 120 Hz displays, and the first step of an ease came one
frame late. Now each frame steps the ease at its start, by the real time since
the last step, before the frame builds. The background tick does nothing while
frames run. It steps again when no frame has run for 100 ms, for example in a
hidden window, so an ease never stalls.TestStepruns the same path.
Approach by @akaenner. -
Web: trackpad scrolling follows the fingers (#1386). The web backend sent
every wheel event as a notched mouse wheel. A trackpad or precision touchpad
already has OS smoothing and momentum, so the gui wheel easing ran a second
time, and scrolling felt slow and late. The backend now setsScrollPrecise
for these devices, and they scroll at once. A mouse wheel is still eased. The
test usesdeltaMode, the legacywheelDelta(Chromium and WebKit count it
in 120 per tick; Chromium divides it bydevicePixelRatio, so the backend
multiplies it back) and, when neither decides, the size of the delta in device
pixels. A notch at 125% or 150% scaling is therefore not taken for a trackpad.
On macOSwheelDeltahas the same ratio for both devices, so a delta of whole
lines (40 CSS px each) is taken as a mouse notch. The result is decided once
per gesture, so a fast wheel spin does not change path part of the way
through. A trackpad moves as far as before: 17.7 CSS px a line, not the 0.075
lines a point of macOS and Wayland. A Firefox mouse wheel now moves exactly 3
lines a notch, asEvent.ScrollYdocuments. The backend readsdeltaMode
first, and Firefox then reports a mouse wheel in lines, not in pixels divided
by 17.7. Before, a notch moved a distance that depended on Firefox's line
height. Approach and first heuristic by @akaenner (#1383). -
macOS: windows keep drawing while a menu or modal dialog gets fast events
(#1392). The frame pump that draws windows during a nested run loop armed a
new 60 Hz timer each time the nested mode started and removed it each time the
mode ended. AppKit runs the mode once per event, so with events coming faster
than 60 a second (a mouse moving over an open menu) each run ended before the
timer fired, and no window drew until the events stopped. The timer now stays
armed until the default mode runs again. Also, the opt-in main-thread test
suite of the Metal backend passes again: its wake-leak check now warms up
before it measures, so the one-time growth of the malloc caches is not taken
for a leak.
What's Changed
Bug fixes
Other changes
- feat(examples): Mahjong Solitaire example by @mike-ward in #1384
- feat(filebrowser): shirei-style in-window file browser by @mike-ward in #1385
- fix(web): detect precise (trackpad) wheel events (#1386) by @mike-ward in #1390
- perf(metal): coalesce wakeUp dispatches (#1387) by @mike-ward in #1391
- fix(metal): keep frame pump armed across nested-mode runs (#1392) by @mike-ward in #1393
- fix(scroll): step smooth scrolling synchronously in FrameFn (#1388) by @mike-ward in #1394
- perf(render): cache anonymous text blocks and cull offscreen scroll children (#1389) by @mike-ward in #1395
- fix(gui): one step per wheel detent on date roller and slider by @mike-ward in #1396
- feat(gui): hold-to-action button (ButtonCfg.HoldDuration) by @mike-ward in #1397
- chore(deps): bump go-glyph to v1.31.0 and regexp2/v2 to v2.14.0 by @mike-ward in #1398
- changelog: add v0.101.0 (hold button, file browser, mahjong) by @mike-ward in #1399
Full Changelog: v0.100.1...v0.101.0