Skip to content

Ariadne: pictures and players that fill the width, autoplay in view, and :shortcode: pictures in text - #1052

Merged
transfix merged 4 commits into
masterfrom
feat/ariadne-fill-width-inline-pictures
Nov 8, 2026
Merged

transfix merged 4 commits into
masterfrom
feat/ariadne-fill-width-inline-pictures

Conversation

@transfix

@transfix transfix commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

nicotina's feed on the web page (https://cyberpcangel.com/nicotina/) showed four problems. One was its page's CSP (cy-pca/nicotina#18). Two need the host: pictures and video should fill the card's width at their own shape, and tx.wtf's custom :emoji: should show. This PR adds both, and an autoplay that suits a feed. Spec in docs/ARIADNE.md §5.11 and §5.13.

Pictures and players that fill the width

  • size: "N%". image: and video: take that share of the width the widget has on its line, the picture's own shape setting the height. size: ["N%", h] is a box that wide.
  • max_height: h. A picture whose height follows its shape stays within h, drawn narrower instead: a phone's portrait video in a feed.
  • ImGui measures the line with the new Backend::available_width.
    • In a window that fits its content, the picture is as wide as the other content makes the window, and at least the widget's own width (256 / 480). So a window holding only the picture still has room for it.
    • The raster is fitted at the width rounded up to 64 px and scaled in between, so resizing a window doesn't refit it every frame.
  • The terminals can't measure before they lay out, so there the widget is its own width. A document can keep separate terminal sizes behind (has? "term").

autoplay in view

autoplay: true plays while the video's picture shows (the new Backend::item_visible, which is ImGui's IsItemVisible). Scrolled out of view, or with its window closed, it pauses, and back in view it plays on. This holds until the user presses Play or Pause, or the document writes playing. A feed's videos no longer all play at once.

:shortcode: pictures in text: emoji:

text: takes emoji:, a state key holding a map of shortcode names to picture URIs, or to text.

  • Pictures. A :name: mapped to a URI is drawn as that picture, one line tall at its own shape, through the new Backend::text_runs (ImGui draws them). A GIF or WebP animates, and a video URL plays as a silent loop. Hovering one shows its :name:.
  • Text. A :name: mapped to text is replaced by it in every backend. That is a unicode emoji's character: txwtf's content_html gives :100: as 💯.
  • Shortcodes are found as txwtf, Slack and Mastodon find them: 1-64 of [A-Za-z0-9_+-] between colons that aren't glued to a word character, so 14:50:47 stays a time.
  • Terminals keep a picture's :name: as text, and don't fetch it.

A predicate the frame's budget skips keeps last frame's answer

Every visible_when, enabled_when and computed bind shares a 30 ms budget per frame. In the browser, nicotina's feed (ten cards, several predicates each) spent it on a slow frame, and a skipped visible_when hid its widget for that frame, so the last cards flickered. The console said "skipped — per-frame budget exhausted" for card 7's predicates.

  • Skips: a skipped visible_when / enabled_when / disabled_when now keeps last frame's value, as a repeat count already did. One that never ran stays fail-safe (hidden or disabled).
  • Setting the budget: Runtime::set_reactive_frame_budget sets it, for a host on a slow device and for the test. An engine created mid-frame takes it too.
  • Test: AriadneReactiveBudget.ASkippedPredicateKeepsLastFramesAnswer.

Other changes

  • Capability tokens image.fill and text.emoji.
  • The schema takes a size: map or string, max_height and emoji.

Checked (Windows, MSVC, shared)

  • ariadne_media_test: 41 passed, 2 skipped, the skips being the FTXUI ones this build lacks. The new tests:
    • the loader;
    • fill width, and the own width where the line can't be measured;
    • max_height, with a portrait PNG;
    • a filling video that waits out of view, starts in view, pauses and resumes, then becomes the user's after Pause;
    • the shortcode rules and text values;
    • an inline GIF and WebP publishing new frames on the clock;
    • an inline video playing as a silent loop.
  • Other suites:
    • ariadne_loader_test: 222 passed;
    • ariadne_requires_test: 18;
    • ariadne_host_test: 46;
    • cvcgl_imgui_media: passes.
  • arigl snapshot of a test document, with a window fitting a 70-character row:
    • the picture and the video span the window;
    • the line shows an animated GIF, a PNG, a playing MP4, a text-mapped :100: and an unmapped :nope:.

