Skip to content

Draw every widget through layout blocks #16

Closed

Description

@M4n0x

Problem

Widgets are drawn in two ways. Built-in types (text, clock, active app, and script or provider widgets without a layout) draw through a switch and label() (Sources/StableBar/BarView.swift:321, :392). Widgets with a layout, overlays and popups draw through PopupBlockView. A widget's text is also derived in three places: content(), block() for layout fields (BarView.swift:366) and overflowTitle for the More widgets menu (BarView.swift:161).

Anything that changes how text appears would have to be built twice:

  • Transitions. There are none today, so changed text, and widgets that show or hide, snap into place. A clock minute, a new track title or a new front app can't roll or fade in.
  • Temporary output, such as showing the volume number for 1.5 s after a change before returning to the icon.
  • scrollSpeed, which works on text and field blocks but not on a built-in widget's label.

Proposal

  1. Give each widget kind one function that returns its text, icon and fields. The renderer, the overflow menu and the inspector all use it.
  2. Give each built-in type a default layout, such as a row of symbol (icon) and field (text), and draw every widget through PopupBlockView. A configured layout replaces the default, as today. The workspace widget keeps its own view. Add ImageRenderer snapshot tests of the default layouts before switching, so existing bars stay pixel-identical.
  3. Then add, in the block renderer only:
    • transition on widgets and text, field and symbol blocks: none, fade, roll, numeric (contentTransition(.numericText())). It uses animation and respects Reduce Motion.
    • An enter and exit transition when output hidden changes.
    • Temporary output, for example "temporary": { "fields": { "text": "62" }, "duration": 1.5 }.

This would unlock:

  • Content and show/hide transitions
  • Temporary output
  • Scrolling text on built-in widgets

Possible today

A layout already gives a widget per-part styles and scrolling text. Nothing gives transitions. animation only affects style and hover changes (BarView.swift:310).

Related

None tracked. #15 (style resolution) also changes BarView.swift. Landing it first keeps this one smaller.

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    enhancement
    on Oct 15, 2026
  2. M4n0x commented on Oct 15, 2026

    @M4n0x
    CollaboratorAuthor

    Performance

    The bar draws each widget twice per display: once visibly, and once in a hidden copy that measures widths for the overflow planner (Sources/StableBar/BarView.swift:60-77). If transitions animate in that copy, the measured widths change every frame and the bar's layout is replanned 60–120 times a second for the length of each animation.

    Requirements for this change:

    • No animations or transitions in the measuring copy, for example .transaction { $0.disablesAnimations = true }. It measures final widths only.
    • An idle bar stays idle: no TimelineView or repeating animation runs unless something is moving, such as scrolling text or a progress block heading for its target.
    • Block children are built through AnyView (Sources/StableBar/PopupView.swift:125). Before every built-in widget goes through blocks, replace it with a concrete view per block type, or show with Instruments that it doesn't matter at a typical size (about 20 widgets on two displays).
    • Reduce Motion skips transitions entirely.

    Triaged by Claude Code (Claude Opus 5.5).

  3. M4n0x commented on Oct 17, 2026

    @M4n0x
    CollaboratorAuthor
    pr16-transitions.mp4
  4. stablebar-releases commented on Oct 21, 2026

    @stablebar-releases

    🎉 This issue has been resolved in version 0.5.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions