github go-gui-org/go-gui v0.85.0

latest releases: v0.98.0, v0.97.0, v0.96.0...
one month ago

Added

  • RenderCmd.VertexColorsFlat marks vertex colors that are not a gradient
    (#945)
    — a RenderSvg command can now carry triangles of different flat
    colors that must blend over each other in order, as separate commands would. A
    backend that blends every triangle in submit order (Metal, GL, web, iOS,
    Android) needs no change. A backend that draws vertex colors as one seamless
    mesh must draw a flagged command as ordered same-color runs instead; the soft
    backend now does, so its screenshots of a ThinkingOrb are unchanged.

  • DrawCanvasCfg.VersionFn reads a canvas version at render time (#939) — a
    canvas whose content changes between frames could not repaint under a
    render-only refresh (InvalidateRender, AnimationRefreshRenderOnly):
    Version is read only while the view is built, which such a frame skips. The
    choices were a full frame (InvalidateLayout) or AlwaysRedraw, which runs
    OnDraw on every pass. VersionFn is called when the canvas is drawn, and
    OnDraw runs again only when its value changes. OnDraw must read the same
    live state, and VersionFn runs under the window lock, so it must be cheap
    and must not call window APIs; an atomic load is the intended use. A panic in
    it falls back to Version.

  • InWindowOpenDialog, InWindowSaveDialog and InWindowFolderDialog
    (#831)
    — open the in-window file browser on purpose, on any OS, without
    trying the native picker first. They take the same Native*DialogCfg types
    and report through the same OnDone, so moving a call between the two is a
    rename. Use them when an app wants one look on every OS, or to show the
    browser in a demo. Paths have a zero Grant: on macOS a sandboxed app gets no
    security-scoped access this way and should keep Native*Dialog. The showcase
    shows all three under Overlays → Dialog → In-Window File Browser.

  • Showcase has a DX Cheat Sheet page — the cheat sheet in
    docs/dx-cheat-sheet.md lists the places where the obvious reading of the API
    is wrong, but people who use the showcase did not see it. It is now under
    Welcome → DX Cheat Sheet. The showcase embeds a copy, because go:embed
    cannot read outside its package. TestDocMirrors fails when the copy and
    docs/ differ; to update the copy, run
    go test ./examples/showcase/ -run TestDocMirrors -update.

  • LoadSecret / SaveSecret / DeleteSecret keep secrets in the OS
    credential store (#920)
    — SaveSettings writes plain JSON, so an app that
    kept an access token had to write its own store. The new functions use the
    Keychain on macOS and iOS, Credential Manager on Windows, and the Secret
    Service (GNOME Keyring, KWallet) on Linux, with the app ID as the service
    name. A value is 1 to 2560 bytes on every platform. Where no store exists
    (web, Android, a Linux session with no Secret Service daemon) they return
    ErrSecretsUnsupported and never fall back to a plain file. A missing key
    returns ErrSecretNotFound. NewTestWindow uses a memory store. See
    docs/specs/secure-storage.md.

  • Experimental native Wayland backend behind GOGUI_WAYLAND=1 (#919) — on a
    Wayland desktop go-gui ran only through XWayland, which blurs at fractional
    scales and is unavailable on devices with no X11 EGL platform (#916). With
    GOGUI_WAYLAND=1 a Linux app (amd64 or arm64) opens native Wayland windows.
    They render with the same GL renderer at fractional and integer scales, take
    pointer, keyboard, scroll, touch and input method (text-input-v3) input, share
    the clipboard and primary selection, set cursors, and move and resize. The
    frame comes from the compositor (KDE, wlroots) or from libdecor (GNOME,
    Cinnamon, weston), and a warning names the missing package when neither can
    draw one. Without the variable nothing changes. If Wayland setup fails (no
    compositor, or no libwayland-client, libwayland-egl or libxkbcommon), go-gui
    prints a warning and uses X11. The build stays cgo-free: the libraries are
    opened at run time. Tested under sway, weston, KWin and Cinnamon 6.6; reports
    from other desktops and GPUs are wanted on #919. See
    docs/specs/wayland-backend.md.

  • DialogCfg.EscapeDisabled stops Escape from closing a dialog (#909) — a
    progress dialog had no way to block the Escape path, so the user could close
    it before the work finished. Set EscapeDisabled to keep the dialog open. A
    blocked Escape stays unhandled, so content in the dialog can still use the
    key. DialogDismiss() still closes the dialog, and OnCancelNo does not fire
    for a blocked Escape.

  • DrawContext.Rotate turns canvas drawing by an angle (#904) — the canvas
    transform stack (Translate / ScaleBy / Save / Restore) was scale and
    translate only, so a rotated shape, text or image could not be drawn; the
    qcpainterbench Flower port now draws its cached outline under a
    rotate-about-center instead of rotating 193 points on the CPU every frame. The
    transform is now the full 2×3 affine, composed in call order (positive angles
    turn clockwise, as in TextStyle.RotationRadians), and geometry still rides
    unbaked: batches and RenderCmd carry all six floats (XformXY / XformYX
    join the existing fields) for every backend to apply per vertex. Text maps its
    anchor through the matrix and gains the angle on RotationRadians (or a
    composed AffineTransform, which keeps precedence); images record their
    rotated frame for a backend rotation bracket; the lowered radial-quad path
    survives rotation (a circle stays a circle) and still falls back to the ring
    mesh under a non-uniform scale. DrawRecorder exporters see baked coordinates
    with no interface change: rotated rects arrive as outline polygons, rotated
    ellipses flatten at the arc tolerance. DrawCanvasTriBatch.Transform keeps
    its shape but returns ok=false for a rotated batch, whose vertices are still
    in local space; a caller that reads ok=false as "already in canvas space"
    misplaces rotated geometry. Move Transform callers to the new
    TransformAffine, whose ok=false means untransformed only.

  • WindowCfg.VSyncOff presents without waiting for vsync (#907) — a
    renderer benchmark that redraws every frame read the display refresh rate
    until a frame took longer than one refresh, so it could not report raw
    throughput. The flag is opt-in and fixed when the window is made; the default
    keeps vsync on. X11 sets EGL swap interval 0 and Windows sets WGL swap
    interval 0. macOS, iOS, Android and web ignore the flag: on macOS the window
    compositor hands back a Metal drawable once per refresh even with the layer's
    display sync off, in a window and in full screen. An idle window still sleeps,
    and animations still tick every 16 ms: frames run past the refresh rate only
    when the app invalidates every frame. gui.Debug reports a refused or ignored
    flag under DebugWindowDegraded, through the new Window.DebugWindowVSync.
    examples/qcpainterbench takes -novsync.

  • examples/qcpainterbench, a canvas benchmark ported from Qt (#723) — it
    draws the six workloads of Qt's qcpainterbench (ruler, circles, bezier lines,
    bars, icons and text, flower) through DrawCanvas, N times per frame. It
    shows FPS and go-gui's CPU time per frame. -sweep 1,2,4,…,512 prints one CSV
    row per render count. No Qt code is copied: the workloads follow the behavior
    written in docs/specs/qcpainterbench.md. Vsync stays on, so FPS stops at the
    display refresh rate; round caps ride StrokeStyle since #905, and concave
    path fill is emulated in the example and tracked in #906 (rotation since #904
    rides DrawContext.Rotate).

  • Canvas strokes take caps and joins through StrokeStyle (#905) — Line,
    Polyline, PolylineJoined, Arc and the beziers (plus Circle and
    RoundedRect) each gain a *Styled twin that draws round and square caps and
    round joins on top of the one stroker gui/svg shares. The zero style draws
    exactly what the unstyled call draws, so existing code sees no change in
    pixels, triangle counts or recorder output. A recorder that wants the style
    implements the optional DrawStrokeRecorder extension; all others still get
    the stroke as the equivalent unstyled primitive. The qcpainterbench Circles
    port drops its 34 half-disc fills per pass, and the curves draw with round
    joins like Qt.

  • Canvas paths fill concave shapes through CanvasPath (#906) — a reusable
    path value built with MoveTo / LineTo / QuadTo / CubicTo / ArcTo /
    Close, drawn with FillPath (solid color), FillPathGradient (gradient)
    and StrokePath (color, width, StrokeStyle). Fills honor FillNonzero (the
    zero value, as in SVG) and FillEvenOdd, so holes carve and overlaps follow
    the rule instead of fanning from the first point the way FilledPolygon does.
    The tessellator is the one gui/svg shares, moved to gui/internal/pathfill;
    SVG output is unchanged. Reset rebuilds a path without allocating, and a
    redrawn canvas fills its paths with zero allocations. A recorder that wants
    the path implements the optional DrawPathRecorder extension; all others
    still get the fill as one flat polygon per triangle and the stroke as one
    joined polyline per contour. The qcpainterbench Lines port fills path cubics
    closed to the baseline and the Flower port fills its cached outline as one
    closed contour, dropping both hand-built triangulations.

Changed

  • A ThinkingOrb frame is one draw command, not hundreds (#945) — each line
    and dot of the orb has its own color, and a canvas batch held only one color,
    so a frame sent between 1 and 534 triangle batches to the backend for one
    small widget. The orb now draws every mark into one batch with a color per
    vertex, in the same order, so the pixels do not change. Other canvases keep
    one color per batch: a reader of DrawContext.Batches() that looks only at
    Color, such as go-charts' PNG export, stays correct.

  • Looping loading widgets repaint without a layout (#939) — an indefinite
    ProgressBar, a Skeleton, a MathSpinner and a ThinkingOrb used to run
    the view function and layout for the whole window on every animation tick, 60
    times a second. Their ticks now ask for a render-only frame, which redraws
    from the layout already built. On a 200-button window a ProgressBar tick drops
    from about 142 µs and 1600 allocations to about 7 µs and none. What they draw
    is unchanged: a test checks that a render-only frame emits the same commands
    as a full frame. Pulsar and animated text still use full frames.

  • Widget factories no longer copy their Cfg to the heap on every call (#937)
    — a factory with an auto-ID branch built a ViewFunc closure that captured
    the cfg parameter. A Cfg is larger than the 128 bytes Go copies into a
    closure, so Go moved the whole Cfg to the heap at the start of each call, also
    when ID was set and the closure was never built. The branch now captures a
    copy of its own, and handlers that read a few Cfg fields capture those fields.
    A frame of 50 rows (BenchmarkViewFrame/rows_50) drops from 353 to 202
    allocations, from 158 KiB to 87 KiB, and builds 30% faster. A frame of 50
    buttons drops from 453 to 352 allocations. Column, Row, Button and most
    input factories now allocate once per call, the view itself.
    TestFactoryCfgDoesNotEscape holds each factory to its count. No API changes.

  • File dialogs fall back to an in-window file browser (#831) — when there is
    no native file picker, NativeOpenDialog, NativeSaveDialog and
    NativeFolderDialog used to call OnDone at once with a DialogError
    ("unsupported", or "no_dialog_tool" on Linux without zenity or kdialog).
    The user saw nothing. They now open a file browser inside the window: a path
    bar, a folder list, a filter select when there is more than one filter, and a
    name field for save. Enter accepts, Escape cancels, and focus stays in the
    dialog. OnDone gets DialogOK with the chosen paths, or DialogCancel.
    This also applies to a nil native platform, so NewTestWindow tests now see
    the browser, and can drive it with TestKey and TestClick. A test that
    expected the "unsupported" error must change. A bad Cfg and a real
    platform error still report DialogError. Paths from the browser have no
    macOS security-scoped grant. See docs/specs/in-window-file-browser.md.

  • gui no longer carries a MinGW __ms_vsscanf shim on Windows (#886) —
    gui/compat_mingw.go defined a weak __ms_vsscanf for the SDL2 static
    libraries, which were removed in #60. It was the only cgo file in gui on
    Windows, so a cgo-enabled Windows build of gui now compiles no C. An app
    that links its own MinGW static library that needs __ms_vsscanf must now
    supply the symbol.

Fixed

  • Shift+Arrow and Shift+Home/End select text on X11 again (#948) — X servers
    list arrows, Home and End with an empty shifted keysym column, and the X11
    backend handed that empty NoSymbol (0) to the input method as the key. IBus,
    the default on GNOME and Fedora, swallowed it, so a Shift+motion key never
    reached Input and no selection grew. The lookup now falls back to the
    unshifted keysym, as the core protocol specifies, and the key arrives with
    ModShift intact.

  • Two MathSpinners no longer share one animation (#941) — a spinner keyed
    its tick and progress by the bare ID, so two spinners with the same ID
    under different ID-bearing parents, or two with no ID, drew the same frame.
    It now keys them by its effective ID, like ThinkingOrb, and ID may be
    empty: the spinner takes a generated leaf. The *Window argument is now
    unused and kept so callers still compile.

  • A canvas whose batch count changes per redraw no longer allocates (#940) —
    a redraw that emitted fewer triangle batches or lowered gradients than the one
    before dropped the spare pooled buffers, so the next larger redraw allocated
    them again. A ThinkingOrb tick, whose batch count moves every frame,
    allocated about 7 times; it now allocates nothing once the animation has run a
    full cycle. A canvas now keeps the buffers of its largest redraw for as long
    as its cache entry lives.

  • An idle window with a focused input stops rendering after 10 s (#929) —
    the caret blinked for as long as an input held focus, and each blink presents
    a full frame. With software GL on a slow device, such as a phone running
    Phosh, that cost 30–80% of a core while the app sat untouched. The caret now
    stops blinking after 10 s with no caret activity, the same default as GTK's
    gtk-cursor-blink-timeout. It stays solid, the blink animation retires, and
    the window renders nothing until something happens. Typing, clicking or
    dragging in the field, moving focus, or refocusing the window starts the blink
    again. A Pulsar keeps blinking.

  • Linux: no double scale under XWayland when Xft.dpi is unset (#918) — on
    a Wayland desktop that does not publish Xft.dpi (Phosh), the X11 path took
    its scale from the monitor's physical DPI. The compositor also scales XWayland
    windows by the output scale, so the scale was applied twice: on a FuriLabs
    FLX1s at 174%, go-gui drew at 1.81 and the compositor enlarged that by 1.74,
    and at 100% go-gui was still about twice the size of other apps. Under
    XWayland with no Xft.dpi, the scale is now 1.0, the same as GTK and Qt, and
    the compositor applies the desktop scale. Xft.dpi, when set, still wins.
    Bare X11 sessions keep the per-monitor RandR scale.

  • Closing one window no longer blanks the others' GL resources (#921) — each
    window owns an unshared GL context, and object names repeat across them, so
    destroying a window freed the surviving windows' same-numbered textures,
    buffers, VAOs and shader programs instead of its own. The window now makes its
    own context current before deleting its objects. Single-window apps were never
    affected.

  • Linux: GL starts when the default EGL driver has OpenGL ES only (#916) —
    on a libhybris phone (FuriLabs, Phosh on Wayland) the default EGL display is
    the Android GPU driver, which has no desktop-OpenGL config, so every app
    failed with eglChooseConfig: no matching config (egl error 0x3000). When the
    default display has no desktop-GL config, the backend now tries the Mesa X11
    platform display (eglGetPlatformDisplay). On that phone Mesa renders in
    software (llvmpipe), so the app runs but is slow. When no display has desktop
    GL, the error now says the driver offers OpenGL ES only, in place of only the
    old "update the GPU driver" hint. Desktop systems are not affected: their
    default display succeeds and the fallback never runs.

  • macOS: event loop no longer leaks one NSEvent per frame — the Metal
    backend polled AppKit events with no autorelease pool, and the Go event loop
    has no Cocoa run loop to drain one. Every dequeued event and every wake event
    stayed in memory, so an app with a repeating animation (the solar_system
    example) grew by about 60 events, ~40 KB, a second for as long as it ran. The
    poll now drains its own pool, and memory stays flat.

  • SVG round joins and square caps draw on the correct side (#905) — the
    round-join fan swept the long way around the vertex, painting the inner disc
    the segment quads already cover and leaving the outer corner open, and the
    square cap extended sideways along the normal instead of along the path.
    Moving the stroker into gui exposed both, confirmed with coverage probes
    before the fix. Round caps, miter joins and bevel joins were already correct
    and draw byte-identical output.

What's Changed

Performance

Other changes

Full Changelog: v0.84.0...v0.85.0

Don't miss a new go-gui release

NewReleases is sending notifications on new releases.