Not run here:

  • the ImGui golden tests (cvcgl_ari_golden can't load its GL DLLs on this box) and the FTXUI suites. CI runs them.
  • a wasm arigl-web against nicotina's feed in a browser. That is building, and the result will go on this PR.

…and :shortcode: pictures in text

nicotina's feed on the web page needed three things from the host (cy-pca/nicotina#18 has the rest).

- image: and video: take size: "N%": that share of the width the widget has on its line, the
  picture's own shape setting the height, or ["N%", h] for a box. max_height: keeps a picture whose
  height follows its shape no taller, narrower instead (a portrait phone video). ImGui measures the
  line (Backend::available_width); a window that fits its content is as wide as its other content,
  and at least the widget's own width. A filling picture is fitted every 64 px of width and scaled
  between, so resizing a window doesn't refit it every frame. The terminals can't measure before
  they lay out: there the widget is its own width.
- autoplay: true plays while the video's picture shows (Backend::item_visible, ImGui's
  IsItemVisible), until the user or the document plays or pauses it: scrolled out of view it
  pauses, back in view it plays on. A feed's videos no longer all play at once.
- text: takes emoji:, a state key holding a map of shortcode names to picture URIs. A :name: the
  map names is drawn as that picture, one line tall, where the backend can put a picture in a line
  (Backend::text_runs; ImGui does). Shortcodes are found as txwtf, Slack and Mastodon find them,
  so 14:50:47 stays a time. Terminals keep the text.
- Capability tokens image.fill and text.emoji; the schema takes a size: map or string, max_height
  and emoji.
…pictures move in the line

- A name whose value isn't a URI is replaced by that text in every backend: a unicode emoji's
  character, as txwtf gives 💯 for its standard emoji.
- An animated GIF or WebP in the line moves, as an image:'s does (tested); a video URL plays in
  the line as a decorative video (silent, looping, by itself).
- A terminal doesn't fetch or play an emoji picture it can't draw in a line.
In a sized window a slider in a table cell took all the width left on its line, so the player's
row (Play, the seek slider, Mute) pushed Mute out of the card. In a horizontal row with no
col_widths a slider now takes at most the 16 font sizes ImGui gives an auto-resizing window's
items.
@transfix

transfix commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Checked in a browser: a lean single-threaded arigl.wasm built from this branch's head (a7bb47b), on nicotina's page as stage.sh lays it out. It ran with nicotina's merged documents (cy-pca/nicotina#18, #19) against tests/stub_txwtf.py on another origin behind a CORS proxy, with the deploy's CSP plus media-src, driven in headless Chrome:

  • the first card's picture and video fill the card (630 px) at their own shapes;
  • the video autoplays muted and plays to its end;
  • the player row shows Play, a bounded seek slider and Mute inside the card;
  • post 304 draws its custom :gear: (/social/emojis/12/image) in the line, and 14:50:47 stays a time;
  • its :100: becomes 💯, which draws as ?: the browser build's font is ASCII-only, and imgui's ImWchar is 16-bit. That is the next PR (imgui with 32-bit characters, FreeType colour glyphs, a bundled Twemoji).

The read-lane budget (30 ms a frame for every visible_when, enabled_when and computed bind)
skipped what came after it in a slow frame, and a skipped visible_when hid its widget for that
frame: nicotina's feed in the browser, ten cards of several predicates each, flickered its last
cards' pictures. A skipped visible_when / enabled_when / disabled_when now keeps the value it had
last frame (as a repeat count already did); one that never ran stays fail-safe.
Runtime::set_reactive_frame_budget sets the budget (a host on a slow device; the test), and an
engine made mid-frame takes it.
@transfix
transfix merged commit 1828c45 into master Nov 8, 2026
28 of 29 checks passed
@transfix
transfix deleted the feat/ariadne-fill-width-inline-pictures branch November 8, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant