Repository navigation
HUD plugins: the layout compiler; classic compiles to the hand-written layout's geometry - #1151
Merged
Merged
Conversation
… state, and classic compiles to exactly the hand-written layout
`hud_format::compile::compile(&Package, &dyn Measure, CompileCtx) -> Compiled` lays a parsed package
out once in every state `reach` enumerates (it iterates `Layout::valuations` / `Layout::explore` and
evaluates `when` with `Layout::holds`, so there is no second state walk and no second condition
evaluator). A `CompiledState` carries the rect of every control keyed by id, a flat draw list in draw
order, the scrim, the bands, the bar and grab rects and the stand-ins, and
`Compiled::geometry(state, SkipKind) -> HudGeometry` is the one geometry type the player reads.
`Compiled::band()` is `HudBand::from_controls_top` over the compact states (classic is
`HudBand::CLASSIC`). Per state the compiler REPORTS a cost (draw ops, glyph runs, texture bytes,
blended pixel area, the three largest contributors); nothing enforces it, the ceilings are
calibrated on the television later. `CompileKey` is the cache key's type only.
Text is measured through the existing `plx_machine::machine::Measure`, the capability
`classic::geometry` takes; the compiler defines no measurer. Widths come from the same widget
functions the hand-written layout calls, and two values classic computed privately are now exposed
with no frame change: `classic::stand_in_w` (the stand-in pill formula `ctrl_slot_measure` used) and
`up_next::layout_at` (`layout_of` over any row anchor). `reach`'s `Slot`, `State`, `Valuation` and
`Layout` are published to the sibling compiler without a semantic change, and `title_right`,
`info_panel::{card_geometry, button_rect}` and `chapters_panel::{card_rect, label_ys}` widen to
`pub(crate)` for the golden.
`compiled_classic_matches_the_hand_written_layout` compares the compiled classic package with
`classic::geometry` field for field and to the exact f32, in every compact slot (Discs, Up Next, Skip
at both labels), for a movie and an episode, with and without chapters, in all ten shipped languages,
under both `FixtureMeasure` and `ShippedMeasure`. The info section matches `info_panel`'s card, still
and buttons; the chapters strip matches `chapters_panel`'s cards but for its top, which sits one
CAPTION line higher because the timestamp is a line with a height in the compiled chain (the fixture's
chapters gap is the placeholder; the delta is pinned, not forced). Every fixture compiles in every
state with its controls inside the canvas, and the state counts are `reach`'s (classic 18, reference
6, minimal 3). The prose that named PR5c as the lint flag's PR now names PR5d.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Brings in PR3 (#1150: command vocabulary, control identity, the shared performer), which touched up_next.rs and player_hud/. No conflict. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The compiled-vs-hand-written golden now checks its comparison count exactly (10 languages x 2 measurers x movie/episode x with/without chapters x 4 slots = 320), so a loop that quietly compares less cannot pass. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… stand-ins, one band Fixes the review of #1151 (FIX FIRST) in one round: - check-localization: the compiler's rect fields are bound to locals before the struct initialiser, so no `title:`/`caption:` initialiser names a format key. - transport.paused is an axis of the compile when a `when` or a number or gap names it (StateKey::paused); it never enters reach's valuations, so a package that does not name it keeps reach's state count (classic 18). Ink and bold keyed on it stay Live. - item.* is the strip card's: a card's cell keeps its room and is present per card as a Live<bool> (CardOp::present); an ink or bold keyed on one stays Live. A number or gap keyed on one is a CompileFinding (PR5d registers its code), never a silent default. - Up Next, the Skip pill and Standin::row anchor an end-aligned offer on the end edge of the replaced segments, not the band's. - A Skip state carries the title laid out for the other pill too (skip_variant), so the fill stops at the label actually shown, as classic::title_right does. - The band counts the bar with its largest (focused) knob and is one field of HudGeometry, filled by classic from its row anchor and by the compiler from its extents; band() reads the field. - Compiled keeps every row control in `controls` and `row_ids`; the report's BTN_N = 5 slots are PR7's to widen (commented at the zip). - max_lines and genres_max read through the keyed-value resolver like every other keyable number. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…in list-caps Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
marked this pull request as ready for review
October 30, 2026 01:07
GLinnik21
added a commit
to LovelessCodes/plx-native
that referenced
this pull request
Oct 31, 2026
Main landed the HUD plugin work (plxnative#1151, plxnative#1153, plxnative#1154): the layout compiler, the lint and one renderer drawing from the embedded builtin:classic package. The hand-written classic draw this PR edited is gone, so the Skip pill joining the transport row now lives in the compiled layout. - classic.rs, motion.rs: main's versions. The PR's join_slot / draw_discs / icon_hit edits targeted code main deleted; their behaviour is carried by the compiler (`layout.up_next.joins`, set by builtin:classic) and state.rs. - hud_format/compile.rs: a joined Skip state keeps the five disc stops from the package row and puts the pill at items[BTN_SKIP], a CONTROL_GAP left of the run. A package that does not set `joins` still replaces the row. - player_hud/geometry.rs: frame_state looks the Skip state up with the episode pair; row_len / row_command / row_enabled / row_primary treat a Skip pill that replaces the row as the row's one stop; new row_joined. - player_hud/render.rs, skip_pill.rs: the Disc widget draws under a Skip slot; the SkipPill widget draws at its own ordinal when joined. - player/mod.rs: neighbour walks ControlSlot::travel when the pill is joined. - Re-recorded the Skip rows of the three frozen goldens (geometry, title-right, census). Every non-Skip line is byte-identical. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
PR5c of the player-HUD plugin plan (
docs/hud-plugins.md, "Architecture", "Package format 1.0", "Cost", "Captions: the band a HUD occupies").hud_formatcould parse a package and prove its reachability; it could not lay one out. This PR adds the layout compiler, and proves it on the one package whose answer is already known: classic, compiled, reports the same rects as the hand-written layout (the geometry report; the chapters strip's top is the one pinned delta, below). It changes no frame of classic and draws nothing.What changes
appkit/src/hud_format/compile.rs(new, pure):compile(&Package, &dyn Measure, CompileCtx) -> Compiled.reach's. The compiler iteratesLayout::valuationsandLayout::exploreand evaluates everywhenwithLayout::holds, so there is no second state walk and no second condition evaluator: the state count isreach's (classic 18, reference 6, minimal 3). The one addition istransport.paused, an axis only when the package names it in awhenor in a number or gap (see "Review fixes").reach.rspublishesSlot,State,ValuationandLayoutto its sibling with no semantic change.CompiledStatecarries the rect of every control keyed by id, a flatVec<DrawOp>in draw order (scrim, then the bands inzorder: text, image, icon, rule, ground, facts, playbar, strip, control, the Up Next offer, the Skip pill), the scrim, the band boxes, the bar and grab rects, and the stand-ins.Compiled::geometry(state, SkipKind) -> Option<HudGeometry>is the one geometry type the player reads (grab band, bar, row andRowAnchor, items, tab row, title, tabs, band).Compiled::band() -> HudBandisHudBand::from_controls_topover the compact states of every valuation, slot and pause: interactive extents (controls, the stand-ins, the bar WITH its largest knob, the tabs) underband: controls, every drawn extent but the scrim underband: block. Classic isHudBand::CLASSIC, pinned. It is also thebandfield of everyHudGeometrythe package reports.CompileKey { sha256, app_version, lang }is the cache key's type only: no cache, no store, no global, no hashing.plx_machine::machine::Measure, the capabilityclassic::geometry(.., &dyn Measure)takes (TtfMeasure,TableMeasure,FixtureMeasure). The compiler defines no measurer and implements none.classic::stand_in_w(advance, floor): the stand-in pill formulactrl_slot_measureused (advance + 2 * 34, never belowfloor). The float result is identical.up_next::layout_at(anchor, next_w, credits_w):layout_ofover any row anchor;layout_ofis nowlayout_at(frame_geometry().row_anchor, ..).pub(crate)for the golden:title_right,info_panel::{card_geometry, button_rect},chapters_panel::{card_rect, label_ys}.HudGeometrycarries the caption band as a field (review fix 5):classic::frame_geometryfills it from its row anchor exactly asband()computed it (no frame change), the compiler from the compiled extents, andband()reads the field.HudGeometryno longer derivesDefault(it had no user).hud_format.rs's module doc no longer says the compiler is wave B's, andreport.rs/schema_emit.rsname PR5d (not PR5c) as the lint and schema flags' PR.Why
The compiler is the piece PR7 renders from and PR5d lints with. The risk is a layout that is subtly not classic's; the golden de-risks that before anything draws.
Mismatches and their fixes
None in the geometry.
compiled_classic_matches_the_hand_written_layoutpassed on its first run: 320 comparisons (10 shipped languages x 2 measurers x movie/episode x with/without chapters x Discs, Up Next, Skip at both labels), each over all 13 rects ofHudGeometry(grab, bar, row, anchor, five items, tab row, title, two tabs), every one the exact f32; the test asserts the count. That is a statement about the compiler's rules, so the test is made to discriminate: with the Skip/Up Next floor temporarily removed from the compiler it fails with 180 mismatches (the row and the Skip pill,compiled x=1616 w=208againsthand-written x=1592 w=232). The temporary line is not in the commit.What the compiler needed to reproduce classic (the rules the format's prose leaves to the compiler, now in
compile.rs's module doc and tests):VStackanchored at the safe area's bottom minusinset, and a band'sgap_beforeis the gap to the band above. That alone gives classic's 1013 / 949 / 890 / 882 / 856 / 792 / 768 chain.w: fillruns to the nearest left edge of a later group's present cell scaled byCTRL_FOCUS_SCALE, minus the band gap: that isclassic::title_right, and tests pin the compiled title's right edge to it, in a Skip state for the label actually shown.up_next.alignnames (an end-aligned offer on the END of the replaced segments, not the band's); their floor is the replaced segment's width with every absentable item collapsed (232 for classic), so the transport does not jump when a segment begins.The chapters strip. The compiled strip matches
chapters_panel's card size and pitch, and the name and timestamp sit 26 and 34 px under it aschapters_panel::label_yshas them (pinned), but the strip sits one CAPTION line (28.8 px withFixtureMeasure) aboveCH_TOP: the timestamp is a line with a height in the compiled chain, while the hand-written layout places it by origin. The fixture's chaptersgap_before(43) is the PR5b placeholder; the value that reproducesCH_TOPis43 - line_h(CAPTION), measurer-dependent. The test pins the delta (to a thousandth of a pixel) rather than forcing it. PR7 or the fixture's owner decides.Decisions and deviations from the brief
Measuretrait (brief item 1 as written said to define one): the coordinator's correction applies, and the existingplx_machine::machine::Measureis used.Compiled::geometry(key, SkipKind) -> Option<HudGeometry>, where the brief wrotegeometry(state) -> HudGeometry. Skip has two labels and so two widths; a key the package cannot reach has no state. A Skip state carries the layout for the other label too (CompiledState::skip_variant(kind)), because the host band's start-aligned fills (the title) stop at the pill actually shown.AppLabelsis plain data inCompileCtx; the app builds it from the viewer's language (a different language is a different compile, which is whatCompileKey::langis for). There is no production constructor here: the tests build it fromi18n::msg, and PR7 owns the real one. A pill or button whose command has no label measures its padding only.title.is_episodeis false. A reach gap to report, not fixed here (deferred to PR5d,reach.rs): a package that places previous/next without namingtitle.is_episode(the reference) has one valuation, so it has no movie-form compiled state and a movie playing under it would show them.reachcounting a placedprevious/nextas naming the condition would give it a movie valuation (about 12 states instead of 6).band: controls(hero-center's band is the top of the focused knob's glow,KNOB_GLOW_R= 17 above the track's middle).!sectionsbands are absent there), whereclassic::frame_geometryreports them always. Only the compact states are held against the hand-written layout, as the brief asks.ShippedMeasure(plx_base::fontcov::advances) parses the shipped fonts itself and runs headless undermake test-crate, so the golden uses the real fonts as well asFixtureMeasure.Review fixes
The review of the first head (
5f0101dff) returned FIX FIRST. Each finding, and what was done:check-localizationred. The checker follows simpleletbindings intotitle:/caption:initialisers; the compiler's RECT fields (title,caption) were built inline from format key names. They are now bound to locals first and the struct uses the shorthand. The checker and its ledgers are untouched.python3 ci/check-localization.pyexits 0.transport.pausedis a compile AXIS whenever awhenor a number or gap names it (StateKey::paused,Compiled::lookup(.., paused)): every state is compiled twice and the renderer picks per frame. It never entersreach's valuations (R1 counts it as holding either way), so a package that does not name it keepsreach's count: classic stays 18, reference 6, minimal 3. An ink or bold keyed on it moves nothing and staysLive.item.*is the strip card's. A card's cell keeps its room on every card; whether a card DRAWS it is aLive<bool>over the cell'sitem.*terms (CardOp::present, with the negation applied byLive::at). An ink or bold keyed on anitem.*term staysLive. A NUMBER or GAP keyed on one cannot be (a layout per card): the base value applies andCompiled::findings()reports aCompileFinding { pointer, term, message }. That finding is NOT a registered code: PR5d adds one (the06xxfamily) and prints it with the other lint findings.item.*terms are lenient inwhen, treated true"; "transport.pausedis not a state dimension") was wrong and is corrected here and in the handoff.when: item.is_current) is present for the current card only; an item-gated cell under the art is present per card and keeps its room; atitleband withwhen: transport.pausedis present exactly in the paused states (12 states, twice the 6); a gap keyed ontransport.pausedmoves the title and nothing else, and only while paused; classic, reference, palette and hero-center keepreach's counts; a gap keyed onitem.focusedis a finding and lays out as the base.align: endanchored on the band's edge. Up Next, the Skip pill andStandin::rownow anchor onunion.x + union.w, the end edge of the replaced segments. Test: a band[end: row (replaced), end: menu]; the offer ends at the replaced row's end and does not overlapmenu. Classic has no segment after the row, so its 320-comparison golden is unchanged.CompiledState::skip_variant(SkipKind),skip_altfor the credits layout when it differs). Test: the title's right edge againstclassic::title_rightfor both labels in all ten languages, under both measurers.top()takes the bar's top as the focused knob's glow (classic::KNOB_GLOW_R= 17, a named constant now shared withdraw_playbar) above the track's middle, so the band never moves with focus. Classic staysHudBand::CLASSIC(pinned). Hero-center is re-pinned totrack.y + track.h / 2 - 17(was the track's top), with the arithmetic in the test.HudGeometryhas abandfield;classic::frame_geometryfills it from its row anchor exactly as before; the compiler fills it from the compiled extents;HudGeometry::band()reads it. A test asserts the geometry's band equalsCompiled::band()for every state of every fixture, both skip kinds. Every existing band pin is green.BTN_N.HudGeometry::itemsholdsBTN_N= 5 stops (classic's row); the reference has 9 and R1 guarantees More.Compiledkeeps all of them:controlsandrow_idshold every control, and a test asserts the reference's nine. The zip intoitemscarries a comment naming the PR7 obligation (widen the report to the longest row a package can place). PR7 must do this (see the handoff's "What PR7 needs").label_yswas widened for the golden but unread. The chapters test now compares the strip template's name and time text y withchapters_panel::label_ys()(26 / 34 under the card), to a thousandth of a pixel. Shown live by shifting the expected value by 1 px: the test fails.Also:
max_linesandgenres_maxwere read without the keyed-value resolver (a keyed value read as 0 / 1); they go through it like every other keyable number.Known edge, named not fixed: a keyable number that is really a PAINT-like scalar,
text.alpha, is classified as geometry. Keyed onitem.*it reports the finding (whose wording says "laid out once for every card"); keyed ontransport.pausedit makes paused an axis. No fixture keys it. WideningDrawOp::Text::alphatoLive<f32>is PR5d's call if the lint wants it.Tests
compile_tests.rs(31 tests): the golden (above); the title's right edge againsttitle_right(Discs, Up Next, and Skip at each label in all ten languages);band() == HudBand::CLASSICunder both measurers; the state counts againstcheck(18 / 6 / 3); all six fixtures compile in every state, in every shipped language, under both measurers, with controls, bands, bar and grab inside the canvas and the count equal tocheck(..).states; the info section againstinfo_panel; the chapters strip againstchapters_panel(the delta above, and the 26 / 34 name and time offsets); classic's compact cost pinned and the strip's visible-card count (6);Livevalues; an unreachable state has no geometry; the Skip pill is end-anchored at both widths in every language; a centred offer stays centred on what it replaces (the reference); the replaced segments leave the frame but not the layout; a different label is a different width;band: blockagainstband: controls; compiling twice is one value;CompileKeyis a plain value; and the ten tests the review fixes added (equaliser per card, item-gated cell per card, paused band, paused gap, classic's counts, item-keyed finding, end-anchored offer beside a menu, one band value, the reference's nine controls, the Skip title per label), plus thelabel_ysoffsets in the chapters test.Issue
No issue tracks the HUD-plugin work; none was opened for this PR.
Gates
Local, on the final head
6d337288b(committed tree,git status --shortempty after the runs,origin/mainalready an ancestor). Crate tests only; CI is the full gate:make test-crate C=plx_appkit T=hud_format:test result: ok. 210 passed; 0 failed; 0 ignored; 0 measured; 378 filtered out; finished in 5.40smake test-crate C=plx_appkit T=player_hud:test result: ok. 73 passed; 0 failed; 0 ignored; 0 measured; 515 filtered out; finished in 8.40spython3 ci/check-localization.py: exit 0 ("Localization inventory: product text boundaries passed")T=up_next(7 passed),T=info_panel(17 passed),T=chapters_panel(6 passed),T=skip_pill(2 passed),python3 ci/check-module-layers.pyandbash ci/check-deps.sh(all gates green).Not run here, left to CI:
make check,make check-nodef, the ARM build, and any crate downstream ofplx_appkit(HudGeometrylostDefaultand gained the requiredbandfield; a search found no constructor outsideclassic.rs). No TV or simulator pass: classic's frames do not change (stand_in_wandlayout_atare the old expressions moved, andbandis filled asband()computed it), and nothing draws from the compiled value yet.🤖 Generated with Claude Code