chore(release): v0.1.4 - 1:1 SyncLyrics, scroll isolation, object-fit cover, Concerts icon, friends' likes & duplicate-title albums
This commit is contained in:
parent
0b2561503f
commit
28f91f4a24
21 changed files with 1287 additions and 288 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -6325,7 +6325,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yandex-music-rs"
|
name = "yandex-music-rs"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "yandex-music-rs"
|
name = "yandex-music-rs"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text"
|
description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases):
|
Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases):
|
||||||
|
|
||||||
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.3-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.4-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
||||||
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.3-1_amd64.deb` и установите:
|
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.4-1_amd64.deb` и установите:
|
||||||
```bash
|
```bash
|
||||||
sudo apt install ./yandex-music-rs_0.1.3-1_amd64.deb
|
sudo apt install ./yandex-music-rs_0.1.4-1_amd64.deb
|
||||||
```
|
```
|
||||||
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.3-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`).
|
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.4-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`).
|
||||||
|
|
||||||
## Стек и возможности
|
## Стек и возможности
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFFFFF">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
|
||||||
<path d="M9.21045 2.5625L9.21338 2.56641C9.21634 2.57313 9.22214 2.58822 9.23193 2.6084C9.25167 2.64901 9.28502 2.71412 9.3335 2.79492C9.4315 2.95824 9.58683 3.17912 9.80713 3.39941C10.2365 3.82878 10.9225 4.26746 11.9995 4.26758C13.0768 4.26758 13.7634 3.82885 14.1929 3.39941C14.413 3.17929 14.5675 2.9582 14.6655 2.79492C14.714 2.71412 14.7483 2.64901 14.7681 2.6084C14.7778 2.58825 14.7837 2.57312 14.7866 2.56641C14.7878 2.56379 14.7896 2.5625 14.7896 2.5625L15.0142 2H21.0698V21.5H15.0142L14.7896 20.9375L14.7866 20.9336C14.7837 20.9269 14.7778 20.9118 14.7681 20.8916C14.7483 20.851 14.714 20.7859 14.6655 20.7051C14.5675 20.5418 14.413 20.3207 14.1929 20.1006C13.7634 19.6711 13.0768 19.2324 11.9995 19.2324C10.9225 19.2325 10.2365 19.6712 9.80713 20.1006C9.58683 20.3209 9.4315 20.5418 9.3335 20.7051C9.28502 20.7859 9.25167 20.851 9.23193 20.8916C9.22214 20.9118 9.21634 20.9269 9.21338 20.9336C9.21215 20.9362 9.21045 20.9375 9.21045 20.9375L8.98584 21.5H2.93018V14.2441H4.74365V19.6865H7.8335C7.99017 19.4377 8.21477 19.1276 8.52393 18.8184C9.22813 18.1142 10.3562 17.4191 11.9995 17.4189C13.6431 17.4189 14.7708 18.1141 15.4751 18.8184C15.7845 19.1277 16.0098 19.4376 16.1665 19.6865H19.2554V11.5234H10.3677C9.02751 11.5234 7.94894 11.5238 7.08936 11.4307C6.21319 11.3357 5.45728 11.1344 4.80029 10.6572C4.41531 10.3775 4.0761 10.0383 3.79639 9.65332C3.31915 8.99631 3.11695 8.24047 3.02197 7.36426C2.92884 6.50469 2.93018 5.42607 2.93018 4.08594V2H8.98584L9.21045 2.5625Z" fill="#FFFFFF" />
|
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M4.5 2H9A3 3 0 0 0 15 2H19.5A1.5 1.5 0 0 1 21 3.5V20A1.5 1.5 0 0 1 19.5 21.5H15A3 3 0 0 0 9 21.5H4.5A1.5 1.5 0 0 1 3 20V3.5A1.5 1.5 0 0 1 4.5 2ZM6.1 11.75A1.15 1.15 0 1 0 8.4 11.75A1.15 1.15 0 1 0 6.1 11.75ZM10.85 11.75A1.15 1.15 0 1 0 13.15 11.75A1.15 1.15 0 1 0 10.85 11.75ZM15.6 11.75A1.15 1.15 0 1 0 17.9 11.75A1.15 1.15 0 1 0 15.6 11.75Z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 492 B |
|
|
@ -92,6 +92,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_1".into(),
|
id: "rel_1".into(),
|
||||||
title: "YAMAKASI (Deluxe)".into(),
|
title: "YAMAKASI (Deluxe)".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a1", "Miyagi & Эндшпиль")],
|
artists: vec![artist("a1", "Miyagi & Эндшпиль")],
|
||||||
|
|
@ -103,6 +104,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_2".into(),
|
id: "rel_2".into(),
|
||||||
title: "Ночной проспект".into(),
|
title: "Ночной проспект".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a2", "Zivert")],
|
artists: vec![artist("a2", "Zivert")],
|
||||||
|
|
@ -114,6 +116,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_3".into(),
|
id: "rel_3".into(),
|
||||||
title: "Зеркала и эхо".into(),
|
title: "Зеркала и эхо".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a3", "Три дня дождя")],
|
artists: vec![artist("a3", "Три дня дождя")],
|
||||||
|
|
@ -125,6 +128,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_4".into(),
|
id: "rel_4".into(),
|
||||||
title: "Midnight Horizons".into(),
|
title: "Midnight Horizons".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a4", "The Weeknd")],
|
artists: vec![artist("a4", "The Weeknd")],
|
||||||
|
|
@ -136,6 +140,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_5".into(),
|
id: "rel_5".into(),
|
||||||
title: "Синтетика".into(),
|
title: "Синтетика".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a5", "Saluki")],
|
artists: vec![artist("a5", "Saluki")],
|
||||||
|
|
@ -147,6 +152,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "rel_6".into(),
|
id: "rel_6".into(),
|
||||||
title: "Тихий океан".into(),
|
title: "Тихий океан".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("a6", "Баста")],
|
artists: vec![artist("a6", "Баста")],
|
||||||
|
|
@ -234,6 +240,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "pod_1".into(),
|
id: "pod_1".into(),
|
||||||
title: "Подкаст «Запуск завтра»".into(),
|
title: "Подкаст «Запуск завтра»".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("p1", "Самат Галимов")],
|
artists: vec![artist("p1", "Самат Галимов")],
|
||||||
|
|
@ -245,6 +252,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "pod_2".into(),
|
id: "pod_2".into(),
|
||||||
title: "Дневники Лоры Палны".into(),
|
title: "Дневники Лоры Палны".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("p2", "Студия Терменвокс")],
|
artists: vec![artist("p2", "Студия Терменвокс")],
|
||||||
|
|
@ -256,6 +264,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "pod_3".into(),
|
id: "pod_3".into(),
|
||||||
title: "Краткая история времени".into(),
|
title: "Краткая история времени".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2025),
|
year: Some(2025),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("p3", "Стивен Хокинг (Аудиокнига)")],
|
artists: vec![artist("p3", "Стивен Хокинг (Аудиокнига)")],
|
||||||
|
|
@ -267,6 +276,7 @@ pub fn demo_landing() -> LandingData {
|
||||||
AlbumSummary {
|
AlbumSummary {
|
||||||
id: "pod_4".into(),
|
id: "pod_4".into(),
|
||||||
title: "Хоббит, или Туда и обратно".into(),
|
title: "Хоббит, или Туда и обратно".into(),
|
||||||
|
version: None,
|
||||||
year: Some(2025),
|
year: Some(2025),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![artist("p4", "Дж. Р. Р. Толкин")],
|
artists: vec![artist("p4", "Дж. Р. Р. Толкин")],
|
||||||
|
|
@ -557,6 +567,7 @@ pub fn demo_lyrics(track: &Track) -> TrackLyrics {
|
||||||
is_synced: true,
|
is_synced: true,
|
||||||
lines,
|
lines,
|
||||||
writers: Some("Яндекс Музыка Rust (Демо-режим)".into()),
|
writers: Some("Яндекс Музыка Rust (Демо-режим)".into()),
|
||||||
|
major: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
457
src/api/mod.rs
457
src/api/mod.rs
|
|
@ -670,7 +670,7 @@ impl YandexApiClient {
|
||||||
let res = self.get_json("/pins").await?;
|
let res = self.get_json("/pins").await?;
|
||||||
let ru = self.language == "ru";
|
let ru = self.language == "ru";
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
let mut seen_likes = false;
|
let mut seen_keys: HashSet<(String, String)> = HashSet::new();
|
||||||
let arr = res["pins"].as_array().or_else(|| res.as_array());
|
let arr = res["pins"].as_array().or_else(|| res.as_array());
|
||||||
if let Some(items) = arr {
|
if let Some(items) = arr {
|
||||||
for item in items {
|
for item in items {
|
||||||
|
|
@ -679,30 +679,37 @@ impl YandexApiClient {
|
||||||
match kind {
|
match kind {
|
||||||
"playlist" | "playlist_item" | "liked_playlist_item" | "personal_playlist_item" => {
|
"playlist" | "playlist_item" | "liked_playlist_item" | "personal_playlist_item" => {
|
||||||
if let Some(pl) = parse_playlist(data) {
|
if let Some(pl) = parse_playlist(data) {
|
||||||
let is_likes = pl.kind == "3"
|
// Only explicit `liked_playlist_item` is guaranteed to be the user's own system Favorites.
|
||||||
|| kind == "liked_playlist_item"
|
// A friend's "Мне нравится" playlist ALSO has `pl.kind == "3"` (with a different `owner_uid`),
|
||||||
|| pl.title == "Мне нравится"
|
// so preserve `owner_uid:kind` here and let `AppState::normalize_pins` collapse only `my_uid:3`!
|
||||||
|| pl.title == "My Favorites";
|
let is_system_likes = kind == "liked_playlist_item";
|
||||||
if is_likes {
|
let pin_kind = if is_system_likes {
|
||||||
if seen_likes {
|
"likes".to_string()
|
||||||
continue;
|
} else {
|
||||||
}
|
"playlist".to_string()
|
||||||
seen_likes = true;
|
};
|
||||||
|
let pin_id = if is_system_likes {
|
||||||
|
"likes".to_string()
|
||||||
|
} else {
|
||||||
|
format!("{}:{}", pl.owner_uid, pl.kind)
|
||||||
|
};
|
||||||
|
if !seen_keys.insert((pin_kind.clone(), pin_id.clone())) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
let likes_title = if ru { "Мне нравится" } else { "My Favorites" };
|
||||||
|
let title = if is_system_likes
|
||||||
|
|| (pl.kind == "3" && pl.title.trim().is_empty())
|
||||||
|
{
|
||||||
|
likes_title.into()
|
||||||
|
} else {
|
||||||
|
pl.title
|
||||||
|
};
|
||||||
out.push(PinnedItem {
|
out.push(PinnedItem {
|
||||||
id: if is_likes {
|
id: pin_id,
|
||||||
"likes".into()
|
kind: pin_kind,
|
||||||
} else {
|
title,
|
||||||
format!("{}:{}", pl.owner_uid, pl.kind)
|
|
||||||
},
|
|
||||||
kind: if is_likes { "likes".into() } else { "playlist".into() },
|
|
||||||
title: if is_likes {
|
|
||||||
if ru { "Мне нравится".into() } else { "My Favorites".into() }
|
|
||||||
} else {
|
|
||||||
pl.title
|
|
||||||
},
|
|
||||||
subtitle: if ru { "Плейлист".into() } else { "Playlist".into() },
|
subtitle: if ru { "Плейлист".into() } else { "Playlist".into() },
|
||||||
cover_uri: if is_likes { None } else { pl.cover_uri },
|
cover_uri: if is_system_likes { None } else { pl.cover_uri },
|
||||||
owner_uid: Some(pl.owner_uid),
|
owner_uid: Some(pl.owner_uid),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1739,74 +1746,186 @@ impl YandexApiClient {
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_liked_albums(&self, uid: u64) -> Result<Vec<AlbumSummary>> {
|
pub async fn fetch_albums_by_ids(&self, ids: &[String]) -> Result<Vec<AlbumSummary>> {
|
||||||
let res = match self
|
if ids.is_empty() {
|
||||||
.get_json(&format!(
|
return Ok(Vec::new());
|
||||||
"/users/{}/likes/albums/page?rich=true&page=0&pageSize=100",
|
}
|
||||||
uid
|
let mut out = Vec::with_capacity(ids.len());
|
||||||
))
|
let mut seen = HashSet::new();
|
||||||
.await
|
for chunk in ids.chunks(100) {
|
||||||
{
|
let joined = chunk.join(",");
|
||||||
Ok(v) => v,
|
if let Ok(res) = self
|
||||||
Err(_) => {
|
.post_form("/albums", &[("album-ids", joined)])
|
||||||
self.get_json(&format!("/users/{}/likes/albums?rich=true", uid))
|
.await
|
||||||
.await?
|
{
|
||||||
}
|
let arr = res.as_array().or_else(|| res["albums"].as_array());
|
||||||
};
|
if let Some(items) = arr {
|
||||||
let arr = res["albums"]
|
for item in items {
|
||||||
.as_array()
|
if let Some(alb) = parse_album(item) {
|
||||||
.or_else(|| res["items"].as_array())
|
if seen.insert(alb.id.clone()) {
|
||||||
.or_else(|| res.as_array());
|
out.push(alb);
|
||||||
let mut out = Vec::new();
|
}
|
||||||
if let Some(items) = arr {
|
}
|
||||||
for item in items {
|
}
|
||||||
let node = if item.get("album").is_some() {
|
|
||||||
&item["album"]
|
|
||||||
} else {
|
|
||||||
item
|
|
||||||
};
|
|
||||||
if let Some(alb) = parse_album(node) {
|
|
||||||
out.push(alb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_liked_artists(&self, uid: u64) -> Result<Vec<ArtistSummary>> {
|
pub async fn fetch_artists_by_ids(&self, ids: &[String]) -> Result<Vec<ArtistSummary>> {
|
||||||
let res = match self
|
if ids.is_empty() {
|
||||||
.get_json(&format!(
|
return Ok(Vec::new());
|
||||||
"/users/{}/likes/artists/page?page=0&pageSize=100",
|
}
|
||||||
uid
|
let mut out = Vec::with_capacity(ids.len());
|
||||||
))
|
let mut seen = HashSet::new();
|
||||||
.await
|
for chunk in ids.chunks(100) {
|
||||||
{
|
let joined = chunk.join(",");
|
||||||
Ok(v) => v,
|
if let Ok(res) = self
|
||||||
Err(_) => {
|
.post_form("/artists", &[("artist-ids", joined)])
|
||||||
self.get_json(&format!("/users/{}/likes/artists", uid))
|
.await
|
||||||
.await?
|
{
|
||||||
}
|
let arr = res.as_array().or_else(|| res["artists"].as_array());
|
||||||
};
|
if let Some(items) = arr {
|
||||||
let arr = res["artists"]
|
for item in items {
|
||||||
.as_array()
|
if let Some(art) = parse_artist(item) {
|
||||||
.or_else(|| res["items"].as_array())
|
if seen.insert(art.id.clone()) {
|
||||||
.or_else(|| res.as_array());
|
out.push(art);
|
||||||
let mut out = Vec::new();
|
}
|
||||||
if let Some(items) = arr {
|
}
|
||||||
for item in items {
|
}
|
||||||
let node = if item.get("artist").is_some() {
|
|
||||||
&item["artist"]
|
|
||||||
} else {
|
|
||||||
item
|
|
||||||
};
|
|
||||||
if let Some(art) = parse_artist(node) {
|
|
||||||
out.push(art);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn fetch_liked_albums(&self, uid: u64) -> Result<Vec<AlbumSummary>> {
|
||||||
|
let mut out: Vec<AlbumSummary> = Vec::new();
|
||||||
|
let mut seen_ids: HashSet<String> = HashSet::new();
|
||||||
|
let mut bare_ids: Vec<String> = Vec::new();
|
||||||
|
let mut seen_bare: HashSet<String> = HashSet::new();
|
||||||
|
|
||||||
|
for page in 0..5u32 {
|
||||||
|
let path = format!(
|
||||||
|
"/users/{}/likes/albums/page?rich=true&metaType=music&page={}&pageSize=100",
|
||||||
|
uid, page
|
||||||
|
);
|
||||||
|
let Ok(res) = self.get_json(&path).await else {
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
let (raw_count, page_albs, page_bare) = parse_liked_albums_entries(&res);
|
||||||
|
for alb in page_albs {
|
||||||
|
if seen_ids.insert(alb.id.clone()) {
|
||||||
|
out.push(alb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for bid in page_bare {
|
||||||
|
if !seen_ids.contains(&bid) && seen_bare.insert(bid.clone()) {
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if raw_count < 100 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback if `/likes/albums/page` failed or returned nothing
|
||||||
|
if out.is_empty() && bare_ids.is_empty() {
|
||||||
|
if let Ok(res) = self
|
||||||
|
.get_json(&format!("/users/{}/likes/albums?rich=true", uid))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
let (_, page_albs, page_bare) = parse_liked_albums_entries(&res);
|
||||||
|
for alb in page_albs {
|
||||||
|
if seen_ids.insert(alb.id.clone()) {
|
||||||
|
out.push(alb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for bid in page_bare {
|
||||||
|
if !seen_ids.contains(&bid) && seen_bare.insert(bid.clone()) {
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bare_ids.is_empty() {
|
||||||
|
if let Ok(hydrated) = self.fetch_albums_by_ids(&bare_ids).await {
|
||||||
|
for alb in hydrated {
|
||||||
|
if seen_ids.insert(alb.id.clone()) {
|
||||||
|
out.push(alb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn fetch_liked_artists(&self, uid: u64) -> Result<Vec<ArtistSummary>> {
|
||||||
|
let mut out: Vec<ArtistSummary> = Vec::new();
|
||||||
|
let mut seen_ids: HashSet<String> = HashSet::new();
|
||||||
|
let mut bare_ids: Vec<String> = Vec::new();
|
||||||
|
let mut seen_bare: HashSet<String> = HashSet::new();
|
||||||
|
|
||||||
|
for page in 0..5u32 {
|
||||||
|
let path = format!(
|
||||||
|
"/users/{}/likes/artists/page?page={}&pageSize=100",
|
||||||
|
uid, page
|
||||||
|
);
|
||||||
|
let Ok(res) = self.get_json(&path).await else {
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
let (raw_count, page_arts, page_bare) = parse_liked_artists_entries(&res);
|
||||||
|
for art in page_arts {
|
||||||
|
if seen_ids.insert(art.id.clone()) {
|
||||||
|
out.push(art);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for bid in page_bare {
|
||||||
|
if !seen_ids.contains(&bid) && seen_bare.insert(bid.clone()) {
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if raw_count < 100 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback if `/likes/artists/page` failed or returned empty!
|
||||||
|
if out.is_empty() && bare_ids.is_empty() {
|
||||||
|
if let Ok(res) = self
|
||||||
|
.get_json(&format!("/users/{}/likes/artists", uid))
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
let (_, page_arts, page_bare) = parse_liked_artists_entries(&res);
|
||||||
|
for art in page_arts {
|
||||||
|
if seen_ids.insert(art.id.clone()) {
|
||||||
|
out.push(art);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for bid in page_bare {
|
||||||
|
if !seen_ids.contains(&bid) && seen_bare.insert(bid.clone()) {
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bare_ids.is_empty() {
|
||||||
|
if let Ok(hydrated) = self.fetch_artists_by_ids(&bare_ids).await {
|
||||||
|
for art in hydrated {
|
||||||
|
if seen_ids.insert(art.id.clone()) {
|
||||||
|
out.push(art);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn fetch_bookshelf_liked(&self) -> Result<Vec<AlbumSummary>> {
|
pub async fn fetch_bookshelf_liked(&self) -> Result<Vec<AlbumSummary>> {
|
||||||
let mut out: Vec<AlbumSummary> = Vec::new();
|
let mut out: Vec<AlbumSummary> = Vec::new();
|
||||||
let mut seen: HashSet<String> = HashSet::new();
|
let mut seen: HashSet<String> = HashSet::new();
|
||||||
|
|
@ -1967,10 +2086,7 @@ impl YandexApiClient {
|
||||||
.as_array()
|
.as_array()
|
||||||
.map(|a| a.iter().filter_map(parse_track).collect())
|
.map(|a| a.iter().filter_map(parse_track).collect())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let albums = res["albums"]
|
let albums = parse_artist_detail_albums(&res);
|
||||||
.as_array()
|
|
||||||
.map(|a| a.iter().filter_map(parse_album).collect())
|
|
||||||
.unwrap_or_default();
|
|
||||||
let similar_artists = res["similarArtists"]
|
let similar_artists = res["similarArtists"]
|
||||||
.as_array()
|
.as_array()
|
||||||
.map(|a| a.iter().filter_map(parse_artist).collect())
|
.map(|a| a.iter().filter_map(parse_artist).collect())
|
||||||
|
|
@ -2478,6 +2594,7 @@ impl YandexApiClient {
|
||||||
is_synced: false,
|
is_synced: false,
|
||||||
lines,
|
lines,
|
||||||
writers,
|
writers,
|
||||||
|
major: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2515,6 +2632,11 @@ impl YandexApiClient {
|
||||||
.filter(|u| !u.is_empty())
|
.filter(|u| !u.is_empty())
|
||||||
.ok_or_else(|| anyhow!("No lyrics downloadUrl ({})", format))?;
|
.ok_or_else(|| anyhow!("No lyrics downloadUrl ({})", format))?;
|
||||||
let writers = parse_writers_field(&res["writers"]);
|
let writers = parse_writers_field(&res["writers"]);
|
||||||
|
let major = res["major"]["prettyName"]
|
||||||
|
.as_str()
|
||||||
|
.map(str::trim)
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
|
.map(String::from);
|
||||||
let resp = self.http.get(download_url).send().await?;
|
let resp = self.http.get(download_url).send().await?;
|
||||||
if !resp.status().is_success() {
|
if !resp.status().is_success() {
|
||||||
return Err(anyhow!(
|
return Err(anyhow!(
|
||||||
|
|
@ -2533,6 +2655,7 @@ impl YandexApiClient {
|
||||||
is_synced: parsed_synced && format == "LRC",
|
is_synced: parsed_synced && format == "LRC",
|
||||||
lines,
|
lines,
|
||||||
writers,
|
writers,
|
||||||
|
major,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3310,9 +3433,103 @@ fn parse_artist(v: &Value) -> Option<ArtistSummary> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_liked_albums_entries(res: &Value) -> (usize, Vec<AlbumSummary>, Vec<String>) {
|
||||||
|
let arr = res["albums"]
|
||||||
|
.as_array()
|
||||||
|
.or_else(|| res["items"].as_array())
|
||||||
|
.or_else(|| res["library"]["albums"].as_array())
|
||||||
|
.or_else(|| res.as_array());
|
||||||
|
let Some(items) = arr else {
|
||||||
|
return (0, Vec::new(), Vec::new());
|
||||||
|
};
|
||||||
|
let mut albs = Vec::new();
|
||||||
|
let mut bare_ids = Vec::new();
|
||||||
|
for item in items {
|
||||||
|
let parsed = if item["data"]["album"].is_object() {
|
||||||
|
parse_album_with_fallback_artists(&item["data"]["album"], item["data"].get("artists"))
|
||||||
|
} else if item["album"].is_object() {
|
||||||
|
parse_album_with_fallback_artists(&item["album"], item.get("artists"))
|
||||||
|
} else if item["data"].is_object() {
|
||||||
|
parse_album_with_fallback_artists(&item["data"], item["data"].get("artists"))
|
||||||
|
} else {
|
||||||
|
parse_album(item)
|
||||||
|
};
|
||||||
|
if let Some(alb) = parsed {
|
||||||
|
albs.push(alb);
|
||||||
|
} else if let Some(bid) = value_id(&item["id"])
|
||||||
|
.or_else(|| value_id(&item["album"]["id"]))
|
||||||
|
.or_else(|| value_id(&item["data"]["id"]))
|
||||||
|
{
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(items.len(), albs, bare_ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_liked_artists_entries(res: &Value) -> (usize, Vec<ArtistSummary>, Vec<String>) {
|
||||||
|
let arr = res["artists"]
|
||||||
|
.as_array()
|
||||||
|
.or_else(|| res["items"].as_array())
|
||||||
|
.or_else(|| res["library"]["artists"].as_array())
|
||||||
|
.or_else(|| res.as_array());
|
||||||
|
let Some(items) = arr else {
|
||||||
|
return (0, Vec::new(), Vec::new());
|
||||||
|
};
|
||||||
|
let mut arts = Vec::new();
|
||||||
|
let mut bare_ids = Vec::new();
|
||||||
|
for item in items {
|
||||||
|
let node = if item["data"]["artist"].is_object() {
|
||||||
|
&item["data"]["artist"]
|
||||||
|
} else if item["artist"].is_object() {
|
||||||
|
&item["artist"]
|
||||||
|
} else if item["data"].is_object() {
|
||||||
|
&item["data"]
|
||||||
|
} else {
|
||||||
|
item
|
||||||
|
};
|
||||||
|
if let Some(art) = parse_artist(node) {
|
||||||
|
arts.push(art);
|
||||||
|
} else if let Some(bid) = value_id(&node["id"]).or_else(|| value_id(&item["id"])) {
|
||||||
|
bare_ids.push(bid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(items.len(), arts, bare_ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_artist_detail_albums(res: &Value) -> Vec<AlbumSummary> {
|
||||||
|
let mut out = Vec::new();
|
||||||
|
let mut seen_ids = HashSet::new();
|
||||||
|
for key in ["albums", "alsoAlbums", "discography"] {
|
||||||
|
if let Some(arr) = res[key].as_array() {
|
||||||
|
for item in arr {
|
||||||
|
if let Some(alb) = parse_album(item) {
|
||||||
|
if seen_ids.insert(alb.id.clone()) {
|
||||||
|
out.push(alb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(dups) = item["duplicates"].as_array() {
|
||||||
|
for dup in dups {
|
||||||
|
if let Some(alb) = parse_album(dup) {
|
||||||
|
if seen_ids.insert(alb.id.clone()) {
|
||||||
|
out.push(alb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_album(v: &Value) -> Option<AlbumSummary> {
|
fn parse_album(v: &Value) -> Option<AlbumSummary> {
|
||||||
let title = v["title"].as_str()?.to_string();
|
let title = v["title"].as_str()?.to_string();
|
||||||
let id = value_id(&v["id"])?;
|
let id = value_id(&v["id"])?;
|
||||||
|
let version = v["version"]
|
||||||
|
.as_str()
|
||||||
|
.map(str::trim)
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
|
.map(String::from);
|
||||||
let year = v["year"].as_u64().map(|y| y as u32);
|
let year = v["year"].as_u64().map(|y| y as u32);
|
||||||
let cover_uri = v["coverUri"]
|
let cover_uri = v["coverUri"]
|
||||||
.as_str()
|
.as_str()
|
||||||
|
|
@ -3334,6 +3551,7 @@ fn parse_album(v: &Value) -> Option<AlbumSummary> {
|
||||||
Some(AlbumSummary {
|
Some(AlbumSummary {
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
|
version,
|
||||||
year,
|
year,
|
||||||
cover_uri,
|
cover_uri,
|
||||||
artists,
|
artists,
|
||||||
|
|
@ -3854,4 +4072,79 @@ mod tests {
|
||||||
assert_eq!(tabs[0].items[0].seeds, vec!["language:english"]);
|
assert_eq!(tabs[0].items[0].seeds, vec!["language:english"]);
|
||||||
assert_eq!(tabs[0].items[0].color_hex.as_deref(), Some("#3B82F6"));
|
assert_eq!(tabs[0].items[0].color_hex.as_deref(), Some("#3B82F6"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_duplicate_title_albums_and_liked_library_parsers() {
|
||||||
|
let artist_res = json!({
|
||||||
|
"albums": [
|
||||||
|
{
|
||||||
|
"id": 1001,
|
||||||
|
"title": "After Hours",
|
||||||
|
"year": 2020,
|
||||||
|
"duplicates": [
|
||||||
|
{
|
||||||
|
"id": 1002,
|
||||||
|
"title": "After Hours",
|
||||||
|
"version": "Deluxe",
|
||||||
|
"year": 2020
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"alsoAlbums": [
|
||||||
|
{
|
||||||
|
"id": 1003,
|
||||||
|
"title": "After Hours (Deluxe)",
|
||||||
|
"version": "Deluxe",
|
||||||
|
"year": 2020
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1001,
|
||||||
|
"title": "After Hours",
|
||||||
|
"year": 2020
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
let albs = parse_artist_detail_albums(&artist_res);
|
||||||
|
// Strictly deduped by ID (1001, 1002, 1003), NEVER by title!
|
||||||
|
assert_eq!(albs.len(), 3);
|
||||||
|
assert_eq!(albs[0].id, "1001");
|
||||||
|
assert_eq!(albs[0].full_title(), "After Hours");
|
||||||
|
assert_eq!(albs[1].id, "1002");
|
||||||
|
assert_eq!(albs[1].full_title(), "After Hours (Deluxe)");
|
||||||
|
// Version already in title -> no double "(Deluxe) (Deluxe)"
|
||||||
|
assert_eq!(albs[2].id, "1003");
|
||||||
|
assert_eq!(albs[2].full_title(), "After Hours (Deluxe)");
|
||||||
|
|
||||||
|
// Liked albums mixed shapes + bare ID record
|
||||||
|
let liked_albs_res = json!({
|
||||||
|
"albums": [
|
||||||
|
{ "album": { "id": 10, "title": "Same Title" } },
|
||||||
|
{ "data": { "id": 11, "title": "Same Title", "version": "Slowed" } },
|
||||||
|
{ "id": 12 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
let (cnt, parsed_albs, bare_alb_ids) = parse_liked_albums_entries(&liked_albs_res);
|
||||||
|
assert_eq!(cnt, 3);
|
||||||
|
assert_eq!(parsed_albs.len(), 2);
|
||||||
|
assert_eq!(parsed_albs[0].full_title(), "Same Title");
|
||||||
|
assert_eq!(parsed_albs[1].full_title(), "Same Title (Slowed)");
|
||||||
|
assert_eq!(bare_alb_ids, vec!["12"]);
|
||||||
|
|
||||||
|
// Liked artists mixed shapes + bare ID record
|
||||||
|
let liked_arts_res = json!({
|
||||||
|
"artists": [
|
||||||
|
{ "artist": { "id": 20, "name": "Artist One" } },
|
||||||
|
{ "data": { "artist": { "id": 21, "name": "Artist Two" } } },
|
||||||
|
{ "id": 22 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
let (acnt, parsed_arts, bare_art_ids) = parse_liked_artists_entries(&liked_arts_res);
|
||||||
|
assert_eq!(acnt, 3);
|
||||||
|
assert_eq!(parsed_arts.len(), 2);
|
||||||
|
assert_eq!(parsed_arts[0].name, "Artist One");
|
||||||
|
assert_eq!(parsed_arts[1].name, "Artist Two");
|
||||||
|
assert_eq!(bare_art_ids, vec!["22"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ pub struct ArtistSummary {
|
||||||
pub struct AlbumSummary {
|
pub struct AlbumSummary {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub version: Option<String>,
|
||||||
pub year: Option<u32>,
|
pub year: Option<u32>,
|
||||||
pub cover_uri: Option<String>,
|
pub cover_uri: Option<String>,
|
||||||
pub artists: Vec<ArtistSummary>,
|
pub artists: Vec<ArtistSummary>,
|
||||||
|
|
@ -35,6 +37,24 @@ pub struct AlbumSummary {
|
||||||
pub content_type: Option<String>,
|
pub content_type: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AlbumSummary {
|
||||||
|
/// Display title including edition/version (e.g. `"Album (Deluxe)"`) when `version` is non-empty
|
||||||
|
/// and not already present in `title`, so duplicate-title editions stay clearly distinguishable.
|
||||||
|
pub fn full_title(&self) -> String {
|
||||||
|
match self
|
||||||
|
.version
|
||||||
|
.as_deref()
|
||||||
|
.map(str::trim)
|
||||||
|
.filter(|v| !v.is_empty())
|
||||||
|
{
|
||||||
|
Some(ver) if !self.title.to_lowercase().contains(&ver.to_lowercase()) => {
|
||||||
|
format!("{} ({})", self.title, ver)
|
||||||
|
}
|
||||||
|
_ => self.title.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Track {
|
pub struct Track {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
@ -158,6 +178,8 @@ pub struct TrackLyrics {
|
||||||
pub is_synced: bool,
|
pub is_synced: bool,
|
||||||
pub lines: Vec<LyricLine>,
|
pub lines: Vec<LyricLine>,
|
||||||
pub writers: Option<String>,
|
pub writers: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub major: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -1461,8 +1461,24 @@ impl AppState {
|
||||||
let api_c = api.clone();
|
let api_c = api.clone();
|
||||||
let tx_c = tx.clone();
|
let tx_c = tx.clone();
|
||||||
rt.spawn(async move {
|
rt.spawn(async move {
|
||||||
|
let mut merged = Vec::new();
|
||||||
|
let mut seen = HashSet::new();
|
||||||
if let Ok(pls) = api_c.fetch_user_playlists(uid).await {
|
if let Ok(pls) = api_c.fetch_user_playlists(uid).await {
|
||||||
let _ = tx_c.send(ApiEvent::UserPlaylistsLoaded(pls));
|
for pl in pls {
|
||||||
|
if seen.insert((pl.owner_uid.clone(), pl.kind.clone())) {
|
||||||
|
merged.push(pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(liked_pls) = api_c.fetch_liked_playlists(uid).await {
|
||||||
|
for pl in liked_pls {
|
||||||
|
if seen.insert((pl.owner_uid.clone(), pl.kind.clone())) {
|
||||||
|
merged.push(pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !merged.is_empty() {
|
||||||
|
let _ = tx_c.send(ApiEvent::UserPlaylistsLoaded(merged));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1779,7 +1795,10 @@ impl AppState {
|
||||||
match ev {
|
match ev {
|
||||||
ApiEvent::AccountLoaded(Ok(acc)) => {
|
ApiEvent::AccountLoaded(Ok(acc)) => {
|
||||||
self.show_toast(t.toast_welcome(&acc.display_name));
|
self.show_toast(t.toast_welcome(&acc.display_name));
|
||||||
|
let uid = acc.uid;
|
||||||
self.account = Some(acc);
|
self.account = Some(acc);
|
||||||
|
normalize_pins(&mut self.config.pinned_items, Some(uid), t.is_ru());
|
||||||
|
self.save_config();
|
||||||
self.ensure_words_for_current_track();
|
self.ensure_words_for_current_track();
|
||||||
if self.concerts.is_empty() && !self.concerts_loading {
|
if self.concerts.is_empty() && !self.concerts_loading {
|
||||||
self.refresh_concerts();
|
self.refresh_concerts();
|
||||||
|
|
@ -1901,20 +1920,8 @@ impl AppState {
|
||||||
self.bookshelf_items = items;
|
self.bookshelf_items = items;
|
||||||
}
|
}
|
||||||
ApiEvent::PinsLoaded(mut pins) => {
|
ApiEvent::PinsLoaded(mut pins) => {
|
||||||
let mut seen_likes = false;
|
let my_uid = self.account.as_ref().map(|a| a.uid);
|
||||||
pins.retain(|p| {
|
normalize_pins(&mut pins, my_uid, t.is_ru());
|
||||||
let is_likes = p.kind == "likes"
|
|
||||||
|| p.id == "likes"
|
|
||||||
|| p.title == "Мне нравится"
|
|
||||||
|| p.title == "My Favorites";
|
|
||||||
if is_likes {
|
|
||||||
if seen_likes {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
seen_likes = true;
|
|
||||||
}
|
|
||||||
true
|
|
||||||
});
|
|
||||||
self.config.pinned_items = pins;
|
self.config.pinned_items = pins;
|
||||||
self.save_config();
|
self.save_config();
|
||||||
}
|
}
|
||||||
|
|
@ -3039,6 +3046,26 @@ pub fn is_newer_version(remote: &str, current: &str) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Normalize pinned items so only the signed-in user's own `kind == "3"` (`{my_uid}:3`)
|
||||||
|
/// collapses into system `kind: "likes", id: "likes"`, while friends' `"Мне нравится"` playlists
|
||||||
|
/// (`{friend_uid}:3`) are ALWAYS preserved as distinct `"playlist"` pins!
|
||||||
|
fn normalize_pins(pins: &mut Vec<PinnedItem>, my_uid: Option<u64>, ru: bool) {
|
||||||
|
if let Some(uid) = my_uid {
|
||||||
|
let my_likes_id = format!("{}:3", uid);
|
||||||
|
let likes_title = if ru { "Мне нравится" } else { "My Favorites" };
|
||||||
|
for p in pins.iter_mut() {
|
||||||
|
if p.kind == "playlist" && p.id == my_likes_id {
|
||||||
|
p.id = "likes".into();
|
||||||
|
p.kind = "likes".into();
|
||||||
|
p.cover_uri = None;
|
||||||
|
p.title = likes_title.into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut seen: HashSet<(String, String)> = HashSet::new();
|
||||||
|
pins.retain(|p| seen.insert((p.kind.clone(), p.id.clone())));
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -3054,4 +3081,41 @@ mod tests {
|
||||||
assert!(!is_newer_version("v0.0.9", "0.1.0"));
|
assert!(!is_newer_version("v0.0.9", "0.1.0"));
|
||||||
assert!(!is_newer_version("", "0.1.0"));
|
assert!(!is_newer_version("", "0.1.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_normalize_pins_keeps_friends_favorites_playlist() {
|
||||||
|
let mut pins = vec![
|
||||||
|
PinnedItem {
|
||||||
|
id: "likes".into(),
|
||||||
|
kind: "likes".into(),
|
||||||
|
title: "Мне нравится".into(),
|
||||||
|
subtitle: "Плейлист".into(),
|
||||||
|
cover_uri: None,
|
||||||
|
owner_uid: Some("1001".into()),
|
||||||
|
},
|
||||||
|
PinnedItem {
|
||||||
|
id: "1001:3".into(),
|
||||||
|
kind: "playlist".into(),
|
||||||
|
title: "Мне нравится".into(),
|
||||||
|
subtitle: "Плейлист".into(),
|
||||||
|
cover_uri: None,
|
||||||
|
owner_uid: Some("1001".into()),
|
||||||
|
},
|
||||||
|
PinnedItem {
|
||||||
|
id: "2002:3".into(),
|
||||||
|
kind: "playlist".into(),
|
||||||
|
title: "Мне нравится".into(),
|
||||||
|
subtitle: "Плейлист".into(),
|
||||||
|
cover_uri: None,
|
||||||
|
owner_uid: Some("2002".into()),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
normalize_pins(&mut pins, Some(1001), true);
|
||||||
|
assert_eq!(pins.len(), 2, "Own likes + friend's kind=3 likes must BOTH remain");
|
||||||
|
assert_eq!(pins[0].kind, "likes");
|
||||||
|
assert_eq!(pins[0].id, "likes");
|
||||||
|
assert_eq!(pins[1].kind, "playlist");
|
||||||
|
assert_eq!(pins[1].id, "2002:3");
|
||||||
|
assert_eq!(pins[1].owner_uid.as_deref(), Some("2002"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ pub struct CoverEntry {
|
||||||
pub texture_id: TextureId,
|
pub texture_id: TextureId,
|
||||||
pub dominant_color: Color,
|
pub dominant_color: Color,
|
||||||
pub hue: f32,
|
pub hue: f32,
|
||||||
|
pub width: u32,
|
||||||
|
pub height: u32,
|
||||||
pub last_used_frame: u64,
|
pub last_used_frame: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,6 +150,8 @@ impl CoverCache {
|
||||||
texture_id: tex_id,
|
texture_id: tex_id,
|
||||||
dominant_color: dom,
|
dominant_color: dom,
|
||||||
hue,
|
hue,
|
||||||
|
width: width as u32,
|
||||||
|
height: height as u32,
|
||||||
last_used_frame: frame_id,
|
last_used_frame: frame_id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -175,6 +179,8 @@ impl CoverCache {
|
||||||
texture_id: tex_id,
|
texture_id: tex_id,
|
||||||
dominant_color: dom,
|
dominant_color: dom,
|
||||||
hue,
|
hue,
|
||||||
|
width: width as u32,
|
||||||
|
height: height as u32,
|
||||||
last_used_frame: frame_id,
|
last_used_frame: frame_id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -208,6 +214,8 @@ impl CoverCache {
|
||||||
texture_id: tex_id,
|
texture_id: tex_id,
|
||||||
dominant_color: done.dominant_color,
|
dominant_color: done.dominant_color,
|
||||||
hue: done.hue,
|
hue: done.hue,
|
||||||
|
width: done.width,
|
||||||
|
height: done.height,
|
||||||
last_used_frame: frame_id,
|
last_used_frame: frame_id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -246,6 +254,17 @@ impl CoverCache {
|
||||||
/// Reuses an already-cached higher-resolution entry (`200x200` / `400x400`) when available
|
/// Reuses an already-cached higher-resolution entry (`200x200` / `400x400`) when available
|
||||||
/// because our Vulkan SDF renderer samples full hardware mipmap chains cleanly at any size!
|
/// because our Vulkan SDF renderer samples full hardware mipmap chains cleanly at any size!
|
||||||
pub fn get_or_fetch(&mut self, uri: &str, size_px: u32) -> Option<(TextureId, Color, f32)> {
|
pub fn get_or_fetch(&mut self, uri: &str, size_px: u32) -> Option<(TextureId, Color, f32)> {
|
||||||
|
self.get_or_fetch_with_size(uri, size_px)
|
||||||
|
.map(|(tex, dom, hue, _, _)| (tex, dom, hue))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `(TextureId, dominant_color, hue, width, height)` if loaded, or triggers background fetch.
|
||||||
|
/// Exposes decoded pixel dimensions so `draw_cover_art` can apply exact `object-fit: cover` UV cropping.
|
||||||
|
pub fn get_or_fetch_with_size(
|
||||||
|
&mut self,
|
||||||
|
uri: &str,
|
||||||
|
size_px: u32,
|
||||||
|
) -> Option<(TextureId, Color, f32, u32, u32)> {
|
||||||
if uri.is_empty() {
|
if uri.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +272,13 @@ impl CoverCache {
|
||||||
let url = Self::format_url(uri, size_px);
|
let url = Self::format_url(uri, size_px);
|
||||||
if let Some(entry) = self.cache.get_mut(&url) {
|
if let Some(entry) = self.cache.get_mut(&url) {
|
||||||
entry.last_used_frame = frame_id;
|
entry.last_used_frame = frame_id;
|
||||||
return Some((entry.texture_id, entry.dominant_color, entry.hue));
|
return Some((
|
||||||
|
entry.texture_id,
|
||||||
|
entry.dominant_color,
|
||||||
|
entry.hue,
|
||||||
|
entry.width,
|
||||||
|
entry.height,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cross-resolution mipmap reuse: if a higher-resolution variant is already cached,
|
// Cross-resolution mipmap reuse: if a higher-resolution variant is already cached,
|
||||||
|
|
@ -272,7 +297,13 @@ impl CoverCache {
|
||||||
}
|
}
|
||||||
if let Some(entry) = self.cache.get_mut(&hi_url) {
|
if let Some(entry) = self.cache.get_mut(&hi_url) {
|
||||||
entry.last_used_frame = frame_id;
|
entry.last_used_frame = frame_id;
|
||||||
return Some((entry.texture_id, entry.dominant_color, entry.hue));
|
return Some((
|
||||||
|
entry.texture_id,
|
||||||
|
entry.dominant_color,
|
||||||
|
entry.hue,
|
||||||
|
entry.width,
|
||||||
|
entry.height,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if self.in_flight.contains(&hi_url) {
|
if self.in_flight.contains(&hi_url) {
|
||||||
return None;
|
return None;
|
||||||
|
|
@ -335,7 +366,9 @@ fn decode_and_analyze(bytes: &[u8], target_px: u32) -> Option<(u32, u32, Vec<u8>
|
||||||
let (ow, oh) = (dyn_img.width(), dyn_img.height());
|
let (ow, oh) = (dyn_img.width(), dyn_img.height());
|
||||||
let max_dim = target_px.max(128);
|
let max_dim = target_px.max(128);
|
||||||
if ow > max_dim || oh > max_dim {
|
if ow > max_dim || oh > max_dim {
|
||||||
dyn_img = dyn_img.resize_exact(max_dim, max_dim, image::imageops::FilterType::Lanczos3);
|
// Preserve original aspect ratio so non-square concert posters / banners never stretch;
|
||||||
|
// `draw_cover_art` applies CSS `object-fit: cover` UV cropping using `(width, height)`.
|
||||||
|
dyn_img = dyn_img.resize(max_dim, max_dim, image::imageops::FilterType::Lanczos3);
|
||||||
}
|
}
|
||||||
let rgba = dyn_img.to_rgba8();
|
let rgba = dyn_img.to_rgba8();
|
||||||
let (w, h) = rgba.dimensions();
|
let (w, h) = rgba.dimensions();
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,28 @@ impl UiContext {
|
||||||
.draw_text_wrapped(dl, &mut self.textures, text, style, rect, max_lines, align)
|
.draw_text_wrapped(dl, &mut self.textures, text, style, rect, max_lines, align)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Draw wrapped multi-line text vertically centered inside `rect` and uniformly scaled
|
||||||
|
/// around `rect.center()` by `scale` (CSS `transform: scale(...)` without wrap-jump).
|
||||||
|
pub fn draw_text_wrapped_scaled(
|
||||||
|
&mut self,
|
||||||
|
text: &str,
|
||||||
|
style: TextStyle,
|
||||||
|
rect: Rect,
|
||||||
|
scale: f32,
|
||||||
|
align: TextAlign,
|
||||||
|
) -> Vec2 {
|
||||||
|
let dl = &mut self.layers[self.current_layer.index()];
|
||||||
|
self.text.draw_text_wrapped_scaled(
|
||||||
|
dl,
|
||||||
|
&mut self.textures,
|
||||||
|
text,
|
||||||
|
style,
|
||||||
|
rect,
|
||||||
|
scale,
|
||||||
|
align,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn draw_rich_text(
|
pub fn draw_rich_text(
|
||||||
&mut self,
|
&mut self,
|
||||||
spans: &[RichSpan<'_>],
|
spans: &[RichSpan<'_>],
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ impl ScrollState {
|
||||||
if horizontal {
|
if horizontal {
|
||||||
let dx = if input.wheel_delta.x.abs() > 0.01 {
|
let dx = if input.wheel_delta.x.abs() > 0.01 {
|
||||||
-input.wheel_delta.x
|
-input.wheel_delta.x
|
||||||
} else if !vertical || input.modifiers.shift {
|
} else if input.modifiers.shift {
|
||||||
-input.wheel_delta.y
|
-input.wheel_delta.y
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,68 @@ impl TextEngine {
|
||||||
size
|
size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Draw wrapped multi-line text vertically centered inside `rect` and uniformly scaled
|
||||||
|
/// around `rect.center()` by `scale` (1-to-1 CSS `transform: scale(...)` with zero wrap-jump
|
||||||
|
/// or fractional-size glyph atlas churn).
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn draw_text_wrapped_scaled(
|
||||||
|
&mut self,
|
||||||
|
dl: &mut DisplayList,
|
||||||
|
textures: &mut TextureRegistry,
|
||||||
|
text: &str,
|
||||||
|
style: TextStyle,
|
||||||
|
rect: Rect,
|
||||||
|
scale: f32,
|
||||||
|
align: TextAlign,
|
||||||
|
) -> Vec2 {
|
||||||
|
if text.is_empty() || style.color.a == 0 || rect.w <= 1.0 || scale <= 0.001 {
|
||||||
|
return Vec2::ZERO;
|
||||||
|
}
|
||||||
|
let (key, size) = self.get_or_shape(text, style, Some(rect.w), None, false, align);
|
||||||
|
let origin = Pos2::new(rect.x, rect.center_y() - size.y * 0.5);
|
||||||
|
if (scale - 1.0).abs() < 0.0005 {
|
||||||
|
self.emit_cached_buffer(dl, textures, key, origin, style.color, None);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
let Some((buffer, _)) = self.shape_cache.get(&key) else {
|
||||||
|
return size;
|
||||||
|
};
|
||||||
|
|
||||||
|
let dpi = self.scale_factor;
|
||||||
|
let inv_dpi = 1.0 / dpi;
|
||||||
|
let origin_px = (origin.x * dpi).round();
|
||||||
|
let center = rect.center();
|
||||||
|
|
||||||
|
let mut glyphs_to_draw = Vec::with_capacity(64);
|
||||||
|
for run in buffer.layout_runs() {
|
||||||
|
let baseline_py = ((origin.y + run.line_y) * dpi).floor();
|
||||||
|
for glyph in run.glyphs.iter() {
|
||||||
|
let phys = glyph.physical((0.0, 0.0), dpi);
|
||||||
|
glyphs_to_draw.push((phys, baseline_py));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (phys, baseline_py) in glyphs_to_draw {
|
||||||
|
if let Some(entry) = self.atlas.get_or_insert(
|
||||||
|
phys.cache_key,
|
||||||
|
&mut self.font_system,
|
||||||
|
&mut self.swash_cache,
|
||||||
|
textures,
|
||||||
|
) {
|
||||||
|
let gx = (origin_px + (phys.x + entry.left) as f32) * inv_dpi;
|
||||||
|
let gy = (baseline_py + (phys.y - entry.top) as f32) * inv_dpi;
|
||||||
|
let gw = entry.width as f32 * inv_dpi;
|
||||||
|
let gh = entry.height as f32 * inv_dpi;
|
||||||
|
|
||||||
|
let sx = center.x + (gx - center.x) * scale;
|
||||||
|
let sy = center.y + (gy - center.y) * scale;
|
||||||
|
let sw = gw * scale;
|
||||||
|
let sh = gh * scale;
|
||||||
|
dl.push_glyph(Rect::from_xywh(sx, sy, sw, sh), entry.uv, style.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size
|
||||||
|
}
|
||||||
|
|
||||||
/// Draw multi-span rich text (e.g. clickable `SeparatedArtists` or `Title + Version`) inside `rect`.
|
/// Draw multi-span rich text (e.g. clickable `SeparatedArtists` or `Title + Version`) inside `rect`.
|
||||||
/// Returns screen-space bounding `Rect`s for every span whose `metadata != 0` so callers can
|
/// Returns screen-space bounding `Rect`s for every span whose `metadata != 0` so callers can
|
||||||
/// perform exact per-span hover & click hit-testing!
|
/// perform exact per-span hover & click hit-testing!
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,32 @@ pub fn draw_plus_badge(
|
||||||
(resp, rect)
|
(resp, rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw cover artwork with SDF rounded-rect / circular clip:
|
/// Compute exact CSS `object-fit: cover` UV sub-rect so images never stretch when
|
||||||
|
/// `(tex_w / tex_h)` differs from `dst.w / dst.h`.
|
||||||
|
/// Uses `focal_y` (e.g. `0.35`) when cropping vertically so portrait faces/heads stay framed,
|
||||||
|
/// and `0.5` when cropping horizontally.
|
||||||
|
#[inline]
|
||||||
|
pub fn cover_fit_uv(tex_w: u32, tex_h: u32, dst: Rect, focal_y: f32) -> Rect {
|
||||||
|
if tex_w == 0 || tex_h == 0 || dst.w <= 0.0 || dst.h <= 0.0 {
|
||||||
|
return Rect::UNIT_UV;
|
||||||
|
}
|
||||||
|
let tex_ar = tex_w as f32 / tex_h as f32;
|
||||||
|
let dst_ar = dst.w / dst.h;
|
||||||
|
if (tex_ar - dst_ar).abs() < 0.015 {
|
||||||
|
return Rect::UNIT_UV;
|
||||||
|
}
|
||||||
|
if tex_ar > dst_ar {
|
||||||
|
let uw = (dst_ar / tex_ar).clamp(0.01, 1.0);
|
||||||
|
let u = (1.0 - uw) * 0.5;
|
||||||
|
Rect::from_xywh(u, 0.0, uw, 1.0)
|
||||||
|
} else {
|
||||||
|
let vh = (tex_ar / dst_ar).clamp(0.01, 1.0);
|
||||||
|
let v = (1.0 - vh) * focal_y.clamp(0.0, 1.0);
|
||||||
|
Rect::from_xywh(0.0, v, 1.0, vh)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Draw cover artwork with SDF rounded-rect / circular clip and CSS `object-fit: cover` UV crop:
|
||||||
/// - When `special_likes == true`: exact crimson vignette `#8D0F10 -> #59090A` + centered official `heart.png`
|
/// - When `special_likes == true`: exact crimson vignette `#8D0F10 -> #59090A` + centered official `heart.png`
|
||||||
/// with SDF rounded-rect clip (ZERO `+9.5%` y-shift bug!). If a real CDN cover URI is loaded, uses it.
|
/// with SDF rounded-rect clip (ZERO `+9.5%` y-shift bug!). If a real CDN cover URI is loaded, uses it.
|
||||||
/// - Otherwise: renders real fetched cover texture with SDF rounded/circle clip, or theme-aware neutral placeholder.
|
/// - Otherwise: renders real fetched cover texture with SDF rounded/circle clip, or theme-aware neutral placeholder.
|
||||||
|
|
@ -399,9 +424,10 @@ pub fn draw_cover_art(
|
||||||
if special_likes {
|
if special_likes {
|
||||||
// Prefer real CDN cover if provided & already loaded
|
// Prefer real CDN cover if provided & already loaded
|
||||||
if let Some(u) = uri {
|
if let Some(u) = uri {
|
||||||
let px = rect.width().ceil() as u32;
|
let px = rect.width().max(rect.height()).ceil() as u32;
|
||||||
if let Some((tex_id, dom, hue)) = covers.get_or_fetch(u, px) {
|
if let Some((tex_id, dom, hue, tw, th)) = covers.get_or_fetch_with_size(u, px) {
|
||||||
ctx.dl().push_image(rect, tex_id, cr, Color::WHITE);
|
let uv = cover_fit_uv(tw, th, rect, 0.35);
|
||||||
|
ctx.dl().push_image_uv(rect, tex_id, uv, cr, Color::WHITE);
|
||||||
return (dom, hue);
|
return (dom, hue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -428,9 +454,10 @@ pub fn draw_cover_art(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(u) = uri {
|
if let Some(u) = uri {
|
||||||
let px = rect.width().ceil() as u32;
|
let px = rect.width().max(rect.height()).ceil() as u32;
|
||||||
if let Some((tex_id, dom, hue)) = covers.get_or_fetch(u, px) {
|
if let Some((tex_id, dom, hue, tw, th)) = covers.get_or_fetch_with_size(u, px) {
|
||||||
ctx.dl().push_image(rect, tex_id, cr, Color::WHITE);
|
let uv = cover_fit_uv(tw, th, rect, 0.35);
|
||||||
|
ctx.dl().push_image_uv(rect, tex_id, uv, cr, Color::WHITE);
|
||||||
return (dom, hue);
|
return (dom, hue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1101,8 +1128,9 @@ pub fn stacked_mix_card(
|
||||||
let card_r = Rect::from_xywh(plate_x, plate_y + 8.0, plate_w, plate_w);
|
let card_r = Rect::from_xywh(plate_x, plate_y + 8.0, plate_w, plate_w);
|
||||||
let mut drew_tex = false;
|
let mut drew_tex = false;
|
||||||
if let Some(u) = cover_uri {
|
if let Some(u) = cover_uri {
|
||||||
if let Some((tex_id, _, _)) = covers.get_or_fetch(u, 200) {
|
if let Some((tex_id, _, _, tw, th)) = covers.get_or_fetch_with_size(u, 200) {
|
||||||
ctx.dl().push_image(card_r, tex_id, 6.0, Color::WHITE);
|
let uv = cover_fit_uv(tw, th, card_r, 0.35);
|
||||||
|
ctx.dl().push_image_uv(card_r, tex_id, uv, 6.0, Color::WHITE);
|
||||||
drew_tex = true;
|
drew_tex = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1181,8 +1209,9 @@ pub fn artist_promo_card(
|
||||||
// 1. Full-bleed artist photo (or theme-aware gradient placeholder)
|
// 1. Full-bleed artist photo (or theme-aware gradient placeholder)
|
||||||
let mut has_photo = false;
|
let mut has_photo = false;
|
||||||
if let Some(u) = artist_photo_uri {
|
if let Some(u) = artist_photo_uri {
|
||||||
if let Some((tex_id, _, _)) = covers.get_or_fetch(u, 400) {
|
if let Some((tex_id, _, _, tw, th)) = covers.get_or_fetch_with_size(u, 400) {
|
||||||
ctx.dl().push_image(img_r, tex_id, 8.0, Color::WHITE);
|
let uv = cover_fit_uv(tw, th, img_r, 0.35);
|
||||||
|
ctx.dl().push_image_uv(img_r, tex_id, uv, 8.0, Color::WHITE);
|
||||||
has_photo = true;
|
has_photo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ pub fn render_collection(
|
||||||
cx += card_w + gap;
|
cx += card_w + gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
for pl in playlists.iter().take(24) {
|
for (idx, pl) in playlists.iter().take(60).enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if cr.right() >= row_vp.left() - 24.0 && cr.left() <= row_vp.right() + 24.0 {
|
if cr.right() >= row_vp.left() - 24.0 && cr.left() <= row_vp.right() + 24.0 {
|
||||||
let sub = t.count_tracks(pl.track_count as usize);
|
let sub = t.count_tracks(pl.track_count as usize);
|
||||||
|
|
@ -363,14 +363,17 @@ pub fn render_collection(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("col_ov_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
WidgetId::from_pair(
|
||||||
|
"col_ov_pl",
|
||||||
|
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
&sub,
|
&sub,
|
||||||
pl.cover_uri.as_deref(),
|
pl.cover_uri.as_deref(),
|
||||||
&format!("upl_{}_{}", pl.owner_uid, pl.kind),
|
&format!("upl_{}_{}", pl.owner_uid, pl.kind),
|
||||||
false,
|
false,
|
||||||
false,
|
pl.kind == "3" && pl.cover_uri.is_none(),
|
||||||
);
|
);
|
||||||
if let Some(pos) = m.right_clicked_pos {
|
if let Some(pos) = m.right_clicked_pos {
|
||||||
shell.open_entity_menu(EntityContextMenuState {
|
shell.open_entity_menu(EntityContextMenuState {
|
||||||
|
|
@ -407,7 +410,7 @@ pub fn render_collection(
|
||||||
ctx.end_scroll_h(
|
ctx.end_scroll_h(
|
||||||
h_id,
|
h_id,
|
||||||
pal,
|
pal,
|
||||||
(playlists.len().min(24) + 1) as f32 * (card_w + gap),
|
(playlists.len().min(60) + 1) as f32 * (card_w + gap),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
y += card_h + 26.0;
|
y += card_h + 26.0;
|
||||||
|
|
@ -454,9 +457,10 @@ pub fn render_collection(
|
||||||
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||||
let mut cx = x - sx;
|
let mut cx = x - sx;
|
||||||
|
|
||||||
for alb in albums.iter().take(24) {
|
for (idx, alb) in albums.iter().take(60).enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if cr.right() >= row_vp.left() - 24.0 && cr.left() <= row_vp.right() + 24.0 {
|
if cr.right() >= row_vp.left() - 24.0 && cr.left() <= row_vp.right() + 24.0 {
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let sub = alb
|
let sub = alb
|
||||||
.artists
|
.artists
|
||||||
.first()
|
.first()
|
||||||
|
|
@ -466,9 +470,9 @@ pub fn render_collection(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("col_ov_alb", &alb.id),
|
WidgetId::from_pair("col_ov_alb", (idx, &alb.id)),
|
||||||
cr,
|
cr,
|
||||||
&alb.title,
|
&alb_title,
|
||||||
sub,
|
sub,
|
||||||
alb.cover_uri.as_deref(),
|
alb.cover_uri.as_deref(),
|
||||||
&format!("alb_{}", alb.id),
|
&format!("alb_{}", alb.id),
|
||||||
|
|
@ -479,7 +483,7 @@ pub fn render_collection(
|
||||||
shell.open_entity_menu(EntityContextMenuState {
|
shell.open_entity_menu(EntityContextMenuState {
|
||||||
kind: "album".into(),
|
kind: "album".into(),
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title.clone(),
|
||||||
subtitle: t.album().into(),
|
subtitle: t.album().into(),
|
||||||
cover_uri: alb.cover_uri.clone(),
|
cover_uri: alb.cover_uri.clone(),
|
||||||
owner_uid: None,
|
owner_uid: None,
|
||||||
|
|
@ -491,12 +495,12 @@ pub fn render_collection(
|
||||||
} else if m.play_clicked {
|
} else if m.play_clicked {
|
||||||
actions.push(AppAction::PlayAlbum {
|
actions.push(AppAction::PlayAlbum {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
});
|
});
|
||||||
} else if m.clicked {
|
} else if m.clicked {
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +509,7 @@ pub fn render_collection(
|
||||||
ctx.end_scroll_h(
|
ctx.end_scroll_h(
|
||||||
h_id,
|
h_id,
|
||||||
pal,
|
pal,
|
||||||
albums.len().min(24) as f32 * (card_w + gap),
|
albums.len().min(60) as f32 * (card_w + gap),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
y += card_h + 26.0;
|
y += card_h + 26.0;
|
||||||
|
|
@ -793,7 +797,7 @@ pub fn render_collection(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let sub = t.count_tracks(pl.track_count as usize);
|
let sub = t.count_tracks(pl.track_count as usize);
|
||||||
let wid = WidgetId::from_pair("col_pl", format!("{}_{}", pl.owner_uid, pl.kind));
|
let wid = WidgetId::from_pair("col_pl", (i, format!("{}_{}", pl.owner_uid, pl.kind)));
|
||||||
let m = media_card(
|
let m = media_card(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
|
|
@ -805,7 +809,7 @@ pub fn render_collection(
|
||||||
pl.cover_uri.as_deref(),
|
pl.cover_uri.as_deref(),
|
||||||
&format!("upl_{}_{}", pl.owner_uid, pl.kind),
|
&format!("upl_{}_{}", pl.owner_uid, pl.kind),
|
||||||
false,
|
false,
|
||||||
false,
|
pl.kind == "3" && pl.cover_uri.is_none(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Own playlists (not Liked kind=3) get quick Rename & Delete action icons on hover!
|
// Own playlists (not Liked kind=3) get quick Rename & Delete action icons on hover!
|
||||||
|
|
@ -928,6 +932,7 @@ pub fn render_collection(
|
||||||
card_h,
|
card_h,
|
||||||
);
|
);
|
||||||
if cr.bottom() >= rect.top() - 40.0 && cr.top() <= rect.bottom() + 40.0 {
|
if cr.bottom() >= rect.top() - 40.0 && cr.top() <= rect.bottom() + 40.0 {
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let sub = alb
|
let sub = alb
|
||||||
.artists
|
.artists
|
||||||
.first()
|
.first()
|
||||||
|
|
@ -937,9 +942,9 @@ pub fn render_collection(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("col_alb", &alb.id),
|
WidgetId::from_pair("col_alb", (idx, &alb.id)),
|
||||||
cr,
|
cr,
|
||||||
&alb.title,
|
&alb_title,
|
||||||
sub,
|
sub,
|
||||||
alb.cover_uri.as_deref(),
|
alb.cover_uri.as_deref(),
|
||||||
&format!("alb_{}", alb.id),
|
&format!("alb_{}", alb.id),
|
||||||
|
|
@ -950,7 +955,7 @@ pub fn render_collection(
|
||||||
shell.open_entity_menu(EntityContextMenuState {
|
shell.open_entity_menu(EntityContextMenuState {
|
||||||
kind: "album".into(),
|
kind: "album".into(),
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title.clone(),
|
||||||
subtitle: t.album().into(),
|
subtitle: t.album().into(),
|
||||||
cover_uri: alb.cover_uri.clone(),
|
cover_uri: alb.cover_uri.clone(),
|
||||||
owner_uid: None,
|
owner_uid: None,
|
||||||
|
|
@ -962,12 +967,12 @@ pub fn render_collection(
|
||||||
} else if m.play_clicked {
|
} else if m.play_clicked {
|
||||||
actions.push(AppAction::PlayAlbum {
|
actions.push(AppAction::PlayAlbum {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
});
|
});
|
||||||
} else if m.clicked {
|
} else if m.clicked {
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ pub fn render_detail(
|
||||||
};
|
};
|
||||||
let p_id = format!("{}:{}", owner_uid, kind);
|
let p_id = format!("{}:{}", owner_uid, kind);
|
||||||
let p_seed = format!("pl_{}_{}", owner_uid, kind);
|
let p_seed = format!("pl_{}_{}", owner_uid, kind);
|
||||||
|
let is_likes_art = kind == "3" && pl_cov.is_none();
|
||||||
(
|
(
|
||||||
EntityKind::Playlist {
|
EntityKind::Playlist {
|
||||||
owner_uid: owner_uid.clone(),
|
owner_uid: owner_uid.clone(),
|
||||||
|
|
@ -156,7 +157,7 @@ pub fn render_detail(
|
||||||
pl_cov,
|
pl_cov,
|
||||||
p_seed,
|
p_seed,
|
||||||
false,
|
false,
|
||||||
false,
|
is_likes_art,
|
||||||
"playlist",
|
"playlist",
|
||||||
p_id,
|
p_id,
|
||||||
Some(owner_uid),
|
Some(owner_uid),
|
||||||
|
|
@ -902,9 +903,10 @@ pub fn render_detail(
|
||||||
let h_id = WidgetId::new("artist_albums_hscroll");
|
let h_id = WidgetId::new("artist_albums_hscroll");
|
||||||
let sx = ctx.begin_scroll_h(h_id, vp, 0.0);
|
let sx = ctx.begin_scroll_h(h_id, vp, 0.0);
|
||||||
let mut cx = x - sx;
|
let mut cx = x - sx;
|
||||||
for alb in art_detail.albums.iter().take(16) {
|
for (idx, alb) in art_detail.albums.iter().take(48).enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if cr.right() >= vp.left() - 80.0 && cr.left() <= vp.right() + 80.0 {
|
if cr.right() >= vp.left() - 80.0 && cr.left() <= vp.right() + 80.0 {
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let yr = alb
|
let yr = alb
|
||||||
.year
|
.year
|
||||||
.map(|yr| yr.to_string())
|
.map(|yr| yr.to_string())
|
||||||
|
|
@ -913,9 +915,9 @@ pub fn render_detail(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("art_alb", &alb.id),
|
WidgetId::from_pair("art_alb", (idx, &alb.id)),
|
||||||
cr,
|
cr,
|
||||||
&alb.title,
|
&alb_title,
|
||||||
&yr,
|
&yr,
|
||||||
alb.cover_uri.as_deref(),
|
alb.cover_uri.as_deref(),
|
||||||
&format!("artalb_{}", alb.id),
|
&format!("artalb_{}", alb.id),
|
||||||
|
|
@ -925,12 +927,12 @@ pub fn render_detail(
|
||||||
if m.play_clicked {
|
if m.play_clicked {
|
||||||
actions.push(AppAction::PlayAlbum {
|
actions.push(AppAction::PlayAlbum {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
});
|
});
|
||||||
} else if m.clicked {
|
} else if m.clicked {
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -939,7 +941,7 @@ pub fn render_detail(
|
||||||
ctx.end_scroll_h(
|
ctx.end_scroll_h(
|
||||||
h_id,
|
h_id,
|
||||||
pal,
|
pal,
|
||||||
art_detail.albums.len().min(16) as f32 * (card_w + 16.0),
|
art_detail.albums.len().min(48) as f32 * (card_w + 16.0),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,7 @@ pub fn render_for_you(
|
||||||
|
|
||||||
let playlists = app.landing.personal_playlists.clone();
|
let playlists = app.landing.personal_playlists.clone();
|
||||||
let mut cx = x - scroll_x;
|
let mut cx = x - scroll_x;
|
||||||
for pl in &playlists {
|
for (idx, pl) in playlists.iter().enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
||||||
let sub = pl.description.as_deref().unwrap_or(t.playlist());
|
let sub = pl.description.as_deref().unwrap_or(t.playlist());
|
||||||
|
|
@ -473,7 +473,10 @@ pub fn render_for_you(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("fy_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
WidgetId::from_pair(
|
||||||
|
"fy_pl",
|
||||||
|
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
sub,
|
sub,
|
||||||
|
|
@ -652,14 +655,17 @@ pub fn render_for_you(
|
||||||
|
|
||||||
let playlists = app.landing.popular_playlists.clone();
|
let playlists = app.landing.popular_playlists.clone();
|
||||||
let mut cx = x - scroll_x;
|
let mut cx = x - scroll_x;
|
||||||
for pl in &playlists {
|
for (idx, pl) in playlists.iter().enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
||||||
let m = media_card(
|
let m = media_card(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("tr_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
WidgetId::from_pair(
|
||||||
|
"tr_pl",
|
||||||
|
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
&pl.owner_name,
|
&pl.owner_name,
|
||||||
|
|
@ -954,8 +960,9 @@ fn render_new_releases_carousel(
|
||||||
if row_vp.bottom() >= viewport.top() - 120.0 && row_vp.top() <= viewport.bottom() + 120.0 {
|
if row_vp.bottom() >= viewport.top() - 120.0 && row_vp.top() <= viewport.bottom() + 120.0 {
|
||||||
let scroll_x = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
let scroll_x = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||||
let mut cx = x - scroll_x;
|
let mut cx = x - scroll_x;
|
||||||
for item in &items {
|
for (idx, item) in items.iter().enumerate() {
|
||||||
let alb = &item.album;
|
let alb = &item.album;
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let outer_r = Rect::from_xywh(cx, y, card_w, card_h);
|
let outer_r = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
if outer_r.right() >= row_vp.left() - 80.0 && outer_r.left() <= row_vp.right() + 80.0 {
|
if outer_r.right() >= row_vp.left() - 80.0 && outer_r.left() <= row_vp.right() + 80.0 {
|
||||||
// 1. Huge 236x236 circular artist portrait overlapping the bottom card by 56px
|
// 1. Huge 236x236 circular artist portrait overlapping the bottom card by 56px
|
||||||
|
|
@ -1012,7 +1019,7 @@ fn render_new_releases_carousel(
|
||||||
.artists
|
.artists
|
||||||
.first()
|
.first()
|
||||||
.map(|a| a.name.as_str())
|
.map(|a| a.name.as_str())
|
||||||
.unwrap_or(alb.title.as_str());
|
.unwrap_or(alb_title.as_str());
|
||||||
let art_lbl_r = Rect::from_xywh(
|
let art_lbl_r = Rect::from_xywh(
|
||||||
circle_r.left() + 18.0,
|
circle_r.left() + 18.0,
|
||||||
y + portrait_d - overlap - 54.0,
|
y + portrait_d - overlap - 54.0,
|
||||||
|
|
@ -1028,14 +1035,14 @@ fn render_new_releases_carousel(
|
||||||
);
|
);
|
||||||
|
|
||||||
let port_click_r = Rect::from_xywh(circle_r.left(), circle_r.top(), portrait_d, portrait_d - overlap);
|
let port_click_r = Rect::from_xywh(circle_r.left(), circle_r.top(), portrait_d, portrait_d - overlap);
|
||||||
let port_resp = ctx.interact(WidgetId::from_pair(salt, format!("port_{}", alb.id)), port_click_r);
|
let port_resp = ctx.interact(WidgetId::from_pair(salt, (idx, format!("port_{}", alb.id))), port_click_r);
|
||||||
if port_resp.hovered {
|
if port_resp.hovered {
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
ctx.set_cursor(CursorKind::Pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Bottom 80px colored rounded release card (`radius: 14px`)
|
// 2. Bottom 80px colored rounded release card (`radius: 14px`)
|
||||||
let card_r = Rect::from_xywh(cx, y + portrait_d - overlap, card_w, bottom_h);
|
let card_r = Rect::from_xywh(cx, y + portrait_d - overlap, card_w, bottom_h);
|
||||||
let card_resp = ctx.interact(WidgetId::from_pair(salt, format!("card_{}", alb.id)), card_r);
|
let card_resp = ctx.interact(WidgetId::from_pair(salt, (idx, format!("card_{}", alb.id))), card_r);
|
||||||
let card_bg = if card_resp.hovered {
|
let card_bg = if card_resp.hovered {
|
||||||
card_tint.lerp(Color::WHITE, 0.08)
|
card_tint.lerp(Color::WHITE, 0.08)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1074,7 +1081,7 @@ fn render_new_releases_carousel(
|
||||||
// Right 38x38 crisp white circular Play/Pause button
|
// Right 38x38 crisp white circular Play/Pause button
|
||||||
let play_c = Pos2::new(card_r.right() - 28.0, card_r.center_y());
|
let play_c = Pos2::new(card_r.right() - 28.0, card_r.center_y());
|
||||||
let play_r = Rect::from_center_size(play_c, Vec2::splat(38.0));
|
let play_r = Rect::from_center_size(play_c, Vec2::splat(38.0));
|
||||||
let play_resp = ctx.interact(WidgetId::from_pair(salt, format!("play_{}", alb.id)), play_r);
|
let play_resp = ctx.interact(WidgetId::from_pair(salt, (idx, format!("play_{}", alb.id))), play_r);
|
||||||
let play_rad = if play_resp.hovered { 20.0 } else { 19.0 };
|
let play_rad = if play_resp.hovered { 20.0 } else { 19.0 };
|
||||||
ctx.dl().push_circle(play_c, play_rad, Color::WHITE);
|
ctx.dl().push_circle(play_c, play_rad, Color::WHITE);
|
||||||
let alb_playing = app.is_context_playing(&format!("album:{}", alb.id));
|
let alb_playing = app.is_context_playing(&format!("album:{}", alb.id));
|
||||||
|
|
@ -1092,7 +1099,7 @@ fn render_new_releases_carousel(
|
||||||
let tx_l = cov_r.right() + 12.0;
|
let tx_l = cov_r.right() + 12.0;
|
||||||
let tx_w = (play_r.left() - tx_l - 8.0).max(40.0);
|
let tx_w = (play_r.left() - tx_l - 8.0).max(40.0);
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
&alb.title,
|
&alb_title,
|
||||||
TextStyle::bold(14.5, Color::WHITE),
|
TextStyle::bold(14.5, Color::WHITE),
|
||||||
Rect::from_xywh(tx_l, card_r.top() + 18.0, tx_w, 20.0),
|
Rect::from_xywh(tx_l, card_r.top() + 18.0, tx_w, 20.0),
|
||||||
TextAlign::Left,
|
TextAlign::Left,
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ pub struct ShellUiState {
|
||||||
pub queue_drag: Option<QueueDragState>,
|
pub queue_drag: Option<QueueDragState>,
|
||||||
pub fs_lyrics_scroll_y: f32,
|
pub fs_lyrics_scroll_y: f32,
|
||||||
pub fs_lyrics_manual_until: f64,
|
pub fs_lyrics_manual_until: f64,
|
||||||
|
pub fs_lyrics_upper_until: f64,
|
||||||
|
pub fs_lyrics_last_mouse: Option<Pos2>,
|
||||||
pub fs_lyrics_track_id: String,
|
pub fs_lyrics_track_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -640,37 +642,9 @@ pub fn render_fullscreen_player(
|
||||||
ctx.register_blocker(screen);
|
ctx.register_blocker(screen);
|
||||||
ctx.dl().push_rect(screen, 0.0, bg_color);
|
ctx.dl().push_rect(screen, 0.0, bg_color);
|
||||||
|
|
||||||
// Top-right circular `v` collapse button (`FullscreenPlayerDesktop_closeButton`)
|
// Render track player + 50/50 split BEFORE top-right `v` collapse button so
|
||||||
let close_r = Rect::from_center_size(
|
// SyncLyrics top gradient fade mask never slices over `FullscreenPlayerDesktop_closeButton`!
|
||||||
Pos2::new(screen.right() - 44.0, screen.top() + 56.0),
|
if let Some(tr) = track {
|
||||||
Vec2::splat(40.0),
|
|
||||||
);
|
|
||||||
let close_resp = ctx.interact(WidgetId::new("fs_close"), close_r);
|
|
||||||
ctx.dl().push_circle(
|
|
||||||
close_r.center(),
|
|
||||||
if close_resp.hovered { 21.0 } else { 20.0 },
|
|
||||||
if close_resp.hovered {
|
|
||||||
css_rgba(255, 255, 255, 36)
|
|
||||||
} else {
|
|
||||||
css_rgba(255, 255, 255, 22)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
ctx.draw_icon(
|
|
||||||
Icon::ArrowDown,
|
|
||||||
Rect::from_center_size(close_r.center(), Vec2::splat(24.0)),
|
|
||||||
Color::WHITE,
|
|
||||||
);
|
|
||||||
if close_resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
ctx.show_tooltip(close_r, i18n.close());
|
|
||||||
}
|
|
||||||
if close_resp.clicked {
|
|
||||||
actions.push(AppAction::SetFullscreen(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
let Some(tr) = track else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mutually exclusive right split modes (SyncLyrics OR PlayQueue) WITHOUT closing fullscreen!
|
// Mutually exclusive right split modes (SyncLyrics OR PlayQueue) WITHOUT closing fullscreen!
|
||||||
let is_split = app.fullscreen_lyrics_open || app.fullscreen_queue_open;
|
let is_split = app.fullscreen_lyrics_open || app.fullscreen_queue_open;
|
||||||
|
|
@ -692,7 +666,8 @@ pub fn render_fullscreen_player(
|
||||||
let cx_center = screen.center_x();
|
let cx_center = screen.center_x();
|
||||||
let cx_left = screen.left() + screen.width() * 0.25;
|
let cx_left = screen.left() + screen.width() * 0.25;
|
||||||
let cx = cx_center + (cx_left - cx_center) * split_t;
|
let cx = cx_center + (cx_left - cx_center) * split_t;
|
||||||
let cov_cy = screen.center_y() - 36.0;
|
// Center the entire (poster + 110px info) block symmetrically around `screen.center_y()`
|
||||||
|
let cov_cy = screen.center_y() - 55.0;
|
||||||
let cov_r = Rect::from_center_size(Pos2::new(cx, cov_cy), Vec2::splat(cov_sz));
|
let cov_r = Rect::from_center_size(Pos2::new(cx, cov_cy), Vec2::splat(cov_sz));
|
||||||
|
|
||||||
// Soft cover elevation shadow
|
// Soft cover elevation shadow
|
||||||
|
|
@ -956,7 +931,7 @@ pub fn render_fullscreen_player(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Below Cover: Clickable Track Title + Explicit + Individually Clickable Artists
|
// Below Cover: Clickable Track Title + Explicit + Individually Clickable Artists
|
||||||
let title_y = cov_r.bottom() + 20.0;
|
let title_y = cov_r.bottom() + 24.0;
|
||||||
let meta_w = cov_sz.max(320.0);
|
let meta_w = cov_sz.max(320.0);
|
||||||
let full_title = tr.full_title();
|
let full_title = tr.full_title();
|
||||||
let measured_tw = ctx
|
let measured_tw = ctx
|
||||||
|
|
@ -1003,7 +978,7 @@ pub fn render_fullscreen_player(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Individually clickable artists below title (`SeparatedArtists`)!
|
// Individually clickable artists below title (`SeparatedArtists`)!
|
||||||
let art_r = Rect::from_center_size(Pos2::new(cx, title_y + 34.0), Vec2::new(meta_w, 22.0));
|
let art_r = Rect::from_xywh(cx - meta_w * 0.5, title_y + 26.0, meta_w, 22.0);
|
||||||
if let Some((aid, aname)) = separated_artists(
|
if let Some((aid, aname)) = separated_artists(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
|
|
@ -1020,7 +995,7 @@ pub fn render_fullscreen_player(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress bar (`ChangeTimecode`: 4px `#E6E6E6` fill/thumb + hover timecodes + smooth drag seek)
|
// Progress bar (`ChangeTimecode`: 4px `#E6E6E6` fill/thumb + hover timecodes + smooth drag seek)
|
||||||
let bar_y = title_y + 64.0;
|
let bar_y = cov_r.bottom() + 86.0;
|
||||||
let bar_hit = Rect::from_center_size(Pos2::new(cx, bar_y), Vec2::new(cov_sz, 22.0));
|
let bar_hit = Rect::from_center_size(Pos2::new(cx, bar_y), Vec2::new(cov_sz, 22.0));
|
||||||
let bar_resp = ctx.interact(WidgetId::new("fs_progress"), bar_hit);
|
let bar_resp = ctx.interact(WidgetId::new("fs_progress"), bar_hit);
|
||||||
let bar_r = Rect::from_center_size(Pos2::new(cx, bar_y), Vec2::new(cov_sz, 4.0));
|
let bar_r = Rect::from_center_size(Pos2::new(cx, bar_y), Vec2::new(cov_sz, 4.0));
|
||||||
|
|
@ -1090,13 +1065,24 @@ pub fn render_fullscreen_player(
|
||||||
ctx.dl().push_circle(Pos2::new(fill_x, bar_y), 6.0, fill_col);
|
ctx.dl().push_circle(Pos2::new(fill_x, bar_y), 6.0, fill_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right-Half 50/50 Animated Pane: SyncLyrics OR PlayQueue!
|
// Right-Half 50/50 Animated Pane (`FullscreenPlayerDesktopContent_additionalContent`): SyncLyrics OR PlayQueue!
|
||||||
if split_t > 0.02 {
|
if split_t > 0.02 {
|
||||||
let right_rect = Rect::from_min_max(
|
let indent = if screen.width() > 1060.0 {
|
||||||
Pos2::new(screen.left() + screen.width() * 0.48, screen.top() + 56.0),
|
44.0
|
||||||
Pos2::new(screen.right() - 48.0, screen.bottom() - 40.0),
|
} else if screen.width() > 960.0 {
|
||||||
);
|
20.0
|
||||||
|
} else {
|
||||||
|
10.0
|
||||||
|
};
|
||||||
|
let right_left = screen.left() + screen.width() * 0.50 - indent;
|
||||||
|
let right_right = (right_left + screen.width() * 0.50).min(screen.right());
|
||||||
|
let right_bottom = screen.bottom() - (screen.height() * 0.09).max(56.0);
|
||||||
|
|
||||||
if app.fullscreen_queue_open {
|
if app.fullscreen_queue_open {
|
||||||
|
let right_rect = Rect::from_min_max(
|
||||||
|
Pos2::new(right_left, screen.top() + 56.0),
|
||||||
|
Pos2::new((right_right - 48.0).max(right_left + 120.0), right_bottom),
|
||||||
|
);
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
i18n.queue(),
|
i18n.queue(),
|
||||||
TextStyle::headline(22.0, Color::WHITE.with_alpha_f32(split_t)),
|
TextStyle::headline(22.0, Color::WHITE.with_alpha_f32(split_t)),
|
||||||
|
|
@ -1119,12 +1105,17 @@ pub fn render_fullscreen_player(
|
||||||
actions,
|
actions,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
let lyr_rect = Rect::from_min_max(
|
||||||
|
Pos2::new(right_left, screen.top() + 32.0),
|
||||||
|
Pos2::new(right_right, right_bottom),
|
||||||
|
);
|
||||||
render_fullscreen_sync_lyrics(
|
render_fullscreen_sync_lyrics(
|
||||||
ctx,
|
ctx,
|
||||||
app.current_lyrics.as_ref(),
|
app.current_lyrics.as_ref(),
|
||||||
tr,
|
tr,
|
||||||
position_ms,
|
position_ms,
|
||||||
right_rect,
|
is_playing,
|
||||||
|
lyr_rect,
|
||||||
bg_color,
|
bg_color,
|
||||||
split_t,
|
split_t,
|
||||||
ru,
|
ru,
|
||||||
|
|
@ -1133,13 +1124,41 @@ pub fn render_fullscreen_player(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bottom-right Volume / Mute button with upward 44×216 `ym_volume_capsule` hover popover!
|
} // end `if let Some(tr) = track`
|
||||||
// Smoothly shifts into the left player column when `split_t > 0` so neither the button nor
|
|
||||||
// its upward popover ever collides with `right_rect` (SyncLyrics / Queue split pane).
|
// Top-right circular `v` collapse button (`FullscreenPlayerDesktop_closeButton`, z-index: header)
|
||||||
let vol_x_centered = screen.right() - 44.0;
|
let close_r = Rect::from_center_size(
|
||||||
let vol_x_split = (screen.left() + screen.width() * 0.48 - 34.0).max(screen.left() + 44.0);
|
Pos2::new(screen.right() - 44.0, screen.top() + 56.0),
|
||||||
let vol_x = vol_x_centered + (vol_x_split - vol_x_centered) * split_t;
|
Vec2::splat(40.0),
|
||||||
let vol_center = Pos2::new(vol_x, screen.bottom() - 44.0);
|
);
|
||||||
|
let close_resp = ctx.interact(WidgetId::new("fs_close"), close_r);
|
||||||
|
ctx.dl().push_circle(
|
||||||
|
close_r.center(),
|
||||||
|
if close_resp.hovered { 21.0 } else { 20.0 },
|
||||||
|
if close_resp.hovered {
|
||||||
|
css_rgba(255, 255, 255, 36)
|
||||||
|
} else {
|
||||||
|
css_rgba(255, 255, 255, 22)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
ctx.draw_icon(
|
||||||
|
Icon::ArrowDown,
|
||||||
|
Rect::from_center_size(close_r.center(), Vec2::splat(24.0)),
|
||||||
|
Color::WHITE,
|
||||||
|
);
|
||||||
|
if close_resp.hovered {
|
||||||
|
ctx.set_cursor(CursorKind::Pointer);
|
||||||
|
ctx.show_tooltip(close_r, i18n.close());
|
||||||
|
}
|
||||||
|
if close_resp.clicked {
|
||||||
|
actions.push(AppAction::SetFullscreen(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if track.is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Bottom-right Volume / Mute button anchored cleanly at bottom-right aligned with top-right `v`!
|
||||||
|
let vol_center = Pos2::new(screen.right() - 44.0, screen.bottom() - 40.0);
|
||||||
let vol_btn_r = Rect::from_center_size(vol_center, Vec2::splat(40.0));
|
let vol_btn_r = Rect::from_center_size(vol_center, Vec2::splat(40.0));
|
||||||
let vol_resp = ctx.interact(WidgetId::new("fs_vol_btn"), vol_btn_r);
|
let vol_resp = ctx.interact(WidgetId::new("fs_vol_btn"), vol_btn_r);
|
||||||
let vol_val = app.config.volume;
|
let vol_val = app.config.volume;
|
||||||
|
|
@ -1207,12 +1226,19 @@ pub fn render_fullscreen_player(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 1-to-1 Official `SyncLyrics` (`83ceed5f9f3f6e01.css` + `9631.422e0bf38581fe75.js`):
|
||||||
|
/// - `40vh` active anchor, `32px` Swiper spacing, `base_sz` `(2.5vw clamped 32..48px)`, `scale(1.2)` active line
|
||||||
|
/// - `INTRO` 4 staggered pulsing dots + `PREPARE` `3/2/1` countdown slot above line 0
|
||||||
|
/// - `withVisibleUpperLyrics` (3s on mouse move) & `withVisibleScrolledLyrics` (3s on wheel scroll)
|
||||||
|
/// - Exact opacity ladder (`1.0` active, `0.30` next, `0.10` upcoming / upper-visible, `0.0` hidden past)
|
||||||
|
/// - Official `SyncLyricsFooter` (`Авторы:` / `Writers:` + `Источник:` / `Source:`) + `80px` top/bottom fades
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn render_fullscreen_sync_lyrics(
|
fn render_fullscreen_sync_lyrics(
|
||||||
ctx: &mut UiContext,
|
ctx: &mut UiContext,
|
||||||
lyrics: Option<&TrackLyrics>,
|
lyrics: Option<&TrackLyrics>,
|
||||||
track: &Track,
|
track: &Track,
|
||||||
position_ms: u64,
|
position_ms: u64,
|
||||||
|
is_playing: bool,
|
||||||
lyr_rect: Rect,
|
lyr_rect: Rect,
|
||||||
bg_color: Color,
|
bg_color: Color,
|
||||||
split_t: f32,
|
split_t: f32,
|
||||||
|
|
@ -1224,6 +1250,8 @@ fn render_fullscreen_sync_lyrics(
|
||||||
shell.fs_lyrics_track_id = track.id.clone();
|
shell.fs_lyrics_track_id = track.id.clone();
|
||||||
shell.fs_lyrics_scroll_y = 0.0;
|
shell.fs_lyrics_scroll_y = 0.0;
|
||||||
shell.fs_lyrics_manual_until = 0.0;
|
shell.fs_lyrics_manual_until = 0.0;
|
||||||
|
shell.fs_lyrics_upper_until = 0.0;
|
||||||
|
shell.fs_lyrics_last_mouse = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(lyr) = lyrics.filter(|l| !l.lines.is_empty()) else {
|
let Some(lyr) = lyrics.filter(|l| !l.lines.is_empty()) else {
|
||||||
|
|
@ -1241,52 +1269,85 @@ fn render_fullscreen_sync_lyrics(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let active_idx = if lyr.is_synced {
|
let screen = ctx.screen_rect();
|
||||||
lyr.lines
|
let screen_w = screen.width();
|
||||||
.iter()
|
let base_sz = (screen_w * 0.025).clamp(32.0, 48.0).round();
|
||||||
.rposition(|l| l.time_ms <= position_ms)
|
let active_sz = (base_sz * 1.2).round();
|
||||||
.unwrap_or(0)
|
let base_lh = (base_sz * 1.25).round();
|
||||||
|
let active_lh = (active_sz * 1.25).round();
|
||||||
|
let max_line_w = (lyr_rect.width() * 0.80).max(200.0);
|
||||||
|
let line_gap = 32.0f32; // exact Swiper `spaceBetween: 32`
|
||||||
|
|
||||||
|
// Exact `--sync-lyrics-scroller-inset-top-vh: 40vh` anchor
|
||||||
|
let anchor_y = (screen.top() + screen.height() * 0.40)
|
||||||
|
.clamp(lyr_rect.top() + 48.0, lyr_rect.bottom() - 80.0);
|
||||||
|
|
||||||
|
// Exact state machine: INTRO / PREPARE / PLAYING
|
||||||
|
let start_ms = lyr.lines.first().map_or(0, |l| l.time_ms);
|
||||||
|
let is_prepare = lyr.is_synced
|
||||||
|
&& start_ms >= 3000
|
||||||
|
&& position_ms < start_ms
|
||||||
|
&& (start_ms - position_ms) <= 3000;
|
||||||
|
let is_intro = lyr.is_synced && start_ms > 0 && position_ms < start_ms && !is_prepare;
|
||||||
|
let active_idx: Option<usize> = if lyr.is_synced && !is_intro && !is_prepare {
|
||||||
|
lyr.lines.iter().rposition(|l| l.time_ms <= position_ms)
|
||||||
} else {
|
} else {
|
||||||
usize::MAX
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let screen_w = ctx.screen_rect().width();
|
// Pre-measure every line at fixed `base_sz` / `base_lh` (zero wrap-jumping during `scale(1.2)`)
|
||||||
let base_sz = (screen_w * 0.022).clamp(24.0, 32.0);
|
let measure_style = TextStyle::headline(base_sz, Color::WHITE).with_line_height(base_lh);
|
||||||
let active_sz = base_sz * 1.15;
|
|
||||||
let max_line_w = (lyr_rect.width() - 48.0).max(200.0);
|
|
||||||
|
|
||||||
// Pre-measure lines
|
|
||||||
let mut line_heights = Vec::with_capacity(lyr.lines.len());
|
let mut line_heights = Vec::with_capacity(lyr.lines.len());
|
||||||
let mut line_y = Vec::with_capacity(lyr.lines.len());
|
let mut line_y = Vec::with_capacity(lyr.lines.len());
|
||||||
let mut cur_y = 0.0f32;
|
let mut cur_y = 0.0f32;
|
||||||
for (i, line) in lyr.lines.iter().enumerate() {
|
for line in &lyr.lines {
|
||||||
let is_active = i == active_idx;
|
|
||||||
let sz = if is_active { active_sz } else { base_sz };
|
|
||||||
let txt = if line.text.trim().is_empty() {
|
let txt = if line.text.trim().is_empty() {
|
||||||
"• • •"
|
"• • •"
|
||||||
} else {
|
} else {
|
||||||
line.text.as_str()
|
line.text.as_str()
|
||||||
};
|
};
|
||||||
let measured = ctx.measure_text(txt, TextStyle::headline(sz, Color::WHITE), Some(max_line_w));
|
let measured = ctx.measure_text(txt, measure_style, Some(max_line_w));
|
||||||
let h = measured.y.max(sz * 1.25);
|
let h = measured.y.max(base_lh);
|
||||||
line_y.push(cur_y + h * 0.5);
|
line_y.push(cur_y + h * 0.5);
|
||||||
line_heights.push(h);
|
line_heights.push(h);
|
||||||
cur_y += h + 22.0;
|
cur_y += h + line_gap;
|
||||||
}
|
}
|
||||||
let total_h = cur_y;
|
let total_h = cur_y;
|
||||||
|
let counter_y = -(line_gap + 22.0);
|
||||||
|
let min_scroll = if is_intro || is_prepare { counter_y } else { 0.0 };
|
||||||
|
|
||||||
let now_t = ctx.input.time;
|
let now_t = ctx.input.time;
|
||||||
let dt = ctx.input.dt;
|
let dt = ctx.input.dt;
|
||||||
|
|
||||||
|
// Mouse movement (`> 2px`) reveals past upper lines for 3s (`withVisibleUpperLyrics`)
|
||||||
|
if let Some(pos) = ctx.input.pointer_pos {
|
||||||
|
if let Some(prev) = shell.fs_lyrics_last_mouse {
|
||||||
|
if pos.distance(prev) > 2.0 {
|
||||||
|
shell.fs_lyrics_upper_until = now_t + 3.0;
|
||||||
|
shell.fs_lyrics_last_mouse = Some(pos);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
shell.fs_lyrics_last_mouse = Some(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wheel scroll enters manual browse mode for 3s (`withVisibleScrolledLyrics`)
|
||||||
let wheel_dy = if ctx.is_hovered(lyr_rect) {
|
let wheel_dy = if ctx.is_hovered(lyr_rect) {
|
||||||
ctx.input.wheel_delta.y
|
ctx.input.wheel_delta.y
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
if wheel_dy.abs() > 0.25 {
|
if wheel_dy.abs() > 0.25 {
|
||||||
shell.fs_lyrics_scroll_y = (shell.fs_lyrics_scroll_y - wheel_dy).clamp(0.0, total_h.max(0.0));
|
shell.fs_lyrics_scroll_y = (shell.fs_lyrics_scroll_y - wheel_dy).clamp(min_scroll, total_h.max(0.0));
|
||||||
shell.fs_lyrics_manual_until = now_t + 3.0;
|
shell.fs_lyrics_manual_until = now_t + 3.0;
|
||||||
} else if lyr.is_synced && active_idx < line_y.len() && now_t >= shell.fs_lyrics_manual_until {
|
} else if lyr.is_synced && now_t >= shell.fs_lyrics_manual_until {
|
||||||
let target_y = line_y[active_idx];
|
let target_y = if is_intro || is_prepare {
|
||||||
|
counter_y
|
||||||
|
} else if let Some(act) = active_idx {
|
||||||
|
line_y[act]
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
};
|
||||||
let alpha = 1.0 - (-dt * 7.5).exp();
|
let alpha = 1.0 - (-dt * 7.5).exp();
|
||||||
shell.fs_lyrics_scroll_y += (target_y - shell.fs_lyrics_scroll_y) * alpha;
|
shell.fs_lyrics_scroll_y += (target_y - shell.fs_lyrics_scroll_y) * alpha;
|
||||||
if (target_y - shell.fs_lyrics_scroll_y).abs() > 0.4 {
|
if (target_y - shell.fs_lyrics_scroll_y).abs() > 0.4 {
|
||||||
|
|
@ -1295,82 +1356,190 @@ fn render_fullscreen_sync_lyrics(
|
||||||
}
|
}
|
||||||
|
|
||||||
let manual_scrolled = now_t < shell.fs_lyrics_manual_until;
|
let manual_scrolled = now_t < shell.fs_lyrics_manual_until;
|
||||||
let center_y = lyr_rect.center_y();
|
let upper_visible = now_t < shell.fs_lyrics_upper_until;
|
||||||
let lyr_cx = lyr_rect.center_x();
|
let lyr_cx = lyr_rect.center_x();
|
||||||
|
|
||||||
ctx.push_clip(lyr_rect, 0.0);
|
ctx.push_clip(lyr_rect, 0.0);
|
||||||
|
|
||||||
|
// Counter / Loader slot above line 0 (`INTRO`: 4 staggered pulsing dots; `PREPARE`: "3"/"2"/"1")
|
||||||
|
if is_intro || is_prepare {
|
||||||
|
let cy_screen = anchor_y + (counter_y - shell.fs_lyrics_scroll_y);
|
||||||
|
if cy_screen >= lyr_rect.top() - 40.0 && cy_screen <= lyr_rect.bottom() + 40.0 {
|
||||||
|
if is_prepare {
|
||||||
|
let rem_ms = start_ms.saturating_sub(position_ms);
|
||||||
|
let digit = ((rem_ms.saturating_sub(1)) / 1000 + 1).clamp(1, 3);
|
||||||
|
ctx.draw_text_ellipsis(
|
||||||
|
&digit.to_string(),
|
||||||
|
TextStyle::headline(base_sz, Color::WHITE.with_alpha_f32(0.50 * split_t)),
|
||||||
|
Rect::from_center_size(Pos2::new(lyr_cx, cy_screen), Vec2::new(80.0, base_lh)),
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let spacing = 20.0f32;
|
||||||
|
let start_x = lyr_cx - spacing * 1.5;
|
||||||
|
for k in 0..4 {
|
||||||
|
let (dy, dot_a) = if is_playing {
|
||||||
|
let phase = (now_t as f32 * 4.2 - k as f32 * 0.55).sin();
|
||||||
|
(-phase.max(0.0) * 6.0, (0.30 + 0.55 * (phase * 0.5 + 0.5)) * split_t)
|
||||||
|
} else {
|
||||||
|
(0.0, 0.35 * split_t)
|
||||||
|
};
|
||||||
|
ctx.dl().push_circle(
|
||||||
|
Pos2::new(start_x + k as f32 * spacing, cy_screen + dy),
|
||||||
|
5.5,
|
||||||
|
Color::WHITE.with_alpha_f32(dot_a),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if is_playing {
|
||||||
|
ctx.request_repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i, line) in lyr.lines.iter().enumerate() {
|
for (i, line) in lyr.lines.iter().enumerate() {
|
||||||
let y_screen = center_y + (line_y[i] - shell.fs_lyrics_scroll_y);
|
let y_screen = anchor_y + (line_y[i] - shell.fs_lyrics_scroll_y);
|
||||||
let h = line_heights[i];
|
let h = line_heights[i];
|
||||||
if y_screen + h * 0.5 < lyr_rect.top() - 40.0 || y_screen - h * 0.5 > lyr_rect.bottom() + 40.0 {
|
let is_active = !manual_scrolled && active_idx == Some(i);
|
||||||
|
|
||||||
|
let target_op: f32 = if !lyr.is_synced || manual_scrolled {
|
||||||
|
1.0
|
||||||
|
} else if is_intro || is_prepare {
|
||||||
|
if i == 0 { 0.30 } else { 0.10 }
|
||||||
|
} else if let Some(act) = active_idx {
|
||||||
|
if i == act {
|
||||||
|
1.0
|
||||||
|
} else if i == act + 1 {
|
||||||
|
0.30
|
||||||
|
} else if i > act + 1 {
|
||||||
|
0.10
|
||||||
|
} else if upper_visible {
|
||||||
|
0.10
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
0.10
|
||||||
|
};
|
||||||
|
|
||||||
|
let op_t = ctx.animate_f32(WidgetId::from_pair("fs_lyr_op", i), target_op, 0.45);
|
||||||
|
let act_t = ctx.animate_bool(WidgetId::from_pair("fs_lyr_act", i), is_active, 0.45);
|
||||||
|
|
||||||
|
if y_screen + h * 0.65 < lyr_rect.top() - 48.0
|
||||||
|
|| y_screen - h * 0.65 > lyr_rect.bottom() + 48.0
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_active = i == active_idx;
|
let line_visible = op_t > 0.02 || manual_scrolled || upper_visible || !lyr.is_synced;
|
||||||
let is_next = active_idx != usize::MAX && i == active_idx + 1;
|
let hit_r = Rect::from_center_size(Pos2::new(lyr_cx, y_screen), Vec2::new(max_line_w, h + 14.0));
|
||||||
let hit_r = Rect::from_center_size(Pos2::new(lyr_cx, y_screen), Vec2::new(max_line_w, h + 12.0));
|
|
||||||
let resp = ctx.interact(WidgetId::from_pair("fs_lyr_ln", i), hit_r);
|
let resp = ctx.interact(WidgetId::from_pair("fs_lyr_ln", i), hit_r);
|
||||||
|
|
||||||
let act_t = ctx.animate_bool(WidgetId::from_pair("fs_lyr_act", i), is_active, 0.35);
|
|
||||||
let hov_t = ctx.animate_bool(
|
let hov_t = ctx.animate_bool(
|
||||||
WidgetId::from_pair("fs_lyr_hov", i),
|
WidgetId::from_pair("fs_lyr_hov", i),
|
||||||
resp.hovered && lyr.is_synced,
|
resp.hovered && lyr.is_synced && line_visible,
|
||||||
0.18,
|
0.18,
|
||||||
);
|
);
|
||||||
|
|
||||||
let base_alpha = if !lyr.is_synced || manual_scrolled {
|
let alpha = op_t.max(0.85 * hov_t) * split_t;
|
||||||
0.90f32
|
if alpha > 0.005 {
|
||||||
} else if is_next {
|
let col = Color::WHITE.with_alpha_f32(alpha);
|
||||||
0.34
|
let txt = if line.text.trim().is_empty() {
|
||||||
} else {
|
"• • •"
|
||||||
0.16
|
} else {
|
||||||
};
|
line.text.as_str()
|
||||||
let alpha = (base_alpha + (1.0 - base_alpha) * act_t)
|
};
|
||||||
.max(0.90 * hov_t)
|
|
||||||
* split_t;
|
|
||||||
let sz = base_sz + (active_sz - base_sz) * act_t;
|
|
||||||
let col = Color::WHITE.with_alpha_f32(alpha);
|
|
||||||
let txt = if line.text.trim().is_empty() {
|
|
||||||
"• • •"
|
|
||||||
} else {
|
|
||||||
line.text.as_str()
|
|
||||||
};
|
|
||||||
|
|
||||||
let draw_r = Rect::from_center_size(Pos2::new(lyr_cx, y_screen), Vec2::new(max_line_w, h + 6.0));
|
if act_t < 0.01 {
|
||||||
ctx.draw_text_wrapped(txt, TextStyle::headline(sz, col), draw_r, None, TextAlign::Center);
|
ctx.draw_text_wrapped_scaled(
|
||||||
|
txt,
|
||||||
|
TextStyle::headline(base_sz, col).with_line_height(base_lh),
|
||||||
|
Rect::from_center_size(Pos2::new(lyr_cx, y_screen), Vec2::new(max_line_w, h)),
|
||||||
|
1.0,
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let sc = (1.0 + 0.2 * act_t) / 1.2;
|
||||||
|
ctx.draw_text_wrapped_scaled(
|
||||||
|
txt,
|
||||||
|
TextStyle::headline(active_sz, col).with_line_height(active_lh),
|
||||||
|
Rect::from_center_size(
|
||||||
|
Pos2::new(lyr_cx, y_screen),
|
||||||
|
Vec2::new(max_line_w * 1.2, h * 1.2),
|
||||||
|
),
|
||||||
|
sc,
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if lyr.is_synced {
|
if lyr.is_synced && line_visible {
|
||||||
if resp.hovered {
|
if resp.hovered {
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
ctx.set_cursor(CursorKind::Pointer);
|
||||||
}
|
}
|
||||||
if resp.clicked {
|
if resp.clicked {
|
||||||
actions.push(AppAction::SeekMs(line.time_ms));
|
actions.push(AppAction::SeekMs(line.time_ms.saturating_add(10)));
|
||||||
shell.fs_lyrics_manual_until = 0.0;
|
shell.fs_lyrics_manual_until = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writers footer
|
// Official `SyncLyricsFooter`: Writers + Source (`major`) attribution at `0.50` alpha
|
||||||
if let Some(ref writers) = lyr.writers {
|
let has_writers = lyr.writers.as_deref().map_or(false, |s| !s.trim().is_empty());
|
||||||
let fy = center_y + (total_h + 24.0 - shell.fs_lyrics_scroll_y);
|
let has_major = lyr.major.as_deref().map_or(false, |s| !s.trim().is_empty());
|
||||||
if fy >= lyr_rect.top() - 40.0 && fy <= lyr_rect.bottom() + 40.0 {
|
if has_writers || has_major {
|
||||||
|
let footer_pad_top = (screen_w * 0.0625).clamp(48.0, 96.0);
|
||||||
|
let footer_sz = (screen_w * 0.0125).clamp(15.0, 20.0);
|
||||||
|
let footer_col = Color::WHITE.with_alpha_f32(0.50 * split_t);
|
||||||
|
let footer_style = TextStyle::medium(footer_sz, footer_col);
|
||||||
|
let mut fy = anchor_y + (total_h + footer_pad_top - shell.fs_lyrics_scroll_y);
|
||||||
|
|
||||||
|
if let Some(ref writers) = lyr.writers.as_deref().filter(|s| !s.trim().is_empty()) {
|
||||||
let txt = if ru {
|
let txt = if ru {
|
||||||
format!("Авторы: {}", writers)
|
format!("Авторы: {}", writers)
|
||||||
} else {
|
} else {
|
||||||
format!("Writers: {}", writers)
|
format!("Writers: {}", writers)
|
||||||
};
|
};
|
||||||
ctx.draw_text_wrapped(
|
let mh = ctx
|
||||||
&txt,
|
.measure_text(&txt, footer_style, Some(max_line_w))
|
||||||
TextStyle::regular(14.0, Color::WHITE.with_alpha_f32(0.5 * split_t)),
|
.y
|
||||||
Rect::from_center_size(Pos2::new(lyr_cx, fy), Vec2::new(max_line_w, 40.0)),
|
.max(footer_sz * 1.35);
|
||||||
Some(2),
|
if fy + mh >= lyr_rect.top() - 40.0 && fy <= lyr_rect.bottom() + 40.0 {
|
||||||
TextAlign::Center,
|
ctx.draw_text_wrapped(
|
||||||
);
|
&txt,
|
||||||
|
footer_style,
|
||||||
|
Rect::from_xywh(lyr_cx - max_line_w * 0.5, fy, max_line_w, mh + 4.0),
|
||||||
|
Some(3),
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fy += mh + 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(ref major) = lyr.major.as_deref().filter(|s| !s.trim().is_empty()) {
|
||||||
|
let txt = if ru {
|
||||||
|
format!("Источник: {}", major)
|
||||||
|
} else {
|
||||||
|
format!("Source: {}", major)
|
||||||
|
};
|
||||||
|
let mh = ctx
|
||||||
|
.measure_text(&txt, footer_style, Some(max_line_w))
|
||||||
|
.y
|
||||||
|
.max(footer_sz * 1.35);
|
||||||
|
if fy + mh >= lyr_rect.top() - 40.0 && fy <= lyr_rect.bottom() + 40.0 {
|
||||||
|
ctx.draw_text_wrapped(
|
||||||
|
&txt,
|
||||||
|
footer_style,
|
||||||
|
Rect::from_xywh(lyr_cx - max_line_w * 0.5, fy, max_line_w, mh + 4.0),
|
||||||
|
Some(2),
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smooth top & bottom gradient fade masks into `bg_color`
|
// Official `80px` (`5rem`) top & bottom gradient fade masks into `bg_color`
|
||||||
let fade_h = 84.0f32.min(lyr_rect.height() * 0.22);
|
let fade_h = 80.0f32.min(lyr_rect.height() * 0.25);
|
||||||
let bg_clear = bg_color.with_alpha(0);
|
let bg_clear = bg_color.with_alpha(0);
|
||||||
ctx.dl().push_gradient_rect(
|
ctx.dl().push_gradient_rect(
|
||||||
Rect::from_xywh(lyr_rect.left(), lyr_rect.top(), lyr_rect.width(), fade_h),
|
Rect::from_xywh(lyr_rect.left(), lyr_rect.top(), lyr_rect.width(), fade_h),
|
||||||
|
|
|
||||||
|
|
@ -1194,7 +1194,7 @@ pub fn render_concerts(
|
||||||
ctx.request_repaint();
|
ctx.request_repaint();
|
||||||
let t_sec = app.start_time.elapsed().as_secs_f32() * 3.0;
|
let t_sec = app.start_time.elapsed().as_secs_f32() * 3.0;
|
||||||
|
|
||||||
// 3 featured shimmer poster cards
|
// 3 featured shimmer poster cards (matching official 0.963 TopConcertsCarousel aspect ratio)
|
||||||
let gap = 16.0;
|
let gap = 16.0;
|
||||||
let f_cols = if avail_w >= 860.0 {
|
let f_cols = if avail_w >= 860.0 {
|
||||||
3usize
|
3usize
|
||||||
|
|
@ -1203,16 +1203,17 @@ pub fn render_concerts(
|
||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
let f_w = ((avail_w - gap * (f_cols as f32 - 1.0)) / f_cols as f32).max(220.0);
|
let f_w = ((avail_w - gap * (f_cols as f32 - 1.0)) / f_cols as f32).clamp(240.0, 440.0);
|
||||||
|
let f_h = (f_w / 0.963).clamp(240.0, 320.0);
|
||||||
for i in 0..f_cols {
|
for i in 0..f_cols {
|
||||||
let col = shimmer_color(pal, t_sec + i as f32 * 0.55);
|
let col = shimmer_color(pal, t_sec + i as f32 * 0.55);
|
||||||
ctx.dl().push_rect(
|
ctx.dl().push_rect(
|
||||||
Rect::from_xywh(x + i as f32 * (f_w + gap), y, f_w, 210.0),
|
Rect::from_xywh(x + i as f32 * (f_w + gap), y, f_w, f_h),
|
||||||
16.0,
|
16.0,
|
||||||
col,
|
col,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
y += 236.0;
|
y += f_h + 26.0;
|
||||||
|
|
||||||
// 4 shimmer feed rows
|
// 4 shimmer feed rows
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
|
|
@ -1276,7 +1277,7 @@ pub fn render_concerts(
|
||||||
}
|
}
|
||||||
.max(1);
|
.max(1);
|
||||||
let f_w = ((avail_w - gap * (f_cols as f32 - 1.0)) / f_cols as f32).clamp(240.0, 440.0);
|
let f_w = ((avail_w - gap * (f_cols as f32 - 1.0)) / f_cols as f32).clamp(240.0, 440.0);
|
||||||
let f_h = 216.0;
|
let f_h = (f_w / 0.963).clamp(240.0, 320.0);
|
||||||
|
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
if ru { "Рекомендуем" } else { "Featured" },
|
if ru { "Рекомендуем" } else { "Featured" },
|
||||||
|
|
|
||||||
|
|
@ -339,8 +339,9 @@ pub fn render_search(
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
let balb_title = balb.full_title();
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
&balb.title,
|
&balb_title,
|
||||||
TextStyle::bold(16.5, pal.text_bright),
|
TextStyle::bold(16.5, pal.text_bright),
|
||||||
Rect::from_xywh(text_x, card_r.top() + 22.0, text_w, 24.0),
|
Rect::from_xywh(text_x, card_r.top() + 22.0, text_w, 24.0),
|
||||||
TextAlign::Left,
|
TextAlign::Left,
|
||||||
|
|
@ -726,8 +727,9 @@ pub fn render_search(
|
||||||
let h_id = WidgetId::new("search_albums_hscroll");
|
let h_id = WidgetId::new("search_albums_hscroll");
|
||||||
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||||
let mut cx = x - sx;
|
let mut cx = x - sx;
|
||||||
for alb in res.albums.iter().take(12) {
|
for (idx, alb) in res.albums.iter().take(12).enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let sub = alb
|
let sub = alb
|
||||||
.artists
|
.artists
|
||||||
.first()
|
.first()
|
||||||
|
|
@ -737,9 +739,9 @@ pub fn render_search(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("s_alb", &alb.id),
|
WidgetId::from_pair("s_alb", (idx, &alb.id)),
|
||||||
cr,
|
cr,
|
||||||
&alb.title,
|
&alb_title,
|
||||||
sub,
|
sub,
|
||||||
alb.cover_uri.as_deref(),
|
alb.cover_uri.as_deref(),
|
||||||
&format!("alb_{}", alb.id),
|
&format!("alb_{}", alb.id),
|
||||||
|
|
@ -749,12 +751,12 @@ pub fn render_search(
|
||||||
if m.play_clicked {
|
if m.play_clicked {
|
||||||
actions.push(AppAction::PlayAlbum {
|
actions.push(AppAction::PlayAlbum {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
});
|
});
|
||||||
} else if m.clicked {
|
} else if m.clicked {
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
cx += card_w + 16.0;
|
cx += card_w + 16.0;
|
||||||
|
|
@ -776,6 +778,7 @@ pub fn render_search(
|
||||||
card_h,
|
card_h,
|
||||||
);
|
);
|
||||||
if cr.bottom() >= body_vp.top() - 40.0 && cr.top() <= body_vp.bottom() + 40.0 {
|
if cr.bottom() >= body_vp.top() - 40.0 && cr.top() <= body_vp.bottom() + 40.0 {
|
||||||
|
let alb_title = alb.full_title();
|
||||||
let sub = alb
|
let sub = alb
|
||||||
.artists
|
.artists
|
||||||
.first()
|
.first()
|
||||||
|
|
@ -785,9 +788,9 @@ pub fn render_search(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("s_alb_grid", &alb.id),
|
WidgetId::from_pair("s_alb_grid", (idx, &alb.id)),
|
||||||
cr,
|
cr,
|
||||||
&alb.title,
|
&alb_title,
|
||||||
sub,
|
sub,
|
||||||
alb.cover_uri.as_deref(),
|
alb.cover_uri.as_deref(),
|
||||||
&format!("alb_{}", alb.id),
|
&format!("alb_{}", alb.id),
|
||||||
|
|
@ -797,12 +800,12 @@ pub fn render_search(
|
||||||
if m.play_clicked {
|
if m.play_clicked {
|
||||||
actions.push(AppAction::PlayAlbum {
|
actions.push(AppAction::PlayAlbum {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
});
|
});
|
||||||
} else if m.clicked {
|
} else if m.clicked {
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
id: alb.id.clone(),
|
id: alb.id.clone(),
|
||||||
title: alb.title.clone(),
|
title: alb_title,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -831,13 +834,16 @@ pub fn render_search(
|
||||||
let h_id = WidgetId::new("search_playlists_hscroll");
|
let h_id = WidgetId::new("search_playlists_hscroll");
|
||||||
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
||||||
let mut cx = x - sx;
|
let mut cx = x - sx;
|
||||||
for pl in res.playlists.iter().take(12) {
|
for (idx, pl) in res.playlists.iter().take(12).enumerate() {
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
let m = media_card(
|
let m = media_card(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("s_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
WidgetId::from_pair(
|
||||||
|
"s_pl",
|
||||||
|
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
&pl.owner_name,
|
&pl.owner_name,
|
||||||
|
|
@ -889,7 +895,7 @@ pub fn render_search(
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair(
|
WidgetId::from_pair(
|
||||||
"s_pl_grid",
|
"s_pl_grid",
|
||||||
format!("{}_{}", pl.owner_uid, pl.kind),
|
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
),
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,8 @@ pub fn render_sidebar(
|
||||||
};
|
};
|
||||||
let cover_rect = Rect::from_center_size(cover_center, Vec2::splat(40.0));
|
let cover_rect = Rect::from_center_size(cover_center, Vec2::splat(40.0));
|
||||||
let is_circle = pin.kind == "artist" || is_wave;
|
let is_circle = pin.kind == "artist" || is_wave;
|
||||||
|
let is_likes_art = pin.kind == "likes"
|
||||||
|
|| (pin.kind == "playlist" && pin.id.ends_with(":3") && pin.cover_uri.is_none());
|
||||||
draw_cover_art(
|
draw_cover_art(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
|
|
@ -296,7 +298,7 @@ pub fn render_sidebar(
|
||||||
&pin.id,
|
&pin.id,
|
||||||
4.0,
|
4.0,
|
||||||
is_circle,
|
is_circle,
|
||||||
pin.kind == "likes",
|
is_likes_art,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Hover Play/Pause overlay on ALL pinned items (playlists, albums, favorites, artists & waves!)
|
// Hover Play/Pause overlay on ALL pinned items (playlists, albums, favorites, artists & waves!)
|
||||||
|
|
|
||||||
|
|
@ -1890,6 +1890,7 @@ fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
|
||||||
let mk_album = |id: &str, title: &str, artist: &str| AlbumSummary {
|
let mk_album = |id: &str, title: &str, artist: &str| AlbumSummary {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
title: title.into(),
|
title: title.into(),
|
||||||
|
version: None,
|
||||||
year: Some(2026),
|
year: Some(2026),
|
||||||
cover_uri: None,
|
cover_uri: None,
|
||||||
artists: vec![ArtistSummary {
|
artists: vec![ArtistSummary {
|
||||||
|
|
@ -2170,9 +2171,9 @@ fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||||
let _ = img.save(out_dir.join("concerts_official.png"));
|
let _ = img.save(out_dir.join("concerts_official.png"));
|
||||||
|
|
||||||
// Verify Top 3 colored poster cards + upcoming feed rendered cleanly
|
// Verify Top 3 poster cards (aspect 0.963, h~320px) + cashback pills + yellow price CTAs rendered cleanly
|
||||||
let mut poster_chromatic_px = 0usize;
|
let mut poster_chromatic_px = 0usize;
|
||||||
for y in 160..420 {
|
for y in 160..540 {
|
||||||
for x in 250..1240 {
|
for x in 250..1240 {
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
let [r, g, b] = img.get_pixel(x, y).0;
|
||||||
if r.max(g).max(b).saturating_sub(r.min(g).min(b)) >= 20 {
|
if r.max(g).max(b).saturating_sub(r.min(g).min(b)) >= 20 {
|
||||||
|
|
@ -2244,3 +2245,273 @@ fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_ext_18_qa_sync_lyrics_scroll_concerts_duplicate_albums() {
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
use yandex_music_rs::api::models::{AlbumSummary, LyricLine, TrackLyrics};
|
||||||
|
use yandex_music_rs::app::CollectionTab;
|
||||||
|
use yandex_music_rs::engine::input::{InputState, ZLayer};
|
||||||
|
use yandex_music_rs::engine::scroll::ScrollState;
|
||||||
|
use yandex_music_rs::engine::types::{Pos2, Rect};
|
||||||
|
use yandex_music_rs::engine::widgets::cover_fit_uv;
|
||||||
|
|
||||||
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
|
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
|
||||||
|
let out_dir = output_dir();
|
||||||
|
let _ = std::fs::create_dir_all(&out_dir);
|
||||||
|
|
||||||
|
// 1. 1-to-1 Official FullscreenPlayerDesktop 50/50 SyncLyrics (`fullscreen_sync_lyrics_official.png`)
|
||||||
|
{
|
||||||
|
let mut shell = make_base_shell(
|
||||||
|
rt.handle().clone(),
|
||||||
|
vk.gpu_name.clone(),
|
||||||
|
Route::LikedTracks,
|
||||||
|
ThemeMode::Dark,
|
||||||
|
Language::Ru,
|
||||||
|
0.0,
|
||||||
|
);
|
||||||
|
if let Some(tr) = shell.app.queue.get_mut(0) {
|
||||||
|
tr.derived_average_hex = Some("#1A2238".into());
|
||||||
|
}
|
||||||
|
shell.app.current_lyrics = Some(TrackLyrics {
|
||||||
|
track_id: "t_1".into(),
|
||||||
|
is_synced: true,
|
||||||
|
lines: vec![
|
||||||
|
LyricLine { time_ms: 4_000, text: "Первая строчка уходит вверх".into() },
|
||||||
|
LyricLine { time_ms: 10_000, text: "Вторая строчка уже прозвучала".into() },
|
||||||
|
LyricLine { time_ms: 16_000, text: "Третья строчка перед текущей".into() },
|
||||||
|
LyricLine { time_ms: 21_000, text: "Активная яркая строка прямо по центру".into() },
|
||||||
|
LyricLine { time_ms: 28_000, text: "Следующая строчка ждёт своей очереди".into() },
|
||||||
|
LyricLine { time_ms: 35_000, text: "Пятая строчка чуть дальше вниз".into() },
|
||||||
|
LyricLine { time_ms: 42_000, text: "Шестая строчка в приглушённом цвете".into() },
|
||||||
|
LyricLine { time_ms: 49_000, text: "Финальная строчка композиции".into() },
|
||||||
|
],
|
||||||
|
writers: Some("Test Writer".into()),
|
||||||
|
major: Some("Genius".into()),
|
||||||
|
});
|
||||||
|
shell.app.fullscreen_open = true;
|
||||||
|
shell.app.fullscreen_lyrics_open = true;
|
||||||
|
shell.app.audio.state.position_ms.store(22_000, Ordering::SeqCst);
|
||||||
|
shell.app.audio.state.is_playing.store(true, Ordering::SeqCst);
|
||||||
|
shell.shell.fs_lyrics_upper_until = 0.0;
|
||||||
|
shell.shell.fs_lyrics_manual_until = 0.0;
|
||||||
|
|
||||||
|
// Settle 0.45s split + opacity animations cleanly with mouse idle
|
||||||
|
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||||
|
for f in 1..25 {
|
||||||
|
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.05);
|
||||||
|
}
|
||||||
|
let _ = img.save(out_dir.join("fullscreen_sync_lyrics_official.png"));
|
||||||
|
|
||||||
|
// Verify bright white active line near 40vh (y=250..410, x=600..1220)
|
||||||
|
let mut active_bright_px = 0usize;
|
||||||
|
for y in 250..410 {
|
||||||
|
for x in 600..1220 {
|
||||||
|
let [r, g, b] = img.get_pixel(x, y).0;
|
||||||
|
if r >= 200 && g >= 200 && b >= 200 {
|
||||||
|
active_bright_px += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert!(
|
||||||
|
active_bright_px >= 600,
|
||||||
|
"[fullscreen_sync_lyrics] Expected bright white active line near 40vh, found {} px",
|
||||||
|
active_bright_px
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify past lines above active (y=60..210, x=640..1180) are hidden (0 bright white px) when mouse is idle
|
||||||
|
let mut past_bright_px = 0usize;
|
||||||
|
for y in 60..210 {
|
||||||
|
for x in 640..1180 {
|
||||||
|
let [r, g, b] = img.get_pixel(x, y).0;
|
||||||
|
if r >= 170 && g >= 170 && b >= 170 {
|
||||||
|
past_bright_px += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_eq!(
|
||||||
|
past_bright_px, 0,
|
||||||
|
"[fullscreen_sync_lyrics] Past upper lines must be hidden (opacity 0.0) when mouse is idle, found {} bright px",
|
||||||
|
past_bright_px
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify Volume button is anchored in the bottom-right corner (center ~(1236, 760)), NOT bottom-center
|
||||||
|
let mut vol_corner_bright_px = 0usize;
|
||||||
|
for y in 740..780 {
|
||||||
|
for x in 1216..1256 {
|
||||||
|
let [r, g, b] = img.get_pixel(x, y).0;
|
||||||
|
if r >= 160 && g >= 160 && b >= 160 {
|
||||||
|
vol_corner_bright_px += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert!(
|
||||||
|
vol_corner_bright_px >= 25,
|
||||||
|
"[fullscreen_sync_lyrics] Expected Volume icon anchored in bottom-right corner (1236,760), found {} bright px",
|
||||||
|
vol_corner_bright_px
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Horizontal Scroll Isolation: plain vertical wheel MUST NOT scroll horizontal-only carousels!
|
||||||
|
{
|
||||||
|
let vp = Rect::from_xywh(0.0, 0.0, 600.0, 200.0);
|
||||||
|
let mut st = ScrollState::new();
|
||||||
|
st.content_size = Vec2::new(2000.0, 200.0);
|
||||||
|
|
||||||
|
let mut inp = InputState::new();
|
||||||
|
inp.pointer_pos = Some(Pos2::new(200.0, 100.0));
|
||||||
|
inp.wheel_delta = Vec2::new(0.0, -120.0);
|
||||||
|
st.update(&inp, ZLayer::Base, vp, false, true);
|
||||||
|
assert!(
|
||||||
|
st.target.x.abs() < 0.001,
|
||||||
|
"Horizontal-only ScrollState must ignore plain vertical wheel_delta.y, got target.x={}",
|
||||||
|
st.target.x
|
||||||
|
);
|
||||||
|
|
||||||
|
// Shift + vertical wheel scrolls horizontally
|
||||||
|
inp.modifiers.shift = true;
|
||||||
|
st.update(&inp, ZLayer::Base, vp, false, true);
|
||||||
|
assert!(
|
||||||
|
st.target.x > 50.0,
|
||||||
|
"Shift + wheel_delta.y must scroll horizontally, got target.x={}",
|
||||||
|
st.target.x
|
||||||
|
);
|
||||||
|
|
||||||
|
// Trackpad horizontal wheel_delta.x scrolls horizontally without Shift
|
||||||
|
st.reset();
|
||||||
|
inp.modifiers.shift = false;
|
||||||
|
inp.wheel_delta = Vec2::new(-120.0, 0.0);
|
||||||
|
st.update(&inp, ZLayer::Base, vp, false, true);
|
||||||
|
assert!(
|
||||||
|
st.target.x > 50.0,
|
||||||
|
"Horizontal wheel_delta.x must scroll horizontally, got target.x={}",
|
||||||
|
st.target.x
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. `object-fit: cover` (`cover_fit_uv`) preserves aspect ratio with zero stretching
|
||||||
|
{
|
||||||
|
let uv_wide = cover_fit_uv(400, 400, Rect::from_xywh(0.0, 0.0, 300.0, 150.0), 0.35);
|
||||||
|
assert!(
|
||||||
|
(uv_wide.w - 1.0).abs() < 1e-4 && (uv_wide.h - 0.5).abs() < 1e-4,
|
||||||
|
"400x400 in 300x150 expected uv (w=1.0, h=0.5), got {:?}",
|
||||||
|
uv_wide
|
||||||
|
);
|
||||||
|
let uv_portrait = cover_fit_uv(200, 400, Rect::from_xywh(0.0, 0.0, 200.0, 200.0), 0.35);
|
||||||
|
assert!(
|
||||||
|
(uv_portrait.w - 1.0).abs() < 1e-4 && (uv_portrait.h - 0.5).abs() < 1e-4,
|
||||||
|
"200x400 in 200x200 expected uv (w=1.0, h=0.5), got {:?}",
|
||||||
|
uv_portrait
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Concerts Active Icon (`Icon::ConcertsSelected`) rasterizes with symmetric filled ticket silhouette
|
||||||
|
{
|
||||||
|
let opt = resvg::usvg::Options::default();
|
||||||
|
let tree = resvg::usvg::Tree::from_data(Icon::ConcertsSelected.raw_svg(), &opt)
|
||||||
|
.expect("ConcertsSelected SVG parse failed");
|
||||||
|
let sz = 48u32;
|
||||||
|
let mut pixmap = resvg::tiny_skia::Pixmap::new(sz, sz).unwrap();
|
||||||
|
let sx = sz as f32 / tree.size().width();
|
||||||
|
let sy = sz as f32 / tree.size().height();
|
||||||
|
resvg::render(
|
||||||
|
&tree,
|
||||||
|
resvg::tiny_skia::Transform::from_scale(sx, sy),
|
||||||
|
&mut pixmap.as_mut(),
|
||||||
|
);
|
||||||
|
let data = pixmap.data();
|
||||||
|
let mut left_cov = 0u64;
|
||||||
|
let mut right_cov = 0u64;
|
||||||
|
for y in 0..sz {
|
||||||
|
for x in 0..sz {
|
||||||
|
let a = data[((y * sz + x) * 4 + 3) as usize] as u64;
|
||||||
|
if x < sz / 2 {
|
||||||
|
left_cov += a;
|
||||||
|
} else {
|
||||||
|
right_cov += a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let total = left_cov + right_cov;
|
||||||
|
assert!(
|
||||||
|
total > 40_000,
|
||||||
|
"ConcertsSelected SVG coverage too small ({})",
|
||||||
|
total
|
||||||
|
);
|
||||||
|
let asym = (left_cov as i64 - right_cov as i64).unsigned_abs() as f64 / total as f64;
|
||||||
|
assert!(
|
||||||
|
asym < 0.05,
|
||||||
|
"ConcertsSelected SVG is asymmetric (left={}, right={}, asym={:.3})",
|
||||||
|
left_cov,
|
||||||
|
right_cov,
|
||||||
|
asym
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Duplicate-Title Albums render distinctly in Collection overview + Albums sub-view with zero panics
|
||||||
|
{
|
||||||
|
let mk_dup = |id: &str, version: Option<&str>| AlbumSummary {
|
||||||
|
id: id.into(),
|
||||||
|
title: "Same Title Album".into(),
|
||||||
|
version: version.map(String::from),
|
||||||
|
year: Some(2025),
|
||||||
|
cover_uri: None,
|
||||||
|
artists: vec![ArtistSummary {
|
||||||
|
id: "art_dup".into(),
|
||||||
|
name: "Test Artist".into(),
|
||||||
|
cover_uri: None,
|
||||||
|
genres: vec![],
|
||||||
|
}],
|
||||||
|
track_count: 10,
|
||||||
|
genre: Some("pop".into()),
|
||||||
|
is_explicit: false,
|
||||||
|
content_type: Some("album".into()),
|
||||||
|
};
|
||||||
|
let std_alb = mk_dup("alb_std", None);
|
||||||
|
let dlx_alb = mk_dup("alb_dlx", Some("Deluxe"));
|
||||||
|
assert_eq!(std_alb.full_title(), "Same Title Album");
|
||||||
|
assert_eq!(dlx_alb.full_title(), "Same Title Album (Deluxe)");
|
||||||
|
|
||||||
|
let mut shell = make_base_shell(
|
||||||
|
rt.handle().clone(),
|
||||||
|
vk.gpu_name.clone(),
|
||||||
|
Route::Collection,
|
||||||
|
ThemeMode::Dark,
|
||||||
|
Language::Ru,
|
||||||
|
0.0,
|
||||||
|
);
|
||||||
|
shell.app.liked_albums = vec![std_alb, dlx_alb];
|
||||||
|
shell.app.collection_tab = CollectionTab::Tracks;
|
||||||
|
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
||||||
|
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
||||||
|
|
||||||
|
shell.app.collection_tab = CollectionTab::Albums;
|
||||||
|
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
|
||||||
|
let img_albums = render_single_frame(&mut vk, &mut shell, 0.048);
|
||||||
|
|
||||||
|
// Confirm both album cards rendered distinct non-empty content in the Albums grid (x=250..650, y=130..360)
|
||||||
|
let mut card1_lit = 0usize;
|
||||||
|
let mut card2_lit = 0usize;
|
||||||
|
for y in 130..360 {
|
||||||
|
for x in 250..430 {
|
||||||
|
let [r, g, b] = img_albums.get_pixel(x, y).0;
|
||||||
|
if r > 30 || g > 30 || b > 30 {
|
||||||
|
card1_lit += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for x in 450..630 {
|
||||||
|
let [r, g, b] = img_albums.get_pixel(x, y).0;
|
||||||
|
if r > 30 || g > 30 || b > 30 {
|
||||||
|
card2_lit += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert!(
|
||||||
|
card1_lit > 2_000 && card2_lit > 2_000,
|
||||||
|
"Expected both duplicate-title album cards to render distinctly (card1={}, card2={})",
|
||||||
|
card1_lit,
|
||||||
|
card2_lit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue