fix(slint): immersive Coverflow z-order + ghost (left/right repeaters, no per-element z)

Slint 1.16 has no per-element z-index (paint order = model/child order), so a
single Repeater painted the right (upcoming) side near->far = far covers on top
(disordered), and it also drew a ghost center card under the dedicated one.

- Split the fan into a LEFT Repeater (forward coverflow-tracks: paints
  far-left->near-left, near on top) and a RIGHT Repeater over a new reversed
  model coverflow-tracks-rev (walks far-upcoming->near-upcoming, near on top).
  Both compute offset from the original flat index so geometry matches and the
  ±0.5 hand-off during a slide is seamless. Center band owned solely by the
  dedicated top card -> no ghost.
- coverflow-tracks-rev is built only under the same id-sequence-hash rebuild
  gate (no churn on advance) by cloning+reversing the forward QueueItems, so a
  track's element holds the SAME decoded image on both lists: no source
  reassignment on advance (no spike), and the animated `scroll` slide is intact.
- 3 past + center + 3 upcoming, mirror POSITIONS (scale/dim by |offset| only;
  no reflection). Nav mapping (play-history / play-coverflow-upcoming) preserved.

cc
This commit is contained in:
vicrodh committed 2026-06-14 03:04:33 -06:00
1 parent d00ec1fa71
commit 421e84c571
3 files changed
+103 -24

No files matched your search

+26 -1
View File
@@ -443,7 +443,18 @@ impl QueueController {
.iter() .iter()
.map(|r| to_item_reuse(r, &prior_all)) .map(|r| to_item_reuse(r, &prior_all))
.collect(); .collect();
// The reversed model: same QueueItems (so a track's element holds
// the SAME decoded handle on both sides — no extra decode), just
// in reverse order. The RIGHT Repeater iterates THIS so it paints
// far-upcoming -> near-upcoming, putting the nearer cover on top.
// Rebuilt under the SAME seq gate as the forward model, so a pure
// advance never touches it either.
let mut cf_items_rev = cf_items.clone();
cf_items_rev.reverse();
qs.set_coverflow_tracks(slint::ModelRc::new(slint::VecModel::from(cf_items))); qs.set_coverflow_tracks(slint::ModelRc::new(slint::VecModel::from(cf_items)));
qs.set_coverflow_tracks_rev(slint::ModelRc::new(slint::VecModel::from(
cf_items_rev,
)));
qs.set_coverflow_seq_hash(coverflow_seq_hash as i32); qs.set_coverflow_seq_hash(coverflow_seq_hash as i32);
log::debug!( log::debug!(
"[coverflow-perf] rebuild seq={coverflow_seq_hash} len={} idx={coverflow_index}", "[coverflow-perf] rebuild seq={coverflow_seq_hash} len={} idx={coverflow_index}",
@@ -1075,12 +1086,26 @@ fn apply_queue_art(win: &AppWindow, target: ArtTarget, img: slint::Image) {
ArtTarget::CoverflowFlat(idx) => { ArtTarget::CoverflowFlat(idx) => {
let items = qs.get_coverflow_tracks(); let items = qs.get_coverflow_tracks();
if let Some(mut item) = items.row_data(idx) { if let Some(mut item) = items.row_data(idx) {
item.artwork = img; item.artwork = img.clone();
// set_row_data on a SINGLE flat row — does NOT replace the // set_row_data on a SINGLE flat row — does NOT replace the
// VecModel, so the Repeater is not rebuilt and the other covers' // VecModel, so the Repeater is not rebuilt and the other covers'
// sources are untouched. Only this one cell's image changes. // sources are untouched. Only this one cell's image changes.
items.set_row_data(idx, item); items.set_row_data(idx, item);
} }
// Mirror the decode onto the reversed model used by the RIGHT
// Repeater. The reversed model is the forward list reversed, so the
// same track sits at `len-1-idx`. Updating a single row here (not
// replacing the VecModel) keeps that Repeater stable too — no rebuild,
// no churn — it just fills in the same cover the forward side got.
let rev = qs.get_coverflow_tracks_rev();
let rev_len = rev.row_count();
if rev_len > 0 && idx < rev_len {
let rev_idx = rev_len - 1 - idx;
if let Some(mut item) = rev.row_data(rev_idx) {
item.artwork = img;
rev.set_row_data(rev_idx, item);
}
}
} }
} }
} }
@@ -100,18 +100,27 @@ component CoverCard inherits Rectangle {
in property <length> stage-cx; // window-x of the center in property <length> stage-cx; // window-x of the center
in property <length> stage-height; in property <length> stage-height;
in property <bool> interactive: false; in property <bool> interactive: false;
// Whether THIS card is the one responsible for painting its slot. The fan is
// split into a LEFT Repeater (forward model) and a RIGHT Repeater (reversed
// model) plus a dedicated center card; each repeater card sets this true only
// for its own side's offset window so a slot is never double-drawn (GHOST FIX
// + symmetric Z-ORDER). Defaults true for the standalone center card.
in property <bool> paint-side: true;
callback navigate(); callback navigate();
property <float> ao: Math.abs(root.offset); property <float> ao: Math.abs(root.offset);
// Step-down scale: center 1.0 -> ~0.5 at |offset| >= ~2.8. // Step-down scale: center 1.0 -> ~0.5 at |offset| >= ~2.8. Symmetric: depends
// only on |offset|, so a left and right card at the same |offset| match.
property <float> scale: Math.max(0.5, 1.0 - 0.18 * root.ao); property <float> scale: Math.max(0.5, 1.0 - 0.18 * root.ao);
property <length> slot: root.base-art * root.scale; property <length> slot: root.base-art * root.scale;
// Per-depth black overlay: 0 at center, up to 0.55 outward. // Per-depth black overlay: 0 at center, up to 0.55 outward. Symmetric in |offset|.
property <float> dim: Math.min(0.55, root.ao * 0.18); property <float> dim: Math.min(0.55, root.ao * 0.18);
// Only ~7 cards near the center paint; the rest are dropped (no texture // Only ~7 cards near the center paint; the rest are dropped (no texture cost
// cost from off-screen rows — visible:false stops painting). // from off-screen rows). A card paints only inside the ±3.2 clamp AND when it
visible: root.ao <= 3.2; // owns its side (paint-side) — the latter hides the center-index Repeater
// copies (ghost) and the opposite half.
visible: root.ao <= 3.2 && root.paint-side;
width: root.slot; width: root.slot;
height: root.slot; height: root.slot;
@@ -199,35 +208,68 @@ export component CoverflowPanel inherits Rectangle {
height: root.base-art + 56px; height: root.base-art + 56px;
property <length> cx: root.viewport-width / 2; property <length> cx: root.viewport-width / 2;
// Length of the flat model — used to map a reversed-model index back to
// the ORIGINAL flat index on the RIGHT side. Read once here (not `parent`
// in a card root binding, which Slint forbids).
property <int> cf-len: QueueState.coverflow-tracks.length;
// All side + far covers from the stable flat model. The center is drawn // --- LEFT (history) Repeater -------------------------------------
// separately (below) so it paints on top — a Repeater renders in data // Iterates the FORWARD model in ascending index, so it paints
// order and cannot reorder by |offset|. // far-left -> near-left: the near-left cover (highest left index) is
// declared last among the left cards => paints ON TOP. Correct as-is.
// Visible only for the history side: offset in (-3.5, -0.5) (strictly
// left of center; the center itself is the dedicated top card).
for item[i] in QueueState.coverflow-tracks: CoverCard { for item[i] in QueueState.coverflow-tracks: CoverCard {
offset: i - root.scroll; property <float> off: i - root.scroll;
offset: self.off;
base-art: root.base-art; base-art: root.base-art;
pitch: root.pitch; pitch: root.pitch;
stage-cx: parent.cx; stage-cx: parent.cx;
stage-height: parent.height; stage-height: parent.height;
art: item.artwork; art: item.artwork;
has-art: item.artwork.width > 0; has-art: item.artwork.width > 0;
// The center (i == current index) is drawn by the top instance; this // Left side only; hides the center-index card (GHOST FIX: the
// Repeater copy stays non-interactive and hides exactly at center so // dedicated center card below is the ONLY center cover) and the whole
// there is no double-draw flicker through the 320ms ease. // right half (the RIGHT Repeater owns it). The strict < -0.5 / > -3.5
interactive: i != root.center-idx; // window mirrors the right side's (0.5, 3.5).
paint-side: self.off < -0.5 && self.off > -3.5;
interactive: true;
navigate => { navigate => {
// Flat index -> queue-wide play call. Flat order is // i < center-idx -> a history cover. flat history is oldest-first
// [history.reversed (oldest-first) ++ NOW ++ upcoming], and // while QueueStateFull.history is most-recent-first, so
// center-idx = history.len(): // hist_index = center-idx - 1 - i.
// i < center-idx -> a history cover. flat history is
// oldest-first while QueueStateFull.history is most-recent-
// first, so hist_index = center-idx - 1 - i.
// i > center-idx -> an upcoming cover.
// up_index = i - center-idx - 1.
if (i < root.center-idx) { if (i < root.center-idx) {
QueueState.play-history(root.center-idx - 1 - i); QueueState.play-history(root.center-idx - 1 - i);
} else if (i > root.center-idx) { }
QueueState.play-coverflow-upcoming(i - root.center-idx - 1); }
}
// --- RIGHT (upcoming) Repeater -----------------------------------
// Iterates the REVERSED model. rev index `j` is original flat index
// `orig = cf-len - 1 - j`, so the loop walks orig = high..low, i.e.
// far-upcoming -> near-upcoming: the near-upcoming cover is declared last
// among the right cards => paints ON TOP (Z-ORDER FIX, symmetric with the
// left). Offset is computed from `orig` so x/scale/dim match the left
// side exactly; at the ±0.5 hand-off a track's left- and right-element
// share the SAME offset (= orig - scroll) -> seamless. Visible only for
// offset in (0.5, 3.5).
for item[j] in QueueState.coverflow-tracks-rev: CoverCard {
property <int> orig: parent.cf-len - 1 - j;
property <float> off: self.orig - root.scroll;
offset: self.off;
base-art: root.base-art;
pitch: root.pitch;
stage-cx: parent.cx;
stage-height: parent.height;
art: item.artwork;
has-art: item.artwork.width > 0;
paint-side: self.off > 0.5 && self.off < 3.5;
interactive: true;
navigate => {
// orig > center-idx -> an upcoming cover.
// up_index = orig - center-idx - 1.
if (self.orig > root.center-idx) {
QueueState.play-coverflow-upcoming(self.orig - root.center-idx - 1);
} }
} }
} }
+12
View File
@@ -3259,6 +3259,18 @@ export global QueueState {
// Image churn), so visible covers never re-decode. Windowed (±4) lazy decode // Image churn), so visible covers never re-decode. Windowed (±4) lazy decode
// keeps at most one new cover decoding per advance. // keeps at most one new cover decoding per advance.
in property <[QueueItem]> coverflow-tracks: []; in property <[QueueItem]> coverflow-tracks: [];
// The SAME flat model, REVERSED (last..first). Rebuilt under the same
// id-sequence gate as `coverflow-tracks` (so equally stable — never touched
// on a pure advance). The RIGHT (upcoming) Repeater iterates THIS list so it
// paints far-upcoming -> near-upcoming: a Slint Repeater paints in model
// order and there is no per-element z-index in Slint 1.16, so reversing the
// model is how we get the nearer (upcoming) cover to paint ON TOP of farther
// ones — symmetric with the LEFT side, which already paints far->near in
// ascending index order. A track's element holds the SAME decoded image on
// both lists (the reversed list is built by cloning + reversing the forward
// QueueItems), so no extra decode and offsets computed from the original
// index match the forward side exactly during the ±0.5 slide hand-off.
in property <[QueueItem]> coverflow-tracks-rev: [];
// Flat index of the NOW-PLAYING cover within `coverflow-tracks` // Flat index of the NOW-PLAYING cover within `coverflow-tracks`
// (= history.len() when a current track exists, else 0). The .slint panel // (= history.len() when a current track exists, else 0). The .slint panel
// binds an animated `scroll` float to this int so a change eases the fan. // binds an animated `scroll` float to this int so a change eases the fan.