diff --git a/crates/qbz-slint/src/queue.rs b/crates/qbz-slint/src/queue.rs index 554e30ccf..19a8fb26e 100644 --- a/crates/qbz-slint/src/queue.rs +++ b/crates/qbz-slint/src/queue.rs @@ -443,7 +443,18 @@ impl QueueController { .iter() .map(|r| to_item_reuse(r, &prior_all)) .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_rev(slint::ModelRc::new(slint::VecModel::from( + cf_items_rev, + ))); qs.set_coverflow_seq_hash(coverflow_seq_hash as i32); log::debug!( "[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) => { let items = qs.get_coverflow_tracks(); 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 // VecModel, so the Repeater is not rebuilt and the other covers' // sources are untouched. Only this one cell's image changes. 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); + } + } } } } diff --git a/crates/qbz-slint/ui/immersive/CoverflowPanel.slint b/crates/qbz-slint/ui/immersive/CoverflowPanel.slint index b09951aa3..633c06043 100644 --- a/crates/qbz-slint/ui/immersive/CoverflowPanel.slint +++ b/crates/qbz-slint/ui/immersive/CoverflowPanel.slint @@ -100,18 +100,27 @@ component CoverCard inherits Rectangle { in property stage-cx; // window-x of the center in property stage-height; in property 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 paint-side: true; callback navigate(); property 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 scale: Math.max(0.5, 1.0 - 0.18 * root.ao); property 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 dim: Math.min(0.55, root.ao * 0.18); - // Only ~7 cards near the center paint; the rest are dropped (no texture - // cost from off-screen rows — visible:false stops painting). - visible: root.ao <= 3.2; + // Only ~7 cards near the center paint; the rest are dropped (no texture cost + // from off-screen rows). A card paints only inside the ±3.2 clamp AND when it + // 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; height: root.slot; @@ -199,35 +208,68 @@ export component CoverflowPanel inherits Rectangle { height: root.base-art + 56px; property 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 cf-len: QueueState.coverflow-tracks.length; - // All side + far covers from the stable flat model. The center is drawn - // separately (below) so it paints on top — a Repeater renders in data - // order and cannot reorder by |offset|. + // --- LEFT (history) Repeater ------------------------------------- + // Iterates the FORWARD model in ascending index, so it paints + // 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 { - offset: i - root.scroll; + property off: i - 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; - // The center (i == current index) is drawn by the top instance; this - // Repeater copy stays non-interactive and hides exactly at center so - // there is no double-draw flicker through the 320ms ease. - interactive: i != root.center-idx; + // Left side only; hides the center-index card (GHOST FIX: the + // dedicated center card below is the ONLY center cover) and the whole + // right half (the RIGHT Repeater owns it). The strict < -0.5 / > -3.5 + // window mirrors the right side's (0.5, 3.5). + paint-side: self.off < -0.5 && self.off > -3.5; + interactive: true; navigate => { - // Flat index -> queue-wide play call. Flat order is - // [history.reversed (oldest-first) ++ NOW ++ upcoming], and - // center-idx = history.len(): - // 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. + // 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. if (i < root.center-idx) { 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 orig: parent.cf-len - 1 - j; + property 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); } } } diff --git a/crates/qbz-slint/ui/state.slint b/crates/qbz-slint/ui/state.slint index e01540456..691510b48 100644 --- a/crates/qbz-slint/ui/state.slint +++ b/crates/qbz-slint/ui/state.slint @@ -3259,6 +3259,18 @@ export global QueueState { // Image churn), so visible covers never re-decode. Windowed (±4) lazy decode // keeps at most one new cover decoding per advance. 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` // (= 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.