Skip to content

HUD plugins: the caption band as a value through every caption reader - #1148

Merged
GLinnik21 merged 2 commits into
mainfrom
hud/pr4-hudband
Oct 29, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
hud/pr4-hudband

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

PR4 of the player-HUD plugin plan (docs/hud-plugins.md, "Captions: the band a HUD occupies", F28, D8). Captions' lift was three constants that every caption reader read directly. It is now one value, HudBand, that the layout reports and every reader takes as an argument. It changes no frame of classic.

What changes

  • media/src/player/text_style.rs: HudBand { ceil_y, controls_top_y, lift }. One constructor, HudBand::from_controls_top(y), derives ceil_y = y - CAPTION_INK_CLEARANCE (12 px) and lift = SUB_BASE_Y - ceil_y. HudBand::CLASSIC is that constructor's value for classic's row: controls_top_y 792, ceil_y 780, lift 200, pinned by a test against today's numbers. SUB_CEIL_Y and HUD_LIFT are gone; HUD_CONTROLS_TOP_Y is now private and is CLASSIC's only input. Media still names nothing above it.

  • Every reader takes the band as an argument. The sites the grep found, re-found after PR2's split:

    Reader Where Was
    today_baseline, today_ink_baseline media/.../text_style.rs SUB_CEIL_Y
    caption_geometry, caption_geometry_for, draw_subtitle_message appkit/.../player_hud/mod.rs SUB_CEIL_Y
    hud_lift, overhangs, draw_subtitle_bitmap appkit/.../player_hud/mod.rs SUB_CEIL_Y
    lift_dys, AssSubtitles::draw (the libass lift) screens/src/player/ass_subtitles.rs HUD_LIFT
    BTN_Y (classic's row top) appkit/.../player_hud/classic.rs HUD_CONTROLS_TOP_Y
    synth test native_hud_up_deep_marks_clear_the_transport_controls, and the ink-baseline synth test media/.../ass/tests/synth.rs HUD_LIFT, HUD_CONTROLS_TOP_Y
    tie, lift and layout tests appkit/.../player_hud/tests.rs, screens/.../ass_subtitles.rs, text_style.rs the constants

    The comment in plex/src/plex/session.rs that named SUB_CEIL_Y is reworded.

  • HudGeometry::band() (appkit/.../geometry.rs) returns HudBand::from_controls_top(row_anchor.top): the compact row's top, which is where the Skip and Up Next stand-ins land too, so it is the same in every slot. For classic that is HudBand::CLASSIC. PlayerScreen::draw reads it from classic::frame_geometry() (no measuring) each frame and passes it to the libass lift, the text caption draw and the bitmap lift, so the band is a value from the layout, not a global. classic::BTN_Y is HudBand::CLASSIC.controls_top_y, so 792 is written once.

  • player_hud::min_controls_top_y(): the highest controls_top_y for which a caption block of CAPTION_ANCHOR_LINES lines at the largest SubtitleSize and the highest SubtitlePosition still fits between SAFE's top and the lifted baseline. It is a plain fn over caption_layout, size_scale and position_lift (it reads the ladders for "largest" and "highest"), not a lazy static. The real number is 646: 54 + 3 x 48 x 1.8 + 320 + 12 = 645.2, rounded up to a whole pixel so the bound is never optimistic (the plan's estimate was ~645). Its name does not match MAX_*, so ci/list-caps.ini needs no row.

Why

D8 makes the band a per-package value derived from the compact state. The compiler (PR5c) and the renderer (PR7) can only supply one if every F28 reader takes it instead of reading a constant. This PR does that with classic as the only producer, so the swap is mechanical later and nothing about classic can move now.

Grep after the change

grep -rn 'SUB_CEIL_Y\|HUD_CONTROLS_TOP_Y\|HUD_LIFT' rust-modules:

rust-modules/media/src/player/text_style.rs:57:const HUD_CONTROLS_TOP_Y: f32 = SCR_H - 288.0;
rust-modules/media/src/player/text_style.rs:91:    pub const CLASSIC: Self = Self::from_controls_top(HUD_CONTROLS_TOP_Y);
rust-modules/media/src/player/text_style.rs:325:        assert_eq!(HUD_CONTROLS_TOP_Y, 792.0);
rust-modules/media/src/player/text_style.rs:326:        assert_eq!(HudBand::CLASSIC, HudBand::from_controls_top(HUD_CONTROLS_TOP_Y));

That is the constant, CLASSIC's construction and its pin; no other reader names them.

Tests

  • Classic unchanged in meaning: classic_band_is_todays_constants pins HudBand::CLASSIC == { ceil_y: 780, controls_top_y: 792, lift: 200 }; the existing tie tests (today_baseline_is_the_old_geometry, text_style_baseline_ties_to_caption_geometry_and_layout, bottom_cues_rise_exactly_the_hud_lift_at_every_position_and_size, the image-lift tests) pass for CLASSIC, and the tie test runs again for from_controls_top(700).
  • A non-classic band: a_non_classic_band_moves_the_lifted_caption_by_its_difference (media and appkit), image_sub_lift_follows_the_band, bottom_cues_rise_exactly_the_bands_lift_for_a_non_classic_band (libass lift): the baseline, the floor, the ink row, the image lift and the libass lift move by exactly the 92 px difference between from_controls_top(700) and classic's band; the HUD-down placement does not move.
  • Red first. With each reader temporarily ignoring its band argument (let band = HudBand::CLASSIC;), the five band tests fail (left: 0.0 right: 92.0, and min_controls_top_y_is_where_the_largest_block_just_fits at its "one px higher does not" line); they pass once the readers use it. The temporary lines are not in the commit.
  • The bound: min_controls_top_y_is_where_the_largest_block_just_fits pins 646; a band at it keeps the largest block inside SAFE through caption_geometry_for, and one px higher does not. hud_lift and the libass lift clamp the block on screen (their clamp is to the screen, not to SAFE), and the libass block sits 3 px lower (INK_TRIM) than the bespoke one, so the bespoke draw is the binding one; the tests assert on-screen at the bound for both and that relationship, not a "one px higher fails" they cannot show.
  • the_layouts_band_is_classics_in_every_slot: HudGeometry::band() is HudBand::CLASSIC from frame_geometry() and from geometry() in all four slot states.
  • native_hud_up_deep_marks_clear_the_transport_controls is #[ignore] (it needs the native libass artifact); it now loops over classic's band and from_controls_top(700). It is band-invariant by construction (lift follows the ceiling), so it is not run here.

Issue

No issue tracks the HUD-plugin work; none was opened for this PR.

Gates

Local, on the committed tree (git status --short empty), crate tests only; CI is the full gate:

  • make test-crate C=plx_media: test result: ok. 1960 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 40.08s
  • make test-hostsim C=plx_media: test result: ok. 2183 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 64.70s
  • make test-crate C='plx_appkit plx_screens': test result: ok. 549 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.21s (plx_appkit), three test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; ... 1759 filtered out; finished in 0.00s lines, then test result: ok. 1760 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 26.96s (plx_screens)

Not run here, left to CI: make check, make check-nodef, the ARM build. No TV or simulator pass: no frame of classic changes, and HudBand::CLASSIC is pinned equal to the constants it replaces.

🤖 Generated with Claude Code

Review

Head 20c9a8773. origin/main had not moved (git log HEAD..origin/main empty), so no merge was needed. The review's verdict was MERGE with one finding.

  1. MINOR, two "at the bound" assertions passed whether or not the reader used the band: fixed (cheap and certain). The reviewer was right: with classic's ceiling the image block's top stayed at ~400 and the libass block's at ~204, both inside SAFE. The tests now also assert what ties each reader to the band: hud_lift lands the block's bottom on the band's ceiling (close(bottom - lift, band.ceil_y) at the bound and one px past it), and the libass block rises by exactly band.lift (assert_eq!(lifted, top - band.lift)). The clamp lines are commented as testing the clamp, not the bound. Red check: with hud_lift/overhangs and lift_dys temporarily forced to HudBand::CLASSIC, min_controls_top_y_is_where_the_largest_block_just_fits fails (bottom on the ceiling) and the_libass_lift_keeps_the_largest_block_on_screen_at_the_bound fails (the rise is the band's lift, left: 203.80002); they pass with the readers restored. The temporary lines are not in the commit.

Required checks, re-run on the committed tree (git status --short empty):

  • make test-crate C=plx_media: test result: ok. 1960 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 42.12s
  • make test-hostsim C=plx_media: test result: ok. 2183 passed; 0 failed; 78 ignored; 0 measured; 0 filtered out; finished in 65.04s
  • make test-crate C='plx_appkit plx_screens': test result: ok. 549 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 15.04s (plx_appkit), three test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; ... 1759 filtered out; finished in 0.00s lines, then test result: ok. 1760 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 36.73s (plx_screens)

GLinnik21 and others added 2 commits October 30, 2026 01:42
The ceiling a lifted caption is held under, the top of the control row and the
distance a text caption rises were three constants (SUB_CEIL_Y, HUD_CONTROLS_TOP_Y,
HUD_LIFT) that each caption reader read directly. They are now one value,
text_style::HudBand { ceil_y, controls_top_y, lift }, built by a single
constructor, HudBand::from_controls_top (ceil_y = controls_top_y - 12,
lift = SUB_BASE_Y - ceil_y). HudBand::CLASSIC is that constructor's value for
classic's row (792, 780, 200) and is pinned against today's numbers.

Every reader takes the band as an argument: today_baseline and
today_ink_baseline, caption_geometry_for, hud_lift/overhangs, the libass lift
(lift_dys) and the synth test. HudGeometry::band() returns the band a layout
occupies, the compact row's top, which is classic's in every slot; the player
screen reads it from classic::frame_geometry() each frame and passes it to the
caption draw, the bitmap lift and the libass lift. classic's row top (BTN_Y) is
now HudBand::CLASSIC.controls_top_y, so the number exists in one place.

player_hud::min_controls_top_y() is the highest row top for which the largest
caption block (three lines, Huge, High) still fits inside SAFE: 646 px (645.2
rounded up to a whole pixel). A plain fn over caption_layout, size_scale and
position_lift, not a global.

No frame of classic changes: captions sit where they sat in every state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t ignores the band

The "at the bound" assertions for the image lift and the libass lift passed
whether or not the reader used the band: with classic's numbers the block's top
was still inside SAFE. They now assert what ties each reader to the band (the
image block's bottom lands on the band's ceiling; the libass block rises by
exactly band.lift) next to the on-screen check, and the clamp lines say they test
the clamp, not the bound. Both fail with the reader neutered to classic's band.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 marked this pull request as ready for review October 29, 2026 22:59
@GLinnik21
GLinnik21 merged commit c0b61df into main Oct 29, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the hud/pr4-hudband branch October 29, 2026 23:08
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