Repository navigation
Ariadne: pictures and players that fill the width, autoplay in view, and :shortcode: pictures in text - #1052
Merged
Conversation
…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.
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
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:andvideo: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 withinh, drawn narrower instead: a phone's portrait video in a feed.Backend::available_width.(has? "term").autoplay in view
autoplay: trueplays while the video's picture shows (the newBackend::item_visible, which is ImGui'sIsItemVisible). 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 writesplaying. A feed's videos no longer all play at once.:shortcode:pictures in text:emoji:text:takesemoji:, a state key holding a map of shortcode names to picture URIs, or to text.:name:mapped to a URI is drawn as that picture, one line tall at its own shape, through the newBackend::text_runs(ImGui draws them). A GIF or WebP animates, and a video URL plays as a silent loop. Hovering one shows its:name:.:name:mapped to text is replaced by it in every backend. That is a unicode emoji's character: txwtf'scontent_htmlgives:100:as 💯.[A-Za-z0-9_+-]between colons that aren't glued to a word character, so14:50:47stays a time.:name:as text, and don't fetch it.A predicate the frame's budget skips keeps last frame's answer
Every
visible_when,enabled_whenand 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 skippedvisible_whenhid its widget for that frame, so the last cards flickered. The console said "skipped — per-frame budget exhausted" for card 7's predicates.visible_when/enabled_when/disabled_whennow keeps last frame's value, as a repeat count already did. One that never ran stays fail-safe (hidden or disabled).Runtime::set_reactive_frame_budgetsets it, for a host on a slow device and for the test. An engine created mid-frame takes it too.AriadneReactiveBudget.ASkippedPredicateKeepsLastFramesAnswer.Other changes
image.fillandtext.emoji.size:map or string,max_heightandemoji.Checked (Windows, MSVC, shared)
ariadne_media_test: 41 passed, 2 skipped, the skips being the FTXUI ones this build lacks. The new tests:max_height, with a portrait PNG;ariadne_loader_test: 222 passed;ariadne_requires_test: 18;ariadne_host_test: 46;cvcgl_imgui_media: passes.arigl snapshotof a test document, with a window fitting a 70-character row::100:and an unmapped:nope:.Not run here:
cvcgl_ari_goldencan't load its GL DLLs on this box) and the FTXUI suites. CI runs them.