Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
180
AGENTS.md
|
|
@ -1,180 +0,0 @@
|
||||||
# Инструкция для AI-агентов (Git, коммиты и релизы на git.tatar)
|
|
||||||
|
|
||||||
Этот репозиторий хостится на **Forgejo** (`https://git.tatar/marwy/yandex-music-rs`).
|
|
||||||
Авторизация на `https://git.tatar` должна храниться в Windows Credential Manager как **бессрочный Personal Access Token (PAT)** с `credential.https://git.tatar.provider = generic` (НЕ через OAuth-окно GCM — OAuth-токен Forgejo протухает через ~1 час, после чего `git push` удаляет запись из Credential Manager).
|
|
||||||
|
|
||||||
> **ВАЖНО:**
|
|
||||||
> 1. **НИКОГДА не используй браузер** для создания релизов, загрузки ассетов или настройки репозитория на `git.tatar` — браузер не авторизован и упрётся в страницу логина. Все операции с `git.tatar` выполняются через **Forgejo REST API v1** с токеном из `git credential fill`.
|
|
||||||
> 2. **НИКОГДА не печатай токен** в stdout, логи, файлы или ответы пользователю.
|
|
||||||
> 3. **НИКОГДА не коммить** `target/`, `original_yandex_music/`, `Yandex_Music_*.exe`, локальные `.deb`/`.exe`/`.tar.gz` и личные OAuth-токены Яндекс Музыки.
|
|
||||||
> 4. **Перед `git push` проверяй токен без интерактива** (`$env:GCM_INTERACTIVE = "never"` + `GET https://git.tatar/api/v1/user`): если токен отсутствует или истёк (401), не вешай `git push` на невидимом окне GCM — сразу попроси пользователя сохранить бессрочный PAT из `https://git.tatar/user/settings/applications` (см. раздел 0).
|
|
||||||
> 5. **Релизы и теги строго иммутабельны — НИКОГДА не перезаписывай и не двигай уже выпущенную версию!** Запрещено делать `git tag -f` на существующий релиз, удалять/перезаливать ассеты под старым `vX.Y.Z` или пересобирать новую правку под уже отданным пользователю номером версии. Любое изменение после сборки/публикации `vX.Y.Z` **всегда** выходит как **новая версия** (`v0.1.2` → `v0.1.3`), чтобы у клиентов никогда не было разных бинарников под одним номером версии и автообновление работало корректно.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 0. Первичная настройка бессрочного токена (делается пользователем 1 раз)
|
|
||||||
|
|
||||||
Если токен отсутствует или протух (401), пользователь создаёт **Access Token** на `https://git.tatar/user/settings/applications` (права: `write:repository`, `read:user`) и сохраняет его один раз:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
git config --global credential.https://git.tatar.provider generic
|
|
||||||
"protocol=https`nhost=git.tatar`nusername=marwy`npassword=<TOKEN>`n" | git credential approve
|
|
||||||
```
|
|
||||||
|
|
||||||
Проверка из агента (никогда не выводить `$token`, всегда ставить `GCM_INTERACTIVE=never`):
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
$env:GCM_INTERACTIVE = "never"
|
|
||||||
$credOut = "protocol=https`nhost=git.tatar`n`n" | git credential fill 2>$null
|
|
||||||
$token = ($credOut | Where-Object { $_ -like 'password=*' }) -replace '^password=',''
|
|
||||||
if (-not $token) { throw "No token in Credential Manager (need PAT for git.tatar)" }
|
|
||||||
$u = Invoke-RestMethod -Uri "https://git.tatar/api/v1/user" -Headers @{ Authorization = "token $token" }
|
|
||||||
Write-Output ("AUTH_OK: " + $u.login)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. Коммиты и пуш (`git push`)
|
|
||||||
|
|
||||||
- Ветка по умолчанию: `main`.
|
|
||||||
- Используй Conventional Commits (`feat: ...`, `fix: ...`, `chore(release): vX.Y.Z`, `docs: ...`).
|
|
||||||
- На Windows **PowerShell 5.1 не поддерживает `&&`** — разделяй команды через `;` с проверкой `if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }`.
|
|
||||||
- При добавлении новых shell-скриптов (`*.sh`, `packaging/debian/*`) на Windows обязательно выставляй бит исполняемости в индексе:
|
|
||||||
```powershell
|
|
||||||
git update-index --chmod=+x packaging/build-deb.sh packaging/debian/postinst packaging/debian/postrm
|
|
||||||
```
|
|
||||||
- Обычный `git push origin main` и `git push origin vX.Y.Z` работают автоматически через системный Git Credential Manager (авторизация уже сохранена).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Сборка релиза `vX.Y.Z` (Windows + Linux)
|
|
||||||
|
|
||||||
1. Обнови версию в `Cargo.toml` (и при необходимости ссылки в `README.md`), закоммить и запушь:
|
|
||||||
```powershell
|
|
||||||
git add Cargo.toml Cargo.lock README.md
|
|
||||||
git commit -m "chore(release): vX.Y.Z"
|
|
||||||
git push origin main
|
|
||||||
```
|
|
||||||
2. **Windows x64** (все ресурсы встроены через `include_bytes!`, получается единый portable `.exe`):
|
|
||||||
```powershell
|
|
||||||
cargo build --release
|
|
||||||
```
|
|
||||||
Бинарник: `target\release\yandex-music-rs.exe`.
|
|
||||||
3. **Linux x64 (`.deb` + `.tar.gz`)** через WSL (передавай bash-скрипт через `stdin` в `wsl bash -s`, чтобы Windows не ломал кавычки):
|
|
||||||
```powershell
|
|
||||||
$ver = "0.1.1"
|
|
||||||
$dist = "D:\YandexMusicRust\target\release-dist-v$ver"
|
|
||||||
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
|
||||||
|
|
||||||
Copy-Item -Force "D:\YandexMusicRust\target\release\yandex-music-rs.exe" "$dist\yandex-music-rs-v$ver-windows-x86_64.exe"
|
|
||||||
|
|
||||||
$bashScript = @"
|
|
||||||
set -euo pipefail
|
|
||||||
cd /mnt/d/YandexMusicRust
|
|
||||||
./packaging/build-deb.sh
|
|
||||||
TMP=`$(mktemp -d)
|
|
||||||
cp "`$HOME/.cache/yandex-music-rs-target/release/yandex-music-rs" "`$TMP/yandex-music-rs"
|
|
||||||
chmod +x "`$TMP/yandex-music-rs"
|
|
||||||
cp /mnt/d/YandexMusicRust/README.md "`$TMP/README.md"
|
|
||||||
tar -czf "/mnt/d/YandexMusicRust/target/release-dist-v$ver/yandex-music-rs-v$ver-linux-x86_64.tar.gz" -C "`$TMP" yandex-music-rs README.md
|
|
||||||
rm -rf "`$TMP"
|
|
||||||
"@ -replace "`r`n", "`n"
|
|
||||||
$bashScript | wsl bash -s
|
|
||||||
|
|
||||||
Copy-Item -Force "D:\YandexMusicRust\target\debian\yandex-music-rs_${ver}-1_amd64.deb" "$dist\yandex-music-rs_${ver}-1_amd64.deb"
|
|
||||||
```
|
|
||||||
4. **Контрольные суммы (`SHA256SUMS.txt`)**:
|
|
||||||
```powershell
|
|
||||||
$files = @(
|
|
||||||
"yandex-music-rs-v$ver-windows-x86_64.exe",
|
|
||||||
"yandex-music-rs_${ver}-1_amd64.deb",
|
|
||||||
"yandex-music-rs-v$ver-linux-x86_64.tar.gz"
|
|
||||||
)
|
|
||||||
$sums = foreach ($f in $files) {
|
|
||||||
$h = (Get-FileHash -Algorithm SHA256 "$dist\$f").Hash.ToLower()
|
|
||||||
"$h $f"
|
|
||||||
}
|
|
||||||
[System.IO.File]::WriteAllText("$dist\SHA256SUMS.txt", ($sums -join "`n") + "`n", [System.Text.UTF8Encoding]::new($false))
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Публикация релиза на `git.tatar` через Forgejo API (БЕЗ браузера!)
|
|
||||||
|
|
||||||
1. Создай и запушь аннотированный тег:
|
|
||||||
```powershell
|
|
||||||
git tag -a "v$ver" -m "v$ver"
|
|
||||||
git push origin "v$ver"
|
|
||||||
```
|
|
||||||
2. Получи токен из Git Credential Manager (не выводя его в консоль) и создай релиз + загрузи файлы через `curl.exe`:
|
|
||||||
```powershell
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
$ver = "0.1.1"
|
|
||||||
$dist = "D:\YandexMusicRust\target\release-dist-v$ver"
|
|
||||||
|
|
||||||
# Токен из Git Credential Manager (НИКОГДА не печатать!)
|
|
||||||
$credOut = "protocol=https`nhost=git.tatar`n`n" | git credential fill 2>$null
|
|
||||||
$token = ($credOut | Where-Object { $_ -like 'password=*' }) -replace '^password=',''
|
|
||||||
if (-not $token) { throw "No token from git credential fill" }
|
|
||||||
|
|
||||||
$headers = @{
|
|
||||||
"Authorization" = "token $token"
|
|
||||||
"Accept" = "application/json"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Создание релиза (обязательно UTF-8 bytes, чтобы кириллица не побилась в PowerShell 5.1)
|
|
||||||
$payloadObj = @{
|
|
||||||
tag_name = "v$ver"
|
|
||||||
target_commitish = "main"
|
|
||||||
name = "v$ver"
|
|
||||||
body = "Описание изменений..."
|
|
||||||
draft = $false
|
|
||||||
prerelease = $false
|
|
||||||
}
|
|
||||||
$payloadBytes = [System.Text.Encoding]::UTF8.GetBytes(($payloadObj | ConvertTo-Json -Depth 5))
|
|
||||||
|
|
||||||
try {
|
|
||||||
$release = Invoke-RestMethod -Method Post `
|
|
||||||
-Uri "https://git.tatar/api/v1/repos/marwy/yandex-music-rs/releases" `
|
|
||||||
-Headers $headers `
|
|
||||||
-ContentType "application/json; charset=utf-8" `
|
|
||||||
-Body $payloadBytes
|
|
||||||
} catch {
|
|
||||||
# Если релиз для этого тега уже создан — получаем его ID
|
|
||||||
$release = Invoke-RestMethod -Method Get `
|
|
||||||
-Uri "https://git.tatar/api/v1/repos/marwy/yandex-music-rs/releases/tags/v$ver" `
|
|
||||||
-Headers $headers
|
|
||||||
}
|
|
||||||
|
|
||||||
# Загрузка ассетов через curl.exe (multipart/form-data, поле attachment)
|
|
||||||
$uploadFiles = @(
|
|
||||||
"yandex-music-rs-v$ver-windows-x86_64.exe",
|
|
||||||
"yandex-music-rs_${ver}-1_amd64.deb",
|
|
||||||
"yandex-music-rs-v$ver-linux-x86_64.tar.gz",
|
|
||||||
"SHA256SUMS.txt"
|
|
||||||
)
|
|
||||||
foreach ($fname in $uploadFiles) {
|
|
||||||
$fpath = "$dist\$fname"
|
|
||||||
$url = "https://git.tatar/api/v1/repos/marwy/yandex-music-rs/releases/$($release.id)/assets?name=$([uri]::EscapeDataString($fname))"
|
|
||||||
$resp = & curl.exe -sS -f -X POST -H "Authorization: token $token" -F "attachment=@$fpath" $url
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "Upload failed for $fname" }
|
|
||||||
$asset = $resp | ConvertFrom-Json
|
|
||||||
Write-Output ("OK: " + $asset.name + " (" + $asset.size + " bytes)")
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Совет для PowerShell 5.1 с кириллицей и Markdown:**
|
|
||||||
> - Для Markdown-текста описания релиза используй **одинарный** here-string `@' ... '@` (в `@" ... "@` обратные кавычки `` ` `` ломают синтаксис!).
|
|
||||||
> - Если сохраняешь временный `.ps1` скрипт в UTF-8 без BOM, запускай его через чтение в UTF-8, иначе PowerShell 5.1 прочитает его как Windows-1251:
|
|
||||||
> ```powershell
|
|
||||||
> $code = [System.IO.File]::ReadAllText("path\to\script.ps1", [System.Text.UTF8Encoding]::new($false))
|
|
||||||
> Invoke-Expression $code
|
|
||||||
> ```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Другие полезные Forgejo API вызовы
|
|
||||||
|
|
||||||
- Проверить токен: `GET https://git.tatar/api/v1/user` с заголовком `Authorization: token $token`
|
|
||||||
- Обновить аватар репозитория: `POST https://git.tatar/api/v1/repos/marwy/yandex-music-rs/avatar` с JSON `{ "image": "<base64 PNG>" }`
|
|
||||||
- Проверить список релизов: `GET https://git.tatar/api/v1/repos/marwy/yandex-music-rs/releases`
|
|
||||||
334
Cargo.lock
generated
|
|
@ -186,15 +186,6 @@ dependencies = [
|
||||||
"x11rb",
|
"x11rb",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arc-swap"
|
|
||||||
version = "1.9.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "84a22b5d51209f6de83d37a0b33d320acb8da88823e42a94c075140708f032a5"
|
|
||||||
dependencies = [
|
|
||||||
"rustversion",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayref"
|
name = "arrayref"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
@ -233,18 +224,6 @@ dependencies = [
|
||||||
"raw-window-metal",
|
"raw-window-metal",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-broadcast"
|
|
||||||
version = "0.7.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
|
|
||||||
dependencies = [
|
|
||||||
"event-listener",
|
|
||||||
"event-listener-strategy",
|
|
||||||
"futures-core",
|
|
||||||
"pin-project-lite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-compression"
|
name = "async-compression"
|
||||||
version = "0.4.52"
|
version = "0.4.52"
|
||||||
|
|
@ -257,28 +236,6 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-recursion"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 3.0.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-trait"
|
|
||||||
version = "0.1.92"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 3.0.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atk"
|
name = "atk"
|
||||||
version = "0.18.2"
|
version = "0.18.2"
|
||||||
|
|
@ -892,15 +849,6 @@ dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-queue"
|
|
||||||
version = "0.3.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae"
|
|
||||||
dependencies = [
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.23"
|
version = "0.8.23"
|
||||||
|
|
@ -1137,33 +1085,6 @@ dependencies = [
|
||||||
"simdutf8",
|
"simdutf8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "endi"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "enumflags2"
|
|
||||||
version = "0.7.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
|
|
||||||
dependencies = [
|
|
||||||
"enumflags2_derive",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "enumflags2_derive"
|
|
||||||
version = "0.7.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.119",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_filter"
|
name = "env_filter"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
|
@ -1218,38 +1139,12 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "event-listener"
|
|
||||||
version = "5.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"
|
|
||||||
dependencies = [
|
|
||||||
"parking",
|
|
||||||
"pin-project-lite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "event-listener-strategy"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
|
|
||||||
dependencies = [
|
|
||||||
"event-listener",
|
|
||||||
"pin-project-lite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "extended"
|
name = "extended"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
|
checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastrand"
|
|
||||||
version = "2.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fax"
|
name = "fax"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
|
@ -1438,19 +1333,6 @@ version = "0.3.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "futures-lite"
|
|
||||||
version = "2.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
|
|
||||||
dependencies = [
|
|
||||||
"fastrand",
|
|
||||||
"futures-core",
|
|
||||||
"futures-io",
|
|
||||||
"parking",
|
|
||||||
"pin-project-lite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-macro"
|
name = "futures-macro"
|
||||||
version = "0.3.34"
|
version = "0.3.34"
|
||||||
|
|
@ -2468,21 +2350,6 @@ version = "3.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ksni"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d49a7ac89853917f01d75f6bac3e7c8e282ae621dd63fbbfc50fe331304fa580"
|
|
||||||
dependencies = [
|
|
||||||
"arc-swap",
|
|
||||||
"crossbeam-queue",
|
|
||||||
"futures-util",
|
|
||||||
"pastey",
|
|
||||||
"serde",
|
|
||||||
"tokio",
|
|
||||||
"zbus",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kuchikiki"
|
name = "kuchikiki"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
|
@ -3328,16 +3195,6 @@ dependencies = [
|
||||||
"libredox",
|
"libredox",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ordered-stream"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
|
|
||||||
dependencies = [
|
|
||||||
"futures-core",
|
|
||||||
"pin-project-lite",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owned_ttf_parser"
|
name = "owned_ttf_parser"
|
||||||
version = "0.25.1"
|
version = "0.25.1"
|
||||||
|
|
@ -3372,12 +3229,6 @@ dependencies = [
|
||||||
"system-deps",
|
"system-deps",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parking"
|
|
||||||
version = "2.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.12.5"
|
version = "0.12.5"
|
||||||
|
|
@ -3401,12 +3252,6 @@ dependencies = [
|
||||||
"windows-link 0.2.1",
|
"windows-link 0.2.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pastey"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.2"
|
version = "2.3.2"
|
||||||
|
|
@ -4366,17 +4211,6 @@ dependencies = [
|
||||||
"zmij",
|
"zmij",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_repr"
|
|
||||||
version = "0.1.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 3.0.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "0.6.9"
|
version = "0.6.9"
|
||||||
|
|
@ -4431,16 +4265,6 @@ version = "2.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "signal-hook-registry"
|
|
||||||
version = "1.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
|
|
||||||
dependencies = [
|
|
||||||
"errno",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simd-adler32"
|
name = "simd-adler32"
|
||||||
version = "0.3.10"
|
version = "0.3.10"
|
||||||
|
|
@ -4993,19 +4817,6 @@ version = "0.12.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tempfile"
|
|
||||||
version = "3.27.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
|
||||||
dependencies = [
|
|
||||||
"fastrand",
|
|
||||||
"getrandom 0.4.3",
|
|
||||||
"once_cell",
|
|
||||||
"rustix 1.1.6",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tendril"
|
name = "tendril"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
|
|
@ -5168,10 +4979,8 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"tracing",
|
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -5341,21 +5150,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"tracing-attributes",
|
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tracing-attributes"
|
|
||||||
version = "0.1.31"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.119",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.36"
|
version = "0.1.36"
|
||||||
|
|
@ -5407,17 +5204,6 @@ version = "1.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "uds_windows"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
|
|
||||||
dependencies = [
|
|
||||||
"memoffset",
|
|
||||||
"tempfile",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.18"
|
version = "0.3.18"
|
||||||
|
|
@ -5562,17 +5348,6 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6"
|
checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "uuid"
|
|
||||||
version = "1.29.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"serde_core",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
@ -6550,7 +6325,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yandex-music-rs"
|
name = "yandex-music-rs"
|
||||||
version = "0.1.9"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|
@ -6572,7 +6347,6 @@ dependencies = [
|
||||||
"hex",
|
"hex",
|
||||||
"hmac",
|
"hmac",
|
||||||
"image",
|
"image",
|
||||||
"ksni",
|
|
||||||
"log",
|
"log",
|
||||||
"lru",
|
"lru",
|
||||||
"md-5",
|
"md-5",
|
||||||
|
|
@ -6626,71 +6400,6 @@ dependencies = [
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zbus"
|
|
||||||
version = "5.19.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907"
|
|
||||||
dependencies = [
|
|
||||||
"async-broadcast",
|
|
||||||
"async-recursion",
|
|
||||||
"async-trait",
|
|
||||||
"enumflags2",
|
|
||||||
"event-listener",
|
|
||||||
"futures-core",
|
|
||||||
"futures-lite",
|
|
||||||
"hex",
|
|
||||||
"libc",
|
|
||||||
"ordered-stream",
|
|
||||||
"rustix 1.1.6",
|
|
||||||
"serde",
|
|
||||||
"serde_repr",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"uds_windows",
|
|
||||||
"uuid",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
"winnow 1.0.5",
|
|
||||||
"zbus_macros",
|
|
||||||
"zbus_names",
|
|
||||||
"zvariant",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zbus_macros"
|
|
||||||
version = "5.19.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-crate 3.5.0",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 3.0.10",
|
|
||||||
"zbus_names",
|
|
||||||
"zvariant",
|
|
||||||
"zvariant_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zbus_names"
|
|
||||||
version = "4.3.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"winnow 1.0.5",
|
|
||||||
"zvariant",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zcheapstr"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2da34e7164b75d803c3197b86e6cf61b874106fbd472c5082575a8bc5fbd0907"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeno"
|
name = "zeno"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|
@ -6818,44 +6527,3 @@ checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zune-core 0.5.3",
|
"zune-core 0.5.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zvariant"
|
|
||||||
version = "5.15.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7"
|
|
||||||
dependencies = [
|
|
||||||
"endi",
|
|
||||||
"enumflags2",
|
|
||||||
"serde",
|
|
||||||
"winnow 1.0.5",
|
|
||||||
"zcheapstr",
|
|
||||||
"zvariant_derive",
|
|
||||||
"zvariant_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zvariant_derive"
|
|
||||||
version = "5.15.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-crate 3.5.0",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 3.0.10",
|
|
||||||
"zvariant_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zvariant_utils"
|
|
||||||
version = "4.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"serde",
|
|
||||||
"syn 3.0.10",
|
|
||||||
"winnow 1.0.5",
|
|
||||||
]
|
|
||||||
|
|
|
||||||
21
Cargo.toml
|
|
@ -1,22 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "yandex-music-rs"
|
name = "yandex-music-rs"
|
||||||
version = "0.1.9"
|
version = "0.1.0"
|
||||||
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"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
linux-webview = ["dep:wry", "dep:gtk"]
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "yandex-music-rs"
|
|
||||||
path = "src/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "yandex-music-auth"
|
|
||||||
path = "src/bin/yandex_music_auth.rs"
|
|
||||||
required-features = ["linux-webview"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core Windowing & Native UI Engine (ash SDF + taffy + cosmic-text)
|
# Core Windowing & Native UI Engine (ash SDF + taffy + cosmic-text)
|
||||||
winit = "0.30"
|
winit = "0.30"
|
||||||
|
|
@ -81,9 +68,8 @@ windows-sys = { version = "0.59", features = [
|
||||||
] }
|
] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
ksni = { version = "0.3", features = ["blocking"] }
|
wry = { version = "0.51", default-features = false, features = ["os-webview"] }
|
||||||
wry = { version = "0.51", default-features = false, features = ["os-webview"], optional = true }
|
gtk = "0.18"
|
||||||
gtk = { version = "0.18", optional = true }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
naga = { version = "24", features = ["wgsl-in", "spv-out"] }
|
naga = { version = "24", features = ["wgsl-in", "spv-out"] }
|
||||||
|
|
@ -108,7 +94,6 @@ recommends = "libvulkan1, mesa-vulkan-drivers, libgl1, libegl1"
|
||||||
maintainer-scripts = "packaging/debian"
|
maintainer-scripts = "packaging/debian"
|
||||||
assets = [
|
assets = [
|
||||||
["target/release/yandex-music-rs", "usr/bin/", "755"],
|
["target/release/yandex-music-rs", "usr/bin/", "755"],
|
||||||
["target/release/yandex-music-auth", "usr/bin/", "755"],
|
|
||||||
["assets/icons/app_icon.png", "usr/share/pixmaps/yandex-music-rs.png", "644"],
|
["assets/icons/app_icon.png", "usr/share/pixmaps/yandex-music-rs.png", "644"],
|
||||||
["assets/icons/app_48.png", "usr/share/icons/hicolor/48x48/apps/yandex-music-rs.png", "644"],
|
["assets/icons/app_48.png", "usr/share/icons/hicolor/48x48/apps/yandex-music-rs.png", "644"],
|
||||||
["packaging/icons/64x64.png", "usr/share/icons/hicolor/64x64/apps/yandex-music-rs.png", "644"],
|
["packaging/icons/64x64.png", "usr/share/icons/hicolor/64x64/apps/yandex-music-rs.png", "644"],
|
||||||
|
|
|
||||||
|
|
@ -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.9-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.0-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
|
||||||
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.9-1_amd64.deb` и установите:
|
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.0-1_amd64.deb` и установите:
|
||||||
```bash
|
```bash
|
||||||
sudo apt install ./yandex-music-rs_0.1.9-1_amd64.deb
|
sudo apt install ./yandex-music-rs_0.1.0-1_amd64.deb
|
||||||
```
|
```
|
||||||
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.9-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`).
|
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.0-linux-x86_64.tar.gz` с готовым бинарником.
|
||||||
|
|
||||||
## Стек и возможности
|
## Стек и возможности
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" 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"/>
|
<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" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,5 +1,4 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M17.129 9.227c.386.743.576 1.662.576 2.77 0 1.118-.213 2.046-.624 2.798a4 4 0 0 1-1.65 1.63c-1.239.665-2.707.686-3.629.688a1.2 1.2 0 0 1-1.202-1.2V8.208a1.2 1.2 0 0 1 1.198-1.2h.09c1.012-.003 2.454-.006 3.634.609a3.7 3.7 0 0 1 1.607 1.61m-4.53-.212v6.079c.69-.038 1.351-.144 1.887-.432.344-.185.63-.443.84-.827.214-.391.38-.97.38-1.839 0-.888-.155-1.467-.352-1.847a1.7 1.7 0 0 0-.756-.759c-.529-.275-1.206-.354-1.998-.375"/>
|
<circle cx="10" cy="6.5" r="3.2" stroke="#ffffff" stroke-width="1.6"/>
|
||||||
<path fill="white" d="M8.258 7.008a1 1 0 0 1 1 1v8.106a1 1 0 1 1-2 0V8.008a1 1 0 0 1 1-1"/>
|
<path d="M3.8 16.5C4.5 13.6 7 11.8 10 11.8C13 11.8 15.5 13.6 16.2 16.5" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M22.01 11.999C22.01 20.002 20.012 22 12.008 22 4.005 22 2.007 20.002 2.007 11.999S4.005 1.997 12.008 1.997 22.01 3.995 22.01 12m-2 0c0 4.016-.55 5.724-1.414 6.587-.864.864-2.571 1.414-6.588 1.414s-5.724-.55-6.587-1.414c-.864-.863-1.414-2.57-1.414-6.587s.55-5.724 1.414-6.588 2.57-1.414 6.587-1.414 5.724.55 6.588 1.414S20.01 7.983 20.01 12"/>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 284 B |
|
|
@ -1,6 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
||||||
<path fill="white" d="M1.707 17.704c1.12-1.12 2.853-1.7 5.256-1.707.274-.704.62-1.377.985-1.972A16 16 0 0 0 7 13.997c-2.912 0-5.165.751-6.707 2.293a1 1 0 1 0 1.414 1.414"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M7.001 12.797c-2.63 0-4.501-2.692-4.501-5.83 0-2.97 1.596-4.97 4.501-4.97s4.499 2 4.499 4.97c0 3.138-1.87 5.83-4.499 5.83m0-2c1.307 0 2.499-1.596 2.499-3.83 0-2.009-.84-2.97-2.499-2.97S4.5 4.96 4.5 6.967c0 2.234 1.194 3.83 2.501 3.83"/>
|
|
||||||
<path fill="white" d="M17 13.5a1 1 0 0 0-1 1V16h-1.5a1 1 0 1 0 0 2H16v1.5a1 1 0 1 0 2 0V18h1.5a1 1 0 1 0 0-2H18v-1.5a1 1 0 0 0-1-1"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M10 17a7 7 0 1 1 14 0 7 7 0 0 1-14 0m7-5a5 5 0 1 0 0 10 5 5 0 0 0 0-10"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 853 B |
|
|
@ -1,3 +1,5 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M22 11.998c0 5.523-4.477 10-10 10s-10-4.477-10-10 4.477-10 10-10 10 4.477 10 10m-2.02.574A8 8 0 0 1 8 18.928v-.58a1 1 0 0 0-.22-.624L6 15.498v-1.78a1 1 0 0 0-.684-.948l-1.31-.436a8 8 0 0 1 .245-2.336h1.335a1 1 0 0 0 .707-.293l2.074-2.074a1 1 0 0 0 .074-1.332l-.806-1.007A7.96 7.96 0 0 1 12 3.998c1.932 0 3.705.685 5.087 1.826L16.5 6.998h-2.71a.958.958 0 0 0-.493 1.778l1.203.722-1.5 1-.63-.315a1 1 0 0 0-.763-.054l-1.04.347a1 1 0 0 0-.13.054l-1.384.692a1 1 0 0 0-.553.894v1.101a1 1 0 0 0 .757.97l1.243.311 1.165 2.717a1 1 0 0 0 1.161.576l.614-.153a1 1 0 0 0 .719-.695l.802-2.81a1 1 0 0 0 .039-.275v-1.86l1-.5.65.976a1 1 0 0 0 .974.435z"/>
|
<circle cx="10" cy="10" r="7.2" stroke="#ffffff" stroke-width="1.5"/>
|
||||||
|
<ellipse cx="10" cy="10" rx="3.4" ry="7.2" stroke="#ffffff" stroke-width="1.5"/>
|
||||||
|
<path d="M3.2 7.5H16.8M3.2 12.5H16.8" stroke="#ffffff" stroke-width="1.4"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 307 B |
|
|
@ -1,4 +1,4 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill="white" d="M21.593 10.943c.584.585.584 1.53 0 2.116L18.71 15.95c-.39.39-1.03.39-1.42 0a.996.996 0 0 1 0-1.41 9.6 9.6 0 0 1 1.689-1.345l.387-.242-.207-.206a10 10 0 0 1-2.24.254h-7.92a1 1 0 1 1 0-2h7.922a10 10 0 0 1 2.239.254l.207-.206-.386-.241a9.6 9.6 0 0 1-1.69-1.348.996.996 0 0 1 0-1.41c.39-.39 1.03-.39 1.42 0z"/>
|
<path d="M8.5 3.2H5.2C4.1 3.2 3.2 4.1 3.2 5.2V14.8C3.2 15.9 4.1 16.8 5.2 16.8H8.5" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round"/>
|
||||||
<path fill="white" d="M14 16a1 1 0 0 0-1 1v1.5a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5v1.505a1 1 0 1 0 2 0V5.5A2.5 2.5 0 0 0 12.5 3h-7A2.5 2.5 0 0 0 3 5.5v13A2.5 2.5 0 0 0 5.5 21h7a2.5 2.5 0 0 0 2.5-2.5V17a1 1 0 0 0-1-1"/>
|
<path d="M12.5 6.5L16.2 10L12.5 13.5M16 10H7.5" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 357 B |
|
|
@ -1,11 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="g" x1="0" y1="0" x2="24" y2="24" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop stop-color="#FF5C4D"/>
|
|
||||||
<stop offset="0.35" stop-color="#EB469F"/>
|
|
||||||
<stop offset="0.75" stop-color="#8341EF"/>
|
|
||||||
<stop offset="1" stop-color="#3F68F9"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="url(#g)" d="M22 11.99c0 5.523-4.477 10-10 10s-10-4.477-10-10 4.477-10 10-10 10 4.478 10 10m-2 0a8 8 0 1 1-5.524-7.609l-1.83 5.61H7.329l-.652 2h5.319l-1.631 5h2.202l1.63-5zm-.252-2h-4.899l1.532-4.695a8 8 0 0 1 3.367 4.696"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 690 B |
|
|
@ -1,4 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M9.172 9.172a4 4 0 1 1 5.656 5.656 4 4 0 0 1-5.656-5.656m1.414 4.242a2 2 0 1 0 2.828-2.828 2 2 0 0 0-2.828 2.828"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="m20.788 5.276 1.427 2.483v.001a1.4 1.4 0 0 1-.365 1.81l-1.858 1.412.002 2.038 1.854 1.41a1.4 1.4 0 0 1 .365 1.814l-1.425 2.479a1.4 1.4 0 0 1-1.755.593l-2.192-.92-1.72.982-.304 2.398A1.404 1.404 0 0 1 13.427 23h-2.853a1.404 1.404 0 0 1-1.39-1.224l-.308-2.421-1.69-.97-2.22.93a1.4 1.4 0 0 1-1.754-.592l-1.427-2.482a1.4 1.4 0 0 1 .365-1.81l1.86-1.413-.004-2.038-1.855-1.41a1.4 1.4 0 0 1-.364-1.814l1.426-2.479a1.4 1.4 0 0 1 1.756-.593l2.191.92 1.72-.982.303-2.398A1.4 1.4 0 0 1 10.573 1h2.853a1.4 1.4 0 0 1 1.39 1.223l.307 2.422 1.69.97 2.22-.93a1.4 1.4 0 0 1 1.755.591m-2.792 8.739-.007-4.023 2.23-1.694-.9-1.565-2.642 1.109-3.412-1.956L12.898 3h-1.796l-.364 2.864L7.294 7.83 4.682 6.733l-.9 1.565 2.222 1.69.007 4.02-2.229 1.694.9 1.565 2.641-1.109 3.412 1.956.367 2.886h1.796l.364-2.864 3.443-1.966 2.613 1.097.9-1.565z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
|
@ -1,3 +1,6 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M5.719 2.535a1.41 1.41 0 0 0-2.028 1.266v2.825l-1.392-.287C1.097 6.092.175 7.392.806 8.444L2.94 12 .806 15.556c-.63 1.052.291 2.352 1.493 2.105l1.392-.287V20.2a1.41 1.41 0 0 0 2.028 1.266l16.762-8.2c1.053-.514 1.053-2.016 0-2.53zM5.509 17v2.223a.2.2 0 0 0 .288.18l9.393-4.595-2.19.65zm9.681-7.808L5.797 4.598a.2.2 0 0 0-.288.18V7l7.49 1.542zM2.845 8.308 20.778 12 2.845 15.692l1.78-2.967a1.41 1.41 0 0 0 0-1.45z"/>
|
<path d="M10 3C5.86 3 2.5 5.91 2.5 9.5C2.5 11.15 3.21 12.66 4.38 13.8L3.5 17L6.92 15.6C7.87 15.86 8.91 16 10 16C14.14 16 17.5 13.09 17.5 9.5C17.5 5.91 14.14 3 10 3Z" stroke="#ffffff" stroke-width="1.6" stroke-linejoin="round"/>
|
||||||
|
<circle cx="7" cy="9.5" r="1" fill="#ffffff"/>
|
||||||
|
<circle cx="10" cy="9.5" r="1" fill="#ffffff"/>
|
||||||
|
<circle cx="13" cy="9.5" r="1" fill="#ffffff"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 451 B |
|
|
@ -1,3 +1,3 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M3.57 17.898c2.437 3.059 7.033 4.626 10.867 3.595 5.282-1.42 8.418-6.857 7.005-12.145-1.026-3.84-4.68-7.041-8.544-7.624a.992.992 0 0 0-1.02 1.45c1.868 3.48 2.02 6.456.526 9.047-1.495 2.592-4.146 3.948-8.09 4.067a.992.992 0 0 0-.745 1.61m15.96-8.036c1.13 4.23-1.38 8.58-5.604 9.717-2.41.647-5.68.004-7.74-1.497 3.438-.551 6.384-2.185 7.932-4.87s1.482-6.049.24-9.306c2.328 1.036 4.527 3.543 5.172 5.956"/>
|
<path d="M15.8 12.4A6.8 6.8 0 0 1 7.6 4.2A6.8 6.8 0 1 0 15.8 12.4Z" stroke="#ffffff" stroke-width="1.6" stroke-linejoin="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 210 B |
|
|
@ -1,5 +1,4 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill="white" d="M15.106.409a1 1 0 0 0-1.225.707l-.647 2.415a1 1 0 0 0 1.932.517l.647-2.414a1 1 0 0 0-.707-1.225"/>
|
<circle cx="10" cy="10" r="3.4" stroke="#ffffff" stroke-width="1.6"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0m11 0a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0"/>
|
<path d="M10 2.4V4.2M10 15.8V17.6M2.4 10H4.2M15.8 10H17.6M4.6 4.6L5.9 5.9M14.1 14.1L15.4 15.4M15.4 4.6L14.1 5.9M5.9 14.1L4.6 15.4" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round"/>
|
||||||
<path fill="white" d="M8.834 19.952a1 1 0 1 1 1.932.517l-.647 2.415a1 1 0 1 1-1.932-.518zm-4.695-4.568a1 1 0 0 1 1 1.732l-2.165 1.25a1 1 0 0 1-1-1.732zM22.392 6a1 1 0 0 0-1.366-.366l-2.165 1.25a1 1 0 0 0 1 1.732l2.165-1.25A1 1 0 0 0 22.392 6M4.048 8.834a1 1 0 1 1-.517 1.932l-2.415-.647a1 1 0 0 1 .518-1.932zm19.543 6.272a1 1 0 0 0-.707-1.225l-2.415-.647a1 1 0 1 0-.517 1.932l2.414.647a1 1 0 0 0 1.225-.707M8.616 4.139a1 1 0 1 1-1.732 1l-1.25-2.165a1 1 0 1 1 1.732-1zM18 22.392a1 1 0 0 0 .366-1.366l-1.25-2.165a1 1 0 1 0-1.732 1l1.25 2.165a1 1 0 0 0 1.366.366"/>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 945 B After Width: | Height: | Size: 342 B |
|
|
@ -1,4 +1,4 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||||
<path fill="white" d="M3 7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3h-2a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h6v3H4a2 2 0 0 1-2-2 1 1 0 0 1 1-1z"/>
|
<rect x="2.5" y="3.5" width="15" height="10" rx="1.8" stroke="#ffffff" stroke-width="1.5"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="white" d="M14 11.4A2.4 2.4 0 0 1 16.4 9h3.2a2.4 2.4 0 0 1 2.4 2.4v8.2a2.4 2.4 0 0 1-2.4 2.4h-3.2a2.4 2.4 0 0 1-2.4-2.4zm2.4-.4a.4.4 0 0 0-.4.4v8.2c0 .22.18.4.4.4h3.2a.4.4 0 0 0 .4-.4v-8.2a.4.4 0 0 0-.4-.4z"/>
|
<path d="M7 16.5H13M10 13.5V16.5" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 513 B After Width: | Height: | Size: 267 B |
|
|
@ -1,54 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 156 48" width="156" height="48">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="carRed" x1="0" y1="0" x2="0.15" y2="1">
|
|
||||||
<stop offset="0%" stop-color="#FF2942"/>
|
|
||||||
<stop offset="48%" stop-color="#D90F26"/>
|
|
||||||
<stop offset="100%" stop-color="#8C0717"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="carHighlight" x1="0" y1="0" x2="1" y2="0">
|
|
||||||
<stop offset="0%" stop-color="#FF7A89" stop-opacity="0.25"/>
|
|
||||||
<stop offset="45%" stop-color="#FF99A5" stop-opacity="0.85"/>
|
|
||||||
<stop offset="100%" stop-color="#FF7A89" stop-opacity="0.2"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="carGlass" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0%" stop-color="#4A5568"/>
|
|
||||||
<stop offset="45%" stop-color="#1A1E26"/>
|
|
||||||
<stop offset="100%" stop-color="#0D0F14"/>
|
|
||||||
</linearGradient>
|
|
||||||
<radialGradient id="rimGrad" cx="50%" cy="50%" r="50%">
|
|
||||||
<stop offset="0%" stop-color="#F5F7FA"/>
|
|
||||||
<stop offset="60%" stop-color="#B8C0CC"/>
|
|
||||||
<stop offset="100%" stop-color="#5C6470"/>
|
|
||||||
</radialGradient>
|
|
||||||
</defs>
|
|
||||||
<!-- Underbody shadow -->
|
|
||||||
<rect x="12" y="37" width="134" height="4" rx="2" fill="#09090C"/>
|
|
||||||
<!-- Main supercar silhouette -->
|
|
||||||
<path d="M8 29.5L10.5 19.5C12.5 16.5 22 14.8 38 14.2L57 8.4C67 5.6 82 5.4 95 7.4L115 15.2C131 16.4 143 19.8 148.5 24.5C150.5 26.2 151.5 29.2 150.5 32.5L146.5 36.2L134 36.8H22L10.5 35.5C8 34.8 7.2 32.2 8 29.5Z" fill="url(#carRed)"/>
|
|
||||||
<!-- Roof & shoulder highlight -->
|
|
||||||
<path d="M18 19.8C36 17.5 64 16.8 106 18.2C125 18.8 139 21.4 146 25" stroke="url(#carHighlight)" stroke-width="1.8" fill="none" stroke-linecap="round"/>
|
|
||||||
<!-- Side cabin glass -->
|
|
||||||
<path d="M55 15.6L71 9.6C80 8.5 91 8.8 101 11.4L111 16.2L55 16.4Z" fill="url(#carGlass)"/>
|
|
||||||
<path d="M77 9.4L73 16.2" stroke="#111318" stroke-width="2.2"/>
|
|
||||||
<!-- Side air intake & door sculpt -->
|
|
||||||
<path d="M46 24.5L68 21.5L66 30.5L47 30.2Z" fill="#5E0611" opacity="0.82"/>
|
|
||||||
<path d="M68 23.2L104 23.8L98 28.6L67 28.4Z" fill="#9E0B1D" opacity="0.65"/>
|
|
||||||
<!-- Tail light -->
|
|
||||||
<path d="M9.5 20.5L18 20L17 24.2L9 24Z" fill="#FF595E"/>
|
|
||||||
<!-- Headlight -->
|
|
||||||
<path d="M134 22.8L147 25.4L144.5 28.4L132 25.6Z" fill="#FFF2A6"/>
|
|
||||||
<path d="M136 23.6L145 25.6" stroke="#FFFFFF" stroke-width="1.3" stroke-linecap="round"/>
|
|
||||||
<!-- Wheel arches -->
|
|
||||||
<circle cx="34" cy="34.5" r="11.2" fill="#121317"/>
|
|
||||||
<circle cx="122" cy="34.5" r="11.2" fill="#121317"/>
|
|
||||||
<!-- Rear wheel -->
|
|
||||||
<circle cx="34" cy="34.5" r="9.6" fill="#23262E"/>
|
|
||||||
<circle cx="34" cy="34.5" r="6.8" fill="url(#rimGrad)"/>
|
|
||||||
<circle cx="34" cy="34.5" r="2.2" fill="#2B2F38"/>
|
|
||||||
<path d="M34 28.2V40.8M27.7 34.5H40.3M29.6 30.1L38.4 38.9M38.4 30.1L29.6 38.9" stroke="#474E5C" stroke-width="1.15"/>
|
|
||||||
<!-- Front wheel -->
|
|
||||||
<circle cx="122" cy="34.5" r="9.6" fill="#23262E"/>
|
|
||||||
<circle cx="122" cy="34.5" r="6.8" fill="url(#rimGrad)"/>
|
|
||||||
<circle cx="122" cy="34.5" r="2.2" fill="#2B2F38"/>
|
|
||||||
<path d="M122 28.2V40.8M115.7 34.5H128.3M117.6 30.1L126.4 38.9M126.4 30.1L117.6 38.9" stroke="#474E5C" stroke-width="1.15"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 3 KiB |
|
|
@ -1,3 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
||||||
<path fill="white" d="M6.16783 3.3431L11.7163 4.16504C12.2676 4.24667 12.6987 4.68292 12.7727 5.23519L13.562 11.1418C13.6111 11.5093 13.5366 11.8828 13.3497 12.203C12.453 13.7384 11.8269 14.8457 11.4722 15.5249C11.0158 16.3991 10.3839 17.7197 9.57684 19.4865C9.47701 19.7609 9.21617 19.9438 8.92417 19.9438C6.30905 19.9436 6.96124 17.0532 8.07458 13.3113C8.07458 13.3113 6.79592 13.3113 4.23993 13.3113C1.85516 13.3112 1.32413 11.2631 1.8555 9.66875L3.32115 5.35157C3.72418 4.14237 4.89712 3.24539 6.16783 3.3431ZM17.4138 3.33334C17.7818 3.33389 18.0798 3.63263 18.0794 4.00065L18.0681 11.8343C18.0675 12.2021 17.7693 12.5 17.4016 12.5H15.9693C15.6321 12.4999 15.3482 12.248 15.3077 11.9133L14.3596 4.0804C14.3563 4.05383 14.3547 4.02662 14.3547 3.99984C14.3548 3.63174 14.6531 3.33335 15.0212 3.33334H17.4138Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 919 B |
|
|
@ -1,44 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="duckBody" x1="0.2" y1="0.1" x2="0.8" y2="0.95">
|
|
||||||
<stop offset="0%" stop-color="#FFE44D"/>
|
|
||||||
<stop offset="55%" stop-color="#FFC818"/>
|
|
||||||
<stop offset="100%" stop-color="#F29F05"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="duckWing" x1="0" y1="0" x2="0.6" y2="1">
|
|
||||||
<stop offset="0%" stop-color="#FFD833"/>
|
|
||||||
<stop offset="100%" stop-color="#E89304"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="duckBeak" x1="0" y1="0" x2="1" y2="0.8">
|
|
||||||
<stop offset="0%" stop-color="#FF8C24"/>
|
|
||||||
<stop offset="100%" stop-color="#E65200"/>
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient id="wheelRim" x1="0" y1="0" x2="1" y2="1">
|
|
||||||
<stop offset="0%" stop-color="#E64B17"/>
|
|
||||||
<stop offset="100%" stop-color="#B0280A"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
<!-- Wheels -->
|
|
||||||
<circle cx="22" cy="54" r="7.5" fill="url(#wheelRim)"/>
|
|
||||||
<circle cx="22" cy="54" r="4.2" fill="#FF8F26"/>
|
|
||||||
<circle cx="22" cy="54" r="1.6" fill="#B0280A"/>
|
|
||||||
<path d="M22 49.8v8.4M17.8 54h8.4" stroke="#C8340E" stroke-width="1.2" stroke-linecap="round"/>
|
|
||||||
<circle cx="41" cy="54" r="7.5" fill="url(#wheelRim)"/>
|
|
||||||
<circle cx="41" cy="54" r="4.2" fill="#FF8F26"/>
|
|
||||||
<circle cx="41" cy="54" r="1.6" fill="#B0280A"/>
|
|
||||||
<path d="M41 49.8v8.4M36.8 54h8.4" stroke="#C8340E" stroke-width="1.2" stroke-linecap="round"/>
|
|
||||||
<!-- Beak -->
|
|
||||||
<path d="M47.5 22.5c5.8 0 11.2 1.8 11.5 4.4.2 2.2-3.4 4.1-9.2 4.3-2.5.1-4.1-.8-4.5-2.6z" fill="url(#duckBeak)"/>
|
|
||||||
<path d="M49 26.8c3.6.3 6.8-.3 8.8-1.2" stroke="#B83B00" stroke-width="1.1" fill="none" stroke-linecap="round" opacity="0.65"/>
|
|
||||||
<!-- Body + Head -->
|
|
||||||
<path d="M12.5 28.5c-2.8-1.4-4.2-3.5-3.2-4.8 1.2-1.4 4.9.2 8.2 3.4 2.4 2.3 5.7 3.1 9.2 2.1 2.2-.6 2.8-2.8 1.5-5.3-1.4-2.7-1.7-5.7-.9-8.8C29 9.5 34.1 6.5 39.8 7c6.4.5 11.3 5.5 11.4 11.8.1 3.7-1.6 7-3.9 9.1-1.3 1.2-1.4 2.4-.2 3.8 2.8 3.2 4.1 7.1 3.5 11.2-.9 6.2-6.1 10.6-13.2 10.9H25.2c-8.2 0-14.6-5.2-15.4-12.6-.5-4.6.6-9.1 2.7-12.7z" fill="url(#duckBody)"/>
|
|
||||||
<!-- Head highlight -->
|
|
||||||
<ellipse cx="36.5" cy="12.5" rx="6" ry="3" transform="rotate(-14 36.5 12.5)" fill="#FFF59D" opacity="0.55"/>
|
|
||||||
<!-- Wing -->
|
|
||||||
<path d="M19.5 36.2c5.4-2.2 13.5-1.5 16.6 2.7 1.7 2.3.9 5.9-2.4 7.7-4.4 2.4-11.2 1.6-14.7-1.7-2.4-2.3-2.3-7.5.5-8.7z" fill="url(#duckWing)"/>
|
|
||||||
<path d="M21.5 38.4c4.3-1.2 9.4-.6 12.1 1.6" stroke="#FFF29A" stroke-width="1.4" fill="none" stroke-linecap="round" opacity="0.6"/>
|
|
||||||
<!-- Eye -->
|
|
||||||
<circle cx="42.4" cy="18.2" r="3.6" fill="#1A1D24"/>
|
|
||||||
<circle cx="43.5" cy="16.9" r="1.25" fill="#FFFFFF"/>
|
|
||||||
<circle cx="41.1" cy="19.5" r="0.55" fill="#FFFFFF" opacity="0.65"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
|
@ -1,3 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
||||||
<path fill="white" d="M3.77685 7.44385C4.11397 7.44393 4.39795 7.69589 4.43847 8.0306L5.38655 15.8634C5.38977 15.89 5.39143 15.9173 5.39143 15.944C5.39123 16.312 5.09296 16.6105 4.72492 16.6105H2.33235C1.96417 16.61 1.66613 16.3106 1.66666 15.9424L1.67805 8.10954C1.67857 7.74172 1.97673 7.44385 2.34456 7.44385H3.77685ZM10.8219 0C13.437 0.000299683 12.7848 2.89069 11.6716 6.63248H15.5062C17.8908 6.63269 18.4218 8.68 17.8907 10.2743L16.425 14.5923C16.0219 15.8014 14.8489 16.6984 13.5782 16.6008L8.02977 15.7788C7.47845 15.6972 7.04733 15.2603 6.97346 14.7078L6.18407 8.80208C6.13495 8.43458 6.2095 8.0611 6.39647 7.74088L7.01822 6.66993C7.58917 5.67872 8.00786 4.92844 8.27392 4.41894C8.73041 3.5448 9.36216 2.22423 10.1692 0.457357C10.2691 0.18292 10.5299 0 10.8219 0Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 881 B |
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="62" height="30" viewBox="0 0 62 30" fill="none">
|
|
||||||
<circle cx="15" cy="15" r="15" fill="#FC3F1D"/>
|
|
||||||
<path fill="#FFFFFF" d="M15.4069 16.5495C16.2834 18.4695 16.5756 19.1374 16.5756 21.4434V24.5008H13.4451V19.3461L7.53906 6.50084H10.8051L15.4069 16.5495ZM19.2678 6.50084L15.4382 15.2034H18.6208L22.4608 6.50084H19.2678Z"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FAFAFF" d="M47 29.9995C59.0033 29.9995 62 27.0028 62 14.9995C62 2.99623 59.0033 -0.000488281 47 -0.000488281C34.9967 -0.000488281 32 2.99623 32 14.9995C32 27.0028 34.9967 29.9995 47 29.9995ZM41.8793 5.99942V23.9994H38.7499V5.99942H41.8793ZM48.9153 5.99942C50.1024 5.99942 51.2031 6.1505 52.2175 6.47424C53.2319 6.7764 54.0952 7.29438 54.829 7.98503C55.5628 8.67568 56.1455 9.60374 56.5556 10.726C56.9873 11.8483 57.1815 13.2512 57.1815 14.9131C57.1815 16.3807 56.9657 17.6757 56.5556 18.8196C56.124 19.9419 55.5412 20.8915 54.7858 21.6685C54.0304 22.4455 53.124 23.0282 52.088 23.4167C51.052 23.8052 49.8865 24.021 48.6563 24.021H44.7067V5.99942H48.9153ZM48.3973 21.5606C49.2391 21.5606 50.016 21.4095 50.7067 21.1289C51.3973 20.8483 51.9801 20.4167 52.4765 19.8771C52.9729 19.316 53.3398 18.6253 53.6204 17.7836C53.8793 16.9419 54.0304 15.9706 54.0304 14.8483C54.0304 13.6397 53.9009 12.6253 53.6419 11.8052C53.3829 10.985 53.016 10.316 52.5412 9.81956C52.0664 9.32316 51.5052 8.95625 50.8362 8.74043C50.1887 8.5246 49.4549 8.41669 48.6563 8.41669H47.8362V21.539H48.3973V21.5606Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="62" height="30" viewBox="0 0 62 30" fill="none">
|
|
||||||
<circle cx="15" cy="15" r="15" fill="#FC3F1D"/>
|
|
||||||
<path fill="#FFFFFF" d="M15.4069 16.5495C16.2834 18.4695 16.5756 19.1374 16.5756 21.4434V24.5008H13.4451V19.3461L7.53906 6.50084H10.8051L15.4069 16.5495ZM19.2678 6.50084L15.4382 15.2034H18.6208L22.4608 6.50084H19.2678Z"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#262633" d="M47 29.9995C59.0033 29.9995 62 27.0028 62 14.9995C62 2.99623 59.0033 -0.000488281 47 -0.000488281C34.9967 -0.000488281 32 2.99623 32 14.9995C32 27.0028 34.9967 29.9995 47 29.9995ZM41.8793 5.99942V23.9994H38.7499V5.99942H41.8793ZM48.9153 5.99942C50.1024 5.99942 51.2031 6.1505 52.2175 6.47424C53.2319 6.7764 54.0952 7.29438 54.829 7.98503C55.5628 8.67568 56.1455 9.60374 56.5556 10.726C56.9873 11.8483 57.1815 13.2512 57.1815 14.9131C57.1815 16.3807 56.9657 17.6757 56.5556 18.8196C56.124 19.9419 55.5412 20.8915 54.7858 21.6685C54.0304 22.4455 53.124 23.0282 52.088 23.4167C51.052 23.8052 49.8865 24.021 48.6563 24.021H44.7067V5.99942H48.9153ZM48.3973 21.5606C49.2391 21.5606 50.016 21.4095 50.7067 21.1289C51.3973 20.8483 51.9801 20.4167 52.4765 19.8771C52.9729 19.316 53.3398 18.6253 53.6204 17.7836C53.8793 16.9419 54.0304 15.9706 54.0304 14.8483C54.0304 13.6397 53.9009 12.6253 53.6419 11.8052C53.3829 10.985 53.016 10.316 52.5412 9.81956C52.0664 9.32316 51.5052 8.95625 50.8362 8.74043C50.1887 8.5246 49.4549 8.41669 48.6563 8.41669H47.8362V21.539H48.3973V21.5606Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="62" height="30" viewBox="0 0 62 30" fill="none">
|
|
||||||
<circle cx="15" cy="15" r="15" fill="#FC3F1D"/>
|
|
||||||
<path fill="#FFFFFF" d="M17.2116 8.40037H15.6936C13.0912 8.40037 11.7899 9.70158 11.7899 11.6534C11.7899 13.8221 12.6574 14.9064 14.6092 16.2076L16.1273 17.2919L11.7899 24.0148H8.32007L12.4405 17.9425C10.055 16.2076 8.7538 14.6895 8.7538 11.8703C8.7538 8.40037 11.1393 6.01483 15.6936 6.01483H20.2478V24.0148H17.2116V8.40037Z"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FAFAFF" d="M47 29.9995C59.0033 29.9995 62 27.0028 62 14.9995C62 2.99623 59.0033 -0.000488281 47 -0.000488281C34.9967 -0.000488281 32 2.99623 32 14.9995C32 27.0028 34.9967 29.9995 47 29.9995ZM41.8793 5.99942V23.9994H38.7499V5.99942H41.8793ZM48.9153 5.99942C50.1024 5.99942 51.2031 6.1505 52.2175 6.47424C53.2319 6.7764 54.0952 7.29438 54.829 7.98503C55.5628 8.67568 56.1455 9.60374 56.5556 10.726C56.9873 11.8483 57.1815 13.2512 57.1815 14.9131C57.1815 16.3807 56.9657 17.6757 56.5556 18.8196C56.124 19.9419 55.5412 20.8915 54.7858 21.6685C54.0304 22.4455 53.124 23.0282 52.088 23.4167C51.052 23.8052 49.8865 24.021 48.6563 24.021H44.7067V5.99942H48.9153ZM48.3973 21.5606C49.2391 21.5606 50.016 21.4095 50.7067 21.1289C51.3973 20.8483 51.9801 20.4167 52.4765 19.8771C52.9729 19.316 53.3398 18.6253 53.6204 17.7836C53.8793 16.9419 54.0304 15.9706 54.0304 14.8483C54.0304 13.6397 53.9009 12.6253 53.6419 11.8052C53.3829 10.985 53.016 10.316 52.5412 9.81956C52.0664 9.32316 51.5052 8.95625 50.8362 8.74043C50.1887 8.5246 49.4549 8.41669 48.6563 8.41669H47.8362V21.539H48.3973V21.5606Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,5 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="62" height="30" viewBox="0 0 62 30" fill="none">
|
|
||||||
<circle cx="15" cy="15" r="15" fill="#FC3F1D"/>
|
|
||||||
<path fill="#FFFFFF" d="M17.2116 8.40037H15.6936C13.0912 8.40037 11.7899 9.70158 11.7899 11.6534C11.7899 13.8221 12.6574 14.9064 14.6092 16.2076L16.1273 17.2919L11.7899 24.0148H8.32007L12.4405 17.9425C10.055 16.2076 8.7538 14.6895 8.7538 11.8703C8.7538 8.40037 11.1393 6.01483 15.6936 6.01483H20.2478V24.0148H17.2116V8.40037Z"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#262633" d="M47 29.9995C59.0033 29.9995 62 27.0028 62 14.9995C62 2.99623 59.0033 -0.000488281 47 -0.000488281C34.9967 -0.000488281 32 2.99623 32 14.9995C32 27.0028 34.9967 29.9995 47 29.9995ZM41.8793 5.99942V23.9994H38.7499V5.99942H41.8793ZM48.9153 5.99942C50.1024 5.99942 51.2031 6.1505 52.2175 6.47424C53.2319 6.7764 54.0952 7.29438 54.829 7.98503C55.5628 8.67568 56.1455 9.60374 56.5556 10.726C56.9873 11.8483 57.1815 13.2512 57.1815 14.9131C57.1815 16.3807 56.9657 17.6757 56.5556 18.8196C56.124 19.9419 55.5412 20.8915 54.7858 21.6685C54.0304 22.4455 53.124 23.0282 52.088 23.4167C51.052 23.8052 49.8865 24.021 48.6563 24.021H44.7067V5.99942H48.9153ZM48.3973 21.5606C49.2391 21.5606 50.016 21.4095 50.7067 21.1289C51.3973 20.8483 51.9801 20.4167 52.4765 19.8771C52.9729 19.316 53.3398 18.6253 53.6204 17.7836C53.8793 16.9419 54.0304 15.9706 54.0304 14.8483C54.0304 13.6397 53.9009 12.6253 53.6419 11.8052C53.3829 10.985 53.016 10.316 52.5412 9.81956C52.0664 9.32316 51.5052 8.95625 50.8362 8.74043C50.1887 8.5246 49.4549 8.41669 48.6563 8.41669H47.8362V21.539H48.3973V21.5606Z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
|
@ -13,10 +13,5 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
# 1. Main player binary: zero WebKit2GTK / GTK DT_NEEDED entries
|
cargo deb --output "$PROJECT_DIR/target/debian/"
|
||||||
cargo build --release --bin yandex-music-rs
|
|
||||||
# 2. Isolated Linux OAuth WebView helper binary
|
|
||||||
cargo build --release --features linux-webview --bin yandex-music-auth
|
|
||||||
# 3. Package both binaries into .deb (cargo-deb resolves target/release/* via CARGO_TARGET_DIR)
|
|
||||||
cargo deb --no-build --output "$PROJECT_DIR/target/debian/"
|
|
||||||
ls -lh "$PROJECT_DIR/target/debian/"*.deb
|
ls -lh "$PROJECT_DIR/target/debian/"*.deb
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ 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 & Эндшпиль")],
|
||||||
|
|
@ -104,7 +103,6 @@ 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")],
|
||||||
|
|
@ -116,7 +114,6 @@ 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", "Три дня дождя")],
|
||||||
|
|
@ -128,7 +125,6 @@ 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")],
|
||||||
|
|
@ -140,7 +136,6 @@ 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")],
|
||||||
|
|
@ -152,7 +147,6 @@ 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", "Баста")],
|
||||||
|
|
@ -240,7 +234,6 @@ 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", "Самат Галимов")],
|
||||||
|
|
@ -252,7 +245,6 @@ 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", "Студия Терменвокс")],
|
||||||
|
|
@ -264,7 +256,6 @@ 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", "Стивен Хокинг (Аудиокнига)")],
|
||||||
|
|
@ -276,7 +267,6 @@ 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", "Дж. Р. Р. Толкин")],
|
||||||
|
|
@ -340,8 +330,6 @@ pub fn demo_landing() -> LandingData {
|
||||||
vibe_tracks,
|
vibe_tracks,
|
||||||
podcasts,
|
podcasts,
|
||||||
kids_playlists,
|
kids_playlists,
|
||||||
rich_new_releases: Vec::new(),
|
|
||||||
vibe_pick_tabs: Vec::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,7 +354,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_2".into(),
|
id: "demo_2".into(),
|
||||||
|
|
@ -387,7 +374,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_3".into(),
|
id: "demo_3".into(),
|
||||||
|
|
@ -408,7 +394,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_4".into(),
|
id: "demo_4".into(),
|
||||||
|
|
@ -429,7 +414,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_5".into(),
|
id: "demo_5".into(),
|
||||||
|
|
@ -450,7 +434,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_6".into(),
|
id: "demo_6".into(),
|
||||||
|
|
@ -471,7 +454,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_7".into(),
|
id: "demo_7".into(),
|
||||||
|
|
@ -492,7 +474,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_8".into(),
|
id: "demo_8".into(),
|
||||||
|
|
@ -513,7 +494,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_9".into(),
|
id: "demo_9".into(),
|
||||||
|
|
@ -534,7 +514,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
Track {
|
Track {
|
||||||
id: "demo_10".into(),
|
id: "demo_10".into(),
|
||||||
|
|
@ -555,7 +534,6 @@ pub fn demo_chart_tracks() -> Vec<Track> {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -577,7 +555,6 @@ 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,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1846
src/api/mod.rs
|
|
@ -8,8 +8,6 @@ pub struct UserAccount {
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
pub has_plus: bool,
|
pub has_plus: bool,
|
||||||
pub avatar_uri: Option<String>,
|
pub avatar_uri: Option<String>,
|
||||||
#[serde(default)]
|
|
||||||
pub default_email: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
@ -24,8 +22,6 @@ 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>,
|
||||||
|
|
@ -37,25 +33,7 @@ pub struct AlbumSummary {
|
||||||
pub content_type: Option<String>,
|
pub content_type: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AlbumSummary {
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
/// 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, Default, Serialize, Deserialize)]
|
|
||||||
pub struct Track {
|
pub struct Track {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
|
|
@ -82,27 +60,6 @@ pub struct Track {
|
||||||
pub derived_average_hex: Option<String>,
|
pub derived_average_hex: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub derived_accent_hex: Option<String>,
|
pub derived_accent_hex: Option<String>,
|
||||||
/// Official Yandex Music track transition points in seconds (`track.fade`)
|
|
||||||
#[serde(default)]
|
|
||||||
pub fade: Option<TrackFade>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Official Yandex Music track transition points in seconds (`track.fade`).
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
|
||||||
pub struct TrackFade {
|
|
||||||
pub in_start: f32,
|
|
||||||
pub in_stop: f32,
|
|
||||||
pub out_start: f32,
|
|
||||||
pub out_stop: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TrackFade {
|
|
||||||
pub fn is_valid(&self) -> bool {
|
|
||||||
self.in_start >= 0.0
|
|
||||||
&& self.in_stop >= self.in_start
|
|
||||||
&& self.out_start > self.in_stop
|
|
||||||
&& self.out_stop > self.out_start
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Track {
|
impl Track {
|
||||||
|
|
@ -199,8 +156,6 @@ 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)]
|
||||||
|
|
@ -227,53 +182,6 @@ pub struct LandingData {
|
||||||
pub vibe_tracks: Vec<Track>,
|
pub vibe_tracks: Vec<Track>,
|
||||||
pub podcasts: Vec<AlbumSummary>,
|
pub podcasts: Vec<AlbumSummary>,
|
||||||
pub kids_playlists: Vec<PlaylistSummary>,
|
pub kids_playlists: Vec<PlaylistSummary>,
|
||||||
#[serde(default)]
|
|
||||||
pub rich_new_releases: Vec<NewReleaseItem>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub vibe_pick_tabs: Vec<VibePickTab>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Rich editorial new release item from `GET /landing/skeleton/web_main` (`NEW_RELEASES`).
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct NewReleaseItem {
|
|
||||||
pub album: AlbumSummary,
|
|
||||||
#[serde(default)]
|
|
||||||
pub artist_cover_uri: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub cover_color: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub release_date: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Single My Vibe wave pick item from `WAVES` / `SETS_BY_WAVES` skeleton block.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct VibePickItem {
|
|
||||||
pub title: String,
|
|
||||||
pub header: String,
|
|
||||||
pub seeds: Vec<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub color_hex: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub background_image_url: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub image_url: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Category tab inside `More Picks` (`Ещё подборки`) from `WAVES` / `SETS_BY_WAVES`.
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
pub struct VibePickTab {
|
|
||||||
pub title: String,
|
|
||||||
pub items: Vec<VibePickItem>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Section block on the Books & Podcasts (`non_music`) landing page.
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
||||||
pub struct NonMusicSection {
|
|
||||||
pub id: String,
|
|
||||||
pub title: String,
|
|
||||||
pub block_type: String,
|
|
||||||
pub albums: Vec<AlbumSummary>,
|
|
||||||
pub playlists: Vec<PlaylistSummary>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -354,7 +262,7 @@ pub struct PlayTelemetryEvent {
|
||||||
pub batch_id: Option<String>,
|
pub batch_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Concert item returned by `GET /concerts/feed` or `GET /landing/skeleton/concerts`
|
/// Concert item returned by `GET /concerts/feed`
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct ConcertItem {
|
pub struct ConcertItem {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
@ -365,18 +273,6 @@ pub struct ConcertItem {
|
||||||
pub date: String,
|
pub date: String,
|
||||||
pub cover_uri: Option<String>,
|
pub cover_uri: Option<String>,
|
||||||
pub afisha_url: Option<String>,
|
pub afisha_url: Option<String>,
|
||||||
#[serde(default)]
|
|
||||||
pub min_price: Option<u64>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub currency: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub cashback_percent: Option<u32>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub cashback_title: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub cover_color: Option<String>,
|
|
||||||
#[serde(default)]
|
|
||||||
pub event_kind: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_wheel_item_type() -> String {
|
fn default_wheel_item_type() -> String {
|
||||||
|
|
@ -497,81 +393,3 @@ pub struct MetatagDetail {
|
||||||
pub artists: Vec<ArtistSummary>,
|
pub artists: Vec<ArtistSummary>,
|
||||||
pub playlists: Vec<PlaylistSummary>,
|
pub playlists: Vec<PlaylistSummary>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optional clickable action link attached to an AI WordsCard (`card.action`).
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub struct WordsCardAction {
|
|
||||||
pub title: String,
|
|
||||||
pub url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// External source citation attached to an AI WordsCard / WordsBigCard (`actions[]`).
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub struct WordsCardSource {
|
|
||||||
pub title: String,
|
|
||||||
pub url: String,
|
|
||||||
pub favicon_url: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Official 5.129.0 AI Track Fact / Reply card returned by `POST /words/cards`.
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub struct WordsCard {
|
|
||||||
pub id: String,
|
|
||||||
pub track_id: String,
|
|
||||||
pub text: String,
|
|
||||||
pub tags: Vec<String>,
|
|
||||||
pub action: Option<WordsCardAction>,
|
|
||||||
pub actions: Vec<WordsCardSource>,
|
|
||||||
pub big_card_ids: Vec<String>,
|
|
||||||
pub feedback_state: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WordsCard {
|
|
||||||
pub fn is_fact(&self) -> bool {
|
|
||||||
self.tags.iter().any(|t| t == "FACT")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_liked(&self) -> bool {
|
|
||||||
self.feedback_state
|
|
||||||
.as_deref()
|
|
||||||
.map_or(false, |s| s.eq_ignore_ascii_case("like"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_disliked(&self) -> bool {
|
|
||||||
self.feedback_state
|
|
||||||
.as_deref()
|
|
||||||
.map_or(false, |s| s.eq_ignore_ascii_case("dislike"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn has_big_card(&self) -> bool {
|
|
||||||
!self.big_card_ids.is_empty()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Expanded full-screen AI fact/story card returned by `POST /words/big-cards`.
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub struct WordsBigCard {
|
|
||||||
pub id: String,
|
|
||||||
pub text: String,
|
|
||||||
pub actions: Vec<WordsCardSource>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Release changelog entry fetched from Forgejo releases API (or built-in fallback).
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct ReleaseNoteEntry {
|
|
||||||
pub tag: String,
|
|
||||||
pub version: String,
|
|
||||||
pub name: String,
|
|
||||||
pub date: String,
|
|
||||||
pub body: String,
|
|
||||||
pub html_url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Available application update metadata for `NotificationUpdate` & Settings card.
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct UpdateInfo {
|
|
||||||
pub version: String,
|
|
||||||
pub html_url: String,
|
|
||||||
pub date: String,
|
|
||||||
pub body: String,
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use crate::config::{Language, ThemeMode};
|
use crate::config::{Language, ThemeMode};
|
||||||
|
|
||||||
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const APP_VERSION: &str = "5.129.0";
|
||||||
|
|
||||||
/// Lightweight zero-allocation localization helper bound to a `Language`.
|
/// Lightweight zero-allocation localization helper bound to a `Language`.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
@ -589,36 +589,6 @@ impl I18n {
|
||||||
self.pick("Неизвестный исполнитель", "Unknown artist")
|
self.pick("Неизвестный исполнитель", "Unknown artist")
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Official 5.129.0 AI WordsCard Strings
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
pub const fn words_feedback_like(self) -> &'static str {
|
|
||||||
self.pick("Спасибо за оценку", "Thank you for your rating!")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn words_feedback_dislike(self) -> &'static str {
|
|
||||||
self.pick(
|
|
||||||
"Спасибо, что помогаете мне стать лучше",
|
|
||||||
"Thank you for making me become better!",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn words_more_similar(self) -> &'static str {
|
|
||||||
self.pick("Больше такого", "More similar replies")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn words_not_cool(self) -> &'static str {
|
|
||||||
self.pick("Мимо", "Not cool")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn words_ai_disclaimer(self) -> &'static str {
|
|
||||||
self.pick(
|
|
||||||
"AI может ошибаться, проверяйте важное",
|
|
||||||
"AI may make mistakes, be sure to double-check important information",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Formatted Labels & Official Toasts (§2.7)
|
// Formatted Labels & Official Toasts (§2.7)
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
@ -804,46 +774,6 @@ impl I18n {
|
||||||
self.pick("Загрузка остановлена", "Download stopped")
|
self.pick("Загрузка остановлена", "Download stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toast_download_failed_count(self, failed: usize) -> String {
|
|
||||||
if self.is_ru() {
|
|
||||||
format!("Не удалось скачать треков: {}", failed)
|
|
||||||
} else {
|
|
||||||
format!("Failed to download {} track(s)", failed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn whats_new(self) -> &'static str {
|
|
||||||
self.pick("Что нового?", "What's new?")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update_available_banner(self, ver: &str) -> String {
|
|
||||||
if self.is_ru() {
|
|
||||||
format!("Доступна версия v{}", ver)
|
|
||||||
} else {
|
|
||||||
format!("Version v{} available", ver)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn update_btn(self) -> &'static str {
|
|
||||||
self.pick("Обновить", "Update")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn download_update(self) -> &'static str {
|
|
||||||
self.pick("Скачать обновление", "Download update")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn up_to_date_badge(self) -> &'static str {
|
|
||||||
self.pick("Актуальная версия", "Up to date")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn current_version_badge(self) -> &'static str {
|
|
||||||
self.pick("Текущая", "Current")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn new_version_badge(self) -> &'static str {
|
|
||||||
self.pick("Новая", "New")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toast_deleted_from_device(self, title: &str) -> String {
|
pub fn toast_deleted_from_device(self, title: &str) -> String {
|
||||||
if self.is_ru() {
|
if self.is_ru() {
|
||||||
format!("Удалено с устройства: {}", title)
|
format!("Удалено с устройства: {}", title)
|
||||||
|
|
@ -908,21 +838,11 @@ impl I18n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toast_latest_version(self) -> String {
|
|
||||||
self.toast_up_to_date()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toast_update_available(self, newer: &str) -> String {
|
pub fn toast_update_available(self, newer: &str) -> String {
|
||||||
if self.is_ru() {
|
if self.is_ru() {
|
||||||
format!(
|
format!("Доступно обновление: {} (текущая {})", newer, APP_VERSION)
|
||||||
"Доступно обновление: {} (текущая {}) — нажмите снова, чтобы открыть",
|
|
||||||
newer, APP_VERSION
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!("Update available: {} (current {})", newer, APP_VERSION)
|
||||||
"Update available: {} (current {}) — click again to open",
|
|
||||||
newer, APP_VERSION
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ impl AppState {
|
||||||
if idx >= self.queue.len() {
|
if idx >= self.queue.len() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.invalidate_preload();
|
|
||||||
self.queue_index = idx;
|
self.queue_index = idx;
|
||||||
let track = self.queue[idx].clone();
|
let track = self.queue[idx].clone();
|
||||||
|
|
||||||
|
|
@ -75,17 +74,14 @@ impl AppState {
|
||||||
track.duration_ms,
|
track.duration_ms,
|
||||||
track.r128_i,
|
track.r128_i,
|
||||||
track.r128_tp,
|
track.r128_tp,
|
||||||
track.fade,
|
|
||||||
);
|
);
|
||||||
self.fetch_lyrics_async(&track);
|
self.fetch_lyrics_async(&track);
|
||||||
self.ensure_words_for_current_track();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report track start to `POST /plays`
|
// Report track start to `POST /plays`
|
||||||
self.send_play_telemetry("start");
|
self.send_play_telemetry("start");
|
||||||
self.fetch_lyrics_async(&track);
|
self.fetch_lyrics_async(&track);
|
||||||
self.ensure_words_for_current_track();
|
|
||||||
|
|
||||||
if self.api.has_token() {
|
if self.api.has_token() {
|
||||||
let api = self.api.clone();
|
let api = self.api.clone();
|
||||||
|
|
@ -94,7 +90,6 @@ impl AppState {
|
||||||
let dur = track.duration_ms;
|
let dur = track.duration_ms;
|
||||||
let r128_i = track.r128_i;
|
let r128_i = track.r128_i;
|
||||||
let r128_tp = track.r128_tp;
|
let r128_tp = track.r128_tp;
|
||||||
let fade = track.fade;
|
|
||||||
let quality = self.config.audio_quality;
|
let quality = self.config.audio_quality;
|
||||||
self.audio.state.is_buffering.store(true, Ordering::SeqCst);
|
self.audio.state.is_buffering.store(true, Ordering::SeqCst);
|
||||||
self.runtime.spawn(async move {
|
self.runtime.spawn(async move {
|
||||||
|
|
@ -107,7 +102,6 @@ impl AppState {
|
||||||
duration_ms: dur,
|
duration_ms: dur,
|
||||||
r128_i,
|
r128_i,
|
||||||
r128_tp,
|
r128_tp,
|
||||||
fade,
|
|
||||||
result,
|
result,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -118,150 +112,6 @@ impl AppState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn peek_next_queue_index(&self) -> Option<usize> {
|
|
||||||
if self.queue.is_empty() || self.repeat == RepeatMode::One {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if self.queue_index + 1 < self.queue.len() {
|
|
||||||
Some(self.queue_index + 1)
|
|
||||||
} else if self.repeat == RepeatMode::All || self.is_vibe_active {
|
|
||||||
Some(0)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn invalidate_preload(&mut self) {
|
|
||||||
self.preloaded_next_track_id = None;
|
|
||||||
self.audio.clear_preload();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn maybe_preload_next_track(&mut self) {
|
|
||||||
if !self.is_audio_playing() || self.is_buffering() || self.preloaded_next_track_id.is_some() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let dur_ms = self.duration_ms();
|
|
||||||
if dur_ms < 8_000 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let pos_ms = self.position_ms();
|
|
||||||
let curr_fade = self.current_track().and_then(|tr| tr.fade);
|
|
||||||
let transition_ms = if self.config.crossfade_enabled {
|
|
||||||
if self.config.crossfade_secs > 0.1 {
|
|
||||||
dur_ms.saturating_sub((self.config.crossfade_secs * 1000.0) as u64)
|
|
||||||
} else if let Some(f) = curr_fade {
|
|
||||||
((f.out_start * 1000.0) as u64).min(dur_ms)
|
|
||||||
} else {
|
|
||||||
dur_ms.saturating_sub(3_500)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dur_ms
|
|
||||||
};
|
|
||||||
if pos_ms + 15_000 < transition_ms {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let Some(next_idx) = self.peek_next_queue_index() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
let next_track = self.queue[next_idx].clone();
|
|
||||||
self.preloaded_next_track_id = Some(next_track.id.clone());
|
|
||||||
|
|
||||||
let cache_dir = AppConfig::offline_cache_dir();
|
|
||||||
if let Some(local_path) = find_offline_track_file(&next_track.id, &cache_dir) {
|
|
||||||
let ext = local_path
|
|
||||||
.extension()
|
|
||||||
.and_then(|e| e.to_str())
|
|
||||||
.unwrap_or("mp3")
|
|
||||||
.to_lowercase();
|
|
||||||
let (codec_label, bitrate_kbps) = match ext.as_str() {
|
|
||||||
"flac" => ("FLAC (Offline)".to_string(), 1000),
|
|
||||||
"m4a" => ("AAC (Offline)".to_string(), 320),
|
|
||||||
_ => ("MP3 (Offline)".to_string(), 320),
|
|
||||||
};
|
|
||||||
let stream = ResolvedStream {
|
|
||||||
url: format!("file://{}", local_path.display()),
|
|
||||||
codec_label,
|
|
||||||
bitrate_kbps,
|
|
||||||
decrypt_key_hex: None,
|
|
||||||
gain_applied: false,
|
|
||||||
};
|
|
||||||
self.audio.preload_next(
|
|
||||||
next_track.id,
|
|
||||||
stream,
|
|
||||||
next_track.duration_ms,
|
|
||||||
next_track.r128_i,
|
|
||||||
next_track.r128_tp,
|
|
||||||
next_track.fade,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.api.has_token() {
|
|
||||||
let api = self.api.clone();
|
|
||||||
let tx = self.tx_api.clone();
|
|
||||||
let tid = next_track.id.clone();
|
|
||||||
let dur = next_track.duration_ms;
|
|
||||||
let r128_i = next_track.r128_i;
|
|
||||||
let r128_tp = next_track.r128_tp;
|
|
||||||
let fade = next_track.fade;
|
|
||||||
let quality = self.config.audio_quality;
|
|
||||||
self.runtime.spawn(async move {
|
|
||||||
let result = api
|
|
||||||
.resolve_track_stream(&tid, quality)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e.to_string());
|
|
||||||
let _ = tx.send(ApiEvent::NextStreamPreloaded {
|
|
||||||
track_id: tid,
|
|
||||||
duration_ms: dur,
|
|
||||||
r128_i,
|
|
||||||
r128_tp,
|
|
||||||
fade,
|
|
||||||
result,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn on_seamless_transition_to(&mut self, next_track_id: &str) {
|
|
||||||
self.preloaded_next_track_id = None;
|
|
||||||
let pos_sec = self.duration_ms() as f64 / 1000.0;
|
|
||||||
let outgoing = self.current_track().cloned();
|
|
||||||
self.send_play_telemetry("finish");
|
|
||||||
if self.is_vibe_active {
|
|
||||||
self.send_rotor_feedback(RotorFeedbackKind::TrackFinished, outgoing.as_ref(), Some(pos_sec));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(next_idx) = self
|
|
||||||
.peek_next_queue_index()
|
|
||||||
.filter(|&i| self.queue.get(i).map_or(false, |tr| tr.id == next_track_id))
|
|
||||||
.or_else(|| self.queue.iter().position(|tr| tr.id == next_track_id))
|
|
||||||
{
|
|
||||||
self.queue_index = next_idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
let Some(track) = self.current_track().cloned() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
self.current_play_id = generate_request_id();
|
|
||||||
self.play_start_iso = iso8601_now();
|
|
||||||
self.play_seeked = false;
|
|
||||||
self.play_paused = false;
|
|
||||||
self.play_from_cache = find_offline_track_file(&track.id, &AppConfig::offline_cache_dir()).is_some();
|
|
||||||
self.last_play_heartbeat = Instant::now();
|
|
||||||
|
|
||||||
if self.is_vibe_active {
|
|
||||||
self.send_rotor_feedback(RotorFeedbackKind::TrackStarted, Some(&track), None);
|
|
||||||
self.maybe_prefetch_rotor_batch();
|
|
||||||
}
|
|
||||||
self.play_history.retain(|t| t.id != track.id);
|
|
||||||
self.play_history.insert(0, track.clone());
|
|
||||||
self.play_history.truncate(50);
|
|
||||||
|
|
||||||
self.send_play_telemetry("start");
|
|
||||||
self.fetch_lyrics_async(&track);
|
|
||||||
self.ensure_words_for_current_track();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fetch_lyrics_async(&mut self, track: &Track) {
|
fn fetch_lyrics_async(&mut self, track: &Track) {
|
||||||
self.current_lyrics = None;
|
self.current_lyrics = None;
|
||||||
self.fetch_lyrics_for_track(track);
|
self.fetch_lyrics_for_track(track);
|
||||||
|
|
@ -486,7 +336,6 @@ impl AppState {
|
||||||
if idx >= self.queue.len() {
|
if idx >= self.queue.len() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.invalidate_preload();
|
|
||||||
let was_playing = self.is_audio_playing();
|
let was_playing = self.is_audio_playing();
|
||||||
let old_len = self.queue.len();
|
let old_len = self.queue.len();
|
||||||
let removed = self.queue.remove(idx);
|
let removed = self.queue.remove(idx);
|
||||||
|
|
@ -527,7 +376,6 @@ impl AppState {
|
||||||
if from >= self.queue.len() || to >= self.queue.len() || from == to {
|
if from >= self.queue.len() || to >= self.queue.len() || from == to {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.invalidate_preload();
|
|
||||||
let item = self.queue.remove(from);
|
let item = self.queue.remove(from);
|
||||||
self.queue.insert(to, item);
|
self.queue.insert(to, item);
|
||||||
|
|
||||||
|
|
@ -541,7 +389,6 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_queue(&mut self) {
|
pub fn clear_queue(&mut self) {
|
||||||
self.invalidate_preload();
|
|
||||||
self.queue.clear();
|
self.queue.clear();
|
||||||
self.unshuffled_queue.clear();
|
self.unshuffled_queue.clear();
|
||||||
self.queue_index = 0;
|
self.queue_index = 0;
|
||||||
|
|
@ -550,13 +397,11 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_to_queue(&mut self, track: Track) {
|
pub fn add_to_queue(&mut self, track: Track) {
|
||||||
self.invalidate_preload();
|
|
||||||
self.show_toast(self.i18n().toast_play_last(&track.title));
|
self.show_toast(self.i18n().toast_play_last(&track.title));
|
||||||
self.queue.push(track);
|
self.queue.push(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn play_next_track(&mut self, track: Track) {
|
pub fn play_next_track(&mut self, track: Track) {
|
||||||
self.invalidate_preload();
|
|
||||||
self.show_toast(self.i18n().toast_play_next(&track.title));
|
self.show_toast(self.i18n().toast_play_next(&track.title));
|
||||||
let pos = if self.queue.is_empty() {
|
let pos = if self.queue.is_empty() {
|
||||||
0
|
0
|
||||||
|
|
@ -609,7 +454,6 @@ impl AppState {
|
||||||
self.show_toast(t.toast_shuffle_vibe_managed());
|
self.show_toast(t.toast_shuffle_vibe_managed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.invalidate_preload();
|
|
||||||
self.shuffle = !self.shuffle;
|
self.shuffle = !self.shuffle;
|
||||||
if self.queue.len() > 1 {
|
if self.queue.len() > 1 {
|
||||||
if self.shuffle {
|
if self.shuffle {
|
||||||
|
|
@ -638,7 +482,6 @@ impl AppState {
|
||||||
|
|
||||||
/// Exact 5.129.0 Repeat Cycle (`Off -> All -> One -> Off`; in VibeContext toggles `Off <-> One` ONLY!)
|
/// Exact 5.129.0 Repeat Cycle (`Off -> All -> One -> Off`; in VibeContext toggles `Off <-> One` ONLY!)
|
||||||
pub fn cycle_repeat(&mut self) {
|
pub fn cycle_repeat(&mut self) {
|
||||||
self.invalidate_preload();
|
|
||||||
self.repeat = if self.is_vibe_active {
|
self.repeat = if self.is_vibe_active {
|
||||||
match self.repeat {
|
match self.repeat {
|
||||||
RepeatMode::Off => RepeatMode::One,
|
RepeatMode::Off => RepeatMode::One,
|
||||||
|
|
@ -775,189 +618,6 @@ impl AppState {
|
||||||
self.start_vibe_by_seeds(default_vibe, vec!["user:onyourwave".to_string()]);
|
self.start_vibe_by_seeds(default_vibe, vec!["user:onyourwave".to_string()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// 1b. OFFICIAL 5.129.0 AI WORDS CARDS (Facts, Replies, BigCard & Feedback)
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
pub fn current_words_card(&self) -> Option<&WordsCard> {
|
|
||||||
let tr = self.current_track()?;
|
|
||||||
let clean_id = tr.id.split(':').next().unwrap_or(&tr.id);
|
|
||||||
self.words_cards
|
|
||||||
.get(&tr.id)
|
|
||||||
.or_else(|| self.words_cards.get(clean_id))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn current_words_feedback_message(&self) -> Option<&str> {
|
|
||||||
let (ref msg, at) = self.words_feedback_message.as_ref()?;
|
|
||||||
if at.elapsed() < Duration::from_secs(3) {
|
|
||||||
Some(msg.as_str())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clear_words_cache(&mut self) {
|
|
||||||
self.words_cards.clear();
|
|
||||||
self.words_loading_tracks.clear();
|
|
||||||
self.words_empty_tracks.clear();
|
|
||||||
self.words_big_card = None;
|
|
||||||
self.words_big_card_loading = false;
|
|
||||||
self.words_big_card_open = false;
|
|
||||||
self.words_feedback_message = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn ensure_words_for_current_track(&mut self) {
|
|
||||||
if !self.api.has_token() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let Some(curr) = self.current_track() else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
let curr_clean = curr.id.split(':').next().unwrap_or(&curr.id).to_string();
|
|
||||||
if self.words_cards.contains_key(&curr_clean)
|
|
||||||
|| self.words_loading_tracks.contains(&curr_clean)
|
|
||||||
|| self.words_empty_tracks.contains(&curr_clean)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Batch current track + up to 2 upcoming tracks so skipping on My Vibe feels instant!
|
|
||||||
let mut req_ids: Vec<String> = Vec::new();
|
|
||||||
for offset in 0..3 {
|
|
||||||
if let Some(tr) = self.queue.get(self.queue_index + offset) {
|
|
||||||
let clean = tr.id.split(':').next().unwrap_or(&tr.id).to_string();
|
|
||||||
if !clean.is_empty()
|
|
||||||
&& !self.words_cards.contains_key(&clean)
|
|
||||||
&& !self.words_loading_tracks.contains(&clean)
|
|
||||||
&& !self.words_empty_tracks.contains(&clean)
|
|
||||||
&& !req_ids.contains(&clean)
|
|
||||||
{
|
|
||||||
self.words_loading_tracks.insert(clean.clone());
|
|
||||||
req_ids.push(clean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if req_ids.is_empty() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let wave_seeds: Option<Vec<String>> = if self.is_vibe_active {
|
|
||||||
let parsed: Vec<String> = self
|
|
||||||
.context_key
|
|
||||||
.strip_prefix("vibe:")
|
|
||||||
.map(|s| {
|
|
||||||
s.split(',')
|
|
||||||
.map(str::trim)
|
|
||||||
.filter(|p| !p.is_empty())
|
|
||||||
.map(String::from)
|
|
||||||
.collect()
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
|
||||||
if parsed.is_empty() {
|
|
||||||
Some(vec!["user:onyourwave".to_string()])
|
|
||||||
} else {
|
|
||||||
Some(parsed)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let api = self.api.clone();
|
|
||||||
let tx = self.tx_api.clone();
|
|
||||||
self.runtime.spawn(async move {
|
|
||||||
match api
|
|
||||||
.fetch_words_cards(&req_ids, wave_seeds.as_deref())
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(entries) => {
|
|
||||||
let _ = tx.send(ApiEvent::WordsCardsLoaded(entries));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
log::debug!("[words] /words/cards failed: {}", e);
|
|
||||||
let empty = req_ids.into_iter().map(|id| (id, None)).collect();
|
|
||||||
let _ = tx.send(ApiEvent::WordsCardsLoaded(empty));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn open_words_big_card(&mut self, track_id: String) {
|
|
||||||
let clean_id = track_id.split(':').next().unwrap_or(&track_id).to_string();
|
|
||||||
self.words_big_card_open = true;
|
|
||||||
let maybe_req = self
|
|
||||||
.words_cards
|
|
||||||
.get(&track_id)
|
|
||||||
.or_else(|| self.words_cards.get(&clean_id))
|
|
||||||
.and_then(|c| c.big_card_ids.first().map(|bid| (bid.clone(), c.id.clone())));
|
|
||||||
|
|
||||||
let Some((big_card_id, card_id)) = maybe_req else {
|
|
||||||
self.words_big_card_loading = false;
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if self
|
|
||||||
.words_big_card
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |bc| bc.id == big_card_id)
|
|
||||||
{
|
|
||||||
self.words_big_card_loading = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.words_big_card = None;
|
|
||||||
if !self.api.has_token() {
|
|
||||||
self.words_big_card_loading = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.words_big_card_loading = true;
|
|
||||||
let api = self.api.clone();
|
|
||||||
let tx = self.tx_api.clone();
|
|
||||||
self.runtime.spawn(async move {
|
|
||||||
let res = api
|
|
||||||
.fetch_words_big_card(&big_card_id, &clean_id, &card_id)
|
|
||||||
.await
|
|
||||||
.ok()
|
|
||||||
.flatten();
|
|
||||||
let _ = tx.send(ApiEvent::WordsBigCardLoaded(res));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_words_feedback(&mut self, track_id: String, card_id: String, state: String) {
|
|
||||||
let clean_id = track_id.split(':').next().unwrap_or(&track_id).to_string();
|
|
||||||
let norm_state = if state.eq_ignore_ascii_case("neutral") {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(state.clone())
|
|
||||||
};
|
|
||||||
let lookup_key = if self.words_cards.contains_key(&track_id) {
|
|
||||||
&track_id
|
|
||||||
} else {
|
|
||||||
&clean_id
|
|
||||||
};
|
|
||||||
if let Some(card) = self.words_cards.get_mut(lookup_key) {
|
|
||||||
card.feedback_state = norm_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
let t = self.i18n();
|
|
||||||
if state.eq_ignore_ascii_case("dislike") {
|
|
||||||
self.words_big_card_open = false;
|
|
||||||
self.words_big_card_loading = false;
|
|
||||||
self.words_feedback_message =
|
|
||||||
Some((t.words_feedback_dislike().to_string(), Instant::now()));
|
|
||||||
} else if state.eq_ignore_ascii_case("like") {
|
|
||||||
self.words_feedback_message =
|
|
||||||
Some((t.words_feedback_like().to_string(), Instant::now()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.api.has_token() && !card_id.is_empty() {
|
|
||||||
let api = self.api.clone();
|
|
||||||
self.runtime.spawn(async move {
|
|
||||||
let _ = api.send_words_feedback(&card_id, &state).await;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// 2. LIKES, DISLIKES & PINS (Playlist, Album, Artist, Liked, Wave)
|
// 2. LIKES, DISLIKES & PINS (Playlist, Album, Artist, Liked, Wave)
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -1767,58 +1427,21 @@ impl AppState {
|
||||||
!tracks.is_empty() && tracks.iter().all(|t| self.downloaded_track_ids.contains(&t.id))
|
!tracks.is_empty() && tracks.iter().all(|t| self.downloaded_track_ids.contains(&t.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn track_download_progress(&self, track_id: &str) -> f32 {
|
|
||||||
self.downloading_track_progress
|
|
||||||
.get(track_id)
|
|
||||||
.copied()
|
|
||||||
.unwrap_or(0.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn download_progress_pct(&self) -> Option<u8> {
|
pub fn download_progress_pct(&self) -> Option<u8> {
|
||||||
if self.downloading_track_ids.is_empty() || self.download_batch_total == 0 {
|
if self.downloading_track_ids.is_empty() || self.download_batch_total == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let in_flight: f32 = self.downloading_track_progress.values().sum();
|
let pct = ((self.download_batch_done as f32 / self.download_batch_total as f32) * 100.0)
|
||||||
let total = self.download_batch_total.max(1) as f32;
|
.round()
|
||||||
let frac = ((self.download_batch_done as f32 + in_flight) / total).clamp(0.0, 0.99);
|
.clamp(0.0, 99.0) as u8;
|
||||||
Some((frac * 100.0).round().clamp(0.0, 99.0) as u8)
|
Some(pct)
|
||||||
}
|
|
||||||
|
|
||||||
pub fn tracks_download_progress_pct(&self, tracks: &[Track]) -> Option<u8> {
|
|
||||||
if tracks.is_empty() || self.downloading_track_ids.is_empty() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut active_count = 0usize;
|
|
||||||
let mut completed_count = 0usize;
|
|
||||||
let mut in_flight = 0.0f32;
|
|
||||||
for tr in tracks {
|
|
||||||
if self.downloaded_track_ids.contains(&tr.id) {
|
|
||||||
completed_count += 1;
|
|
||||||
} else if self.downloading_track_ids.contains(&tr.id) {
|
|
||||||
active_count += 1;
|
|
||||||
in_flight += self.track_download_progress(&tr.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if active_count == 0 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let denom = (completed_count + active_count).max(1) as f32;
|
|
||||||
let frac = ((completed_count as f32 + in_flight) / denom).clamp(0.0, 0.99);
|
|
||||||
Some((frac * 100.0).round().clamp(0.0, 99.0) as u8)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cancel_downloads(&mut self) {
|
pub fn cancel_downloads(&mut self) {
|
||||||
self.download_cancel.store(true, Ordering::SeqCst);
|
self.download_cancel.store(true, Ordering::SeqCst);
|
||||||
self.downloading_track_ids.clear();
|
self.downloading_track_ids.clear();
|
||||||
self.downloading_track_progress.clear();
|
|
||||||
self.download_batch_total = 0;
|
self.download_batch_total = 0;
|
||||||
self.download_batch_done = 0;
|
self.download_batch_done = 0;
|
||||||
self.download_batch_succeeded = 0;
|
|
||||||
self.download_batch_failed = 0;
|
|
||||||
if self.download_config_dirty_count > 0 {
|
|
||||||
self.save_config();
|
|
||||||
self.download_config_dirty_count = 0;
|
|
||||||
}
|
|
||||||
self.show_toast(self.i18n().toast_download_stopped());
|
self.show_toast(self.i18n().toast_download_stopped());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1833,11 +1456,8 @@ impl AppState {
|
||||||
}
|
}
|
||||||
if self.downloading_track_ids.is_empty() {
|
if self.downloading_track_ids.is_empty() {
|
||||||
self.download_cancel.store(false, Ordering::SeqCst);
|
self.download_cancel.store(false, Ordering::SeqCst);
|
||||||
self.download_batch_succeeded = 0;
|
|
||||||
self.download_batch_failed = 0;
|
|
||||||
}
|
}
|
||||||
self.downloading_track_ids.insert(track.id.clone());
|
self.downloading_track_ids.insert(track.id.clone());
|
||||||
self.downloading_track_progress.insert(track.id.clone(), 0.02);
|
|
||||||
self.download_batch_total += 1;
|
self.download_batch_total += 1;
|
||||||
|
|
||||||
let api = self.api.clone();
|
let api = self.api.clone();
|
||||||
|
|
@ -1849,15 +1469,8 @@ impl AppState {
|
||||||
if cancel.load(Ordering::Relaxed) {
|
if cancel.load(Ordering::Relaxed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let tid = track.id.clone();
|
|
||||||
let tx_prog = tx.clone();
|
|
||||||
let res = api
|
let res = api
|
||||||
.download_track_to_cache_with_progress(&track, quality, &cache_dir, &cancel, |p| {
|
.download_track_to_cache(&track, quality, &cache_dir)
|
||||||
let _ = tx_prog.send(ApiEvent::TrackDownloadProgress {
|
|
||||||
track_id: tid.clone(),
|
|
||||||
progress: p,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string());
|
.map_err(|e| e.to_string());
|
||||||
if cancel.load(Ordering::Relaxed) {
|
if cancel.load(Ordering::Relaxed) {
|
||||||
|
|
@ -1874,11 +1487,7 @@ impl AppState {
|
||||||
self.show_toast(self.i18n().toast_sign_in_required());
|
self.show_toast(self.i18n().toast_sign_in_required());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.downloading_track_ids.is_empty() {
|
self.download_cancel.store(false, Ordering::SeqCst);
|
||||||
self.download_cancel.store(false, Ordering::SeqCst);
|
|
||||||
self.download_batch_succeeded = 0;
|
|
||||||
self.download_batch_failed = 0;
|
|
||||||
}
|
|
||||||
let to_download: Vec<Track> = tracks
|
let to_download: Vec<Track> = tracks
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|tr| !self.is_track_downloaded(&tr.id) && !self.is_track_downloading(&tr.id))
|
.filter(|tr| !self.is_track_downloaded(&tr.id) && !self.is_track_downloading(&tr.id))
|
||||||
|
|
@ -1888,7 +1497,6 @@ impl AppState {
|
||||||
}
|
}
|
||||||
for tr in &to_download {
|
for tr in &to_download {
|
||||||
self.downloading_track_ids.insert(tr.id.clone());
|
self.downloading_track_ids.insert(tr.id.clone());
|
||||||
self.downloading_track_progress.insert(tr.id.clone(), 0.01);
|
|
||||||
self.download_batch_total += 1;
|
self.download_batch_total += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1897,52 +1505,20 @@ impl AppState {
|
||||||
let quality = self.config.audio_quality;
|
let quality = self.config.audio_quality;
|
||||||
let cache_dir = AppConfig::offline_cache_dir();
|
let cache_dir = AppConfig::offline_cache_dir();
|
||||||
let cancel = std::sync::Arc::clone(&self.download_cancel);
|
let cancel = std::sync::Arc::clone(&self.download_cancel);
|
||||||
let rt = self.runtime.clone();
|
|
||||||
self.runtime.spawn(async move {
|
self.runtime.spawn(async move {
|
||||||
let sem = std::sync::Arc::new(tokio::sync::Semaphore::new(6));
|
|
||||||
for track in to_download {
|
for track in to_download {
|
||||||
if cancel.load(Ordering::Relaxed) {
|
if cancel.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let Ok(permit) = sem.clone().acquire_owned().await else {
|
let res = api
|
||||||
break;
|
.download_track_to_cache(&track, quality, &cache_dir)
|
||||||
};
|
.await
|
||||||
|
.map_err(|e| e.to_string());
|
||||||
if cancel.load(Ordering::Relaxed) {
|
if cancel.load(Ordering::Relaxed) {
|
||||||
drop(permit);
|
let _ = remove_offline_track_file(&track.id, &cache_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let api_w = api.clone();
|
let _ = tx.send(ApiEvent::TrackDownloaded { track, result: res });
|
||||||
let tx_w = tx.clone();
|
|
||||||
let cache_w = cache_dir.clone();
|
|
||||||
let cancel_w = std::sync::Arc::clone(&cancel);
|
|
||||||
rt.spawn(async move {
|
|
||||||
let _permit = permit;
|
|
||||||
if cancel_w.load(Ordering::Relaxed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let tid = track.id.clone();
|
|
||||||
let tx_prog = tx_w.clone();
|
|
||||||
let res = api_w
|
|
||||||
.download_track_to_cache_with_progress(
|
|
||||||
&track,
|
|
||||||
quality,
|
|
||||||
&cache_w,
|
|
||||||
&cancel_w,
|
|
||||||
|p| {
|
|
||||||
let _ = tx_prog.send(ApiEvent::TrackDownloadProgress {
|
|
||||||
track_id: tid.clone(),
|
|
||||||
progress: p,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|e| e.to_string());
|
|
||||||
if cancel_w.load(Ordering::Relaxed) {
|
|
||||||
let _ = remove_offline_track_file(&track.id, &cache_w);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let _ = tx_w.send(ApiEvent::TrackDownloaded { track, result: res });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2195,7 +1771,6 @@ mod tests {
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2697,92 +2272,4 @@ mod tests {
|
||||||
assert!(!app.shuffle);
|
assert!(!app.shuffle);
|
||||||
assert_eq!(app.repeat, RepeatMode::Off);
|
assert_eq!(app.repeat, RepeatMode::Off);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_words_card_state_feedback_and_big_card() {
|
|
||||||
let tracks = vec![make_track("w1", "Track One"), make_track("w2", "Track Two")];
|
|
||||||
let (_rt, mut app) = make_test_state(tracks);
|
|
||||||
|
|
||||||
// Simulate WordsCardsLoaded delivering a FACT card for w1 and empty for w2
|
|
||||||
app.words_loading_tracks.insert("w1".into());
|
|
||||||
app.words_loading_tracks.insert("w2".into());
|
|
||||||
let card = WordsCard {
|
|
||||||
id: "c_1".into(),
|
|
||||||
track_id: "w1".into(),
|
|
||||||
text: "Факт о треке".into(),
|
|
||||||
tags: vec!["FACT".into()],
|
|
||||||
action: None,
|
|
||||||
actions: vec![WordsCardSource {
|
|
||||||
title: "Wiki".into(),
|
|
||||||
url: "https://wikipedia.org".into(),
|
|
||||||
favicon_url: None,
|
|
||||||
}],
|
|
||||||
big_card_ids: vec!["big_1".into()],
|
|
||||||
feedback_state: None,
|
|
||||||
};
|
|
||||||
let _ = app.tx_api.send(ApiEvent::WordsCardsLoaded(vec![
|
|
||||||
("w1".into(), Some(card)),
|
|
||||||
("w2".into(), None),
|
|
||||||
]));
|
|
||||||
assert!(app.poll_async_events());
|
|
||||||
assert!(app.words_loading_tracks.is_empty());
|
|
||||||
assert!(app.words_empty_tracks.contains("w2"));
|
|
||||||
|
|
||||||
let cur = app.current_words_card().expect("w1 card should be active");
|
|
||||||
assert!(cur.is_fact());
|
|
||||||
assert!(cur.has_big_card());
|
|
||||||
assert!(!cur.is_liked());
|
|
||||||
assert!(!cur.is_disliked());
|
|
||||||
|
|
||||||
// Open big card & load content
|
|
||||||
app.dispatch(AppAction::OpenWordsBigCard {
|
|
||||||
track_id: "w1".into(),
|
|
||||||
});
|
|
||||||
assert!(app.words_big_card_open);
|
|
||||||
let _ = app.tx_api.send(ApiEvent::WordsBigCardLoaded(Some(WordsBigCard {
|
|
||||||
id: "big_1".into(),
|
|
||||||
text: "Полный рассказ о треке".into(),
|
|
||||||
actions: vec![],
|
|
||||||
})));
|
|
||||||
assert!(app.poll_async_events());
|
|
||||||
assert!(!app.words_big_card_loading);
|
|
||||||
assert_eq!(
|
|
||||||
app.words_big_card.as_ref().map(|b| b.id.as_str()),
|
|
||||||
Some("big_1")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Like feedback sets localized toast message
|
|
||||||
app.dispatch(AppAction::SendWordsFeedback {
|
|
||||||
track_id: "w1".into(),
|
|
||||||
card_id: "c_1".into(),
|
|
||||||
state: "like".into(),
|
|
||||||
});
|
|
||||||
assert!(app.current_words_card().unwrap().is_liked());
|
|
||||||
assert_eq!(
|
|
||||||
app.current_words_feedback_message(),
|
|
||||||
Some("Спасибо за оценку")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Dislike feedback closes big card modal and sets EN message after SetLanguage(En)
|
|
||||||
app.config.language = crate::config::Language::En;
|
|
||||||
app.dispatch(AppAction::SendWordsFeedback {
|
|
||||||
track_id: "w1".into(),
|
|
||||||
card_id: "c_1".into(),
|
|
||||||
state: "dislike".into(),
|
|
||||||
});
|
|
||||||
assert!(app.current_words_card().unwrap().is_disliked());
|
|
||||||
assert!(!app.words_big_card_open);
|
|
||||||
assert_eq!(
|
|
||||||
app.current_words_feedback_message(),
|
|
||||||
Some("Thank you for making me become better!")
|
|
||||||
);
|
|
||||||
|
|
||||||
// CloseWordsBigCard & DismissOverlays clear open state
|
|
||||||
app.words_big_card_open = true;
|
|
||||||
app.dispatch(AppAction::CloseWordsBigCard);
|
|
||||||
assert!(!app.words_big_card_open);
|
|
||||||
app.words_big_card_open = true;
|
|
||||||
app.dispatch(AppAction::DismissOverlays);
|
|
||||||
assert!(!app.words_big_card_open);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
760
src/app/state.rs
241
src/audio/dsp.rs
|
|
@ -1,140 +1,28 @@
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
pub const EQ_FREQS: [f32; 10] = [
|
pub const EQ_FREQS: [f32; 10] = [
|
||||||
60.0, 170.0, 310.0, 600.0, 1000.0, 3000.0, 6000.0, 12000.0, 14000.0, 16000.0,
|
32.0, 64.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const EQ_LABELS: [&str; 10] = [
|
pub const EQ_LABELS: [&str; 10] = [
|
||||||
"60", "170", "310", "600", "1k", "3k", "6k", "12k", "14k", "16k",
|
"32", "64", "125", "250", "500", "1k", "2k", "4k", "8k", "16k",
|
||||||
];
|
];
|
||||||
|
|
||||||
pub struct EqPreset {
|
pub struct EqPreset {
|
||||||
pub name_ru: &'static str,
|
pub name: &'static str,
|
||||||
pub name_en: &'static str,
|
|
||||||
pub gains: [f32; 10],
|
pub gains: [f32; 10],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EqPreset {
|
|
||||||
pub const fn name(&self, ru: bool) -> &'static str {
|
|
||||||
if ru {
|
|
||||||
self.name_ru
|
|
||||||
} else {
|
|
||||||
self.name_en
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// All 18 official Yandex Music Desktop 5.129.0 Equalizer Presets (`layout.js:11387-11783`).
|
|
||||||
pub const EQ_PRESETS: &[EqPreset] = &[
|
pub const EQ_PRESETS: &[EqPreset] = &[
|
||||||
EqPreset {
|
EqPreset { name: "Плоский", gains: [0.0; 10] },
|
||||||
name_ru: "По умолчанию",
|
EqPreset { name: "Бас+", gains: [6.0, 5.5, 4.0, 2.0, 0.0, 0.0, 0.5, 1.0, 1.5, 1.5] },
|
||||||
name_en: "Default",
|
EqPreset { name: "Поп", gains: [-1.0, 1.5, 3.5, 4.0, 2.0, -0.5, -1.0, 1.0, 2.5, 3.0] },
|
||||||
gains: [0.0; 10],
|
EqPreset { name: "Рок", gains: [4.5, 3.0, 1.5, -1.0, -1.5, 1.0, 3.5, 4.5, 5.0, 4.0] },
|
||||||
},
|
EqPreset { name: "Электроника", gains: [5.0, 4.0, 1.5, -1.5, -1.0, 1.5, 3.0, 4.0, 4.5, 5.0] },
|
||||||
EqPreset {
|
EqPreset { name: "Вокал", gains: [-2.0, -1.5, 0.0, 2.5, 4.5, 4.5, 3.0, 1.0, -0.5, -1.0] },
|
||||||
name_ru: "Классическая музыка",
|
EqPreset { name: "Джаз", gains: [3.0, 2.0, 1.0, 2.0, -1.0, -1.0, 0.0, 1.5, 2.5, 3.0] },
|
||||||
name_en: "Classical Music",
|
|
||||||
gains: [-0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -3.5, -3.5, -3.5, -4.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Клубная музыка",
|
|
||||||
name_en: "Club music",
|
|
||||||
gains: [-0.5, -0.5, 4.0, 2.5, 2.5, 2.5, 1.5, -0.5, -0.5, -0.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Танцевальная музыка",
|
|
||||||
name_en: "Dance music",
|
|
||||||
gains: [4.5, 3.5, 1.0, -0.5, -0.5, -2.5, -3.5, -3.5, -0.5, -0.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Усиление НЧ",
|
|
||||||
name_en: "Enhanced bass",
|
|
||||||
gains: [4.0, 4.5, 4.5, 2.5, 0.5, -2.0, -4.0, -5.0, -5.5, -5.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Усиление НЧ и ВЧ",
|
|
||||||
name_en: "Enhanced bass and treble",
|
|
||||||
gains: [3.5, 2.5, -0.5, -3.5, -2.0, 0.5, 4.0, 5.5, 6.0, 6.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Усиление ВЧ",
|
|
||||||
name_en: "Enhanced treble",
|
|
||||||
gains: [-4.5, -4.5, -4.5, -2.0, 1.0, 5.5, 8.0, 8.0, 8.0, 8.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Колонки ноутбука",
|
|
||||||
name_en: "Laptop speakers",
|
|
||||||
gains: [2.0, 5.5, 2.5, -1.5, -1.0, 0.5, 2.0, 4.5, 6.0, 7.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Большой зал",
|
|
||||||
name_en: "Large Hall",
|
|
||||||
gains: [5.0, 5.0, 2.5, 2.5, -0.5, -2.0, -2.0, -2.0, -0.5, -0.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Концерт",
|
|
||||||
name_en: "Live",
|
|
||||||
gains: [-2.0, -0.5, 2.0, 2.5, 2.5, 2.5, 2.0, 1.0, 1.0, 1.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Вечеринка",
|
|
||||||
name_en: "Partying",
|
|
||||||
gains: [3.5, 3.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 3.5, 3.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Поп",
|
|
||||||
name_en: "Pop",
|
|
||||||
gains: [-0.5, 2.0, 3.5, 4.0, 2.5, -0.5, -1.0, -1.0, -0.5, -0.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Регги",
|
|
||||||
name_en: "Reggae",
|
|
||||||
gains: [-0.5, -0.5, -0.5, -2.5, -0.5, 3.0, 3.0, -0.5, -0.5, -0.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Рок",
|
|
||||||
name_en: "Rock",
|
|
||||||
gains: [4.0, 2.0, -2.5, -4.0, -1.5, 2.0, 4.0, 5.5, 5.5, 5.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Ска",
|
|
||||||
name_en: "Ska",
|
|
||||||
gains: [-1.0, -2.0, -2.0, -0.5, 2.0, 2.5, 4.0, 4.5, 5.5, 4.5],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Мягкое звучание",
|
|
||||||
name_en: "Soft",
|
|
||||||
gains: [2.0, 0.5, -0.5, -1.0, -0.5, 2.0, 4.0, 4.5, 5.5, 6.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Софт-рок",
|
|
||||||
name_en: "Soft rock",
|
|
||||||
gains: [2.0, 2.0, 1.0, -0.5, -2.0, -2.5, -1.5, -0.5, 1.0, 4.0],
|
|
||||||
},
|
|
||||||
EqPreset {
|
|
||||||
name_ru: "Техно",
|
|
||||||
name_en: "Techno",
|
|
||||||
gains: [4.0, 2.5, -0.5, -2.5, -2.0, -0.5, 4.0, 4.5, 4.5, 4.0],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn active_eq_preset_name(bands: &[f32; 10], ru: bool) -> &'static str {
|
|
||||||
for preset in EQ_PRESETS {
|
|
||||||
if bands
|
|
||||||
.iter()
|
|
||||||
.zip(preset.gains.iter())
|
|
||||||
.all(|(a, b)| (a - b).abs() < 0.15)
|
|
||||||
{
|
|
||||||
return preset.name(ru);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ru {
|
|
||||||
"Своя настройка"
|
|
||||||
} else {
|
|
||||||
"Custom settings"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
struct Biquad {
|
struct Biquad {
|
||||||
b0: f32,
|
b0: f32,
|
||||||
|
|
@ -163,17 +51,13 @@ impl Biquad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_identity(&mut self) {
|
|
||||||
self.b0 = 1.0;
|
|
||||||
self.b1 = 0.0;
|
|
||||||
self.b2 = 0.0;
|
|
||||||
self.a1 = 0.0;
|
|
||||||
self.a2 = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_peaking(&mut self, sample_rate: f32, freq: f32, q: f32, gain_db: f32) {
|
fn set_peaking(&mut self, sample_rate: f32, freq: f32, q: f32, gain_db: f32) {
|
||||||
if gain_db.abs() < 0.05 || freq >= sample_rate * 0.48 {
|
if gain_db.abs() < 0.05 || freq >= sample_rate * 0.48 {
|
||||||
self.set_identity();
|
self.b0 = 1.0;
|
||||||
|
self.b1 = 0.0;
|
||||||
|
self.b2 = 0.0;
|
||||||
|
self.a1 = 0.0;
|
||||||
|
self.a2 = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let a = 10.0f32.powf(gain_db / 40.0);
|
let a = 10.0f32.powf(gain_db / 40.0);
|
||||||
|
|
@ -195,58 +79,6 @@ impl Biquad {
|
||||||
self.a2 = a2 / a0;
|
self.a2 = a2 / a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_lowshelf(&mut self, sample_rate: f32, freq: f32, gain_db: f32) {
|
|
||||||
if gain_db.abs() < 0.05 || freq >= sample_rate * 0.48 {
|
|
||||||
self.set_identity();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let a = 10.0f32.powf(gain_db / 40.0);
|
|
||||||
let w0 = 2.0 * PI * freq / sample_rate;
|
|
||||||
let cos_w0 = w0.cos();
|
|
||||||
let sin_w0 = w0.sin();
|
|
||||||
let alpha = sin_w0 / 2.0 * ((a + 1.0 / a) * (1.0 / 0.707 - 1.0) + 2.0).max(0.1).sqrt();
|
|
||||||
let two_sqrt_a_alpha = 2.0 * a.sqrt() * alpha;
|
|
||||||
|
|
||||||
let b0 = a * ((a + 1.0) - (a - 1.0) * cos_w0 + two_sqrt_a_alpha);
|
|
||||||
let b1 = 2.0 * a * ((a - 1.0) - (a + 1.0) * cos_w0);
|
|
||||||
let b2 = a * ((a + 1.0) - (a - 1.0) * cos_w0 - two_sqrt_a_alpha);
|
|
||||||
let a0 = (a + 1.0) + (a - 1.0) * cos_w0 + two_sqrt_a_alpha;
|
|
||||||
let a1 = -2.0 * ((a - 1.0) + (a + 1.0) * cos_w0);
|
|
||||||
let a2 = (a + 1.0) + (a - 1.0) * cos_w0 - two_sqrt_a_alpha;
|
|
||||||
|
|
||||||
self.b0 = b0 / a0;
|
|
||||||
self.b1 = b1 / a0;
|
|
||||||
self.b2 = b2 / a0;
|
|
||||||
self.a1 = a1 / a0;
|
|
||||||
self.a2 = a2 / a0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_highshelf(&mut self, sample_rate: f32, freq: f32, gain_db: f32) {
|
|
||||||
if gain_db.abs() < 0.05 || freq >= sample_rate * 0.48 {
|
|
||||||
self.set_identity();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let a = 10.0f32.powf(gain_db / 40.0);
|
|
||||||
let w0 = 2.0 * PI * freq / sample_rate;
|
|
||||||
let cos_w0 = w0.cos();
|
|
||||||
let sin_w0 = w0.sin();
|
|
||||||
let alpha = sin_w0 / 2.0 * ((a + 1.0 / a) * (1.0 / 0.707 - 1.0) + 2.0).max(0.1).sqrt();
|
|
||||||
let two_sqrt_a_alpha = 2.0 * a.sqrt() * alpha;
|
|
||||||
|
|
||||||
let b0 = a * ((a + 1.0) + (a - 1.0) * cos_w0 + two_sqrt_a_alpha);
|
|
||||||
let b1 = -2.0 * a * ((a - 1.0) + (a + 1.0) * cos_w0);
|
|
||||||
let b2 = a * ((a + 1.0) + (a - 1.0) * cos_w0 - two_sqrt_a_alpha);
|
|
||||||
let a0 = (a + 1.0) - (a - 1.0) * cos_w0 + two_sqrt_a_alpha;
|
|
||||||
let a1 = 2.0 * ((a - 1.0) - (a + 1.0) * cos_w0);
|
|
||||||
let a2 = (a + 1.0) - (a - 1.0) * cos_w0 - two_sqrt_a_alpha;
|
|
||||||
|
|
||||||
self.b0 = b0 / a0;
|
|
||||||
self.b1 = b1 / a0;
|
|
||||||
self.b2 = b2 / a0;
|
|
||||||
self.a1 = a1 / a0;
|
|
||||||
self.a2 = a2 / a0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn process_stereo(&mut self, l: f32, r: f32) -> (f32, f32) {
|
fn process_stereo(&mut self, l: f32, r: f32) -> (f32, f32) {
|
||||||
let out_l = self.b0 * l + self.z1_l;
|
let out_l = self.b0 * l + self.z1_l;
|
||||||
|
|
@ -264,7 +96,6 @@ impl Biquad {
|
||||||
pub struct Equalizer10Band {
|
pub struct Equalizer10Band {
|
||||||
bands: [Biquad; 10],
|
bands: [Biquad; 10],
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
preamp: f32,
|
|
||||||
sample_rate: f32,
|
sample_rate: f32,
|
||||||
gains_db: [f32; 10],
|
gains_db: [f32; 10],
|
||||||
}
|
}
|
||||||
|
|
@ -274,25 +105,17 @@ impl Equalizer10Band {
|
||||||
Self {
|
Self {
|
||||||
bands: [Biquad::identity(); 10],
|
bands: [Biquad::identity(); 10],
|
||||||
enabled: false,
|
enabled: false,
|
||||||
preamp: 1.0,
|
|
||||||
sample_rate,
|
sample_rate,
|
||||||
gains_db: [0.0; 10],
|
gains_db: [0.0; 10],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, enabled: bool, preamp: f32, gains_db: [f32; 10]) {
|
pub fn update(&mut self, enabled: bool, gains_db: [f32; 10]) {
|
||||||
self.enabled = enabled;
|
self.enabled = enabled;
|
||||||
self.preamp = preamp.clamp(0.5, 1.5);
|
|
||||||
if self.gains_db != gains_db {
|
if self.gains_db != gains_db {
|
||||||
self.gains_db = gains_db;
|
self.gains_db = gains_db;
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
if i == 0 {
|
self.bands[i].set_peaking(self.sample_rate, EQ_FREQS[i], 1.41, gains_db[i]);
|
||||||
self.bands[i].set_lowshelf(self.sample_rate, EQ_FREQS[i], gains_db[i]);
|
|
||||||
} else if i == 9 {
|
|
||||||
self.bands[i].set_highshelf(self.sample_rate, EQ_FREQS[i], gains_db[i]);
|
|
||||||
} else {
|
|
||||||
self.bands[i].set_peaking(self.sample_rate, EQ_FREQS[i], 1.0, gains_db[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,8 +125,6 @@ impl Equalizer10Band {
|
||||||
if !self.enabled {
|
if !self.enabled {
|
||||||
return (l, r);
|
return (l, r);
|
||||||
}
|
}
|
||||||
l *= self.preamp;
|
|
||||||
r *= self.preamp;
|
|
||||||
for band in &mut self.bands {
|
for band in &mut self.bands {
|
||||||
(l, r) = band.process_stereo(l, r);
|
(l, r) = band.process_stereo(l, r);
|
||||||
}
|
}
|
||||||
|
|
@ -357,31 +178,3 @@ impl AudioEnergyAnalyzer {
|
||||||
(self.bass_smooth * 5.2).clamp(0.0, 1.0)
|
(self.bass_smooth * 5.2).clamp(0.0, 1.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_official_18_eq_presets_and_biquad_stability() {
|
|
||||||
assert_eq!(EQ_PRESETS.len(), 18);
|
|
||||||
assert_eq!(EQ_FREQS[0], 60.0);
|
|
||||||
assert_eq!(EQ_FREQS[9], 16000.0);
|
|
||||||
assert_eq!(active_eq_preset_name(&EQ_PRESETS[0].gains, true), "По умолчанию");
|
|
||||||
assert_eq!(active_eq_preset_name(&EQ_PRESETS[13].gains, false), "Rock");
|
|
||||||
assert_eq!(active_eq_preset_name(&[1.2; 10], true), "Своя настройка");
|
|
||||||
assert_eq!(active_eq_preset_name(&[1.2; 10], false), "Custom settings");
|
|
||||||
|
|
||||||
let mut eq = Equalizer10Band::new(48_000.0);
|
|
||||||
eq.update(true, 1.25, EQ_PRESETS[5].gains);
|
|
||||||
for i in 0..1024 {
|
|
||||||
let s = (i as f32 * 0.1).sin() * 0.5;
|
|
||||||
let (l, r) = eq.process(s, -s);
|
|
||||||
assert!(l.is_finite() && r.is_finite());
|
|
||||||
}
|
|
||||||
let mut eq_pre = Equalizer10Band::new(48_000.0);
|
|
||||||
eq_pre.update(true, 0.5, [0.0; 10]);
|
|
||||||
let (pl, pr) = eq_pre.process(0.4, -0.4);
|
|
||||||
assert!((pl - 0.2).abs() < 1e-4 && (pr + 0.2).abs() < 1e-4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
531
src/audio/mod.rs
|
|
@ -16,7 +16,7 @@ use symphonia::core::meta::MetadataOptions;
|
||||||
use symphonia::core::probe::Hint;
|
use symphonia::core::probe::Hint;
|
||||||
use symphonia::core::units::Time;
|
use symphonia::core::units::Time;
|
||||||
|
|
||||||
use crate::api::models::{ResolvedStream, TrackFade};
|
use crate::api::models::ResolvedStream;
|
||||||
use crate::api::signing::decrypt_encraw_at_offset;
|
use crate::api::signing::decrypt_encraw_at_offset;
|
||||||
use dsp::{AudioEnergyAnalyzer, Equalizer10Band};
|
use dsp::{AudioEnergyAnalyzer, Equalizer10Band};
|
||||||
|
|
||||||
|
|
@ -31,21 +31,8 @@ pub enum AudioCommand {
|
||||||
duration_ms: u64,
|
duration_ms: u64,
|
||||||
r128_i: Option<f32>,
|
r128_i: Option<f32>,
|
||||||
r128_tp: Option<f32>,
|
r128_tp: Option<f32>,
|
||||||
fade: Option<TrackFade>,
|
|
||||||
seek_seq: u64,
|
seek_seq: u64,
|
||||||
},
|
},
|
||||||
PreloadNext {
|
|
||||||
track_id: String,
|
|
||||||
stream: ResolvedStream,
|
|
||||||
duration_ms: u64,
|
|
||||||
r128_i: Option<f32>,
|
|
||||||
r128_tp: Option<f32>,
|
|
||||||
fade: Option<TrackFade>,
|
|
||||||
preload_gen: u64,
|
|
||||||
},
|
|
||||||
ClearPreload {
|
|
||||||
preload_gen: u64,
|
|
||||||
},
|
|
||||||
Play,
|
Play,
|
||||||
Pause,
|
Pause,
|
||||||
Stop {
|
Stop {
|
||||||
|
|
@ -66,17 +53,14 @@ pub struct SharedAudioState {
|
||||||
pub muted: AtomicBool,
|
pub muted: AtomicBool,
|
||||||
pub normalize_loudness: AtomicBool,
|
pub normalize_loudness: AtomicBool,
|
||||||
pub track_gain_bits: AtomicU32,
|
pub track_gain_bits: AtomicU32,
|
||||||
pub crossfade_enabled: AtomicBool,
|
|
||||||
pub crossfade_secs_bits: AtomicU32,
|
pub crossfade_secs_bits: AtomicU32,
|
||||||
pub energy_bits: AtomicU32,
|
pub energy_bits: AtomicU32,
|
||||||
pub bass_bits: AtomicU32,
|
pub bass_bits: AtomicU32,
|
||||||
pub eq_enabled: AtomicBool,
|
pub eq_enabled: AtomicBool,
|
||||||
pub eq_preamp_bits: AtomicU32,
|
|
||||||
pub eq_bands: Mutex<[f32; 10]>,
|
pub eq_bands: Mutex<[f32; 10]>,
|
||||||
pub active_codec: Mutex<String>,
|
pub active_codec: Mutex<String>,
|
||||||
pub output_device_name: Mutex<String>,
|
pub output_device_name: Mutex<String>,
|
||||||
pub last_error: Mutex<Option<String>>,
|
pub last_error: Mutex<Option<String>>,
|
||||||
pub crossfaded_track_id: Mutex<Option<String>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedAudioState {
|
impl SharedAudioState {
|
||||||
|
|
@ -84,10 +68,8 @@ impl SharedAudioState {
|
||||||
volume: f32,
|
volume: f32,
|
||||||
muted: bool,
|
muted: bool,
|
||||||
eq_enabled: bool,
|
eq_enabled: bool,
|
||||||
eq_preamp: f32,
|
|
||||||
eq_bands: [f32; 10],
|
eq_bands: [f32; 10],
|
||||||
normalize_loudness: bool,
|
normalize_loudness: bool,
|
||||||
crossfade_enabled: bool,
|
|
||||||
crossfade_secs: f32,
|
crossfade_secs: f32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -102,17 +84,14 @@ impl SharedAudioState {
|
||||||
muted: AtomicBool::new(muted),
|
muted: AtomicBool::new(muted),
|
||||||
normalize_loudness: AtomicBool::new(normalize_loudness),
|
normalize_loudness: AtomicBool::new(normalize_loudness),
|
||||||
track_gain_bits: AtomicU32::new(1.0f32.to_bits()),
|
track_gain_bits: AtomicU32::new(1.0f32.to_bits()),
|
||||||
crossfade_enabled: AtomicBool::new(crossfade_enabled),
|
|
||||||
crossfade_secs_bits: AtomicU32::new(crossfade_secs.clamp(0.0, 12.0).to_bits()),
|
crossfade_secs_bits: AtomicU32::new(crossfade_secs.clamp(0.0, 12.0).to_bits()),
|
||||||
energy_bits: AtomicU32::new(0.0f32.to_bits()),
|
energy_bits: AtomicU32::new(0.0f32.to_bits()),
|
||||||
bass_bits: AtomicU32::new(0.0f32.to_bits()),
|
bass_bits: AtomicU32::new(0.0f32.to_bits()),
|
||||||
eq_enabled: AtomicBool::new(eq_enabled),
|
eq_enabled: AtomicBool::new(eq_enabled),
|
||||||
eq_preamp_bits: AtomicU32::new(eq_preamp.clamp(0.5, 1.5).to_bits()),
|
|
||||||
eq_bands: Mutex::new(eq_bands),
|
eq_bands: Mutex::new(eq_bands),
|
||||||
active_codec: Mutex::new("FLAC / WASAPI".into()),
|
active_codec: Mutex::new("FLAC / WASAPI".into()),
|
||||||
output_device_name: Mutex::new("Системное устройство (WASAPI)".into()),
|
output_device_name: Mutex::new("Системное устройство (WASAPI)".into()),
|
||||||
last_error: Mutex::new(None),
|
last_error: Mutex::new(None),
|
||||||
crossfaded_track_id: Mutex::new(None),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +144,6 @@ pub fn compute_r128_gain(
|
||||||
pub struct AudioEngine {
|
pub struct AudioEngine {
|
||||||
tx_cmd: Sender<AudioCommand>,
|
tx_cmd: Sender<AudioCommand>,
|
||||||
pub state: Arc<SharedAudioState>,
|
pub state: Arc<SharedAudioState>,
|
||||||
preload_gen: AtomicU64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AudioEngine {
|
impl AudioEngine {
|
||||||
|
|
@ -173,20 +151,16 @@ impl AudioEngine {
|
||||||
volume: f32,
|
volume: f32,
|
||||||
muted: bool,
|
muted: bool,
|
||||||
eq_enabled: bool,
|
eq_enabled: bool,
|
||||||
eq_preamp: f32,
|
|
||||||
eq_bands: [f32; 10],
|
eq_bands: [f32; 10],
|
||||||
normalize_loudness: bool,
|
normalize_loudness: bool,
|
||||||
crossfade_enabled: bool,
|
|
||||||
crossfade_secs: f32,
|
crossfade_secs: f32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let state = Arc::new(SharedAudioState::new(
|
let state = Arc::new(SharedAudioState::new(
|
||||||
volume,
|
volume,
|
||||||
muted,
|
muted,
|
||||||
eq_enabled,
|
eq_enabled,
|
||||||
eq_preamp,
|
|
||||||
eq_bands,
|
eq_bands,
|
||||||
normalize_loudness,
|
normalize_loudness,
|
||||||
crossfade_enabled,
|
|
||||||
crossfade_secs,
|
crossfade_secs,
|
||||||
));
|
));
|
||||||
let (tx_cmd, rx_cmd) = unbounded();
|
let (tx_cmd, rx_cmd) = unbounded();
|
||||||
|
|
@ -197,30 +171,16 @@ impl AudioEngine {
|
||||||
.spawn(move || run_audio_worker(rx_cmd, state_bg))
|
.spawn(move || run_audio_worker(rx_cmd, state_bg))
|
||||||
.expect("Failed to spawn audio thread");
|
.expect("Failed to spawn audio thread");
|
||||||
|
|
||||||
Self {
|
Self { tx_cmd, state }
|
||||||
tx_cmd,
|
|
||||||
state,
|
|
||||||
preload_gen: AtomicU64::new(0),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Silent, thread-free audio engine for deterministic headless visual tests.
|
/// Silent, thread-free audio engine for deterministic headless visual tests.
|
||||||
pub fn new_headless(
|
pub fn new_headless(volume: f32, muted: bool, eq_enabled: bool, eq_bands: [f32; 10]) -> Self {
|
||||||
volume: f32,
|
|
||||||
muted: bool,
|
|
||||||
eq_enabled: bool,
|
|
||||||
eq_preamp: f32,
|
|
||||||
eq_bands: [f32; 10],
|
|
||||||
) -> Self {
|
|
||||||
let state = Arc::new(SharedAudioState::new(
|
let state = Arc::new(SharedAudioState::new(
|
||||||
volume, muted, eq_enabled, eq_preamp, eq_bands, true, false, 0.0,
|
volume, muted, eq_enabled, eq_bands, true, 0.0,
|
||||||
));
|
));
|
||||||
let (tx_cmd, _rx_cmd) = unbounded();
|
let (tx_cmd, _rx_cmd) = unbounded();
|
||||||
Self {
|
Self { tx_cmd, state }
|
||||||
tx_cmd,
|
|
||||||
state,
|
|
||||||
preload_gen: AtomicU64::new(0),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_stream(
|
pub fn load_stream(
|
||||||
|
|
@ -230,10 +190,7 @@ impl AudioEngine {
|
||||||
duration_ms: u64,
|
duration_ms: u64,
|
||||||
r128_i: Option<f32>,
|
r128_i: Option<f32>,
|
||||||
r128_tp: Option<f32>,
|
r128_tp: Option<f32>,
|
||||||
fade: Option<TrackFade>,
|
|
||||||
) {
|
) {
|
||||||
self.preload_gen.fetch_add(1, Ordering::SeqCst);
|
|
||||||
*self.state.crossfaded_track_id.lock() = None;
|
|
||||||
let seek_seq = {
|
let seek_seq = {
|
||||||
let _guard = self.state.position_lock.lock();
|
let _guard = self.state.position_lock.lock();
|
||||||
let seq = self.state.seek_seq.fetch_add(1, Ordering::SeqCst) + 1;
|
let seq = self.state.seek_seq.fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
|
|
@ -261,39 +218,10 @@ impl AudioEngine {
|
||||||
duration_ms,
|
duration_ms,
|
||||||
r128_i,
|
r128_i,
|
||||||
r128_tp,
|
r128_tp,
|
||||||
fade,
|
|
||||||
seek_seq,
|
seek_seq,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preload_next(
|
|
||||||
&self,
|
|
||||||
track_id: String,
|
|
||||||
stream: ResolvedStream,
|
|
||||||
duration_ms: u64,
|
|
||||||
r128_i: Option<f32>,
|
|
||||||
r128_tp: Option<f32>,
|
|
||||||
fade: Option<TrackFade>,
|
|
||||||
) {
|
|
||||||
let gen = self.preload_gen.fetch_add(1, Ordering::SeqCst) + 1;
|
|
||||||
let _ = self.tx_cmd.send(AudioCommand::PreloadNext {
|
|
||||||
track_id,
|
|
||||||
stream,
|
|
||||||
duration_ms,
|
|
||||||
r128_i,
|
|
||||||
r128_tp,
|
|
||||||
fade,
|
|
||||||
preload_gen: gen,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clear_preload(&self) {
|
|
||||||
let gen = self.preload_gen.fetch_add(1, Ordering::SeqCst) + 1;
|
|
||||||
let _ = self
|
|
||||||
.tx_cmd
|
|
||||||
.send(AudioCommand::ClearPreload { preload_gen: gen });
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn play(&self) {
|
pub fn play(&self) {
|
||||||
self.state.is_playing.store(true, Ordering::SeqCst);
|
self.state.is_playing.store(true, Ordering::SeqCst);
|
||||||
let _ = self.tx_cmd.send(AudioCommand::Play);
|
let _ = self.tx_cmd.send(AudioCommand::Play);
|
||||||
|
|
@ -315,8 +243,6 @@ impl AudioEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop(&self) {
|
pub fn stop(&self) {
|
||||||
self.preload_gen.fetch_add(1, Ordering::SeqCst);
|
|
||||||
*self.state.crossfaded_track_id.lock() = None;
|
|
||||||
let seek_seq = {
|
let seek_seq = {
|
||||||
let _guard = self.state.position_lock.lock();
|
let _guard = self.state.position_lock.lock();
|
||||||
let seq = self.state.seek_seq.fetch_add(1, Ordering::SeqCst) + 1;
|
let seq = self.state.seek_seq.fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
|
|
@ -359,31 +285,20 @@ impl AudioEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_crossfade_enabled(&self, enabled: bool) {
|
|
||||||
self.state.crossfade_enabled.store(enabled, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_crossfade_secs(&self, secs: f32) {
|
pub fn set_crossfade_secs(&self, secs: f32) {
|
||||||
self.state
|
self.state
|
||||||
.crossfade_secs_bits
|
.crossfade_secs_bits
|
||||||
.store(secs.clamp(0.0, 12.0).to_bits(), Ordering::Relaxed);
|
.store(secs.clamp(0.0, 12.0).to_bits(), Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_eq(&self, enabled: bool, preamp: f32, bands: [f32; 10]) {
|
pub fn set_eq(&self, enabled: bool, bands: [f32; 10]) {
|
||||||
self.state.eq_enabled.store(enabled, Ordering::Relaxed);
|
self.state.eq_enabled.store(enabled, Ordering::Relaxed);
|
||||||
self.state
|
|
||||||
.eq_preamp_bits
|
|
||||||
.store(preamp.clamp(0.5, 1.5).to_bits(), Ordering::Relaxed);
|
|
||||||
*self.state.eq_bands.lock() = bands;
|
*self.state.eq_bands.lock() = bands;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_track_finished(&self) -> bool {
|
pub fn take_track_finished(&self) -> bool {
|
||||||
self.state.track_finished.swap(false, Ordering::SeqCst)
|
self.state.track_finished.swap(false, Ordering::SeqCst)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_crossfaded_track_id(&self) -> Option<String> {
|
|
||||||
self.state.crossfaded_track_id.lock().take()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -522,20 +437,6 @@ struct ActiveStreamDecoder {
|
||||||
min_report_frames: u64,
|
min_report_frames: u64,
|
||||||
total_frames: u64,
|
total_frames: u64,
|
||||||
eof: bool,
|
eof: bool,
|
||||||
meta_track_id: String,
|
|
||||||
duration_ms: u64,
|
|
||||||
codec_label: String,
|
|
||||||
r128_i: Option<f32>,
|
|
||||||
r128_tp: Option<f32>,
|
|
||||||
gain_applied: bool,
|
|
||||||
fade: Option<TrackFade>,
|
|
||||||
fade_in_window: Option<(u64, u64)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OutgoingCrossfade {
|
|
||||||
dec: ActiveStreamDecoder,
|
|
||||||
start_frame: u64,
|
|
||||||
stop_frame: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveStreamDecoder {
|
impl ActiveStreamDecoder {
|
||||||
|
|
@ -833,115 +734,9 @@ fn open_streaming_decoder(
|
||||||
min_report_frames: 0,
|
min_report_frames: 0,
|
||||||
total_frames,
|
total_frames,
|
||||||
eof: false,
|
eof: false,
|
||||||
meta_track_id: String::new(),
|
|
||||||
duration_ms: fallback_duration_ms,
|
|
||||||
codec_label: format!("{} {} kbps", stream.codec_label, stream.bitrate_kbps),
|
|
||||||
r128_i: None,
|
|
||||||
r128_tp: None,
|
|
||||||
gain_applied: stream.gain_applied,
|
|
||||||
fade: None,
|
|
||||||
fade_in_window: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn deck_gain(dec: &ActiveStreamDecoder, normalize: bool) -> f32 {
|
|
||||||
compute_r128_gain(normalize, dec.gain_applied, dec.r128_i, dec.r128_tp)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn fade_out_gain(t: f32) -> f32 {
|
|
||||||
(t.clamp(0.0, 1.0) * std::f32::consts::FRAC_PI_2).cos()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn fade_in_gain(t: f32) -> f32 {
|
|
||||||
(t.clamp(0.0, 1.0) * std::f32::consts::FRAC_PI_2).sin()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn compute_crossfade_out_window(
|
|
||||||
fade: Option<TrackFade>,
|
|
||||||
total_frames: u64,
|
|
||||||
device_rate: u32,
|
|
||||||
crossfade_enabled: bool,
|
|
||||||
crossfade_secs: f32,
|
|
||||||
) -> Option<(u64, u64)> {
|
|
||||||
let rate = device_rate.max(1) as u64;
|
|
||||||
if !crossfade_enabled || total_frames < rate * 4 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if crossfade_secs > 0.1 {
|
|
||||||
let cf = ((crossfade_secs.clamp(0.5, 12.0) * rate as f32) as u64).min(total_frames / 3);
|
|
||||||
return Some((total_frames.saturating_sub(cf), total_frames));
|
|
||||||
}
|
|
||||||
if let Some(f) = fade.filter(|f| f.is_valid()) {
|
|
||||||
let min_start = total_frames / 2;
|
|
||||||
let out_start = ((f.out_start * rate as f32) as u64).clamp(min_start, total_frames);
|
|
||||||
let mut out_stop = ((f.out_stop * rate as f32) as u64).clamp(out_start, total_frames);
|
|
||||||
let min_dur = rate / 2;
|
|
||||||
let max_dur = rate * 12;
|
|
||||||
if out_stop.saturating_sub(out_start) < min_dur {
|
|
||||||
out_stop = (out_start + min_dur).min(total_frames);
|
|
||||||
}
|
|
||||||
if out_stop.saturating_sub(out_start) > max_dur {
|
|
||||||
out_stop = (out_start + max_dur).min(total_frames);
|
|
||||||
}
|
|
||||||
if out_stop > out_start + 100 {
|
|
||||||
return Some((out_start, out_stop));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let cf = ((3.5 * rate as f32) as u64).min(total_frames / 3);
|
|
||||||
Some((total_frames.saturating_sub(cf), total_frames))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn compute_crossfade_in_window(
|
|
||||||
fade: Option<TrackFade>,
|
|
||||||
total_frames: u64,
|
|
||||||
device_rate: u32,
|
|
||||||
crossfade_enabled: bool,
|
|
||||||
crossfade_secs: f32,
|
|
||||||
) -> Option<(u64, u64)> {
|
|
||||||
let rate = device_rate.max(1) as u64;
|
|
||||||
if !crossfade_enabled || total_frames < rate * 4 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if crossfade_secs > 0.1 {
|
|
||||||
let cf = ((crossfade_secs.clamp(0.5, 12.0) * rate as f32) as u64).min(total_frames / 3);
|
|
||||||
return Some((0, cf));
|
|
||||||
}
|
|
||||||
if let Some(f) = fade.filter(|f| f.is_valid()) {
|
|
||||||
let in_start = ((f.in_start * rate as f32) as u64).min(total_frames / 3);
|
|
||||||
let mut in_stop = ((f.in_stop * rate as f32) as u64).clamp(in_start, total_frames / 2);
|
|
||||||
let min_dur = rate / 2;
|
|
||||||
let max_dur = rate * 12;
|
|
||||||
if in_stop.saturating_sub(in_start) < min_dur {
|
|
||||||
in_stop = (in_start + rate * 3).min(total_frames / 2);
|
|
||||||
}
|
|
||||||
if in_stop.saturating_sub(in_start) > max_dur {
|
|
||||||
in_stop = (in_start + max_dur).min(total_frames / 2);
|
|
||||||
}
|
|
||||||
if in_stop > in_start + 100 {
|
|
||||||
return Some((in_start, in_stop));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let cf = ((3.5 * rate as f32) as u64).min(total_frames / 3);
|
|
||||||
Some((0, cf))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_stereo_frame(dec: &mut ActiveStreamDecoder) -> Option<(f32, f32)> {
|
|
||||||
if dec.pending_idx + 1 >= dec.pending.len() && !dec.decode_next_packet() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
if dec.pending_idx + 1 >= dec.pending.len() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let l = dec.pending[dec.pending_idx];
|
|
||||||
let r = dec.pending[dec.pending_idx + 1];
|
|
||||||
dec.pending_idx += 2;
|
|
||||||
dec.played_frames += 1;
|
|
||||||
Some((l, r))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Atomically publish decoder playback position ONLY if no newer `seek_ms` / `load_stream` / `stop`
|
/// Atomically publish decoder playback position ONLY if no newer `seek_ms` / `load_stream` / `stop`
|
||||||
/// has occurred since `applied_seek_seq`. Prevents stale decoder frames from teleporting the seek bar
|
/// has occurred since `applied_seek_seq`. Prevents stale decoder frames from teleporting the seek bar
|
||||||
/// back to the pre-seek position!
|
/// back to the pre-seek position!
|
||||||
|
|
@ -1036,13 +831,12 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let gain = vol;
|
let track_gain = state_cb.track_gain();
|
||||||
|
let gain = vol * track_gain;
|
||||||
|
|
||||||
let eq_on = state_cb.eq_enabled.load(Ordering::Relaxed);
|
let eq_on = state_cb.eq_enabled.load(Ordering::Relaxed);
|
||||||
let preamp = f32::from_bits(state_cb.eq_preamp_bits.load(Ordering::Relaxed))
|
|
||||||
.clamp(0.5, 1.5);
|
|
||||||
if let Some(bands) = state_cb.eq_bands.try_lock() {
|
if let Some(bands) = state_cb.eq_bands.try_lock() {
|
||||||
eq.update(eq_on, preamp, *bands);
|
eq.update(eq_on, *bands);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !playing {
|
if !playing {
|
||||||
|
|
@ -1104,25 +898,10 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
let mut active: Option<ActiveStreamDecoder> = None;
|
let mut active: Option<ActiveStreamDecoder> = None;
|
||||||
let mut outgoing: Option<OutgoingCrossfade> = None;
|
|
||||||
let mut preloaded: Option<ActiveStreamDecoder> = None;
|
|
||||||
let mut latest_preload_gen: u64 = 0;
|
|
||||||
let (tx_preloaded, rx_preloaded) =
|
|
||||||
crossbeam_channel::unbounded::<(u64, ActiveStreamDecoder)>();
|
|
||||||
let mut applied_seek_seq: u64 = 0;
|
let mut applied_seek_seq: u64 = 0;
|
||||||
let mut flush_wait_iters: u8 = 0;
|
let mut flush_wait_iters: u8 = 0;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
while let Ok((gen, dec)) = rx_preloaded.try_recv() {
|
|
||||||
if gen == latest_preload_gen {
|
|
||||||
if let Some(old) = preloaded.replace(dec) {
|
|
||||||
old.abort();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dec.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut raw_cmds = Vec::new();
|
let mut raw_cmds = Vec::new();
|
||||||
while let Ok(cmd) = rx_cmd.try_recv() {
|
while let Ok(cmd) = rx_cmd.try_recv() {
|
||||||
raw_cmds.push(cmd);
|
raw_cmds.push(cmd);
|
||||||
|
|
@ -1132,24 +911,15 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
for cmd in non_seeks {
|
for cmd in non_seeks {
|
||||||
match cmd {
|
match cmd {
|
||||||
AudioCommand::LoadStream {
|
AudioCommand::LoadStream {
|
||||||
track_id,
|
|
||||||
stream,
|
stream,
|
||||||
duration_ms,
|
duration_ms,
|
||||||
r128_i,
|
r128_i,
|
||||||
r128_tp,
|
r128_tp,
|
||||||
fade,
|
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(old) = active.take() {
|
if let Some(old) = active.take() {
|
||||||
old.abort();
|
old.abort();
|
||||||
}
|
}
|
||||||
if let Some(old_out) = outgoing.take() {
|
|
||||||
old_out.dec.abort();
|
|
||||||
}
|
|
||||||
if let Some(old_pre) = preloaded.take() {
|
|
||||||
old_pre.abort();
|
|
||||||
}
|
|
||||||
latest_preload_gen = latest_preload_gen.wrapping_add(1);
|
|
||||||
flush_rb.store(true, Ordering::Release);
|
flush_rb.store(true, Ordering::Release);
|
||||||
flush_wait_iters = 0;
|
flush_wait_iters = 0;
|
||||||
state.is_buffering.store(true, Ordering::SeqCst);
|
state.is_buffering.store(true, Ordering::SeqCst);
|
||||||
|
|
@ -1165,18 +935,13 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
if let Some(ref rt) = rt {
|
if let Some(ref rt) = rt {
|
||||||
match open_streaming_decoder(rt.handle(), &stream, device_rate, duration_ms)
|
match open_streaming_decoder(rt.handle(), &stream, device_rate, duration_ms)
|
||||||
{
|
{
|
||||||
Ok(mut dec) => {
|
Ok(dec) => {
|
||||||
if dec.total_frames > device_rate as u64 {
|
if dec.total_frames > device_rate as u64 {
|
||||||
let ms = (dec.total_frames * 1000) / device_rate as u64;
|
let ms = (dec.total_frames * 1000) / device_rate as u64;
|
||||||
state.duration_ms.store(ms, Ordering::SeqCst);
|
state.duration_ms.store(ms, Ordering::SeqCst);
|
||||||
} else {
|
} else {
|
||||||
state.duration_ms.store(duration_ms, Ordering::SeqCst);
|
state.duration_ms.store(duration_ms, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
dec.meta_track_id = track_id;
|
|
||||||
dec.duration_ms = duration_ms;
|
|
||||||
dec.r128_i = r128_i;
|
|
||||||
dec.r128_tp = r128_tp;
|
|
||||||
dec.fade = fade;
|
|
||||||
active = Some(dec);
|
active = Some(dec);
|
||||||
state.is_playing.store(true, Ordering::SeqCst);
|
state.is_playing.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
@ -1190,42 +955,6 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
}
|
}
|
||||||
state.is_buffering.store(false, Ordering::SeqCst);
|
state.is_buffering.store(false, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
AudioCommand::PreloadNext {
|
|
||||||
track_id,
|
|
||||||
stream,
|
|
||||||
duration_ms,
|
|
||||||
r128_i,
|
|
||||||
r128_tp,
|
|
||||||
fade,
|
|
||||||
preload_gen,
|
|
||||||
} => {
|
|
||||||
latest_preload_gen = preload_gen;
|
|
||||||
if let Some(old_pre) = preloaded.take() {
|
|
||||||
old_pre.abort();
|
|
||||||
}
|
|
||||||
if let Some(ref rt) = rt {
|
|
||||||
let handle = rt.handle().clone();
|
|
||||||
let tx_p = tx_preloaded.clone();
|
|
||||||
rt.spawn_blocking(move || {
|
|
||||||
if let Ok(mut dec) =
|
|
||||||
open_streaming_decoder(&handle, &stream, device_rate, duration_ms)
|
|
||||||
{
|
|
||||||
dec.meta_track_id = track_id;
|
|
||||||
dec.duration_ms = duration_ms;
|
|
||||||
dec.r128_i = r128_i;
|
|
||||||
dec.r128_tp = r128_tp;
|
|
||||||
dec.fade = fade;
|
|
||||||
let _ = tx_p.send((preload_gen, dec));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AudioCommand::ClearPreload { preload_gen } => {
|
|
||||||
latest_preload_gen = preload_gen;
|
|
||||||
if let Some(old_pre) = preloaded.take() {
|
|
||||||
old_pre.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AudioCommand::Play => {
|
AudioCommand::Play => {
|
||||||
state.is_playing.store(true, Ordering::SeqCst);
|
state.is_playing.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
|
@ -1237,13 +966,6 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
if let Some(old) = active.take() {
|
if let Some(old) = active.take() {
|
||||||
old.abort();
|
old.abort();
|
||||||
}
|
}
|
||||||
if let Some(old_out) = outgoing.take() {
|
|
||||||
old_out.dec.abort();
|
|
||||||
}
|
|
||||||
if let Some(old_pre) = preloaded.take() {
|
|
||||||
old_pre.abort();
|
|
||||||
}
|
|
||||||
latest_preload_gen = latest_preload_gen.wrapping_add(1);
|
|
||||||
flush_rb.store(true, Ordering::Release);
|
flush_rb.store(true, Ordering::Release);
|
||||||
flush_wait_iters = 0;
|
flush_wait_iters = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1254,11 +976,7 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
if let Some((ms, seq)) = pending_seek {
|
if let Some((ms, seq)) = pending_seek {
|
||||||
flush_rb.store(true, Ordering::Release);
|
flush_rb.store(true, Ordering::Release);
|
||||||
flush_wait_iters = 0;
|
flush_wait_iters = 0;
|
||||||
if let Some(old_out) = outgoing.take() {
|
|
||||||
old_out.dec.abort();
|
|
||||||
}
|
|
||||||
if let Some(ref mut dec) = active {
|
if let Some(ref mut dec) = active {
|
||||||
dec.fade_in_window = None;
|
|
||||||
if dec.seek_ms(ms) {
|
if dec.seek_ms(ms) {
|
||||||
dec.played_frames = (ms * device_rate as u64) / 1000;
|
dec.played_frames = (ms * device_rate as u64) / 1000;
|
||||||
dec.min_report_frames = dec.played_frames;
|
dec.min_report_frames = dec.played_frames;
|
||||||
|
|
@ -1285,150 +1003,38 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut pushed_any = false;
|
let mut pushed_any = false;
|
||||||
let cf_enabled = state.crossfade_enabled.load(Ordering::Relaxed);
|
if let Some(ref mut dec) = active {
|
||||||
let cf_secs = state.crossfade_secs();
|
let cf_frames = (state.crossfade_secs() * device_rate as f32) as u64;
|
||||||
let normalize = state.normalize_loudness.load(Ordering::Relaxed);
|
|
||||||
|
|
||||||
if active.is_some() {
|
|
||||||
while prod.vacant_len() >= 2048 {
|
while prod.vacant_len() >= 2048 {
|
||||||
|
// Bail immediately if a newer seek/load/stop arrived so we don't decode stale audio.
|
||||||
if applied_seek_seq != state.seek_seq.load(Ordering::Acquire) {
|
if applied_seek_seq != state.seek_seq.load(Ordering::Acquire) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if dec.pending_idx >= dec.pending.len() && !dec.decode_next_packet() {
|
||||||
// Trigger overlapping crossfade if preloaded next deck is ready and we reached out_start
|
|
||||||
let should_crossfade = {
|
|
||||||
let dec = active.as_ref().unwrap();
|
|
||||||
preloaded.is_some()
|
|
||||||
&& outgoing.is_none()
|
|
||||||
&& compute_crossfade_out_window(
|
|
||||||
dec.fade,
|
|
||||||
dec.total_frames,
|
|
||||||
device_rate,
|
|
||||||
cf_enabled,
|
|
||||||
cf_secs,
|
|
||||||
)
|
|
||||||
.map_or(false, |(out_start, _)| dec.played_frames >= out_start)
|
|
||||||
};
|
|
||||||
|
|
||||||
if should_crossfade {
|
|
||||||
let old_dec = active.take().unwrap();
|
|
||||||
let (out_start, out_stop) = compute_crossfade_out_window(
|
|
||||||
old_dec.fade,
|
|
||||||
old_dec.total_frames,
|
|
||||||
device_rate,
|
|
||||||
cf_enabled,
|
|
||||||
cf_secs,
|
|
||||||
)
|
|
||||||
.unwrap_or((old_dec.played_frames, old_dec.total_frames));
|
|
||||||
|
|
||||||
let mut next_dec = preloaded.take().unwrap();
|
|
||||||
if let Some((in_start, in_stop)) = compute_crossfade_in_window(
|
|
||||||
next_dec.fade,
|
|
||||||
next_dec.total_frames,
|
|
||||||
device_rate,
|
|
||||||
cf_enabled,
|
|
||||||
cf_secs,
|
|
||||||
) {
|
|
||||||
if in_start > device_rate as u64 / 20 {
|
|
||||||
let seek_ms = (in_start * 1000) / device_rate as u64;
|
|
||||||
if next_dec.seek_ms(seek_ms) {
|
|
||||||
next_dec.played_frames = in_start;
|
|
||||||
next_dec.min_report_frames = in_start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next_dec.fade_in_window = Some((in_start, in_stop));
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_tid = next_dec.meta_track_id.clone();
|
|
||||||
let new_dur = if next_dec.total_frames > device_rate as u64 {
|
|
||||||
(next_dec.total_frames * 1000) / device_rate as u64
|
|
||||||
} else {
|
|
||||||
next_dec.duration_ms
|
|
||||||
};
|
|
||||||
state.duration_ms.store(new_dur, Ordering::SeqCst);
|
|
||||||
*state.active_codec.lock() = next_dec.codec_label.clone();
|
|
||||||
let new_pos_ms = (next_dec.played_frames * 1000) / device_rate as u64;
|
|
||||||
publish_decoder_position_ms(&state, applied_seek_seq, new_pos_ms);
|
|
||||||
*state.crossfaded_track_id.lock() = Some(new_tid);
|
|
||||||
|
|
||||||
outgoing = Some(OutgoingCrossfade {
|
|
||||||
dec: old_dec,
|
|
||||||
start_frame: out_start,
|
|
||||||
stop_frame: out_stop.max(out_start + 1),
|
|
||||||
});
|
|
||||||
active = Some(next_dec);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode up to 1024 stereo frames from active + optional outgoing crossfade deck
|
|
||||||
let mut frames_mixed = 0usize;
|
|
||||||
while frames_mixed < 1024 {
|
|
||||||
let dec = active.as_mut().unwrap();
|
|
||||||
let Some((al, ar)) = next_stereo_frame(dec) else {
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
let mut in_gain = deck_gain(dec, normalize);
|
|
||||||
if let Some((in_start, in_stop)) = dec.fade_in_window {
|
|
||||||
let span = in_stop.saturating_sub(in_start).max(1) as f32;
|
|
||||||
let prog = (dec.played_frames.saturating_sub(in_start) as f32) / span;
|
|
||||||
in_gain *= fade_in_gain(prog);
|
|
||||||
if dec.played_frames >= in_stop {
|
|
||||||
dec.fade_in_window = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut mix_l = al * in_gain;
|
|
||||||
let mut mix_r = ar * in_gain;
|
|
||||||
|
|
||||||
if let Some(ref mut out) = outgoing {
|
|
||||||
if let Some((ol, or)) = next_stereo_frame(&mut out.dec) {
|
|
||||||
let span = out.stop_frame.saturating_sub(out.start_frame).max(1) as f32;
|
|
||||||
let prog = (out.dec.played_frames.saturating_sub(out.start_frame) as f32)
|
|
||||||
/ span;
|
|
||||||
let og = deck_gain(&out.dec, normalize) * fade_out_gain(prog);
|
|
||||||
mix_l = (mix_l + ol * og).clamp(-1.0, 1.0);
|
|
||||||
mix_r = (mix_r + or * og).clamp(-1.0, 1.0);
|
|
||||||
if out.dec.played_frames >= out.stop_frame {
|
|
||||||
if let Some(done) = outgoing.take() {
|
|
||||||
done.dec.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if let Some(done) = outgoing.take() {
|
|
||||||
done.dec.abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = prod.try_push(mix_l);
|
|
||||||
let _ = prod.try_push(mix_r);
|
|
||||||
frames_mixed += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if frames_mixed == 0 {
|
|
||||||
// Gapless handoff if active reached EOF and next track is preloaded!
|
|
||||||
let dec_eof = active.as_ref().map_or(false, |d| d.eof && d.pending_idx >= d.pending.len());
|
|
||||||
if dec_eof {
|
|
||||||
if let Some(mut next_dec) = preloaded.take() {
|
|
||||||
if let Some(old_done) = active.take() {
|
|
||||||
old_done.abort();
|
|
||||||
}
|
|
||||||
let new_tid = next_dec.meta_track_id.clone();
|
|
||||||
let new_dur = if next_dec.total_frames > device_rate as u64 {
|
|
||||||
(next_dec.total_frames * 1000) / device_rate as u64
|
|
||||||
} else {
|
|
||||||
next_dec.duration_ms
|
|
||||||
};
|
|
||||||
next_dec.fade_in_window = None;
|
|
||||||
state.duration_ms.store(new_dur, Ordering::SeqCst);
|
|
||||||
*state.active_codec.lock() = next_dec.codec_label.clone();
|
|
||||||
publish_decoder_position_ms(&state, applied_seek_seq, 0);
|
|
||||||
*state.crossfaded_track_id.lock() = Some(new_tid);
|
|
||||||
active = Some(next_dec);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
let avail = (dec.pending.len() - dec.pending_idx).min(2048) & !1;
|
||||||
let dec = active.as_ref().unwrap();
|
if avail == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for pair in dec.pending[dec.pending_idx..dec.pending_idx + avail].chunks_exact(2) {
|
||||||
|
// Smooth crossfade envelope (fade-in at start, fade-out near end when enabled)
|
||||||
|
let mut env = 1.0_f32;
|
||||||
|
if cf_frames > 0 {
|
||||||
|
if dec.played_frames < cf_frames {
|
||||||
|
env = (dec.played_frames as f32 / cf_frames as f32).clamp(0.0, 1.0);
|
||||||
|
} else if dec.total_frames > cf_frames
|
||||||
|
&& dec.played_frames + cf_frames > dec.total_frames
|
||||||
|
{
|
||||||
|
let rem = dec.total_frames.saturating_sub(dec.played_frames);
|
||||||
|
env = (rem as f32 / cf_frames as f32).clamp(0.0, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = prod.try_push(pair[0] * env);
|
||||||
|
let _ = prod.try_push(pair[1] * env);
|
||||||
|
dec.played_frames += 1;
|
||||||
|
}
|
||||||
|
dec.pending_idx += avail;
|
||||||
let buffered_frames = if _cpal_stream.is_some() {
|
let buffered_frames = if _cpal_stream.is_some() {
|
||||||
(prod.occupied_len() / 2) as u64
|
(prod.occupied_len() / 2) as u64
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1443,29 +1049,24 @@ fn run_audio_worker(rx_cmd: Receiver<AudioCommand>, state: Arc<SharedAudioState>
|
||||||
pushed_any = true;
|
pushed_any = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep audible playback position smoothly updating while CPAL drains the ring buffer.
|
||||||
if !pushed_any && _cpal_stream.is_some() && !flush_rb.load(Ordering::Acquire) {
|
if !pushed_any && _cpal_stream.is_some() && !flush_rb.load(Ordering::Acquire) {
|
||||||
if let Some(ref dec) = active {
|
let buffered_frames = (prod.occupied_len() / 2) as u64;
|
||||||
let buffered_frames = (prod.occupied_len() / 2) as u64;
|
let audible_frames = dec
|
||||||
let audible_frames = dec
|
.played_frames
|
||||||
.played_frames
|
.saturating_sub(buffered_frames)
|
||||||
.saturating_sub(buffered_frames)
|
.max(dec.min_report_frames);
|
||||||
.max(dec.min_report_frames);
|
let pos_ms = (audible_frames * 1000) / device_rate as u64;
|
||||||
let pos_ms = (audible_frames * 1000) / device_rate as u64;
|
publish_decoder_position_ms(&state, applied_seek_seq, pos_ms);
|
||||||
publish_decoder_position_ms(&state, applied_seek_seq, pos_ms);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if active.as_ref().map_or(false, |dec| {
|
if dec.eof
|
||||||
dec.eof
|
&& dec.pending_idx >= dec.pending.len()
|
||||||
&& dec.pending_idx >= dec.pending.len()
|
&& applied_seek_seq == state.seek_seq.load(Ordering::Acquire)
|
||||||
&& applied_seek_seq == state.seek_seq.load(Ordering::Acquire)
|
{
|
||||||
}) {
|
|
||||||
state.is_playing.store(false, Ordering::SeqCst);
|
state.is_playing.store(false, Ordering::SeqCst);
|
||||||
state.track_finished.store(true, Ordering::SeqCst);
|
state.track_finished.store(true, Ordering::SeqCst);
|
||||||
active = None;
|
active = None;
|
||||||
if let Some(old_out) = outgoing.take() {
|
|
||||||
old_out.dec.abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1481,7 +1082,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn seek_seq_prevents_stale_decoder_position_overwrite() {
|
fn seek_seq_prevents_stale_decoder_position_overwrite() {
|
||||||
let engine = AudioEngine::new_headless(0.8, false, false, 1.0, [0.0; 10]);
|
let engine = AudioEngine::new_headless(0.8, false, false, [0.0; 10]);
|
||||||
|
|
||||||
// Initial playback at seq 0 publishes normally.
|
// Initial playback at seq 0 publishes normally.
|
||||||
assert!(publish_decoder_position_ms(&engine.state, 0, 30_000));
|
assert!(publish_decoder_position_ms(&engine.state, 0, 30_000));
|
||||||
|
|
@ -1540,7 +1141,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn stop_bumps_seek_seq_preventing_old_decoder_overwrite() {
|
fn stop_bumps_seek_seq_preventing_old_decoder_overwrite() {
|
||||||
let engine = AudioEngine::new_headless(0.8, false, false, 1.0, [0.0; 10]);
|
let engine = AudioEngine::new_headless(0.8, false, false, [0.0; 10]);
|
||||||
assert!(publish_decoder_position_ms(&engine.state, 0, 45_000));
|
assert!(publish_decoder_position_ms(&engine.state, 0, 45_000));
|
||||||
engine.stop();
|
engine.stop();
|
||||||
assert_eq!(engine.state.position_ms.load(Ordering::Acquire), 0);
|
assert_eq!(engine.state.position_ms.load(Ordering::Acquire), 0);
|
||||||
|
|
@ -1548,36 +1149,4 @@ mod tests {
|
||||||
assert!(!publish_decoder_position_ms(&engine.state, 0, 45_200));
|
assert!(!publish_decoder_position_ms(&engine.state, 0, 45_200));
|
||||||
assert_eq!(engine.state.position_ms.load(Ordering::Acquire), 0);
|
assert_eq!(engine.state.position_ms.load(Ordering::Acquire), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_crossfade_windows_and_equal_power_curves() {
|
|
||||||
let rate = 48_000u32;
|
|
||||||
let total = 200 * rate as u64;
|
|
||||||
let smart = TrackFade {
|
|
||||||
in_start: 0.5,
|
|
||||||
in_stop: 4.5,
|
|
||||||
out_start: 194.0,
|
|
||||||
out_stop: 199.0,
|
|
||||||
};
|
|
||||||
assert_eq!(
|
|
||||||
compute_crossfade_out_window(Some(smart), total, rate, false, 0.0),
|
|
||||||
None
|
|
||||||
);
|
|
||||||
let out_auto = compute_crossfade_out_window(Some(smart), total, rate, true, 0.0).unwrap();
|
|
||||||
assert_eq!(out_auto, (194 * rate as u64, 199 * rate as u64));
|
|
||||||
let in_auto = compute_crossfade_in_window(Some(smart), total, rate, true, 0.0).unwrap();
|
|
||||||
assert_eq!(in_auto, (rate as u64 / 2, (4.5 * rate as f32) as u64));
|
|
||||||
|
|
||||||
// Fallback when track has no `fade` metadata
|
|
||||||
let out_fb = compute_crossfade_out_window(None, total, rate, true, 0.0).unwrap();
|
|
||||||
assert_eq!(out_fb.1 - out_fb.0, (3.5 * rate as f32) as u64);
|
|
||||||
|
|
||||||
// Manual duration override
|
|
||||||
let out_man = compute_crossfade_out_window(Some(smart), total, rate, true, 6.0).unwrap();
|
|
||||||
assert_eq!(out_man.1 - out_man.0, 6 * rate as u64);
|
|
||||||
|
|
||||||
// Equal-power crossfade preserves constant power at midpoint (0.5^2 + 0.5^2 -> 1.0)
|
|
||||||
let p_mid = fade_out_gain(0.5).powi(2) + fade_in_gain(0.5).powi(2);
|
|
||||||
assert!((p_mid - 1.0).abs() < 1e-5);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
yandex_music_rs::native::run_auth_webview_subprocess();
|
|
||||||
}
|
|
||||||
|
|
@ -10,48 +10,6 @@ pub enum ThemeMode {
|
||||||
Light,
|
Light,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
|
||||||
pub enum PlayerThumbStyle {
|
|
||||||
#[default]
|
|
||||||
Standard,
|
|
||||||
Duck,
|
|
||||||
Car,
|
|
||||||
Claudik,
|
|
||||||
Antigravity,
|
|
||||||
Ferris,
|
|
||||||
Nyan,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PlayerThumbStyle {
|
|
||||||
pub const ALL: &'static [Self] = &[
|
|
||||||
Self::Standard,
|
|
||||||
Self::Duck,
|
|
||||||
Self::Car,
|
|
||||||
Self::Claudik,
|
|
||||||
Self::Antigravity,
|
|
||||||
Self::Ferris,
|
|
||||||
Self::Nyan,
|
|
||||||
];
|
|
||||||
|
|
||||||
pub const fn label(self, ru: bool) -> &'static str {
|
|
||||||
match (self, ru) {
|
|
||||||
(Self::Standard, true) => "Стандартный",
|
|
||||||
(Self::Standard, false) => "Default",
|
|
||||||
(Self::Duck, true) => "Уточка",
|
|
||||||
(Self::Duck, false) => "Duck",
|
|
||||||
(Self::Car, true) => "Машинка",
|
|
||||||
(Self::Car, false) => "Car",
|
|
||||||
(Self::Claudik, true) => "Клодик",
|
|
||||||
(Self::Claudik, false) => "Claudik",
|
|
||||||
(Self::Antigravity, _) => "Antigravity",
|
|
||||||
(Self::Ferris, true) => "Феррис",
|
|
||||||
(Self::Ferris, false) => "Ferris",
|
|
||||||
(Self::Nyan, true) => "Нян-кот",
|
|
||||||
(Self::Nyan, false) => "Nyan Cat",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ThemeMode {
|
impl ThemeMode {
|
||||||
/// Resolve `ThemeMode::System` to concrete dark/light boolean via Windows Registry `AppsUseLightTheme`
|
/// Resolve `ThemeMode::System` to concrete dark/light boolean via Windows Registry `AppsUseLightTheme`
|
||||||
/// (exact match to Chromium's `prefers-color-scheme: light` in Electron 5.129.0).
|
/// (exact match to Chromium's `prefers-color-scheme: light` in Electron 5.129.0).
|
||||||
|
|
@ -194,12 +152,8 @@ pub struct AppConfig {
|
||||||
pub muted: bool,
|
pub muted: bool,
|
||||||
pub sidebar_collapsed: bool,
|
pub sidebar_collapsed: bool,
|
||||||
pub eq_enabled: bool,
|
pub eq_enabled: bool,
|
||||||
#[serde(default = "default_eq_preamp")]
|
pub eq_bands_db: [f32; 10], // 32, 64, 125, 250, 500, 1k, 2k, 4k, 8k, 16k Hz
|
||||||
pub eq_preamp: f32,
|
|
||||||
pub eq_bands_db: [f32; 10], // 60, 170, 310, 600, 1k, 3k, 6k, 12k, 14k, 16k Hz
|
|
||||||
pub normalize_loudness: bool,
|
pub normalize_loudness: bool,
|
||||||
#[serde(default = "default_true")]
|
|
||||||
pub crossfade_enabled: bool,
|
|
||||||
pub crossfade_secs: f32,
|
pub crossfade_secs: f32,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub ai_content_reduction: bool,
|
pub ai_content_reduction: bool,
|
||||||
|
|
@ -207,8 +161,6 @@ pub struct AppConfig {
|
||||||
pub child_mode: bool,
|
pub child_mode: bool,
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
pub close_to_tray: bool,
|
pub close_to_tray: bool,
|
||||||
#[serde(default)]
|
|
||||||
pub player_thumb: PlayerThumbStyle,
|
|
||||||
pub max_cover_cache: usize,
|
pub max_cover_cache: usize,
|
||||||
pub show_perf_hud: bool,
|
pub show_perf_hud: bool,
|
||||||
pub search_history: Vec<String>,
|
pub search_history: Vec<String>,
|
||||||
|
|
@ -241,10 +193,6 @@ fn default_true() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_eq_preamp() -> f32 {
|
|
||||||
1.0
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AppConfig {
|
impl Default for AppConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -256,15 +204,12 @@ impl Default for AppConfig {
|
||||||
muted: false,
|
muted: false,
|
||||||
sidebar_collapsed: false,
|
sidebar_collapsed: false,
|
||||||
eq_enabled: false,
|
eq_enabled: false,
|
||||||
eq_preamp: 1.0,
|
|
||||||
eq_bands_db: [0.0; 10],
|
eq_bands_db: [0.0; 10],
|
||||||
normalize_loudness: true,
|
normalize_loudness: true,
|
||||||
crossfade_enabled: true,
|
|
||||||
crossfade_secs: 0.0,
|
crossfade_secs: 0.0,
|
||||||
ai_content_reduction: false,
|
ai_content_reduction: false,
|
||||||
child_mode: false,
|
child_mode: false,
|
||||||
close_to_tray: true,
|
close_to_tray: true,
|
||||||
player_thumb: PlayerThumbStyle::Standard,
|
|
||||||
max_cover_cache: 256,
|
max_cover_cache: 256,
|
||||||
show_perf_hud: false,
|
show_perf_hud: false,
|
||||||
search_history: Vec::new(),
|
search_history: Vec::new(),
|
||||||
|
|
|
||||||
|
|
@ -7,24 +7,15 @@ use std::sync::Arc;
|
||||||
use crate::engine::textures::TextureRegistry;
|
use crate::engine::textures::TextureRegistry;
|
||||||
use crate::engine::types::{Color, TextureId};
|
use crate::engine::types::{Color, TextureId};
|
||||||
|
|
||||||
/// Hard minimum LRU cover cache capacity.
|
/// Hard minimum LRU cover cache capacity so even dense pages (Artist/Collection + sidebar + player)
|
||||||
/// Leaner on Linux integrated-GPU (UMA) builds where GL textures live directly in system RAM!
|
/// can never thrash or flicker visible avatars/covers.
|
||||||
#[cfg(all(target_os = "linux", not(test)))]
|
|
||||||
pub const MIN_COVER_CACHE_CAPACITY: usize = 64;
|
|
||||||
#[cfg(not(all(target_os = "linux", not(test))))]
|
|
||||||
pub const MIN_COVER_CACHE_CAPACITY: usize = 128;
|
pub const MIN_COVER_CACHE_CAPACITY: usize = 128;
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", not(test)))]
|
|
||||||
const MAX_AUTO_GROW_CAPACITY: usize = 128;
|
|
||||||
#[cfg(not(all(target_os = "linux", not(test))))]
|
|
||||||
const MAX_AUTO_GROW_CAPACITY: usize = 1024;
|
const MAX_AUTO_GROW_CAPACITY: usize = 1024;
|
||||||
|
|
||||||
pub struct CoverEntry {
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +148,6 @@ 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,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -186,8 +175,6 @@ 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,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -221,8 +208,6 @@ 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,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -261,17 +246,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
@ -279,13 +253,7 @@ 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((
|
return Some((entry.texture_id, entry.dominant_color, entry.hue));
|
||||||
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,
|
||||||
|
|
@ -304,13 +272,7 @@ 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((
|
return Some((entry.texture_id, entry.dominant_color, entry.hue));
|
||||||
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;
|
||||||
|
|
@ -373,9 +335,7 @@ 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 {
|
||||||
// Preserve original aspect ratio so non-square concert posters / banners never stretch;
|
dyn_img = dyn_img.resize_exact(max_dim, max_dim, image::imageops::FilterType::Lanczos3);
|
||||||
// `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();
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ impl InputState {
|
||||||
self.pointer_pos = Some(next);
|
self.pointer_pos = Some(next);
|
||||||
if self.left_down {
|
if self.left_down {
|
||||||
if let Some(origin) = self.drag_origin {
|
if let Some(origin) = self.drag_origin {
|
||||||
if origin.distance(next) >= 5.0 {
|
if origin.distance(next) >= 3.0 {
|
||||||
self.is_dragging = true;
|
self.is_dragging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +407,7 @@ impl InputState {
|
||||||
let prev_time = self.time;
|
let prev_time = self.time;
|
||||||
self.time = time;
|
self.time = time;
|
||||||
self.dt = if prev_time > 0.0 && time > prev_time {
|
self.dt = if prev_time > 0.0 && time > prev_time {
|
||||||
((time - prev_time) as f32).clamp(0.001, 0.033)
|
((time - prev_time) as f32).clamp(0.001, 0.1)
|
||||||
} else {
|
} else {
|
||||||
1.0 / 60.0
|
1.0 / 60.0
|
||||||
};
|
};
|
||||||
|
|
@ -554,36 +554,6 @@ impl InputState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consume the current pointer press (`active_id = None`, `left_pressed = false`,
|
|
||||||
/// `right_pressed = false`) so releasing over an underlying widget cannot trigger a click/drag.
|
|
||||||
pub fn consume_pointer_press(&mut self) {
|
|
||||||
self.active_id = None;
|
|
||||||
self.left_pressed = false;
|
|
||||||
self.right_pressed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `clicked_outside`, but also consumes the dismissing press (`active_id = None`,
|
|
||||||
/// `left_pressed = false`, `right_pressed = false`) so releasing over an underlying
|
|
||||||
/// toggle trigger button (e.g. PlayerBar EQ button) can NEVER re-open the overlay.
|
|
||||||
pub fn consume_clicked_outside(&mut self, rect: Rect) -> bool {
|
|
||||||
if self.clicked_outside(rect) {
|
|
||||||
self.consume_pointer_press();
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Multi-rect variant of `consume_clicked_outside`.
|
|
||||||
pub fn consume_clicked_outside_any(&mut self, rects: &[Rect]) -> bool {
|
|
||||||
if self.clicked_outside_any(rects) {
|
|
||||||
self.consume_pointer_press();
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn key_pressed(&self, key: Key) -> bool {
|
pub fn key_pressed(&self, key: Key) -> bool {
|
||||||
self.key_events.iter().any(|e| e.key == key)
|
self.key_events.iter().any(|e| e.key == key)
|
||||||
}
|
}
|
||||||
|
|
@ -724,47 +694,3 @@ impl Animator {
|
||||||
self.values.clear();
|
self.values.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use winit::dpi::PhysicalPosition;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_consume_clicked_outside_prevents_trigger_reopen_on_release() {
|
|
||||||
let mut input = InputState::new();
|
|
||||||
let screen = Vec2::new(1280.0, 800.0);
|
|
||||||
let trigger_id = WidgetId::new("pb_r_eq");
|
|
||||||
let trigger_r = Rect::from_xywh(1000.0, 740.0, 36.0, 36.0);
|
|
||||||
let pop_r = Rect::from_xywh(800.0, 400.0, 430.0, 300.0);
|
|
||||||
|
|
||||||
// Frame 1: Mouse down on the underlying trigger button while popover is open.
|
|
||||||
input.begin_frame(screen, 1.0, 1.0);
|
|
||||||
input.handle_winit_event(&WindowEvent::CursorMoved {
|
|
||||||
device_id: unsafe { std::mem::zeroed() },
|
|
||||||
position: PhysicalPosition::new(1018.0, 758.0),
|
|
||||||
});
|
|
||||||
input.handle_winit_event(&WindowEvent::MouseInput {
|
|
||||||
device_id: unsafe { std::mem::zeroed() },
|
|
||||||
state: ElementState::Pressed,
|
|
||||||
button: MouseButton::Left,
|
|
||||||
});
|
|
||||||
|
|
||||||
let press_resp = input.interact(trigger_id, ZLayer::Base, trigger_r, None);
|
|
||||||
assert!(!press_resp.clicked);
|
|
||||||
assert!(input.consume_clicked_outside(pop_r));
|
|
||||||
assert!(input.active_id.is_none());
|
|
||||||
input.end_frame();
|
|
||||||
|
|
||||||
// Frame 2: Mouse up over the same trigger button — MUST NOT fire clicked!
|
|
||||||
input.begin_frame(screen, 1.0, 1.05);
|
|
||||||
input.handle_winit_event(&WindowEvent::MouseInput {
|
|
||||||
device_id: unsafe { std::mem::zeroed() },
|
|
||||||
state: ElementState::Released,
|
|
||||||
button: MouseButton::Left,
|
|
||||||
});
|
|
||||||
let rel_resp = input.interact(trigger_id, ZLayer::Base, trigger_r, None);
|
|
||||||
assert!(!rel_resp.clicked);
|
|
||||||
input.end_frame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,7 @@ impl UiContext {
|
||||||
if let Some((anchor, label)) = self.pending_tooltip.take() {
|
if let Some((anchor, label)) = self.pending_tooltip.take() {
|
||||||
let prev = self.set_layer(ZLayer::Titlebar);
|
let prev = self.set_layer(ZLayer::Titlebar);
|
||||||
let pad_x = 10.0;
|
let pad_x = 10.0;
|
||||||
let text_style = TextStyle::medium(12.0, pal.text_primary);
|
let text_sz = self.measure_text(&label, TextStyle::medium(12.0, Color::WHITE), None);
|
||||||
let text_sz = self.measure_text(&label, text_style, None);
|
|
||||||
let tip_w = text_sz.x + pad_x * 2.0;
|
let tip_w = text_sz.x + pad_x * 2.0;
|
||||||
let tip_h = 26.0;
|
let tip_h = 26.0;
|
||||||
let screen = self.input.screen_size;
|
let screen = self.input.screen_size;
|
||||||
|
|
@ -133,16 +132,15 @@ impl UiContext {
|
||||||
tx = tx.round();
|
tx = tx.round();
|
||||||
ty = ty.round();
|
ty = ty.round();
|
||||||
let tip_r = Rect::from_xywh(tx, ty, tip_w, tip_h);
|
let tip_r = Rect::from_xywh(tx, ty, tip_w, tip_h);
|
||||||
let tip_bg = if pal.is_dark {
|
|
||||||
Color::rgb(0x26, 0x26, 0x26)
|
|
||||||
} else {
|
|
||||||
Color::WHITE
|
|
||||||
};
|
|
||||||
self.dl()
|
self.dl()
|
||||||
.push_shadow(tip_r, 8.0, 10.0, 0.0, Vec2::new(0.0, 2.0), pal.shadow_menu);
|
.push_shadow(tip_r, 8.0, 10.0, 0.0, Vec2::new(0.0, 2.0), css_rgba(0, 0, 0, 110));
|
||||||
self.dl()
|
self.dl().push_rect(tip_r, 8.0, pal.bg_tooltip);
|
||||||
.push_rect_bordered(tip_r, 8.0, tip_bg, 1.0, pal.border_control);
|
self.draw_text_ellipsis(
|
||||||
self.draw_text_ellipsis(&label, text_style, tip_r, TextAlign::Center);
|
&label,
|
||||||
|
TextStyle::medium(12.0, Color::WHITE),
|
||||||
|
tip_r,
|
||||||
|
TextAlign::Center,
|
||||||
|
);
|
||||||
self.set_layer(prev);
|
self.set_layer(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,9 +152,7 @@ impl UiContext {
|
||||||
let texture_uploads = self.textures.drain_uploads();
|
let texture_uploads = self.textures.drain_uploads();
|
||||||
let immediate_repaint =
|
let immediate_repaint =
|
||||||
self.repaint_requested || self.animator.needs_repaint() || !texture_uploads.is_empty();
|
self.repaint_requested || self.animator.needs_repaint() || !texture_uploads.is_empty();
|
||||||
let repaint_after = if self.repaint_requested || !texture_uploads.is_empty() {
|
let repaint_after = if immediate_repaint {
|
||||||
Some(std::time::Duration::from_millis(1))
|
|
||||||
} else if self.animator.needs_repaint() {
|
|
||||||
Some(std::time::Duration::from_millis(16))
|
Some(std::time::Duration::from_millis(16))
|
||||||
} else {
|
} else {
|
||||||
self.repaint_after
|
self.repaint_after
|
||||||
|
|
@ -370,28 +366,6 @@ 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 input.modifiers.shift {
|
} else if !vertical || input.modifiers.shift {
|
||||||
-input.wheel_delta.y
|
-input.wheel_delta.y
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::engine::types::{
|
||||||
Color, DisplayList, Pos2, Rect, Vec2, GLYPH_ATLAS_TEXTURE_ID,
|
Color, DisplayList, Pos2, Rect, Vec2, GLYPH_ATLAS_TEXTURE_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ATLAS_SIZE: u32 = 1024;
|
const ATLAS_SIZE: u32 = 2048;
|
||||||
|
|
||||||
/// The 4 official Yandex Music 5.129.0 font roles loaded from `assets/fonts/`.
|
/// The 4 official Yandex Music 5.129.0 font roles loaded from `assets/fonts/`.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|
@ -332,25 +332,8 @@ impl TextEngine {
|
||||||
|
|
||||||
db.set_sans_serif_family(&ys_text_family);
|
db.set_sans_serif_family(&ys_text_family);
|
||||||
|
|
||||||
// On Linux, avoid indexing all 400+ system fonts (saves 20-40 MB RSS from Noto CJK/Emoji);
|
// Load system fallback fonts for rare symbols / emoji / CJK
|
||||||
// load only 1-2 lean symbol/fallback faces alongside our 4 embedded official Yandex fonts.
|
db.load_system_fonts();
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
for path in [
|
|
||||||
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
|
|
||||||
"/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf",
|
|
||||||
"/usr/share/fonts/truetype/noto/NotoSansSymbols2-Regular.ttf",
|
|
||||||
] {
|
|
||||||
if std::path::Path::new(path).is_file() {
|
|
||||||
let _ = db.load_font_file(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
{
|
|
||||||
// Load system fallback fonts for rare symbols / emoji / CJK
|
|
||||||
db.load_system_fonts();
|
|
||||||
}
|
|
||||||
|
|
||||||
let font_system = FontSystem::new_with_locale_and_db("ru-RU".to_string(), db);
|
let font_system = FontSystem::new_with_locale_and_db("ru-RU".to_string(), db);
|
||||||
|
|
||||||
|
|
@ -469,68 +452,6 @@ 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,32 +374,7 @@ pub fn draw_plus_badge(
|
||||||
(resp, rect)
|
(resp, rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute exact CSS `object-fit: cover` UV sub-rect so images never stretch when
|
/// Draw cover artwork with SDF rounded-rect / circular clip:
|
||||||
/// `(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.
|
||||||
|
|
@ -424,10 +399,9 @@ 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().max(rect.height()).ceil() as u32;
|
let px = rect.width().ceil() as u32;
|
||||||
if let Some((tex_id, dom, hue, tw, th)) = covers.get_or_fetch_with_size(u, px) {
|
if let Some((tex_id, dom, hue)) = covers.get_or_fetch(u, px) {
|
||||||
let uv = cover_fit_uv(tw, th, rect, 0.35);
|
ctx.dl().push_image(rect, tex_id, cr, Color::WHITE);
|
||||||
ctx.dl().push_image_uv(rect, tex_id, uv, cr, Color::WHITE);
|
|
||||||
return (dom, hue);
|
return (dom, hue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -454,10 +428,9 @@ pub fn draw_cover_art(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(u) = uri {
|
if let Some(u) = uri {
|
||||||
let px = rect.width().max(rect.height()).ceil() as u32;
|
let px = rect.width().ceil() as u32;
|
||||||
if let Some((tex_id, dom, hue, tw, th)) = covers.get_or_fetch_with_size(u, px) {
|
if let Some((tex_id, dom, hue)) = covers.get_or_fetch(u, px) {
|
||||||
let uv = cover_fit_uv(tw, th, rect, 0.35);
|
ctx.dl().push_image(rect, tex_id, cr, Color::WHITE);
|
||||||
ctx.dl().push_image_uv(rect, tex_id, uv, cr, Color::WHITE);
|
|
||||||
return (dom, hue);
|
return (dom, hue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -512,8 +485,6 @@ pub struct TrackRowOptions {
|
||||||
pub is_liked: bool,
|
pub is_liked: bool,
|
||||||
pub is_disliked: bool,
|
pub is_disliked: bool,
|
||||||
pub is_downloaded: bool,
|
pub is_downloaded: bool,
|
||||||
pub is_downloading: bool,
|
|
||||||
pub download_progress: f32,
|
|
||||||
pub menu_open: bool,
|
pub menu_open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -528,8 +499,6 @@ impl Default for TrackRowOptions {
|
||||||
is_liked: false,
|
is_liked: false,
|
||||||
is_disliked: false,
|
is_disliked: false,
|
||||||
is_downloaded: false,
|
is_downloaded: false,
|
||||||
is_downloading: false,
|
|
||||||
download_progress: 0.0,
|
|
||||||
menu_open: false,
|
menu_open: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -698,13 +667,8 @@ pub fn track_row(
|
||||||
pal.text_secondary
|
pal.text_secondary
|
||||||
};
|
};
|
||||||
|
|
||||||
// Title + optional version + explicit badge + downloaded/downloading badge
|
// Title + optional version + explicit badge + downloaded badge
|
||||||
let badge_w = if track.is_explicit { 22.0 } else { 0.0 }
|
let badge_w = if track.is_explicit { 22.0 } else { 0.0 } + if opts.is_downloaded { 20.0 } else { 0.0 };
|
||||||
+ if opts.is_downloaded || opts.is_downloading {
|
|
||||||
20.0
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
};
|
|
||||||
let title_rect = Rect::from_xywh(x, rect.top() + 9.5, (title_col_w - badge_w).max(40.0), 20.0);
|
let title_rect = Rect::from_xywh(x, rect.top() + 9.5, (title_col_w - badge_w).max(40.0), 20.0);
|
||||||
let version_text = track
|
let version_text = track
|
||||||
.version
|
.version
|
||||||
|
|
@ -738,17 +702,7 @@ pub fn track_row(
|
||||||
);
|
);
|
||||||
badge_x += 22.0;
|
badge_x += 22.0;
|
||||||
}
|
}
|
||||||
if opts.is_downloading {
|
if opts.is_downloaded {
|
||||||
draw_downloading_progress(
|
|
||||||
ctx,
|
|
||||||
pal,
|
|
||||||
Pos2::new(badge_x + 8.0, title_rect.center_y()),
|
|
||||||
16.0,
|
|
||||||
opts.download_progress,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
} else if opts.is_downloaded {
|
|
||||||
ctx.draw_icon(
|
ctx.draw_icon(
|
||||||
Icon::Downloaded,
|
Icon::Downloaded,
|
||||||
Rect::from_center_size(Pos2::new(badge_x + 8.0, title_rect.center_y()), Vec2::splat(16.0)),
|
Rect::from_center_size(Pos2::new(badge_x + 8.0, title_rect.center_y()), Vec2::splat(16.0)),
|
||||||
|
|
@ -1147,9 +1101,8 @@ 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, _, _, tw, th)) = covers.get_or_fetch_with_size(u, 200) {
|
if let Some((tex_id, _, _)) = covers.get_or_fetch(u, 200) {
|
||||||
let uv = cover_fit_uv(tw, th, card_r, 0.35);
|
ctx.dl().push_image(card_r, tex_id, 6.0, Color::WHITE);
|
||||||
ctx.dl().push_image_uv(card_r, tex_id, uv, 6.0, Color::WHITE);
|
|
||||||
drew_tex = true;
|
drew_tex = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1228,9 +1181,8 @@ 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, _, _, tw, th)) = covers.get_or_fetch_with_size(u, 400) {
|
if let Some((tex_id, _, _)) = covers.get_or_fetch(u, 400) {
|
||||||
let uv = cover_fit_uv(tw, th, img_r, 0.35);
|
ctx.dl().push_image(img_r, tex_id, 8.0, Color::WHITE);
|
||||||
ctx.dl().push_image_uv(img_r, tex_id, uv, 8.0, Color::WHITE);
|
|
||||||
has_photo = true;
|
has_photo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1818,76 +1770,3 @@ pub fn draw_playing_eq_bars(
|
||||||
ctx.request_repaint_after(std::time::Duration::from_millis(40));
|
ctx.request_repaint_after(std::time::Duration::from_millis(40));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Smooth circular progress ring matching official Yandex Music 5.129.0 `CircleProgress` (`68254`).
|
|
||||||
pub fn draw_circular_progress_ring(
|
|
||||||
ctx: &mut UiContext,
|
|
||||||
center: Pos2,
|
|
||||||
radius: f32,
|
|
||||||
stroke_w: f32,
|
|
||||||
progress: f32,
|
|
||||||
track_color: Color,
|
|
||||||
progress_color: Color,
|
|
||||||
) {
|
|
||||||
use std::f32::consts::{FRAC_PI_2, TAU};
|
|
||||||
|
|
||||||
ctx.dl()
|
|
||||||
.push_circle_stroke(center, radius, stroke_w, track_color);
|
|
||||||
|
|
||||||
let frac = progress.clamp(0.0, 1.0);
|
|
||||||
let (start_angle, sweep) = if frac < 0.03 {
|
|
||||||
if ctx.input.time > 0.001 {
|
|
||||||
ctx.request_repaint_after(std::time::Duration::from_millis(24));
|
|
||||||
}
|
|
||||||
((ctx.input.time as f32 * 3.2) - FRAC_PI_2, 0.24 * TAU)
|
|
||||||
} else {
|
|
||||||
(-FRAC_PI_2, frac * TAU)
|
|
||||||
};
|
|
||||||
|
|
||||||
let segments = ((sweep / TAU) * 32.0).ceil().max(4.0) as usize;
|
|
||||||
let step = sweep / segments as f32;
|
|
||||||
for i in 0..segments {
|
|
||||||
let a0 = start_angle + i as f32 * step;
|
|
||||||
let a1 = start_angle + (i + 1) as f32 * step;
|
|
||||||
let p0 = Pos2::new(center.x + radius * a0.cos(), center.y + radius * a0.sin());
|
|
||||||
let p1 = Pos2::new(center.x + radius * a1.cos(), center.y + radius * a1.sin());
|
|
||||||
ctx.dl().push_line(p0, p1, stroke_w, progress_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Official Yandex Music 5.129.0 `DownloadingProgress` (`79262` / `63298c27abf81dc6.css:210-218`):
|
|
||||||
/// yellow circular progress ring with optional centered `close` (`×`) cancel icon.
|
|
||||||
pub fn draw_downloading_progress(
|
|
||||||
ctx: &mut UiContext,
|
|
||||||
pal: &YmPalette,
|
|
||||||
center: Pos2,
|
|
||||||
size: f32,
|
|
||||||
progress: f32,
|
|
||||||
with_cancel_icon: bool,
|
|
||||||
hovered: bool,
|
|
||||||
) {
|
|
||||||
let stroke_w = if size >= 22.0 { 2.2 } else { 1.8 };
|
|
||||||
let radius = ((size - stroke_w) * 0.5).max(3.0);
|
|
||||||
draw_circular_progress_ring(
|
|
||||||
ctx,
|
|
||||||
center,
|
|
||||||
radius,
|
|
||||||
stroke_w,
|
|
||||||
progress,
|
|
||||||
pal.border_control,
|
|
||||||
pal.yellow,
|
|
||||||
);
|
|
||||||
if with_cancel_icon {
|
|
||||||
let icon_sz = (size * 0.42).clamp(8.0, 12.0);
|
|
||||||
let tint = if hovered {
|
|
||||||
pal.text_bright
|
|
||||||
} else {
|
|
||||||
pal.text_primary
|
|
||||||
};
|
|
||||||
ctx.draw_icon(
|
|
||||||
Icon::Close,
|
|
||||||
Rect::from_center_size(center, Vec2::splat(icon_sz)),
|
|
||||||
tint,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
41
src/icons.rs
|
|
@ -113,26 +113,15 @@ pub enum Icon {
|
||||||
PauseFilledXs,
|
PauseFilledXs,
|
||||||
LinkXxs,
|
LinkXxs,
|
||||||
YandexPlusEn,
|
YandexPlusEn,
|
||||||
// Dedicated Yandex ID Profile & Appearance icons (v2.79.0) + WordsCard thumbs
|
// Dedicated Yandex ID Profile & Appearance icons
|
||||||
ProfileAccountXxs,
|
ProfileAccountXxs,
|
||||||
ProfileSettingsXxs,
|
|
||||||
ProfileSupportXxs,
|
ProfileSupportXxs,
|
||||||
ProfileGlobeXxs,
|
ProfileGlobeXxs,
|
||||||
ProfileAppearanceXxs,
|
ProfileAppearanceXxs,
|
||||||
ProfileAddAccountXxs,
|
|
||||||
ProfileLogoutXxs,
|
ProfileLogoutXxs,
|
||||||
ProfilePlusXxs,
|
|
||||||
ThemeSystemXxs,
|
ThemeSystemXxs,
|
||||||
ThemeDarkXxs,
|
ThemeDarkXxs,
|
||||||
ThemeLightXxs,
|
ThemeLightXxs,
|
||||||
ThumbUpXxs,
|
|
||||||
ThumbDownXxs,
|
|
||||||
YandexIdLogoRuDark,
|
|
||||||
YandexIdLogoRuLight,
|
|
||||||
YandexIdLogoEnDark,
|
|
||||||
YandexIdLogoEnLight,
|
|
||||||
ThumbDuck,
|
|
||||||
ThumbCar,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Icon {
|
impl Icon {
|
||||||
|
|
@ -245,24 +234,13 @@ impl Icon {
|
||||||
Icon::LinkXxs => include_bytes!("../assets/icons/link_xxs.svg"),
|
Icon::LinkXxs => include_bytes!("../assets/icons/link_xxs.svg"),
|
||||||
Icon::YandexPlusEn => include_bytes!("../assets/icons/yandexPlusEn.svg"),
|
Icon::YandexPlusEn => include_bytes!("../assets/icons/yandexPlusEn.svg"),
|
||||||
Icon::ProfileAccountXxs => include_bytes!("../assets/icons/profile_account_xxs.svg"),
|
Icon::ProfileAccountXxs => include_bytes!("../assets/icons/profile_account_xxs.svg"),
|
||||||
Icon::ProfileSettingsXxs => include_bytes!("../assets/icons/profile_settings_xxs.svg"),
|
|
||||||
Icon::ProfileSupportXxs => include_bytes!("../assets/icons/profile_support_xxs.svg"),
|
Icon::ProfileSupportXxs => include_bytes!("../assets/icons/profile_support_xxs.svg"),
|
||||||
Icon::ProfileGlobeXxs => include_bytes!("../assets/icons/profile_globe_xxs.svg"),
|
Icon::ProfileGlobeXxs => include_bytes!("../assets/icons/profile_globe_xxs.svg"),
|
||||||
Icon::ProfileAppearanceXxs => include_bytes!("../assets/icons/profile_appearance_xxs.svg"),
|
Icon::ProfileAppearanceXxs => include_bytes!("../assets/icons/profile_appearance_xxs.svg"),
|
||||||
Icon::ProfileAddAccountXxs => include_bytes!("../assets/icons/profile_add_account_xxs.svg"),
|
|
||||||
Icon::ProfileLogoutXxs => include_bytes!("../assets/icons/profile_logout_xxs.svg"),
|
Icon::ProfileLogoutXxs => include_bytes!("../assets/icons/profile_logout_xxs.svg"),
|
||||||
Icon::ProfilePlusXxs => include_bytes!("../assets/icons/profile_plus_xxs.svg"),
|
|
||||||
Icon::ThemeSystemXxs => include_bytes!("../assets/icons/theme_system_xxs.svg"),
|
Icon::ThemeSystemXxs => include_bytes!("../assets/icons/theme_system_xxs.svg"),
|
||||||
Icon::ThemeDarkXxs => include_bytes!("../assets/icons/theme_dark_xxs.svg"),
|
Icon::ThemeDarkXxs => include_bytes!("../assets/icons/theme_dark_xxs.svg"),
|
||||||
Icon::ThemeLightXxs => include_bytes!("../assets/icons/theme_light_xxs.svg"),
|
Icon::ThemeLightXxs => include_bytes!("../assets/icons/theme_light_xxs.svg"),
|
||||||
Icon::ThumbUpXxs => include_bytes!("../assets/icons/thumb_up_xxs.svg"),
|
|
||||||
Icon::ThumbDownXxs => include_bytes!("../assets/icons/thumb_down_xxs.svg"),
|
|
||||||
Icon::YandexIdLogoRuDark => include_bytes!("../assets/icons/yandex_id_logo_ru_dark.svg"),
|
|
||||||
Icon::YandexIdLogoRuLight => include_bytes!("../assets/icons/yandex_id_logo_ru_light.svg"),
|
|
||||||
Icon::YandexIdLogoEnDark => include_bytes!("../assets/icons/yandex_id_logo_en_dark.svg"),
|
|
||||||
Icon::YandexIdLogoEnLight => include_bytes!("../assets/icons/yandex_id_logo_en_light.svg"),
|
|
||||||
Icon::ThumbDuck => include_bytes!("../assets/icons/thumb_duck.svg"),
|
|
||||||
Icon::ThumbCar => include_bytes!("../assets/icons/thumb_car.svg"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,12 +249,6 @@ impl Icon {
|
||||||
Icon::MusicLogoLeftEn => (276, 96),
|
Icon::MusicLogoLeftEn => (276, 96),
|
||||||
Icon::MusicLogoLeftRu => (256, 72),
|
Icon::MusicLogoLeftRu => (256, 72),
|
||||||
Icon::YandexPlusRu | Icon::YandexPlusEn => (160, 44),
|
Icon::YandexPlusRu | Icon::YandexPlusEn => (160, 44),
|
||||||
Icon::YandexIdLogoRuDark
|
|
||||||
| Icon::YandexIdLogoRuLight
|
|
||||||
| Icon::YandexIdLogoEnDark
|
|
||||||
| Icon::YandexIdLogoEnLight => (124, 60),
|
|
||||||
Icon::ThumbDuck => (96, 96),
|
|
||||||
Icon::ThumbCar => (220, 68),
|
|
||||||
Icon::MusicLogo | Icon::PlayFilled | Icon::PauseFilled | Icon::PlayLarge | Icon::PauseLarge => (72, 72),
|
Icon::MusicLogo | Icon::PlayFilled | Icon::PauseFilled | Icon::PlayLarge | Icon::PauseLarge => (72, 72),
|
||||||
_ => (48, 48),
|
_ => (48, 48),
|
||||||
}
|
}
|
||||||
|
|
@ -396,24 +368,13 @@ impl Icon {
|
||||||
Icon::LinkXxs,
|
Icon::LinkXxs,
|
||||||
Icon::YandexPlusEn,
|
Icon::YandexPlusEn,
|
||||||
Icon::ProfileAccountXxs,
|
Icon::ProfileAccountXxs,
|
||||||
Icon::ProfileSettingsXxs,
|
|
||||||
Icon::ProfileSupportXxs,
|
Icon::ProfileSupportXxs,
|
||||||
Icon::ProfileGlobeXxs,
|
Icon::ProfileGlobeXxs,
|
||||||
Icon::ProfileAppearanceXxs,
|
Icon::ProfileAppearanceXxs,
|
||||||
Icon::ProfileAddAccountXxs,
|
|
||||||
Icon::ProfileLogoutXxs,
|
Icon::ProfileLogoutXxs,
|
||||||
Icon::ProfilePlusXxs,
|
|
||||||
Icon::ThemeSystemXxs,
|
Icon::ThemeSystemXxs,
|
||||||
Icon::ThemeDarkXxs,
|
Icon::ThemeDarkXxs,
|
||||||
Icon::ThemeLightXxs,
|
Icon::ThemeLightXxs,
|
||||||
Icon::ThumbUpXxs,
|
|
||||||
Icon::ThumbDownXxs,
|
|
||||||
Icon::YandexIdLogoRuDark,
|
|
||||||
Icon::YandexIdLogoRuLight,
|
|
||||||
Icon::YandexIdLogoEnDark,
|
|
||||||
Icon::YandexIdLogoEnLight,
|
|
||||||
Icon::ThumbDuck,
|
|
||||||
Icon::ThumbCar,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
140
src/main.rs
|
|
@ -135,8 +135,7 @@ fn build_window_attrs(init_w: f64, init_h: f64) -> WindowAttributes {
|
||||||
.with_inner_size(LogicalSize::new(init_w, init_h))
|
.with_inner_size(LogicalSize::new(init_w, init_h))
|
||||||
.with_min_inner_size(LogicalSize::new(768.0, 650.0))
|
.with_min_inner_size(LogicalSize::new(768.0, 650.0))
|
||||||
.with_decorations(false) // Custom frameless 32px Yandex TitleBar!
|
.with_decorations(false) // Custom frameless 32px Yandex TitleBar!
|
||||||
.with_resizable(true)
|
.with_resizable(true);
|
||||||
.with_visible(false); // Stay hidden until DWM + first pure-black/splash frame is presented!
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
use winit::platform::wayland::WindowAttributesExtWayland;
|
use winit::platform::wayland::WindowAttributesExtWayland;
|
||||||
|
|
@ -169,32 +168,6 @@ fn init_opengl_backend(
|
||||||
Ok((window, RenderBackend::OpenGl(gl)))
|
Ok((window, RenderBackend::OpenGl(gl)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Probe hardware Vulkan in an isolated short-lived subprocess on Linux so Mesa's software
|
|
||||||
/// `libvulkan_lvp.so` + `libLLVM.so` (~80–100 MB) are NEVER mapped into the main OpenGL player
|
|
||||||
/// process on legacy GPUs without hardware Vulkan (e.g. Intel HD Graphics 3000).
|
|
||||||
fn has_hardware_vulkan_isolated() -> bool {
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
use std::process::{Command, Stdio};
|
|
||||||
if let Ok(exe) = std::env::current_exe() {
|
|
||||||
if let Ok(status) = Command::new(exe)
|
|
||||||
.arg("--probe-vulkan")
|
|
||||||
.stdin(Stdio::null())
|
|
||||||
.stdout(Stdio::null())
|
|
||||||
.stderr(Stdio::null())
|
|
||||||
.status()
|
|
||||||
{
|
|
||||||
return status.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
{
|
|
||||||
VulkanContext::has_hardware_vulkan()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AppRunner {
|
struct AppRunner {
|
||||||
runtime: tokio::runtime::Runtime,
|
runtime: tokio::runtime::Runtime,
|
||||||
// Drop GPU backend BEFORE the native winit Window so Vulkan/GL surfaces destroy cleanly!
|
// Drop GPU backend BEFORE the native winit Window so Vulkan/GL surfaces destroy cleanly!
|
||||||
|
|
@ -439,12 +412,7 @@ impl AppRunner {
|
||||||
let is_max = window.is_maximized();
|
let is_max = window.is_maximized();
|
||||||
let elapsed = shell.elapsed_secs();
|
let elapsed = shell.elapsed_secs();
|
||||||
|
|
||||||
let had_splash = shell.splash.is_some();
|
|
||||||
let (frame, win_cmd) = shell.render_frame(logical, sf, elapsed, is_max);
|
let (frame, win_cmd) = shell.render_frame(logical, sf, elapsed, is_max);
|
||||||
if had_splash && shell.splash.is_none() {
|
|
||||||
telemetry::PerfTelemetry::trim_working_set();
|
|
||||||
shell.app.perf.sample_memory();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync cursor icon
|
// Sync cursor icon
|
||||||
if frame.cursor != self.last_cursor {
|
if frame.cursor != self.last_cursor {
|
||||||
|
|
@ -592,7 +560,7 @@ impl ApplicationHandler for AppRunner {
|
||||||
RendererPreference::Vulkan => init_vulkan_backend(event_loop, init_w, init_h)
|
RendererPreference::Vulkan => init_vulkan_backend(event_loop, init_w, init_h)
|
||||||
.expect("Failed to initialize Vulkan renderer (--renderer=vulkan)"),
|
.expect("Failed to initialize Vulkan renderer (--renderer=vulkan)"),
|
||||||
RendererPreference::Auto => {
|
RendererPreference::Auto => {
|
||||||
if has_hardware_vulkan_isolated() {
|
if VulkanContext::has_hardware_vulkan() {
|
||||||
match init_vulkan_backend(event_loop, init_w, init_h) {
|
match init_vulkan_backend(event_loop, init_w, init_h) {
|
||||||
Ok(pair) => pair,
|
Ok(pair) => pair,
|
||||||
Err(vk_err) => {
|
Err(vk_err) => {
|
||||||
|
|
@ -660,17 +628,6 @@ impl ApplicationHandler for AppRunner {
|
||||||
self.window_focused = true;
|
self.window_focused = true;
|
||||||
self.window_occluded = false;
|
self.window_occluded = false;
|
||||||
self.last_frame_hash = None;
|
self.last_frame_hash = None;
|
||||||
|
|
||||||
// Present the first theme-matched + splash frame into the swapchain BEFORE making the
|
|
||||||
// window visible so there is zero white OS/DWM flash on startup!
|
|
||||||
// (On Linux/Wayland where an unmapped window may report 0x0, skip pre-render and reveal.)
|
|
||||||
let init_size = window.inner_size();
|
|
||||||
if init_size.width > 0 && init_size.height > 0 {
|
|
||||||
self.render(event_loop);
|
|
||||||
self.last_frame_hash = None;
|
|
||||||
}
|
|
||||||
window.set_visible(true);
|
|
||||||
window.focus_window();
|
|
||||||
window.request_redraw();
|
window.request_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -923,76 +880,6 @@ fn apply_win11_dwm_style(window: &Window, is_dark: bool) {
|
||||||
&round as *const _ as *const _,
|
&round as *const _ as *const _,
|
||||||
std::mem::size_of::<u32>() as u32,
|
std::mem::size_of::<u32>() as u32,
|
||||||
);
|
);
|
||||||
// DWMWA_CAPTION_COLOR (35): pure black in dark mode, pure white in light mode
|
|
||||||
const DWMWA_CAPTION_COLOR: u32 = 35;
|
|
||||||
let caption_color: u32 = if is_dark { 0x0000_0000 } else { 0x00FF_FFFF };
|
|
||||||
DwmSetWindowAttribute(
|
|
||||||
hwnd,
|
|
||||||
DWMWA_CAPTION_COLOR,
|
|
||||||
&caption_color as *const _ as *const _,
|
|
||||||
std::mem::size_of::<u32>() as u32,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Replace Win32 class background brush (BLACK_BRUSH=4 / WHITE_BRUSH=0) & prime
|
|
||||||
// the client backing surface so Win32 never flashes white before or during resize.
|
|
||||||
#[repr(C)]
|
|
||||||
struct WinRect {
|
|
||||||
left: i32,
|
|
||||||
top: i32,
|
|
||||||
right: i32,
|
|
||||||
bottom: i32,
|
|
||||||
}
|
|
||||||
#[link(name = "gdi32")]
|
|
||||||
extern "system" {
|
|
||||||
fn GetStockObject(i: i32) -> *mut std::ffi::c_void;
|
|
||||||
}
|
|
||||||
#[link(name = "user32")]
|
|
||||||
extern "system" {
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
|
||||||
fn SetClassLongPtrW(
|
|
||||||
hwnd: *mut std::ffi::c_void,
|
|
||||||
index: i32,
|
|
||||||
new_long: isize,
|
|
||||||
) -> isize;
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
|
||||||
fn SetClassLongW(
|
|
||||||
hwnd: *mut std::ffi::c_void,
|
|
||||||
index: i32,
|
|
||||||
new_long: i32,
|
|
||||||
) -> i32;
|
|
||||||
fn GetClientRect(hwnd: *mut std::ffi::c_void, rect: *mut WinRect) -> i32;
|
|
||||||
fn GetDC(hwnd: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
|
|
||||||
fn FillRect(
|
|
||||||
hdc: *mut std::ffi::c_void,
|
|
||||||
rect: *const WinRect,
|
|
||||||
hbr: *mut std::ffi::c_void,
|
|
||||||
) -> i32;
|
|
||||||
fn ReleaseDC(hwnd: *mut std::ffi::c_void, hdc: *mut std::ffi::c_void) -> i32;
|
|
||||||
}
|
|
||||||
const WHITE_BRUSH: i32 = 0;
|
|
||||||
const BLACK_BRUSH: i32 = 4;
|
|
||||||
const GCLP_HBRBACKGROUND: i32 = -10;
|
|
||||||
let brush = GetStockObject(if is_dark { BLACK_BRUSH } else { WHITE_BRUSH });
|
|
||||||
if !brush.is_null() {
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
|
||||||
SetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND, brush as isize);
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
|
||||||
SetClassLongW(hwnd, GCLP_HBRBACKGROUND, brush as i32);
|
|
||||||
|
|
||||||
let mut rc = WinRect {
|
|
||||||
left: 0,
|
|
||||||
top: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
};
|
|
||||||
if GetClientRect(hwnd, &mut rc) != 0 {
|
|
||||||
let hdc = GetDC(hwnd);
|
|
||||||
if !hdc.is_null() {
|
|
||||||
FillRect(hdc, &rc, brush);
|
|
||||||
ReleaseDC(hwnd, hdc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1058,30 +945,7 @@ fn acquire_single_instance_lock() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
|
||||||
fn tune_linux_glibc_allocator() {
|
|
||||||
extern "C" {
|
|
||||||
fn mallopt(param: std::ffi::c_int, value: std::ffi::c_int) -> std::ffi::c_int;
|
|
||||||
}
|
|
||||||
const M_TRIM_THRESHOLD: std::ffi::c_int = -1;
|
|
||||||
const M_MMAP_THRESHOLD: std::ffi::c_int = -3;
|
|
||||||
const M_ARENA_MAX: std::ffi::c_int = -8;
|
|
||||||
unsafe {
|
|
||||||
let _ = mallopt(M_ARENA_MAX, 2);
|
|
||||||
let _ = mallopt(M_TRIM_THRESHOLD, 128 * 1024);
|
|
||||||
let _ = mallopt(M_MMAP_THRESHOLD, 128 * 1024);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
|
||||||
tune_linux_glibc_allocator();
|
|
||||||
|
|
||||||
// Isolated Vulkan HW probe subprocess (keeps libvulkan_lvp / libLLVM out of main Linux RSS)
|
|
||||||
if std::env::args().any(|a| a == "--probe-vulkan") {
|
|
||||||
std::process::exit(if VulkanContext::has_hardware_vulkan() { 0 } else { 1 });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Isolated zero-resident-RAM WebView2 OAuth subprocess (exits immediately after login!)
|
// Isolated zero-resident-RAM WebView2 OAuth subprocess (exits immediately after login!)
|
||||||
if std::env::args().any(|a| a == "--auth-webview") {
|
if std::env::args().any(|a| a == "--auth-webview") {
|
||||||
run_auth_webview_subprocess();
|
run_auth_webview_subprocess();
|
||||||
|
|
|
||||||
|
|
@ -451,267 +451,26 @@ mod imp {
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::NativeEvent;
|
use super::NativeEvent;
|
||||||
use crate::api::models::Track;
|
use crate::api::models::Track;
|
||||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
use crate::api::signing::extract_oauth_token;
|
||||||
use ksni::blocking::{Handle, TrayMethods};
|
use crate::api::YANDEX_OAUTH_URL;
|
||||||
use std::io::{BufRead, BufReader};
|
use gtk::prelude::*;
|
||||||
|
use std::io::{BufRead, BufReader, Write};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::sync::Arc;
|
|
||||||
use winit::window::Window;
|
use winit::window::Window;
|
||||||
|
use wry::{WebViewBuilder, WebViewBuilderExtUnix};
|
||||||
|
|
||||||
const OAUTH_TOKEN_PREFIX: &str = "YM_OAUTH_TOKEN:";
|
const OAUTH_TOKEN_PREFIX: &str = "YM_OAUTH_TOKEN:";
|
||||||
|
|
||||||
struct LinuxTray {
|
pub struct NativeDesktop;
|
||||||
tx: Sender<NativeEvent>,
|
|
||||||
icons: Arc<Vec<ksni::Icon>>,
|
|
||||||
is_ru: bool,
|
|
||||||
window_visible: bool,
|
|
||||||
is_playing: bool,
|
|
||||||
track_summary: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ksni::Tray for LinuxTray {
|
|
||||||
fn id(&self) -> String {
|
|
||||||
"yandex-music-rs".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn category(&self) -> ksni::Category {
|
|
||||||
ksni::Category::ApplicationStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
fn title(&self) -> String {
|
|
||||||
if self.is_ru {
|
|
||||||
"Яндекс Музыка".into()
|
|
||||||
} else {
|
|
||||||
"Yandex Music".into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn icon_name(&self) -> String {
|
|
||||||
"yandex-music-rs".into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn icon_pixmap(&self) -> Vec<ksni::Icon> {
|
|
||||||
(*self.icons).clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tool_tip(&self) -> ksni::ToolTip {
|
|
||||||
ksni::ToolTip {
|
|
||||||
icon_name: "yandex-music-rs".into(),
|
|
||||||
icon_pixmap: Vec::new(),
|
|
||||||
title: self.title(),
|
|
||||||
description: self.track_summary.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn activate(&mut self, _x: i32, _y: i32) {
|
|
||||||
let _ = self.tx.send(NativeEvent::ToggleWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn menu(&self) -> Vec<ksni::MenuItem<Self>> {
|
|
||||||
use ksni::menu::*;
|
|
||||||
let toggle_label = if self.window_visible {
|
|
||||||
if self.is_ru { "Скрыть" } else { "Hide" }
|
|
||||||
} else if self.is_ru {
|
|
||||||
"Показать"
|
|
||||||
} else {
|
|
||||||
"Show"
|
|
||||||
};
|
|
||||||
let play_label = if self.is_playing {
|
|
||||||
if self.is_ru { "Пауза" } else { "Pause" }
|
|
||||||
} else if self.is_ru {
|
|
||||||
"Играть"
|
|
||||||
} else {
|
|
||||||
"Play"
|
|
||||||
};
|
|
||||||
let ver_label = if self.is_ru {
|
|
||||||
format!("Яндекс Музыка {}", env!("CARGO_PKG_VERSION"))
|
|
||||||
} else {
|
|
||||||
format!("Yandex Music {}", env!("CARGO_PKG_VERSION"))
|
|
||||||
};
|
|
||||||
|
|
||||||
vec![
|
|
||||||
StandardItem {
|
|
||||||
label: toggle_label.into(),
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::ToggleWindow);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
StandardItem {
|
|
||||||
label: if self.is_ru {
|
|
||||||
"Проверить обновления".into()
|
|
||||||
} else {
|
|
||||||
"Check updates".into()
|
|
||||||
},
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::CheckUpdates);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
MenuItem::Separator,
|
|
||||||
StandardItem {
|
|
||||||
label: play_label.into(),
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::TogglePlay);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
StandardItem {
|
|
||||||
label: if self.is_ru {
|
|
||||||
"Предыдущий трек".into()
|
|
||||||
} else {
|
|
||||||
"Previous song".into()
|
|
||||||
},
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::Prev);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
StandardItem {
|
|
||||||
label: if self.is_ru {
|
|
||||||
"Следующий трек".into()
|
|
||||||
} else {
|
|
||||||
"Next song".into()
|
|
||||||
},
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::Next);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
MenuItem::Separator,
|
|
||||||
SubMenu {
|
|
||||||
label: if self.is_ru {
|
|
||||||
"О приложении".into()
|
|
||||||
} else {
|
|
||||||
"About the app".into()
|
|
||||||
},
|
|
||||||
submenu: vec![StandardItem {
|
|
||||||
label: ver_label,
|
|
||||||
enabled: false,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into()],
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
MenuItem::Separator,
|
|
||||||
StandardItem {
|
|
||||||
label: if self.is_ru {
|
|
||||||
"Закрыть приложение".into()
|
|
||||||
} else {
|
|
||||||
"Close app".into()
|
|
||||||
},
|
|
||||||
activate: Box::new(|this: &mut Self| {
|
|
||||||
let _ = this.tx.send(NativeEvent::QuitApp);
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
.into(),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decode_ksni_icon(png_bytes: &[u8]) -> Option<ksni::Icon> {
|
|
||||||
let img = image::load_from_memory(png_bytes).ok()?.to_rgba8();
|
|
||||||
let (w, h) = img.dimensions();
|
|
||||||
let mut data = img.into_raw();
|
|
||||||
for px in data.chunks_exact_mut(4) {
|
|
||||||
px.rotate_right(1); // RGBA -> ARGB32 network byte order (SNI spec)
|
|
||||||
}
|
|
||||||
Some(ksni::Icon {
|
|
||||||
width: w as i32,
|
|
||||||
height: h as i32,
|
|
||||||
data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct NativeDesktop {
|
|
||||||
handle: Option<Handle<LinuxTray>>,
|
|
||||||
rx: Receiver<NativeEvent>,
|
|
||||||
last_playing: Option<bool>,
|
|
||||||
last_track_id: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for NativeDesktop {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
if let Some(ref handle) = self.handle {
|
|
||||||
handle.shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NativeDesktop {
|
impl NativeDesktop {
|
||||||
pub fn new(_window: &Window, is_ru: bool) -> Self {
|
pub fn new(_window: &Window, _is_ru: bool) -> Self {
|
||||||
let (tx, rx) = unbounded();
|
Self
|
||||||
let mut pixmaps = Vec::with_capacity(2);
|
|
||||||
if let Some(ic32) = decode_ksni_icon(include_bytes!("../../assets/icons/tray_32.png")) {
|
|
||||||
pixmaps.push(ic32);
|
|
||||||
}
|
|
||||||
if let Some(ic48) = decode_ksni_icon(include_bytes!("../../assets/icons/app_48.png")) {
|
|
||||||
pixmaps.push(ic48);
|
|
||||||
}
|
|
||||||
let tray = LinuxTray {
|
|
||||||
tx,
|
|
||||||
icons: Arc::new(pixmaps),
|
|
||||||
is_ru,
|
|
||||||
window_visible: true,
|
|
||||||
is_playing: false,
|
|
||||||
track_summary: String::new(),
|
|
||||||
};
|
|
||||||
let handle = tray.assume_sni_available(true).spawn().ok();
|
|
||||||
Self {
|
|
||||||
handle,
|
|
||||||
rx,
|
|
||||||
last_playing: None,
|
|
||||||
last_track_id: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
pub fn set_window_visible_label(&self, _visible: bool) {}
|
||||||
pub fn set_window_visible_label(&self, visible: bool) {
|
|
||||||
if let Some(ref handle) = self.handle {
|
|
||||||
handle.update(move |t| {
|
|
||||||
t.window_visible = visible;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn poll_events(&self) -> Vec<NativeEvent> {
|
pub fn poll_events(&self) -> Vec<NativeEvent> {
|
||||||
let mut out = Vec::new();
|
Vec::new()
|
||||||
while let Ok(ev) = self.rx.try_recv() {
|
|
||||||
out.push(ev);
|
|
||||||
}
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sync_playback(&mut self, track: Option<&Track>, is_playing: bool, _pos_ms: u64) {
|
|
||||||
let track_id = track.map(|t| t.id.as_str());
|
|
||||||
if self.last_playing == Some(is_playing) && self.last_track_id.as_deref() == track_id {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.last_playing = Some(is_playing);
|
|
||||||
self.last_track_id = track_id.map(String::from);
|
|
||||||
let summary = track
|
|
||||||
.map(|tr| {
|
|
||||||
let artists = tr.artists_string();
|
|
||||||
if artists.is_empty() {
|
|
||||||
tr.title.clone()
|
|
||||||
} else {
|
|
||||||
format!("{} — {}", artists, tr.title)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
|
||||||
if let Some(ref handle) = self.handle {
|
|
||||||
handle.update(move |t| {
|
|
||||||
t.is_playing = is_playing;
|
|
||||||
t.track_summary = summary;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
pub fn sync_playback(&mut self, _track: Option<&Track>, _is_playing: bool, _pos_ms: u64) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_window_icon() -> Option<winit::window::Icon> {
|
pub fn load_window_icon() -> Option<winit::window::Icon> {
|
||||||
|
|
@ -721,17 +480,8 @@ mod imp {
|
||||||
winit::window::Icon::from_rgba(img.into_raw(), w, h).ok()
|
winit::window::Icon::from_rgba(img.into_raw(), w, h).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Entry point for the short-lived `yandex-music-auth` subprocess on Linux (GTK3 + WebKitGTK).
|
/// Entry point for the short-lived `--auth-webview` subprocess on Linux (GTK3 + WebKitGTK).
|
||||||
/// Compiled ONLY when `--features linux-webview` is enabled so the main player binary has
|
|
||||||
/// zero `libwebkit2gtk` / `libjavascriptcoregtk` / `libgtk-3` DT_NEEDED dependencies!
|
|
||||||
#[cfg(feature = "linux-webview")]
|
|
||||||
pub fn run_auth_webview_subprocess() {
|
pub fn run_auth_webview_subprocess() {
|
||||||
use crate::api::signing::extract_oauth_token;
|
|
||||||
use crate::api::YANDEX_OAUTH_URL;
|
|
||||||
use gtk::prelude::*;
|
|
||||||
use std::io::Write;
|
|
||||||
use wry::{WebViewBuilder, WebViewBuilderExtUnix};
|
|
||||||
|
|
||||||
// Avoid blank WebKitGTK window on NVIDIA/Wayland/VM drivers during OAuth login.
|
// Avoid blank WebKitGTK window on NVIDIA/Wayland/VM drivers during OAuth login.
|
||||||
if std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_none() {
|
if std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_none() {
|
||||||
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||||
|
|
@ -804,38 +554,14 @@ mod imp {
|
||||||
gtk::main();
|
gtk::main();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "linux-webview"))]
|
/// Spawn the isolated `--auth-webview` subprocess and return the captured OAuth token.
|
||||||
pub fn run_auth_webview_subprocess() {
|
|
||||||
eprintln!("yandex-music-auth helper required");
|
|
||||||
std::process::exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Spawn the isolated `yandex-music-auth` helper binary (or `--auth-webview` if built with
|
|
||||||
/// `linux-webview`) and return the captured OAuth token.
|
|
||||||
pub fn spawn_auth_webview_subprocess() -> anyhow::Result<String> {
|
pub fn spawn_auth_webview_subprocess() -> anyhow::Result<String> {
|
||||||
let exe = std::env::current_exe()?;
|
let exe = std::env::current_exe()?;
|
||||||
let sibling_helper = exe.with_file_name("yandex-music-auth");
|
let mut child = Command::new(exe)
|
||||||
|
.arg("--auth-webview")
|
||||||
let mut child = if sibling_helper.is_file() {
|
|
||||||
Command::new(&sibling_helper)
|
|
||||||
.stdout(Stdio::piped())
|
|
||||||
.stderr(Stdio::null())
|
|
||||||
.spawn()?
|
|
||||||
} else if let Ok(c) = Command::new("yandex-music-auth")
|
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.spawn()
|
.spawn()?;
|
||||||
{
|
|
||||||
c
|
|
||||||
} else if cfg!(feature = "linux-webview") {
|
|
||||||
Command::new(&exe)
|
|
||||||
.arg("--auth-webview")
|
|
||||||
.stdout(Stdio::piped())
|
|
||||||
.stderr(Stdio::null())
|
|
||||||
.spawn()?
|
|
||||||
} else {
|
|
||||||
anyhow::bail!("WebKitGTK auth helper (yandex-music-auth) unavailable");
|
|
||||||
};
|
|
||||||
|
|
||||||
let stdout = child
|
let stdout = child
|
||||||
.stdout
|
.stdout
|
||||||
|
|
|
||||||
|
|
@ -61,17 +61,7 @@ impl PerfTelemetry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
#[cfg(not(windows))]
|
||||||
pub fn trim_working_set() {
|
|
||||||
extern "C" {
|
|
||||||
fn malloc_trim(pad: usize) -> i32;
|
|
||||||
}
|
|
||||||
unsafe {
|
|
||||||
let _ = malloc_trim(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(any(windows, all(target_os = "linux", target_env = "gnu"))))]
|
|
||||||
pub fn trim_working_set() {}
|
pub fn trim_working_set() {}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|
@ -96,62 +86,7 @@ impl PerfTelemetry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(not(windows))]
|
||||||
pub fn sample_memory(&mut self) {
|
|
||||||
fn parse_kb_line(line: &str, prefix: &str) -> Option<u64> {
|
|
||||||
let rest = line.strip_prefix(prefix)?;
|
|
||||||
rest.split_whitespace().next()?.parse::<u64>().ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(rollup) = std::fs::read_to_string("/proc/self/smaps_rollup") {
|
|
||||||
let mut rss_kb: Option<u64> = None;
|
|
||||||
let mut pss_kb: Option<u64> = None;
|
|
||||||
let mut priv_clean_kb: u64 = 0;
|
|
||||||
let mut priv_dirty_kb: u64 = 0;
|
|
||||||
let mut has_priv = false;
|
|
||||||
for line in rollup.lines() {
|
|
||||||
if let Some(v) = parse_kb_line(line, "Rss:") {
|
|
||||||
rss_kb = Some(v);
|
|
||||||
} else if let Some(v) = parse_kb_line(line, "Pss:") {
|
|
||||||
pss_kb = Some(v);
|
|
||||||
} else if let Some(v) = parse_kb_line(line, "Private_Clean:") {
|
|
||||||
priv_clean_kb = v;
|
|
||||||
has_priv = true;
|
|
||||||
} else if let Some(v) = parse_kb_line(line, "Private_Dirty:") {
|
|
||||||
priv_dirty_kb = v;
|
|
||||||
has_priv = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(rss) = rss_kb {
|
|
||||||
self.working_set_mb = rss as f32 / 1024.0;
|
|
||||||
let priv_kb = if has_priv {
|
|
||||||
priv_clean_kb.saturating_add(priv_dirty_kb)
|
|
||||||
} else {
|
|
||||||
pss_kb.unwrap_or(rss)
|
|
||||||
};
|
|
||||||
self.private_mb = priv_kb as f32 / 1024.0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(status) = std::fs::read_to_string("/proc/self/status") {
|
|
||||||
let mut rss_kb: Option<u64> = None;
|
|
||||||
let mut anon_kb: Option<u64> = None;
|
|
||||||
for line in status.lines() {
|
|
||||||
if let Some(v) = parse_kb_line(line, "VmRSS:") {
|
|
||||||
rss_kb = Some(v);
|
|
||||||
} else if let Some(v) = parse_kb_line(line, "RssAnon:") {
|
|
||||||
anon_kb = Some(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(rss) = rss_kb {
|
|
||||||
self.working_set_mb = rss as f32 / 1024.0;
|
|
||||||
self.private_mb = anon_kb.unwrap_or(rss) as f32 / 1024.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(any(windows, target_os = "linux")))]
|
|
||||||
pub fn sample_memory(&mut self) {
|
pub fn sample_memory(&mut self) {
|
||||||
self.working_set_mb = 28.0;
|
self.working_set_mb = 28.0;
|
||||||
self.private_mb = 22.0;
|
self.private_mb = 22.0;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ use crate::engine::input::WidgetId;
|
||||||
use crate::engine::scroll::visible_row_range;
|
use crate::engine::scroll::visible_row_range;
|
||||||
use crate::engine::text::{TextAlign, TextStyle};
|
use crate::engine::text::{TextAlign, TextStyle};
|
||||||
use crate::engine::theme::{YmPalette, TRACK_ROW_HEIGHT};
|
use crate::engine::theme::{YmPalette, TRACK_ROW_HEIGHT};
|
||||||
use crate::engine::types::{Color, CornerRadii, CursorKind, Pos2, Rect, Vec2};
|
use crate::engine::types::{CornerRadii, CursorKind, Pos2, Rect, Vec2};
|
||||||
use crate::engine::widgets::{
|
use crate::engine::widgets::{
|
||||||
draw_cover_art, media_card, separated_artists, text_input_widget,
|
draw_cover_art, media_card, secondary_pill_button, separated_artists, text_input_widget,
|
||||||
track_row, yellow_pill_button, TextInputOptions, TrackRowAction, TrackRowOptions,
|
track_row, yellow_pill_button, TextInputOptions, TrackRowAction, TrackRowOptions,
|
||||||
};
|
};
|
||||||
use crate::engine::UiContext;
|
use crate::engine::UiContext;
|
||||||
|
|
@ -144,7 +144,6 @@ 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(),
|
||||||
|
|
@ -157,7 +156,7 @@ pub fn render_detail(
|
||||||
pl_cov,
|
pl_cov,
|
||||||
p_seed,
|
p_seed,
|
||||||
false,
|
false,
|
||||||
is_likes_art,
|
false,
|
||||||
"playlist",
|
"playlist",
|
||||||
p_id,
|
p_id,
|
||||||
Some(owner_uid),
|
Some(owner_uid),
|
||||||
|
|
@ -632,18 +631,12 @@ pub fn render_detail(
|
||||||
.any(|tr| app.is_track_downloading(&tr.id));
|
.any(|tr| app.is_track_downloading(&tr.id));
|
||||||
|
|
||||||
if any_downloading {
|
if any_downloading {
|
||||||
let pct = app
|
let pct = app.download_progress_pct().unwrap_or(0);
|
||||||
.tracks_download_progress_pct(&raw_tracks)
|
|
||||||
.or_else(|| app.download_progress_pct())
|
|
||||||
.unwrap_or(0);
|
|
||||||
let label = format!("{}%", pct);
|
let label = format!("{}%", pct);
|
||||||
let pct_w = ctx
|
let btn_w = 78.0;
|
||||||
.measure_text(&label, TextStyle::medium(13.5, pal.text_primary), None)
|
|
||||||
.x;
|
|
||||||
let btn_w = (pct_w + 48.0).max(80.0).ceil();
|
|
||||||
let dl_r = Rect::from_xywh(bx, btn_y, btn_w, 40.0);
|
let dl_r = Rect::from_xywh(bx, btn_y, btn_w, 40.0);
|
||||||
let resp = ctx.interact(WidgetId::new("det_dl_btn"), dl_r);
|
let resp = ctx.interact(WidgetId::new("det_dl_btn"), dl_r);
|
||||||
ctx.dl().push_rect(
|
ctx.dl().push_rect_bordered(
|
||||||
dl_r,
|
dl_r,
|
||||||
20.0,
|
20.0,
|
||||||
if resp.hovered {
|
if resp.hovered {
|
||||||
|
|
@ -651,20 +644,18 @@ pub fn render_detail(
|
||||||
} else {
|
} else {
|
||||||
pal.surface_secondary
|
pal.surface_secondary
|
||||||
},
|
},
|
||||||
|
1.5,
|
||||||
|
pal.yellow,
|
||||||
);
|
);
|
||||||
crate::engine::widgets::draw_downloading_progress(
|
ctx.draw_icon(
|
||||||
ctx,
|
Icon::Download,
|
||||||
pal,
|
Rect::from_center_size(Pos2::new(dl_r.left() + 20.0, dl_r.center_y()), Vec2::splat(18.0)),
|
||||||
Pos2::new(dl_r.left() + 20.0, dl_r.center_y()),
|
pal.yellow,
|
||||||
24.0,
|
|
||||||
pct as f32 / 100.0,
|
|
||||||
true,
|
|
||||||
resp.hovered,
|
|
||||||
);
|
);
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
&label,
|
&label,
|
||||||
TextStyle::medium(13.5, pal.text_primary),
|
TextStyle::bold(13.0, pal.text_primary),
|
||||||
Rect::from_xywh(dl_r.left() + 38.0, dl_r.top(), (btn_w - 44.0).max(24.0), dl_r.height()),
|
Rect::from_xywh(dl_r.left() + 34.0, dl_r.top(), 40.0, dl_r.height()),
|
||||||
TextAlign::Left,
|
TextAlign::Left,
|
||||||
);
|
);
|
||||||
if resp.hovered {
|
if resp.hovered {
|
||||||
|
|
@ -769,29 +760,16 @@ pub fn render_detail(
|
||||||
None => chip.id == "all",
|
None => chip.id == "all",
|
||||||
Some(sel) => sel == &chip.id,
|
Some(sel) => sel == &chip.id,
|
||||||
};
|
};
|
||||||
let chip_id = WidgetId::from_pair("fav_chip", &chip.id);
|
let (resp, r) = secondary_pill_button(
|
||||||
let text_sz = ctx.measure_text(&chip.name, TextStyle::bold(14.0, pal.text_primary), None);
|
ctx,
|
||||||
let w = (text_sz.x + 36.0).clamp(48.0, 200.0);
|
pal,
|
||||||
let r = Rect::from_xywh(cx, y, w, 40.0);
|
WidgetId::from_pair("fav_chip", &chip.id),
|
||||||
let resp = ctx.interact(chip_id, r);
|
Pos2::new(cx, y),
|
||||||
// Official `PlaylistFilter_root`: idle `#333` dark / `#E6E6E6` light; on hover slightly darkens (`#282828` / `#D6D6D6`)!
|
None,
|
||||||
let hover_bg = if pal.is_dark {
|
|
||||||
Color::rgb(0x28, 0x28, 0x28)
|
|
||||||
} else {
|
|
||||||
Color::rgb(0xD6, 0xD6, 0xD6)
|
|
||||||
};
|
|
||||||
let bg = if resp.hovered { hover_bg } else { pal.chip_bg };
|
|
||||||
let border_col = if is_selected { pal.outline_selected } else { bg };
|
|
||||||
ctx.dl().push_rect_bordered(r, 20.0, bg, 2.0, border_col);
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
&chip.name,
|
&chip.name,
|
||||||
TextStyle::bold(14.0, pal.text_primary),
|
40.0,
|
||||||
Rect::from_xywh(r.left() + 16.0, r.top(), (r.width() - 32.0).max(12.0), r.height()),
|
is_selected,
|
||||||
TextAlign::Center,
|
|
||||||
);
|
);
|
||||||
if resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if resp.clicked {
|
if resp.clicked {
|
||||||
let next_id = if chip.id == "all" {
|
let next_id = if chip.id == "all" {
|
||||||
None
|
None
|
||||||
|
|
@ -845,8 +823,6 @@ pub fn render_detail(
|
||||||
is_liked: app.liked_ids.contains(&tr.id),
|
is_liked: app.liked_ids.contains(&tr.id),
|
||||||
is_disliked: app.disliked_ids.contains(&tr.id),
|
is_disliked: app.disliked_ids.contains(&tr.id),
|
||||||
is_downloaded: app.is_track_downloaded(&tr.id),
|
is_downloaded: app.is_track_downloaded(&tr.id),
|
||||||
is_downloading: app.is_track_downloading(&tr.id),
|
|
||||||
download_progress: app.track_download_progress(&tr.id),
|
|
||||||
menu_open: shell.is_track_menu_open(&tr.id),
|
menu_open: shell.is_track_menu_open(&tr.id),
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -926,10 +902,9 @@ 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 (idx, alb) in art_detail.albums.iter().take(48).enumerate() {
|
for alb in art_detail.albums.iter().take(16) {
|
||||||
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())
|
||||||
|
|
@ -938,9 +913,9 @@ pub fn render_detail(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("art_alb", (idx, &alb.id)),
|
WidgetId::from_pair("art_alb", &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),
|
||||||
|
|
@ -950,12 +925,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,
|
title: alb.title.clone(),
|
||||||
});
|
});
|
||||||
} 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,
|
title: alb.title.clone(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -964,7 +939,7 @@ pub fn render_detail(
|
||||||
ctx.end_scroll_h(
|
ctx.end_scroll_h(
|
||||||
h_id,
|
h_id,
|
||||||
pal,
|
pal,
|
||||||
art_detail.albums.len().min(48) as f32 * (card_w + 16.0),
|
art_detail.albums.len().min(16) as f32 * (card_w + 16.0),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
use std::cell::Cell;
|
|
||||||
|
|
||||||
use crate::api::models::{NewReleaseItem, VibePickItem, VibePickTab};
|
|
||||||
use crate::app::state::{AppAction, AppState, CollectionTab, ForYouTab, Route};
|
use crate::app::state::{AppAction, AppState, CollectionTab, ForYouTab, Route};
|
||||||
use crate::covers::CoverCache;
|
use crate::covers::CoverCache;
|
||||||
use crate::engine::input::WidgetId;
|
use crate::engine::input::WidgetId;
|
||||||
|
|
@ -12,11 +9,7 @@ use crate::engine::widgets::{
|
||||||
};
|
};
|
||||||
use crate::engine::UiContext;
|
use crate::engine::UiContext;
|
||||||
use crate::icons::Icon;
|
use crate::icons::Icon;
|
||||||
use crate::views::overlays::{EntityContextMenuState, ShellUiState};
|
use crate::views::overlays::ShellUiState;
|
||||||
|
|
||||||
thread_local! {
|
|
||||||
static FOR_YOU_PICKS_TAB: Cell<usize> = const { Cell::new(0) };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Exact Yandex Music Desktop 5.129.0 "For you and Trends" page (`vibe_wheel_foryou_spec.md` §4):
|
/// Exact Yandex Music Desktop 5.129.0 "For you and Trends" page (`vibe_wheel_foryou_spec.md` §4):
|
||||||
/// - Persistent heading ("Для вас и Тренды" / "For you and Trends") + IN-PLACE switcher tabs ("Для вас" / "Тренды")
|
/// - Persistent heading ("Для вас и Тренды" / "For you and Trends") + IN-PLACE switcher tabs ("Для вас" / "Тренды")
|
||||||
|
|
@ -465,7 +458,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 (idx, pl) in playlists.iter().enumerate() {
|
for pl in &playlists {
|
||||||
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,10 +466,7 @@ pub fn render_for_you(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair(
|
WidgetId::from_pair("fy_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
"fy_pl",
|
|
||||||
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
|
||||||
),
|
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
sub,
|
sub,
|
||||||
|
|
@ -506,15 +496,10 @@ pub fn render_for_you(
|
||||||
y += card_h + 26.0;
|
y += card_h + 26.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. "New Releases >" (1-to-1 official `NewRelease` + `NewReleaseCard` circular portrait + colored release card!)
|
// 5. "New Releases"
|
||||||
if !app.landing.rich_new_releases.is_empty() || !app.landing.new_releases.is_empty() {
|
if !app.landing.new_releases.is_empty() {
|
||||||
y = render_new_releases_carousel(
|
y = render_new_releases_carousel(ctx, pal, covers, app, x, y, avail_w, "fy_rel", actions);
|
||||||
ctx, pal, covers, app, shell, rect, x, y, avail_w, "fy_rel", actions,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Official "More Picks" / "Ещё подборки" (`Waves` / `SETS_BY_WAVES`)
|
|
||||||
y = render_more_picks_section(ctx, pal, app, rect, x, y, avail_w, actions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForYouTab::Trends => {
|
ForYouTab::Trends => {
|
||||||
|
|
@ -579,8 +564,6 @@ pub fn render_for_you(
|
||||||
is_liked: app.liked_ids.contains(&tr.id),
|
is_liked: app.liked_ids.contains(&tr.id),
|
||||||
is_disliked: app.disliked_ids.contains(&tr.id),
|
is_disliked: app.disliked_ids.contains(&tr.id),
|
||||||
is_downloaded: app.is_track_downloaded(&tr.id),
|
is_downloaded: app.is_track_downloaded(&tr.id),
|
||||||
is_downloading: app.is_track_downloading(&tr.id),
|
|
||||||
download_progress: app.track_download_progress(&tr.id),
|
|
||||||
menu_open: shell.is_track_menu_open(&tr.id),
|
menu_open: shell.is_track_menu_open(&tr.id),
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -623,14 +606,12 @@ pub fn render_for_you(
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. New Releases Carousel
|
// 2. New Releases Carousel
|
||||||
if !app.landing.rich_new_releases.is_empty() || !app.landing.new_releases.is_empty() {
|
if !app.landing.new_releases.is_empty() {
|
||||||
y = render_new_releases_carousel(
|
y = render_new_releases_carousel(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
app,
|
app,
|
||||||
shell,
|
|
||||||
rect,
|
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
avail_w,
|
avail_w,
|
||||||
|
|
@ -657,17 +638,14 @@ 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 (idx, pl) in playlists.iter().enumerate() {
|
for pl in &playlists {
|
||||||
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(
|
WidgetId::from_pair("tr_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
"tr_pl",
|
|
||||||
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
|
||||||
),
|
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
&pl.owner_name,
|
&pl.owner_name,
|
||||||
|
|
@ -700,162 +678,9 @@ pub fn render_for_you(
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 20.0;
|
y += 20.0;
|
||||||
|
let _ = CornerRadii::ZERO;
|
||||||
let total_h = y - (rect.top() - scroll_y);
|
let total_h = y - (rect.top() - scroll_y);
|
||||||
ctx.end_scroll_v(scroll_id, pal, total_h, true);
|
ctx.end_scroll_v(scroll_id, pal, total_h, true);
|
||||||
|
|
||||||
// Sticky Frosted Top Switcher Bar when scrolled (`scroll_y > 72.0` -> zero impact on `scroll_y == 0` parity!)
|
|
||||||
if scroll_y > 72.0 {
|
|
||||||
let fade_in = ((scroll_y - 72.0) / 36.0).clamp(0.0, 1.0);
|
|
||||||
let bar_r = Rect::from_xywh(
|
|
||||||
rect.left() - 25.0,
|
|
||||||
rect.top() - 12.0,
|
|
||||||
rect.width() + 50.0,
|
|
||||||
66.0,
|
|
||||||
);
|
|
||||||
// Subtle atmospheric gradient glow behind the frosted sticky bar
|
|
||||||
let glow_c = if pal.is_dark {
|
|
||||||
Color::rgb(0x4E, 0x35, 0x62)
|
|
||||||
} else {
|
|
||||||
Color::rgb(0xD8, 0xD2, 0xE8)
|
|
||||||
};
|
|
||||||
ctx.dl().push_gradient_rect(
|
|
||||||
bar_r,
|
|
||||||
CornerRadii::top(12.0),
|
|
||||||
glow_c.with_alpha((54.0 * fade_in).round() as u8),
|
|
||||||
glow_c.with_alpha(0),
|
|
||||||
Vec2::new(0.0, 1.0),
|
|
||||||
);
|
|
||||||
let glass_tint = if pal.is_dark {
|
|
||||||
css_rgba(18, 18, 18, (186.0 * fade_in).round() as u8)
|
|
||||||
} else {
|
|
||||||
css_rgba(255, 255, 255, (206.0 * fade_in).round() as u8)
|
|
||||||
};
|
|
||||||
ctx.dl().push_backdrop_blur(
|
|
||||||
bar_r,
|
|
||||||
CornerRadii::top(12.0),
|
|
||||||
2.0,
|
|
||||||
glass_tint,
|
|
||||||
0.0,
|
|
||||||
Color::TRANSPARENT,
|
|
||||||
);
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(bar_r.left(), bar_r.bottom() - 1.0, bar_r.width(), 1.0),
|
|
||||||
0.0,
|
|
||||||
pal.border_subtle.scale_alpha(fade_in),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut sx = x;
|
|
||||||
let sy = bar_r.center_y() - 19.0;
|
|
||||||
for (tab_kind, label) in [
|
|
||||||
(ForYouTab::ForYou, t.for_you()),
|
|
||||||
(ForYouTab::Trends, t.trends()),
|
|
||||||
] {
|
|
||||||
let active = app.for_you_tab == tab_kind;
|
|
||||||
let tw = ctx
|
|
||||||
.measure_text(label, TextStyle::bold(14.5, pal.text_primary), None)
|
|
||||||
.x
|
|
||||||
+ 32.0;
|
|
||||||
let pr = Rect::from_xywh(sx, sy, tw.max(88.0), 38.0);
|
|
||||||
let resp = ctx.interact(WidgetId::from_pair("fy_sticky_tab", tab_kind as u8), pr);
|
|
||||||
if active || resp.hovered {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
pr,
|
|
||||||
19.0,
|
|
||||||
if active {
|
|
||||||
pal.surface_hover
|
|
||||||
} else {
|
|
||||||
pal.surface_secondary
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
label,
|
|
||||||
TextStyle::bold(
|
|
||||||
14.5,
|
|
||||||
if active || resp.hovered {
|
|
||||||
pal.text_bright
|
|
||||||
} else {
|
|
||||||
pal.text_secondary
|
|
||||||
},
|
|
||||||
),
|
|
||||||
pr,
|
|
||||||
TextAlign::Center,
|
|
||||||
);
|
|
||||||
if resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if resp.clicked && !active {
|
|
||||||
actions.push(AppAction::SetForYouTab(tab_kind));
|
|
||||||
}
|
|
||||||
sx = pr.right() + 8.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rich_dark_tint(raw: Color) -> Color {
|
|
||||||
// Rich dark-saturated card tint (~24% lightness) keeping high contrast for white album text
|
|
||||||
let r = (raw.r as f32 / 255.0).clamp(0.0, 1.0);
|
|
||||||
let g = (raw.g as f32 / 255.0).clamp(0.0, 1.0);
|
|
||||||
let b = (raw.b as f32 / 255.0).clamp(0.0, 1.0);
|
|
||||||
let max_c = r.max(g).max(b);
|
|
||||||
let min_c = r.min(g).min(b);
|
|
||||||
let avg = (max_c + min_c) * 0.5;
|
|
||||||
// Slightly boost chroma then scale luminance into ~0.22..0.28 range
|
|
||||||
let sat_r = (avg + (r - avg) * 1.25).clamp(0.0, 1.0);
|
|
||||||
let sat_g = (avg + (g - avg) * 1.25).clamp(0.0, 1.0);
|
|
||||||
let sat_b = (avg + (b - avg) * 1.25).clamp(0.0, 1.0);
|
|
||||||
let luma = (0.299 * sat_r + 0.587 * sat_g + 0.114 * sat_b).max(0.01);
|
|
||||||
let scale = (0.24 / luma).clamp(0.28, 0.95);
|
|
||||||
Color::rgb(
|
|
||||||
((sat_r * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
|
||||||
((sat_g * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
|
||||||
((sat_b * scale).clamp(0.08, 0.48) * 255.0).round() as u8,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn format_release_subtitle(item: &NewReleaseItem, ru: bool) -> String {
|
|
||||||
let is_single = item
|
|
||||||
.album
|
|
||||||
.content_type
|
|
||||||
.as_deref()
|
|
||||||
.map_or(false, |ct| ct.eq_ignore_ascii_case("single"))
|
|
||||||
|| (item.album.track_count > 0 && item.album.track_count <= 3);
|
|
||||||
let kind = if is_single {
|
|
||||||
if ru { "сингл" } else { "single" }
|
|
||||||
} else if ru {
|
|
||||||
"альбом"
|
|
||||||
} else {
|
|
||||||
"album"
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(ref rd) = item.release_date {
|
|
||||||
let date_part = rd.split('T').next().unwrap_or(rd);
|
|
||||||
let parts: Vec<&str> = date_part.split('-').collect();
|
|
||||||
if parts.len() >= 3 {
|
|
||||||
if let (Ok(m), Ok(d)) = (parts[1].parse::<usize>(), parts[2].parse::<u32>()) {
|
|
||||||
if (1..=12).contains(&m) && d > 0 {
|
|
||||||
const MONTHS_RU: [&str; 12] = [
|
|
||||||
"января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа",
|
|
||||||
"сентября", "октября", "ноября", "декабря",
|
|
||||||
];
|
|
||||||
const MONTHS_EN: [&str; 12] = [
|
|
||||||
"January", "February", "March", "April", "May", "June", "July", "August",
|
|
||||||
"September", "October", "November", "December",
|
|
||||||
];
|
|
||||||
return if ru {
|
|
||||||
format!("{} · {} {}", kind, d, MONTHS_RU[m - 1])
|
|
||||||
} else {
|
|
||||||
format!("{} · {} {}", kind, MONTHS_EN[m - 1], d)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(yr) = item.album.year {
|
|
||||||
format!("{} · {}", kind, yr)
|
|
||||||
} else {
|
|
||||||
kind.to_string()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
@ -864,8 +689,6 @@ fn render_new_releases_carousel(
|
||||||
pal: &YmPalette,
|
pal: &YmPalette,
|
||||||
covers: &mut CoverCache,
|
covers: &mut CoverCache,
|
||||||
app: &AppState,
|
app: &AppState,
|
||||||
shell: &mut ShellUiState,
|
|
||||||
viewport: Rect,
|
|
||||||
x: f32,
|
x: f32,
|
||||||
mut y: f32,
|
mut y: f32,
|
||||||
avail_w: f32,
|
avail_w: f32,
|
||||||
|
|
@ -873,590 +696,58 @@ fn render_new_releases_carousel(
|
||||||
actions: &mut Vec<AppAction>,
|
actions: &mut Vec<AppAction>,
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
let t = app.i18n();
|
let t = app.i18n();
|
||||||
let ru = t.is_ru();
|
|
||||||
let items: Vec<NewReleaseItem> = if !app.landing.rich_new_releases.is_empty() {
|
|
||||||
app.landing.rich_new_releases.clone()
|
|
||||||
} else {
|
|
||||||
app.landing
|
|
||||||
.new_releases
|
|
||||||
.iter()
|
|
||||||
.cloned()
|
|
||||||
.map(|album| NewReleaseItem {
|
|
||||||
artist_cover_uri: album.artists.first().and_then(|a| a.cover_uri.clone()),
|
|
||||||
cover_color: None,
|
|
||||||
release_date: None,
|
|
||||||
album,
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
};
|
|
||||||
if items.is_empty() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
let h_id = WidgetId::new(salt);
|
|
||||||
let card_w = 286.0_f32;
|
|
||||||
let gap = 18.0_f32;
|
|
||||||
let portrait_d = 236.0_f32;
|
|
||||||
let overlap = 56.0_f32;
|
|
||||||
let bottom_h = 80.0_f32;
|
|
||||||
let card_h = portrait_d - overlap + bottom_h; // 260.0
|
|
||||||
let total_w = items.len() as f32 * (card_w + gap);
|
|
||||||
|
|
||||||
// Header row: "New Releases >" + circular `<` `>` carousel arrows on right
|
|
||||||
let head_txt = t.new_releases();
|
|
||||||
let head_tw = ctx
|
|
||||||
.measure_text(head_txt, TextStyle::headline(24.0, pal.text_primary), None)
|
|
||||||
.x;
|
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
head_txt,
|
t.new_releases(),
|
||||||
TextStyle::headline(24.0, pal.text_primary),
|
|
||||||
Rect::from_xywh(x, y, head_tw + 4.0, 30.0),
|
|
||||||
TextAlign::Left,
|
|
||||||
);
|
|
||||||
ctx.draw_icon(
|
|
||||||
Icon::ArrowRight,
|
|
||||||
Rect::from_center_size(Pos2::new(x + head_tw + 16.0, y + 15.0), Vec2::splat(22.0)),
|
|
||||||
pal.text_secondary,
|
|
||||||
);
|
|
||||||
|
|
||||||
let (can_left, can_right) = ctx
|
|
||||||
.scrolls
|
|
||||||
.get(h_id)
|
|
||||||
.map(|s| (s.can_scroll_left(), s.can_scroll_right()))
|
|
||||||
.unwrap_or((false, total_w > avail_w + 10.0));
|
|
||||||
let l_btn_c = Pos2::new(x + avail_w - 54.0, y + 15.0);
|
|
||||||
let r_btn_c = Pos2::new(x + avail_w - 16.0, y + 15.0);
|
|
||||||
for (c, ic, enabled, is_right) in [
|
|
||||||
(l_btn_c, Icon::ArrowLeftXxs, can_left, false),
|
|
||||||
(r_btn_c, Icon::ArrowRightXxs, can_right, true),
|
|
||||||
] {
|
|
||||||
let br = Rect::from_center_size(c, Vec2::splat(32.0));
|
|
||||||
let resp = ctx.interact(WidgetId::from_pair(salt, if is_right { "next" } else { "prev" }), br);
|
|
||||||
let bg = if enabled && resp.hovered {
|
|
||||||
pal.surface_hover
|
|
||||||
} else {
|
|
||||||
pal.surface_secondary
|
|
||||||
};
|
|
||||||
ctx.dl().push_circle(c, 16.0, bg);
|
|
||||||
ctx.draw_icon(
|
|
||||||
ic,
|
|
||||||
Rect::from_center_size(c, Vec2::splat(18.0)),
|
|
||||||
if enabled {
|
|
||||||
if resp.hovered { pal.text_bright } else { pal.text_primary }
|
|
||||||
} else {
|
|
||||||
pal.text_disabled
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if enabled && resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if enabled && resp.clicked {
|
|
||||||
let delta = if is_right { (card_w + gap) * 2.0 } else { -(card_w + gap) * 2.0 };
|
|
||||||
ctx.scrolls.scroll_by_x(h_id, delta);
|
|
||||||
ctx.request_repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
y += 42.0;
|
|
||||||
|
|
||||||
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
|
||||||
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 mut cx = x - scroll_x;
|
|
||||||
for (idx, item) in items.iter().enumerate() {
|
|
||||||
let alb = &item.album;
|
|
||||||
let alb_title = alb.full_title();
|
|
||||||
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 {
|
|
||||||
// 1. Huge 236x236 circular artist portrait overlapping the bottom card by 56px
|
|
||||||
let circle_r = Rect::from_xywh(
|
|
||||||
cx + (card_w - portrait_d) * 0.5,
|
|
||||||
y,
|
|
||||||
portrait_d,
|
|
||||||
portrait_d,
|
|
||||||
);
|
|
||||||
let portrait_uri = item
|
|
||||||
.artist_cover_uri
|
|
||||||
.as_deref()
|
|
||||||
.or(alb.cover_uri.as_deref());
|
|
||||||
let (portrait_dom, _) = draw_cover_art(
|
|
||||||
ctx,
|
|
||||||
pal,
|
|
||||||
covers,
|
|
||||||
circle_r,
|
|
||||||
portrait_uri,
|
|
||||||
&format!("nr_art_{}", alb.id),
|
|
||||||
portrait_d * 0.5,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Resolve rich dark-saturated tint from `cover_color` or cover dominant color
|
|
||||||
let raw_tint = item
|
|
||||||
.cover_color
|
|
||||||
.as_deref()
|
|
||||||
.and_then(Color::from_hex_str)
|
|
||||||
.or_else(|| {
|
|
||||||
alb.cover_uri
|
|
||||||
.as_deref()
|
|
||||||
.and_then(|u| covers.get_or_fetch(u, 200))
|
|
||||||
.map(|(_, dom, _)| dom)
|
|
||||||
})
|
|
||||||
.unwrap_or(portrait_dom);
|
|
||||||
let card_tint = rich_dark_tint(raw_tint);
|
|
||||||
|
|
||||||
// Smooth lower gradient fade over lower 42% of circular portrait
|
|
||||||
ctx.push_clip(circle_r, portrait_d * 0.5);
|
|
||||||
let scrim_h = portrait_d * 0.46;
|
|
||||||
ctx.dl().push_gradient_rect(
|
|
||||||
Rect::from_xywh(circle_r.left(), circle_r.bottom() - scrim_h, portrait_d, scrim_h),
|
|
||||||
0.0,
|
|
||||||
card_tint.with_alpha(0),
|
|
||||||
card_tint.with_alpha(232),
|
|
||||||
Vec2::new(0.0, 1.0),
|
|
||||||
);
|
|
||||||
ctx.pop_clip();
|
|
||||||
|
|
||||||
// Bold white centered Artist Name above the card overlap
|
|
||||||
let artist_name = alb
|
|
||||||
.artists
|
|
||||||
.first()
|
|
||||||
.map(|a| a.name.as_str())
|
|
||||||
.unwrap_or(alb_title.as_str());
|
|
||||||
let art_lbl_r = Rect::from_xywh(
|
|
||||||
circle_r.left() + 18.0,
|
|
||||||
y + portrait_d - overlap - 54.0,
|
|
||||||
portrait_d - 36.0,
|
|
||||||
50.0,
|
|
||||||
);
|
|
||||||
ctx.draw_text_wrapped(
|
|
||||||
artist_name,
|
|
||||||
TextStyle::headline(21.0, Color::WHITE).with_line_height(24.0),
|
|
||||||
art_lbl_r,
|
|
||||||
Some(2),
|
|
||||||
TextAlign::Center,
|
|
||||||
);
|
|
||||||
|
|
||||||
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, (idx, format!("port_{}", alb.id))), port_click_r);
|
|
||||||
if port_resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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_resp = ctx.interact(WidgetId::from_pair(salt, (idx, format!("card_{}", alb.id))), card_r);
|
|
||||||
let card_bg = if card_resp.hovered {
|
|
||||||
card_tint.lerp(Color::WHITE, 0.08)
|
|
||||||
} else {
|
|
||||||
card_tint
|
|
||||||
};
|
|
||||||
ctx.dl().push_shadow(
|
|
||||||
card_r,
|
|
||||||
14.0,
|
|
||||||
12.0,
|
|
||||||
0.0,
|
|
||||||
Vec2::new(0.0, 4.0),
|
|
||||||
css_rgba(0, 0, 0, 72),
|
|
||||||
);
|
|
||||||
ctx.dl().push_rect_bordered(
|
|
||||||
card_r,
|
|
||||||
14.0,
|
|
||||||
card_bg,
|
|
||||||
1.0,
|
|
||||||
css_rgba(255, 255, 255, 26),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Left 62x62 rounded (8px) album cover
|
|
||||||
let cov_r = Rect::from_xywh(card_r.left() + 9.0, card_r.top() + 9.0, 62.0, 62.0);
|
|
||||||
draw_cover_art(
|
|
||||||
ctx,
|
|
||||||
pal,
|
|
||||||
covers,
|
|
||||||
cov_r,
|
|
||||||
alb.cover_uri.as_deref(),
|
|
||||||
&format!("nr_alb_{}", alb.id),
|
|
||||||
8.0,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Right 38x38 crisp white circular Play/Pause button
|
|
||||||
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_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 };
|
|
||||||
ctx.dl().push_circle(play_c, play_rad, Color::WHITE);
|
|
||||||
let alb_playing = app.is_context_playing(&format!("album:{}", alb.id));
|
|
||||||
ctx.draw_icon(
|
|
||||||
if alb_playing {
|
|
||||||
Icon::PauseFilledXs
|
|
||||||
} else {
|
|
||||||
Icon::PlayFilledXs
|
|
||||||
},
|
|
||||||
Rect::from_center_size(play_c, Vec2::splat(18.0)),
|
|
||||||
Color::rgb(0x14, 0x14, 0x14),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Middle bold white title + muted release subtitle
|
|
||||||
let tx_l = cov_r.right() + 12.0;
|
|
||||||
let tx_w = (play_r.left() - tx_l - 8.0).max(40.0);
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
&alb_title,
|
|
||||||
TextStyle::bold(14.5, Color::WHITE),
|
|
||||||
Rect::from_xywh(tx_l, card_r.top() + 18.0, tx_w, 20.0),
|
|
||||||
TextAlign::Left,
|
|
||||||
);
|
|
||||||
let sub = format_release_subtitle(item, ru);
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
&sub,
|
|
||||||
TextStyle::medium(12.5, css_rgba(255, 255, 255, 172)),
|
|
||||||
Rect::from_xywh(tx_l, card_r.top() + 42.0, tx_w, 18.0),
|
|
||||||
TextAlign::Left,
|
|
||||||
);
|
|
||||||
|
|
||||||
if play_resp.hovered || card_resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if card_resp.right_clicked {
|
|
||||||
let pos = ctx
|
|
||||||
.input
|
|
||||||
.pointer_pos
|
|
||||||
.unwrap_or(Pos2::new(card_r.center_x(), card_r.bottom()));
|
|
||||||
shell.open_entity_menu(EntityContextMenuState {
|
|
||||||
kind: "album".into(),
|
|
||||||
id: alb.id.clone(),
|
|
||||||
title: alb.title.clone(),
|
|
||||||
subtitle: sub,
|
|
||||||
cover_uri: alb.cover_uri.clone(),
|
|
||||||
owner_uid: None,
|
|
||||||
is_own_playlist: false,
|
|
||||||
tracks: Vec::new(),
|
|
||||||
anchor: pos,
|
|
||||||
share_url: format!("https://music.yandex.ru/album/{}", alb.id),
|
|
||||||
});
|
|
||||||
} else if play_resp.clicked {
|
|
||||||
actions.push(AppAction::PlayAlbum {
|
|
||||||
id: alb.id.clone(),
|
|
||||||
title: alb.title.clone(),
|
|
||||||
});
|
|
||||||
} else if card_resp.clicked {
|
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
|
||||||
id: alb.id.clone(),
|
|
||||||
title: alb.title.clone(),
|
|
||||||
}));
|
|
||||||
} else if port_resp.clicked {
|
|
||||||
if let Some(first) = alb.artists.first() {
|
|
||||||
actions.push(AppAction::Navigate(Route::Artist {
|
|
||||||
id: first.id.clone(),
|
|
||||||
name: first.name.clone(),
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
actions.push(AppAction::Navigate(Route::Album {
|
|
||||||
id: alb.id.clone(),
|
|
||||||
title: alb.title.clone(),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cx += card_w + gap;
|
|
||||||
}
|
|
||||||
ctx.end_scroll_h(h_id, pal, total_w, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
y + card_h + 34.0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fallback_vibe_pick_tabs(ru: bool) -> Vec<VibePickTab> {
|
|
||||||
let mk = |title: &str, header: &str, seed: &str, hex: &str| VibePickItem {
|
|
||||||
title: title.into(),
|
|
||||||
header: header.into(),
|
|
||||||
seeds: vec![seed.into()],
|
|
||||||
color_hex: Some(hex.into()),
|
|
||||||
background_image_url: None,
|
|
||||||
image_url: None,
|
|
||||||
};
|
|
||||||
if ru {
|
|
||||||
vec![
|
|
||||||
VibePickTab {
|
|
||||||
title: "топ".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Английский", "Моя волна по языку", "language:english", "#3F68F9"),
|
|
||||||
mk("Электроника", "Моя волна по жанру", "genre:electronics", "#8341EF"),
|
|
||||||
mk("Бодрое", "Моя волна по настроению", "mood:energetic", "#FF5C4D"),
|
|
||||||
mk("Для работы", "Моя волна по занятию", "activity:work", "#0D9488"),
|
|
||||||
mk("Незнакомое", "Моя волна по характеру", "diversity:discover", "#D97706"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "по языку".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Английский", "Моя волна по языку", "language:english", "#3F68F9"),
|
|
||||||
mk("Русский", "Моя волна по языку", "language:russian", "#E11D48"),
|
|
||||||
mk("Без слов", "Моя волна по языку", "language:without-words", "#0F766E"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "по жанру".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Электроника", "Моя волна по жанру", "genre:electronics", "#7C3AED"),
|
|
||||||
mk("Хип-хоп", "Моя волна по жанру", "genre:hiphop", "#EA580C"),
|
|
||||||
mk("Рок", "Моя волна по жанру", "genre:rock", "#DC2626"),
|
|
||||||
mk("Поп", "Моя волна по жанру", "genre:pop", "#DB2777"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "по настроению".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Бодрое", "Моя волна по настроению", "mood:energetic", "#F97316"),
|
|
||||||
mk("Спокойное", "Моя волна по настроению", "mood:calm", "#2563EB"),
|
|
||||||
mk("Весёлое", "Моя волна по настроению", "mood:fun", "#EAB308"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "по занятию".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Для работы", "Моя волна по занятию", "activity:work", "#0D9488"),
|
|
||||||
mk("Тренировка", "Моя волна по занятию", "activity:workout", "#E11D48"),
|
|
||||||
mk("В дорогу", "Моя волна по занятию", "activity:road-trip", "#4F46E5"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "по характеру".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Незнакомое", "Моя волна по характеру", "diversity:discover", "#8B5CF6"),
|
|
||||||
mk("Любимое", "Моя волна по характеру", "diversity:favorite", "#EC4899"),
|
|
||||||
mk("Популярное", "Моя волна по характеру", "diversity:popular", "#059669"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
vec![
|
|
||||||
VibePickTab {
|
|
||||||
title: "top".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("English", "My Vibe by language", "language:english", "#3F68F9"),
|
|
||||||
mk("Electronic", "My Vibe by genre", "genre:electronics", "#8341EF"),
|
|
||||||
mk("Energetic", "My Vibe by mood", "mood:energetic", "#FF5C4D"),
|
|
||||||
mk("Focus & Work", "My Vibe by activity", "activity:work", "#0D9488"),
|
|
||||||
mk("Discover", "My Vibe by character", "diversity:discover", "#D97706"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "by language".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("English", "My Vibe by language", "language:english", "#3F68F9"),
|
|
||||||
mk("Russian", "My Vibe by language", "language:russian", "#E11D48"),
|
|
||||||
mk("Instrumental", "My Vibe by language", "language:without-words", "#0F766E"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "by genre".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Electronic", "My Vibe by genre", "genre:electronics", "#7C3AED"),
|
|
||||||
mk("Hip-Hop", "My Vibe by genre", "genre:hiphop", "#EA580C"),
|
|
||||||
mk("Rock", "My Vibe by genre", "genre:rock", "#DC2626"),
|
|
||||||
mk("Pop", "My Vibe by genre", "genre:pop", "#DB2777"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "by mood".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Energetic", "My Vibe by mood", "mood:energetic", "#F97316"),
|
|
||||||
mk("Calm", "My Vibe by mood", "mood:calm", "#2563EB"),
|
|
||||||
mk("Upbeat", "My Vibe by mood", "mood:fun", "#EAB308"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "by activity".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Work", "My Vibe by activity", "activity:work", "#0D9488"),
|
|
||||||
mk("Workout", "My Vibe by activity", "activity:workout", "#E11D48"),
|
|
||||||
mk("Road trip", "My Vibe by activity", "activity:road-trip", "#4F46E5"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "by character".into(),
|
|
||||||
items: vec![
|
|
||||||
mk("Discover", "My Vibe by character", "diversity:discover", "#8B5CF6"),
|
|
||||||
mk("Favorites", "My Vibe by character", "diversity:favorite", "#EC4899"),
|
|
||||||
mk("Popular", "My Vibe by character", "diversity:popular", "#059669"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
fn render_more_picks_section(
|
|
||||||
ctx: &mut UiContext,
|
|
||||||
pal: &YmPalette,
|
|
||||||
app: &AppState,
|
|
||||||
viewport: Rect,
|
|
||||||
x: f32,
|
|
||||||
mut y: f32,
|
|
||||||
avail_w: f32,
|
|
||||||
actions: &mut Vec<AppAction>,
|
|
||||||
) -> f32 {
|
|
||||||
let ru = app.i18n().is_ru();
|
|
||||||
let tabs: Vec<VibePickTab> = if !app.landing.vibe_pick_tabs.is_empty() {
|
|
||||||
app.landing.vibe_pick_tabs.clone()
|
|
||||||
} else {
|
|
||||||
fallback_vibe_pick_tabs(ru)
|
|
||||||
};
|
|
||||||
if tabs.is_empty() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
if ru { "Ещё подборки" } else { "More Picks" },
|
|
||||||
TextStyle::headline(24.0, pal.text_primary),
|
TextStyle::headline(24.0, pal.text_primary),
|
||||||
Rect::from_xywh(x, y, avail_w, 30.0),
|
Rect::from_xywh(x, y, avail_w, 30.0),
|
||||||
TextAlign::Left,
|
TextAlign::Left,
|
||||||
);
|
);
|
||||||
y += 40.0;
|
y += 40.0;
|
||||||
|
|
||||||
let active_idx = FOR_YOU_PICKS_TAB.with(|c| c.get()).min(tabs.len() - 1);
|
let card_w = 164.0;
|
||||||
|
let card_h = card_w + 54.0;
|
||||||
// Horizontal category filter tabs (`32px` active pill, clean secondary text inactive)
|
|
||||||
let tabs_vp = Rect::from_xywh(x, y, avail_w, 34.0);
|
|
||||||
let tabs_h_id = WidgetId::new("fy_picks_tabs_hscroll");
|
|
||||||
let tabs_sx = ctx.begin_scroll_h(tabs_h_id, tabs_vp, 0.0);
|
|
||||||
let mut tx = x - tabs_sx;
|
|
||||||
for (idx, tab) in tabs.iter().enumerate() {
|
|
||||||
let is_act = idx == active_idx;
|
|
||||||
let style = TextStyle::medium(
|
|
||||||
14.0,
|
|
||||||
if is_act { pal.text_bright } else { pal.text_secondary },
|
|
||||||
);
|
|
||||||
let tw = ctx.measure_text(&tab.title, style, None).x + 24.0;
|
|
||||||
let tr = Rect::from_xywh(tx, y, tw.max(52.0), 32.0);
|
|
||||||
let resp = ctx.interact(WidgetId::from_pair("fy_pick_tab", idx), tr);
|
|
||||||
if is_act {
|
|
||||||
ctx.dl().push_rect(tr, 16.0, pal.surface_hover);
|
|
||||||
} else if resp.hovered {
|
|
||||||
ctx.dl().push_rect(tr, 16.0, pal.surface_secondary);
|
|
||||||
}
|
|
||||||
ctx.draw_text_ellipsis(
|
|
||||||
&tab.title,
|
|
||||||
TextStyle::medium(
|
|
||||||
14.0,
|
|
||||||
if is_act || resp.hovered {
|
|
||||||
pal.text_bright
|
|
||||||
} else {
|
|
||||||
pal.text_secondary
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tr,
|
|
||||||
TextAlign::Center,
|
|
||||||
);
|
|
||||||
if resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if resp.clicked {
|
|
||||||
FOR_YOU_PICKS_TAB.with(|c| c.set(idx));
|
|
||||||
}
|
|
||||||
tx = tr.right() + 8.0;
|
|
||||||
}
|
|
||||||
ctx.end_scroll_h(tabs_h_id, pal, (tx + tabs_sx) - x, false);
|
|
||||||
y += 46.0;
|
|
||||||
|
|
||||||
// Vibrant gradient-tinted glossy Vibe-Station cards (`260x70`, `radius: 16px`)
|
|
||||||
const CURATED_PALETTE: &[Color] = &[
|
|
||||||
Color::rgb(0x3F, 0x68, 0xF9),
|
|
||||||
Color::rgb(0x83, 0x41, 0xEF),
|
|
||||||
Color::rgb(0xE1, 0x3A, 0x52),
|
|
||||||
Color::rgb(0x0D, 0x94, 0x88),
|
|
||||||
Color::rgb(0xD9, 0x77, 0x06),
|
|
||||||
Color::rgb(0xDB, 0x27, 0x77),
|
|
||||||
];
|
|
||||||
|
|
||||||
let card_w = 260.0_f32;
|
|
||||||
let card_h = 70.0_f32;
|
|
||||||
let gap = 14.0_f32;
|
|
||||||
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
let row_vp = Rect::from_xywh(x, y, avail_w, card_h);
|
||||||
let items = &tabs[active_idx].items;
|
let h_id = WidgetId::new(salt);
|
||||||
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 h_id = WidgetId::from_pair("fy_picks_cards", active_idx);
|
|
||||||
let sx = ctx.begin_scroll_h(h_id, row_vp, 0.0);
|
|
||||||
let mut cx = x - sx;
|
|
||||||
for (idx, item) in items.iter().enumerate() {
|
|
||||||
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
|
||||||
if cr.right() >= row_vp.left() - 60.0 && cr.left() <= row_vp.right() + 60.0 {
|
|
||||||
let resp = ctx.interact(WidgetId::from_pair("fy_pick_card", (active_idx, idx)), cr);
|
|
||||||
let base_c = item
|
|
||||||
.color_hex
|
|
||||||
.as_deref()
|
|
||||||
.and_then(Color::from_hex_str)
|
|
||||||
.unwrap_or(CURATED_PALETTE[idx % CURATED_PALETTE.len()]);
|
|
||||||
let c_left = base_c.lerp(Color::BLACK, if resp.hovered { 0.14 } else { 0.24 });
|
|
||||||
let c_right = base_c.lerp(Color::BLACK, if resp.hovered { 0.36 } else { 0.48 });
|
|
||||||
ctx.dl()
|
|
||||||
.push_gradient_rect(cr, 16.0, c_left, c_right, Vec2::new(1.0, 0.4));
|
|
||||||
// Subtle glossy top sheen
|
|
||||||
ctx.dl().push_gradient_rect(
|
|
||||||
Rect::from_xywh(cr.left(), cr.top(), cr.width(), cr.height() * 0.48),
|
|
||||||
CornerRadii::top(16.0),
|
|
||||||
css_rgba(255, 255, 255, if resp.hovered { 42 } else { 28 }),
|
|
||||||
css_rgba(255, 255, 255, 0),
|
|
||||||
Vec2::new(0.0, 1.0),
|
|
||||||
);
|
|
||||||
ctx.dl().push_rect_bordered(
|
|
||||||
cr,
|
|
||||||
16.0,
|
|
||||||
Color::TRANSPARENT,
|
|
||||||
1.0,
|
|
||||||
css_rgba(255, 255, 255, 28),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Eyebrow ("Моя волна по языку" / "My Vibe by language")
|
let releases = app.landing.new_releases.clone();
|
||||||
if !item.header.is_empty() {
|
let mut cx = x - scroll_x;
|
||||||
ctx.draw_text_ellipsis(
|
for alb in &releases {
|
||||||
&item.header,
|
let cr = Rect::from_xywh(cx, y, card_w, card_h);
|
||||||
TextStyle::medium(12.0, css_rgba(255, 255, 255, 196)),
|
if cr.right() >= row_vp.left() - 20.0 && cr.left() <= row_vp.right() + 20.0 {
|
||||||
Rect::from_xywh(cr.left() + 14.0, cr.top() + 13.0, cr.width() - 28.0, 16.0),
|
let art = alb
|
||||||
TextAlign::Center,
|
.artists
|
||||||
);
|
.first()
|
||||||
}
|
.map(|a| a.name.as_str())
|
||||||
|
.unwrap_or(t.album());
|
||||||
// Centered bold white `▶` + station title (`17px` Headline)
|
let m = media_card(
|
||||||
let title_style = TextStyle::headline(17.0, Color::WHITE);
|
ctx,
|
||||||
let tw = ctx
|
pal,
|
||||||
.measure_text(&item.title, title_style, None)
|
covers,
|
||||||
.x
|
WidgetId::from_pair(salt, &alb.id),
|
||||||
.min(cr.width() - 52.0);
|
cr,
|
||||||
let inner_w = 16.0 + 6.0 + tw;
|
&alb.title,
|
||||||
let tx_start = cr.center_x() - inner_w * 0.5;
|
art,
|
||||||
let row_y = if item.header.is_empty() {
|
alb.cover_uri.as_deref(),
|
||||||
cr.center_y()
|
&format!("alb_{}", alb.id),
|
||||||
} else {
|
false,
|
||||||
cr.top() + 45.0
|
false,
|
||||||
};
|
);
|
||||||
ctx.draw_icon(
|
if m.play_clicked {
|
||||||
Icon::PlayFilledXs,
|
actions.push(AppAction::PlayAlbum {
|
||||||
Rect::from_center_size(Pos2::new(tx_start + 8.0, row_y), Vec2::splat(14.0)),
|
id: alb.id.clone(),
|
||||||
Color::WHITE,
|
title: alb.title.clone(),
|
||||||
);
|
});
|
||||||
ctx.draw_text_ellipsis(
|
} else if m.clicked {
|
||||||
&item.title,
|
actions.push(AppAction::Navigate(Route::Album {
|
||||||
title_style,
|
id: alb.id.clone(),
|
||||||
Rect::from_xywh(tx_start + 22.0, row_y - 11.0, tw + 4.0, 22.0),
|
title: alb.title.clone(),
|
||||||
TextAlign::Left,
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
if resp.hovered {
|
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
|
||||||
}
|
|
||||||
if resp.clicked && !item.seeds.is_empty() {
|
|
||||||
actions.push(AppAction::StartVibeBySeeds {
|
|
||||||
title: item.title.clone(),
|
|
||||||
seeds: item.seeds.clone(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cx += card_w + gap;
|
|
||||||
}
|
}
|
||||||
ctx.end_scroll_h(h_id, pal, items.len() as f32 * (card_w + gap), false);
|
cx += card_w + 16.0;
|
||||||
}
|
}
|
||||||
|
let total_w = (releases.len() as f32) * (card_w + 16.0);
|
||||||
|
ctx.end_scroll_h(h_id, pal, total_w, false);
|
||||||
y + card_h + 26.0
|
y + card_h + 26.0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
194
src/views/mod.rs
|
|
@ -4,7 +4,6 @@ pub mod for_you;
|
||||||
pub mod my_vibe;
|
pub mod my_vibe;
|
||||||
pub mod overlays;
|
pub mod overlays;
|
||||||
pub mod player_bar;
|
pub mod player_bar;
|
||||||
pub mod player_thumbs;
|
|
||||||
pub mod podcasts_kids;
|
pub mod podcasts_kids;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
|
|
@ -24,10 +23,9 @@ use crate::vulkan::vibe_renderer::VibePushConstants;
|
||||||
|
|
||||||
use overlays::{
|
use overlays::{
|
||||||
render_delete_playlist_confirm_modal, render_entity_context_menu, render_eq_popover,
|
render_delete_playlist_confirm_modal, render_entity_context_menu, render_eq_popover,
|
||||||
render_equalizer_modal, render_fullscreen_player, render_login_modal, render_playlist_modal,
|
render_fullscreen_player, render_login_modal, render_playlist_modal, render_right_drawer,
|
||||||
render_release_notes_modal, render_right_drawer, render_shortcuts_modal,
|
render_toast, render_track_context_menu, render_track_detail_modal, render_vibe_settings_modal,
|
||||||
render_toast_with_offset, render_track_context_menu, render_track_detail_modal,
|
ShellUiState, SplashPlayer,
|
||||||
render_update_notification, render_vibe_settings_modal, ShellUiState, SplashPlayer,
|
|
||||||
};
|
};
|
||||||
use player_bar::render_player_bar;
|
use player_bar::render_player_bar;
|
||||||
use sidebar::render_sidebar;
|
use sidebar::render_sidebar;
|
||||||
|
|
@ -248,46 +246,9 @@ impl YandexMusicShell {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route transition (0.20s ease-out upward glide + dissolve; 0 overhead when steady or deterministic test!)
|
// 3. Optional Right Slide-Over Drawer (Queue / Sync Lyrics; hidden when Fullscreen is open)
|
||||||
if self.app.fixed_vibe_time.is_none()
|
|
||||||
&& self.shell.last_route.as_ref() != Some(&self.app.route)
|
|
||||||
{
|
|
||||||
if self.shell.last_route.is_some() {
|
|
||||||
self.shell.route_transition_start = time;
|
|
||||||
}
|
|
||||||
self.shell.last_route = Some(self.app.route.clone());
|
|
||||||
}
|
|
||||||
let route_t = if self.app.fixed_vibe_time.is_some() || self.shell.route_transition_start <= 0.0
|
|
||||||
{
|
|
||||||
1.0f32
|
|
||||||
} else {
|
|
||||||
((time - self.shell.route_transition_start) as f32 / 0.20).clamp(0.0, 1.0)
|
|
||||||
};
|
|
||||||
if route_t < 1.0 {
|
|
||||||
self.ui.request_repaint();
|
|
||||||
}
|
|
||||||
let route_ease = {
|
|
||||||
let u = 1.0 - route_t;
|
|
||||||
1.0 - u * u * u
|
|
||||||
};
|
|
||||||
let page_dy = if route_t < 1.0 {
|
|
||||||
((1.0 - route_ease) * 14.0).round()
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
// 3. Optional Right Slide-Over Drawer (smooth 0.22s slide-in/out; instant in deterministic test!)
|
|
||||||
let show_side_drawer =
|
let show_side_drawer =
|
||||||
self.app.right_drawer != RightDrawerTab::None && !self.app.fullscreen_open;
|
self.app.right_drawer != RightDrawerTab::None && !self.app.fullscreen_open;
|
||||||
let drawer_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if show_side_drawer { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
self.ui.animate_bool(WidgetId::new("ym_right_drawer_anim"), show_side_drawer, 0.22)
|
|
||||||
};
|
|
||||||
let drawer_ease = {
|
|
||||||
let u = 1.0 - drawer_t.clamp(0.0, 1.0);
|
|
||||||
1.0 - u * u * u
|
|
||||||
};
|
|
||||||
let content_bottom = if is_my_vibe_page {
|
let content_bottom = if is_my_vibe_page {
|
||||||
screen.bottom()
|
screen.bottom()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -295,14 +256,13 @@ impl YandexMusicShell {
|
||||||
};
|
};
|
||||||
let drawer_w = 332.0;
|
let drawer_w = 332.0;
|
||||||
let content_top = screen.top() + TITLEBAR_HEIGHT + 1.0;
|
let content_top = screen.top() + TITLEBAR_HEIGHT + 1.0;
|
||||||
let drawer_shift = drawer_ease * (drawer_w + LAYOUT_GAP);
|
|
||||||
let drawer_rect = Rect::from_xywh(
|
let drawer_rect = Rect::from_xywh(
|
||||||
screen.right() - drawer_shift,
|
screen.right() - drawer_w - LAYOUT_GAP,
|
||||||
content_top,
|
content_top,
|
||||||
drawer_w,
|
drawer_w,
|
||||||
(content_bottom - content_top).max(40.0),
|
(content_bottom - content_top).max(40.0),
|
||||||
);
|
);
|
||||||
if drawer_ease > 0.01 {
|
if show_side_drawer {
|
||||||
render_right_drawer(
|
render_right_drawer(
|
||||||
&mut self.ui,
|
&mut self.ui,
|
||||||
&pal,
|
&pal,
|
||||||
|
|
@ -319,7 +279,7 @@ impl YandexMusicShell {
|
||||||
let vibe_rect = Rect::from_xywh(
|
let vibe_rect = Rect::from_xywh(
|
||||||
nav_w,
|
nav_w,
|
||||||
screen.top(),
|
screen.top(),
|
||||||
(screen.width() - nav_w - if drawer_ease > 0.01 { drawer_shift + LAYOUT_GAP } else { 0.0 })
|
(screen.width() - nav_w - if show_side_drawer { drawer_w + LAYOUT_GAP * 2.0 } else { 0.0 })
|
||||||
.max(100.0),
|
.max(100.0),
|
||||||
screen.height(),
|
screen.height(),
|
||||||
);
|
);
|
||||||
|
|
@ -332,15 +292,8 @@ impl YandexMusicShell {
|
||||||
vibe_rect,
|
vibe_rect,
|
||||||
&mut actions,
|
&mut actions,
|
||||||
);
|
);
|
||||||
if route_t < 1.0 {
|
|
||||||
self.ui.dl().push_rect(
|
|
||||||
vibe_rect,
|
|
||||||
0.0,
|
|
||||||
pal.bg_basic.with_alpha_f32((1.0 - route_ease) * 0.55),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let content_right = if drawer_ease > 0.01 {
|
let content_right = if show_side_drawer {
|
||||||
drawer_rect.left() - LAYOUT_GAP
|
drawer_rect.left() - LAYOUT_GAP
|
||||||
} else {
|
} else {
|
||||||
screen.right() - LAYOUT_GAP
|
screen.right() - LAYOUT_GAP
|
||||||
|
|
@ -390,13 +343,7 @@ impl YandexMusicShell {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Exact inner content rect (+25px horizontal, +12px top so inner y stays 45.0 with +1px card_top)
|
// Exact inner content rect (+25px horizontal, +12px top so inner y stays 45.0 with +1px card_top)
|
||||||
let base_inner_r = outer_r.inset(25.0, 12.0, 25.0, 0.0);
|
let inner_r = outer_r.inset(25.0, 12.0, 25.0, 0.0);
|
||||||
let inner_r = Rect::from_xywh(
|
|
||||||
base_inner_r.left(),
|
|
||||||
base_inner_r.top() + page_dy,
|
|
||||||
base_inner_r.width(),
|
|
||||||
base_inner_r.height(),
|
|
||||||
);
|
|
||||||
self.ui.push_clip(outer_r, CONTENT_RADIUS);
|
self.ui.push_clip(outer_r, CONTENT_RADIUS);
|
||||||
match self.app.route.clone() {
|
match self.app.route.clone() {
|
||||||
Route::MyVibe => {}
|
Route::MyVibe => {}
|
||||||
|
|
@ -503,32 +450,11 @@ impl YandexMusicShell {
|
||||||
&mut actions,
|
&mut actions,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
if route_t < 1.0 {
|
|
||||||
self.ui.dl().push_rect(
|
|
||||||
outer_r,
|
|
||||||
CONTENT_RADIUS,
|
|
||||||
pal.bg_content.with_alpha_f32((1.0 - route_ease) * 0.65),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
self.ui.pop_clip();
|
self.ui.pop_clip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. FullscreenPlayerDesktop (ZLayer::Drawer — smooth 0.24s glide-up/down!)
|
// 5. FullscreenPlayerDesktop (ZLayer::Drawer — sits below Popovers/Modals/Titlebar!)
|
||||||
let fs_t = if self.app.fixed_vibe_time.is_some() {
|
if self.app.fullscreen_open {
|
||||||
if self.app.fullscreen_open { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
self.ui.animate_bool(WidgetId::new("ym_fullscreen_anim"), self.app.fullscreen_open, 0.24)
|
|
||||||
};
|
|
||||||
let fs_ease = {
|
|
||||||
let u = 1.0 - fs_t.clamp(0.0, 1.0);
|
|
||||||
1.0 - u * u * u
|
|
||||||
};
|
|
||||||
self.shell.fs_slide_dy = if fs_ease < 0.999 {
|
|
||||||
((1.0 - fs_ease) * 48.0).round()
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
};
|
|
||||||
if fs_ease > 0.01 {
|
|
||||||
render_fullscreen_player(
|
render_fullscreen_player(
|
||||||
&mut self.ui,
|
&mut self.ui,
|
||||||
&pal,
|
&pal,
|
||||||
|
|
@ -540,38 +466,8 @@ impl YandexMusicShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Floating Popovers & Context Menus (ZLayer::Popover)
|
// 6. Floating Popovers & Context Menus (ZLayer::Popover)
|
||||||
let ease_out = |t: f32| -> f32 {
|
if self.app.eq_popover_open {
|
||||||
let u = 1.0 - t.clamp(0.0, 1.0);
|
render_eq_popover(&mut self.ui, &pal, &self.app, &mut actions);
|
||||||
1.0 - u * u * u
|
|
||||||
};
|
|
||||||
let eq_pop_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if self.app.eq_popover_open { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
ease_out(self.ui.animate_bool(
|
|
||||||
WidgetId::new("ym_quality_popover_anim"),
|
|
||||||
self.app.eq_popover_open,
|
|
||||||
0.22,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
let eq_expand_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if self.app.config.eq_enabled { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
self.ui.animate_bool(
|
|
||||||
WidgetId::new("ym_quality_eq_expand"),
|
|
||||||
self.app.config.eq_enabled,
|
|
||||||
0.20,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
if eq_pop_t > 0.01 {
|
|
||||||
render_eq_popover(
|
|
||||||
&mut self.ui,
|
|
||||||
&pal,
|
|
||||||
&self.app,
|
|
||||||
&mut self.shell,
|
|
||||||
eq_pop_t,
|
|
||||||
eq_expand_t,
|
|
||||||
&mut actions,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
render_track_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions);
|
render_track_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions);
|
||||||
render_entity_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions);
|
render_entity_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions);
|
||||||
|
|
@ -594,49 +490,6 @@ impl YandexMusicShell {
|
||||||
if self.app.track_detail_modal.is_some() {
|
if self.app.track_detail_modal.is_some() {
|
||||||
render_track_detail_modal(&mut self.ui, &pal, &mut self.covers, &self.app, &mut actions);
|
render_track_detail_modal(&mut self.ui, &pal, &mut self.covers, &self.app, &mut actions);
|
||||||
}
|
}
|
||||||
let rn_mod_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if self.app.release_notes_modal_open { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
ease_out(self.ui.animate_bool(
|
|
||||||
WidgetId::new("ym_release_notes_modal_anim"),
|
|
||||||
self.app.release_notes_modal_open,
|
|
||||||
0.18,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
if rn_mod_t > 0.01 {
|
|
||||||
render_release_notes_modal(&mut self.ui, &pal, &self.app, rn_mod_t, &mut actions);
|
|
||||||
}
|
|
||||||
let eq_mod_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if self.app.equalizer_modal_open { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
ease_out(self.ui.animate_bool(
|
|
||||||
WidgetId::new("ym_eq_modal_anim"),
|
|
||||||
self.app.equalizer_modal_open,
|
|
||||||
0.18,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
if eq_mod_t > 0.01 {
|
|
||||||
render_equalizer_modal(
|
|
||||||
&mut self.ui,
|
|
||||||
&pal,
|
|
||||||
&self.app,
|
|
||||||
&mut self.shell,
|
|
||||||
eq_mod_t,
|
|
||||||
&mut actions,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let sc_mod_t = if self.app.fixed_vibe_time.is_some() {
|
|
||||||
if self.app.shortcuts_modal_open { 1.0 } else { 0.0 }
|
|
||||||
} else {
|
|
||||||
ease_out(self.ui.animate_bool(
|
|
||||||
WidgetId::new("ym_shortcuts_modal_anim"),
|
|
||||||
self.app.shortcuts_modal_open,
|
|
||||||
0.18,
|
|
||||||
))
|
|
||||||
};
|
|
||||||
if sc_mod_t > 0.01 {
|
|
||||||
render_shortcuts_modal(&mut self.ui, &pal, &self.app, sc_mod_t, &mut actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 8. Transparent 32px Floating TitleBar (ZLayer::Titlebar)
|
// 8. Transparent 32px Floating TitleBar (ZLayer::Titlebar)
|
||||||
let win_cmd = render_titlebar(
|
let win_cmd = render_titlebar(
|
||||||
|
|
@ -647,20 +500,10 @@ impl YandexMusicShell {
|
||||||
self.app.fullscreen_open,
|
self.app.fullscreen_open,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 9. Official `NotificationUpdate` + Floating Toast (when splash is done)
|
// 9. Floating Toast (when splash is done)
|
||||||
let show_upd_notif = self.splash.is_none()
|
|
||||||
&& !self.app.fullscreen_open
|
|
||||||
&& !self.app.update_notification_dismissed
|
|
||||||
&& self.app.available_update.is_some();
|
|
||||||
if show_upd_notif {
|
|
||||||
if let Some(ref upd) = self.app.available_update {
|
|
||||||
render_update_notification(&mut self.ui, &pal, &self.app, upd, &mut actions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if self.splash.is_none() {
|
if self.splash.is_none() {
|
||||||
if let Some(msg) = self.app.current_toast().map(String::from) {
|
if let Some(msg) = self.app.current_toast().map(String::from) {
|
||||||
let extra_offset = if show_upd_notif { 64.0 } else { 0.0 };
|
render_toast(&mut self.ui, &pal, &msg);
|
||||||
render_toast_with_offset(&mut self.ui, &pal, &msg, extra_offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,16 +515,9 @@ impl YandexMusicShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch all actions emitted during this frame
|
// Dispatch all actions emitted during this frame
|
||||||
let had_actions = !actions.is_empty();
|
|
||||||
for act in actions {
|
for act in actions {
|
||||||
self.app.dispatch(act);
|
self.app.dispatch(act);
|
||||||
}
|
}
|
||||||
// Any dispatched UI action may open/close a popover, modal, or start an animation
|
|
||||||
// that wasn't evaluated yet this frame — schedule an immediate follow-up frame so
|
|
||||||
// 0 FPS idle mode never stalls opening a menu until the next mouse move.
|
|
||||||
if had_actions {
|
|
||||||
self.ui.request_repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush any clipboard write requested by Share > Copy link / HTML code
|
// Flush any clipboard write requested by Share > Copy link / HTML code
|
||||||
if let Some(clip_text) = self.app.take_pending_clipboard_text() {
|
if let Some(clip_text) = self.app.take_pending_clipboard_text() {
|
||||||
|
|
|
||||||
1004
src/views/my_vibe.rs
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::api::models::format_ms;
|
use crate::api::models::format_ms;
|
||||||
use crate::app::{AppAction, AppState, RepeatMode, Route};
|
use crate::app::{AppAction, AppState, RepeatMode, Route};
|
||||||
use crate::config::PlayerThumbStyle;
|
|
||||||
use crate::covers::CoverCache;
|
use crate::covers::CoverCache;
|
||||||
use crate::engine::widgets::{draw_cover_art, separated_artists, ym_volume_capsule};
|
use crate::engine::widgets::{draw_cover_art, separated_artists, ym_volume_capsule};
|
||||||
use crate::engine::{
|
use crate::engine::{
|
||||||
|
|
@ -9,7 +8,6 @@ use crate::engine::{
|
||||||
};
|
};
|
||||||
use crate::icons::Icon;
|
use crate::icons::Icon;
|
||||||
use crate::views::overlays::ShellUiState;
|
use crate::views::overlays::ShellUiState;
|
||||||
use crate::views::player_thumbs::render_player_bar_companion;
|
|
||||||
|
|
||||||
/// Exact Yandex Music Desktop 5.129.0 Bottom PlayerBar (`PlayerBarDesktopWithBackgroundProgressBar`):
|
/// Exact Yandex Music Desktop 5.129.0 Bottom PlayerBar (`PlayerBarDesktopWithBackgroundProgressBar`):
|
||||||
/// - Exact 80px height, `hsl(h, s%, 20%)` track-derived bg (or `pal.bg_player`) in BOTH themes
|
/// - Exact 80px height, `hsl(h, s%, 20%)` track-derived bg (or `pal.bg_player`) in BOTH themes
|
||||||
|
|
@ -88,13 +86,11 @@ pub fn render_player_bar(
|
||||||
|
|
||||||
ctx.dl().push_rect(rect, 12.0, base_bg);
|
ctx.dl().push_rect(rect, 12.0, base_bg);
|
||||||
|
|
||||||
// 2. Top-edge progress bar (Standard hover yellow bar OR live animated Duck/Car/Claudik/Antigravity/Ferris/Nyan companion!)
|
// 2. Top-edge 4px yellow progress bar + 12px thumb + hover timecode pills
|
||||||
let thumb_style = app.config.player_thumb;
|
let bar_hover_zone = rect.expand2(Vec2::new(0.0, 6.0));
|
||||||
let is_custom_thumb = thumb_style != PlayerThumbStyle::Standard;
|
|
||||||
let bar_hover_zone = rect.expand2(Vec2::new(0.0, if is_custom_thumb { 20.0 } else { 6.0 }));
|
|
||||||
let bar_hovered = ctx.is_hovered(bar_hover_zone);
|
let bar_hovered = ctx.is_hovered(bar_hover_zone);
|
||||||
let scrub_zone = Rect::from_min_max(
|
let scrub_zone = Rect::from_min_max(
|
||||||
Pos2::new(rect.left() + 8.0, rect.top() - if is_custom_thumb { 22.0 } else { 6.0 }),
|
Pos2::new(rect.left() + 8.0, rect.top() - 6.0),
|
||||||
Pos2::new(rect.right() - 8.0, rect.top() + 12.0),
|
Pos2::new(rect.right() - 8.0, rect.top() + 12.0),
|
||||||
);
|
);
|
||||||
let scrub_resp = ctx.interact(WidgetId::new("pb_top_scrub"), scrub_zone);
|
let scrub_resp = ctx.interact(WidgetId::new("pb_top_scrub"), scrub_zone);
|
||||||
|
|
@ -140,85 +136,65 @@ pub fn render_player_bar(
|
||||||
scrub_resp.hovered || scrub_resp.pressed || scrub_resp.dragged || shell.pb_scrub_frac.is_some();
|
scrub_resp.hovered || scrub_resp.pressed || scrub_resp.dragged || shell.pb_scrub_frac.is_some();
|
||||||
let hover_t = ctx.animate_bool(WidgetId::new("pb_scrub_hover_anim"), bar_hovered || scrub_active, 0.15);
|
let hover_t = ctx.animate_bool(WidgetId::new("pb_scrub_hover_anim"), bar_hovered || scrub_active, 0.15);
|
||||||
|
|
||||||
// Never draw PlayerBar's `ZLayer::Popover` progress bar/companion on top of FullscreenPlayer (`ZLayer::Drawer`)!
|
if hover_t > 0.01 {
|
||||||
if !app.fullscreen_open && (is_custom_thumb || hover_t > 0.01) {
|
|
||||||
let display_frac = display_progress;
|
let display_frac = display_progress;
|
||||||
|
|
||||||
ctx.with_layer(ZLayer::Popover, |ctx| {
|
ctx.with_layer(ZLayer::Popover, |ctx| {
|
||||||
let bar_y = rect.top() + 2.0;
|
let bar_y = rect.top() + 2.0;
|
||||||
if is_custom_thumb {
|
let bar_r = Rect::from_min_max(
|
||||||
let anim_time = app.fixed_vibe_time.unwrap_or(ctx.input.time as f32);
|
Pos2::new(scrub_zone.left(), bar_y - 2.0),
|
||||||
render_player_bar_companion(
|
Pos2::new(scrub_zone.right(), bar_y + 2.0),
|
||||||
ctx,
|
);
|
||||||
pal,
|
ctx.dl()
|
||||||
thumb_style,
|
.push_rect(bar_r, 2.0, css_rgba(255, 255, 255, (38.0 * hover_t).round() as u8));
|
||||||
scrub_zone.left(),
|
|
||||||
scrub_zone.right(),
|
|
||||||
bar_y,
|
|
||||||
display_frac,
|
|
||||||
is_playing,
|
|
||||||
anim_time,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
let bar_r = Rect::from_min_max(
|
|
||||||
Pos2::new(scrub_zone.left(), bar_y - 2.0),
|
|
||||||
Pos2::new(scrub_zone.right(), bar_y + 2.0),
|
|
||||||
);
|
|
||||||
ctx.dl()
|
|
||||||
.push_rect(bar_r, 2.0, css_rgba(255, 255, 255, (38.0 * hover_t).round() as u8));
|
|
||||||
|
|
||||||
let fill_x = scrub_zone.left() + scrub_zone.width() * display_frac;
|
let fill_x = scrub_zone.left() + scrub_zone.width() * display_frac;
|
||||||
let fill_r = Rect::from_min_max(bar_r.min(), Pos2::new(fill_x, bar_r.bottom()));
|
let fill_r = Rect::from_min_max(bar_r.min(), Pos2::new(fill_x, bar_r.bottom()));
|
||||||
let yellow_a = pal.yellow.with_alpha_f32(hover_t);
|
let yellow_a = pal.yellow.with_alpha_f32(hover_t);
|
||||||
ctx.dl().push_rect(fill_r, 2.0, yellow_a);
|
ctx.dl().push_rect(fill_r, 2.0, yellow_a);
|
||||||
|
|
||||||
// Exact 12px circular yellow thumb (`radius = 6px`)
|
// Exact 12px circular yellow thumb (`radius = 6px`)
|
||||||
ctx.dl()
|
ctx.dl()
|
||||||
.push_circle(Pos2::new(fill_x, bar_y), 6.0 * hover_t, yellow_a);
|
.push_circle(Pos2::new(fill_x, bar_y), 6.0 * hover_t, yellow_a);
|
||||||
}
|
|
||||||
|
|
||||||
if hover_t > 0.01 {
|
// Left & right timecode pills
|
||||||
// Left & right timecode pills (lifted cleanly above custom companions)
|
let cur_ms = (display_frac * duration_ms as f32) as u64;
|
||||||
let cur_ms = (display_frac * duration_ms as f32) as u64;
|
let tc_bg = css_rgba(20, 20, 20, (215.0 * hover_t).round() as u8);
|
||||||
let tc_bg = css_rgba(20, 20, 20, (215.0 * hover_t).round() as u8);
|
let tc_fg = Color::rgb(0xE6, 0xE6, 0xE6).with_alpha_f32(hover_t);
|
||||||
let tc_fg = Color::rgb(0xE6, 0xE6, 0xE6).with_alpha_f32(hover_t);
|
|
||||||
let tc_y = rect.top() - if is_custom_thumb { 36.0 } else { 24.0 };
|
|
||||||
|
|
||||||
let left_tc_r = Rect::from_xywh(rect.left() + 8.0, tc_y, 44.0, 18.0);
|
let left_tc_r = Rect::from_xywh(rect.left() + 8.0, rect.top() - 24.0, 44.0, 18.0);
|
||||||
ctx.dl().push_rect(left_tc_r, 9.0, tc_bg);
|
ctx.dl().push_rect(left_tc_r, 9.0, tc_bg);
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
&format_ms(cur_ms),
|
&format_ms(cur_ms),
|
||||||
TextStyle::medium(11.0, tc_fg),
|
TextStyle::medium(11.0, tc_fg),
|
||||||
left_tc_r,
|
left_tc_r,
|
||||||
TextAlign::Center,
|
TextAlign::Center,
|
||||||
);
|
);
|
||||||
|
|
||||||
let right_tc_r = Rect::from_xywh(rect.right() - 52.0, tc_y, 44.0, 18.0);
|
let right_tc_r = Rect::from_xywh(rect.right() - 52.0, rect.top() - 24.0, 44.0, 18.0);
|
||||||
ctx.dl().push_rect(right_tc_r, 9.0, tc_bg);
|
ctx.dl().push_rect(right_tc_r, 9.0, tc_bg);
|
||||||
ctx.draw_text_ellipsis(
|
ctx.draw_text_ellipsis(
|
||||||
&format_ms(duration_ms),
|
&format_ms(duration_ms),
|
||||||
TextStyle::medium(11.0, tc_fg),
|
TextStyle::medium(11.0, tc_fg),
|
||||||
right_tc_r,
|
right_tc_r,
|
||||||
TextAlign::Center,
|
TextAlign::Center,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Hover seek cursor timecode tooltip
|
// Hover seek cursor timecode tooltip
|
||||||
if scrub_active {
|
if scrub_active {
|
||||||
ctx.set_cursor(CursorKind::Pointer);
|
ctx.set_cursor(CursorKind::Pointer);
|
||||||
if let Some(pos) = ctx.input.pointer_pos {
|
if let Some(pos) = ctx.input.pointer_pos {
|
||||||
let frac = ((pos.x - scrub_zone.left()) / scrub_zone.width().max(1.0)).clamp(0.0, 1.0);
|
let frac = ((pos.x - scrub_zone.left()) / scrub_zone.width().max(1.0)).clamp(0.0, 1.0);
|
||||||
let hover_ms = (frac * duration_ms as f32) as u64;
|
let hover_ms = (frac * duration_ms as f32) as u64;
|
||||||
let tip_x = pos.x.clamp(rect.left() + 78.0, (rect.right() - 78.0).max(rect.left() + 78.0));
|
let tip_x = pos.x.clamp(rect.left() + 78.0, (rect.right() - 78.0).max(rect.left() + 78.0));
|
||||||
let tip_y = rect.top() - if is_custom_thumb { 32.0 } else { 18.0 };
|
let tip_r = Rect::from_center_size(Pos2::new(tip_x, rect.top() - 18.0), Vec2::new(50.0, 22.0));
|
||||||
let tip_r = Rect::from_center_size(Pos2::new(tip_x, tip_y), Vec2::new(50.0, 22.0));
|
ctx.dl().push_rect(tip_r, 11.0, css_rgba(20, 20, 20, 230));
|
||||||
ctx.dl().push_rect(tip_r, 11.0, css_rgba(20, 20, 20, 230));
|
ctx.draw_text_ellipsis(
|
||||||
ctx.draw_text_ellipsis(
|
&format_ms(hover_ms),
|
||||||
&format_ms(hover_ms),
|
TextStyle::medium(12.0, Color::WHITE),
|
||||||
TextStyle::medium(12.0, Color::WHITE),
|
tip_r,
|
||||||
tip_r,
|
TextAlign::Center,
|
||||||
TextAlign::Center,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -525,7 +501,9 @@ pub fn render_player_bar(
|
||||||
ctx.draw_icon(
|
ctx.draw_icon(
|
||||||
if is_liked { Icon::Liked } else { Icon::Like },
|
if is_liked { Icon::Liked } else { Icon::Like },
|
||||||
Rect::from_center_size(like_r.center(), Vec2::splat(24.0)),
|
Rect::from_center_size(like_r.center(), Vec2::splat(24.0)),
|
||||||
if is_liked || like_resp.hovered {
|
if is_liked {
|
||||||
|
pal.accent_coral
|
||||||
|
} else if like_resp.hovered {
|
||||||
fg_bright
|
fg_bright
|
||||||
} else {
|
} else {
|
||||||
fg_muted
|
fg_muted
|
||||||
|
|
|
||||||
|
|
@ -1,385 +0,0 @@
|
||||||
use crate::config::PlayerThumbStyle;
|
|
||||||
use crate::engine::theme::YmPalette;
|
|
||||||
use crate::engine::types::{Color, Pos2, Rect, Vec2};
|
|
||||||
use crate::engine::{css_rgba, UiContext};
|
|
||||||
use crate::icons::Icon;
|
|
||||||
|
|
||||||
/// Draws the progress trail + live animated companion on the top edge of `PlayerBar`.
|
|
||||||
/// Called only when `style != PlayerThumbStyle::Standard`.
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn render_player_bar_companion(
|
|
||||||
ctx: &mut UiContext,
|
|
||||||
pal: &YmPalette,
|
|
||||||
style: PlayerThumbStyle,
|
|
||||||
bar_left: f32,
|
|
||||||
bar_right: f32,
|
|
||||||
bar_y: f32,
|
|
||||||
progress: f32,
|
|
||||||
playing: bool,
|
|
||||||
time: f32,
|
|
||||||
) {
|
|
||||||
let frac = progress.clamp(0.0, 1.0);
|
|
||||||
let track_w = (bar_right - bar_left).max(1.0);
|
|
||||||
let fill_x = bar_left + track_w * frac;
|
|
||||||
let anim_t = if playing { time } else { 0.0 };
|
|
||||||
|
|
||||||
// Subtle base track along top edge
|
|
||||||
let track_r = Rect::from_xywh(bar_left, bar_y - 1.5, track_w, 3.0);
|
|
||||||
ctx.dl().push_rect(track_r, 1.5, css_rgba(255, 255, 255, 34));
|
|
||||||
|
|
||||||
// Themed progress trail behind the companion
|
|
||||||
let fill_w = (fill_x - bar_left).max(0.0);
|
|
||||||
if fill_w > 1.0 {
|
|
||||||
match style {
|
|
||||||
PlayerThumbStyle::Standard => {}
|
|
||||||
PlayerThumbStyle::Duck => {
|
|
||||||
ctx.dl()
|
|
||||||
.push_rect(Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, pal.yellow);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Car => {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0),
|
|
||||||
1.5,
|
|
||||||
Color::rgb(0xE8, 0x22, 0x38),
|
|
||||||
);
|
|
||||||
// Tiny drifting exhaust puffs while driving
|
|
||||||
if playing && fill_w > 48.0 {
|
|
||||||
for k in 0..3 {
|
|
||||||
let phase = ((anim_t * 2.4 + k as f32 * 0.33) % 1.0).clamp(0.0, 1.0);
|
|
||||||
let px = fill_x - 30.0 - phase * 24.0;
|
|
||||||
let py = bar_y - 5.0 - phase * 6.0;
|
|
||||||
let a = ((1.0 - phase) * 90.0).round() as u8;
|
|
||||||
if px > bar_left {
|
|
||||||
ctx.dl()
|
|
||||||
.push_circle(Pos2::new(px, py), 2.0 + phase * 2.5, css_rgba(220, 224, 232, a));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Claudik => {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0),
|
|
||||||
1.5,
|
|
||||||
Color::rgb(0xD9, 0x77, 0x57),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Antigravity => {
|
|
||||||
ctx.dl().push_gradient_rect(
|
|
||||||
Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0),
|
|
||||||
1.5,
|
|
||||||
Color::rgb(0x9B, 0x84, 0xEC),
|
|
||||||
Color::rgb(0x52, 0xB6, 0xFF),
|
|
||||||
Vec2::new(1.0, 0.0),
|
|
||||||
);
|
|
||||||
// Twinkling cosmic star dust trailing behind Antigravity
|
|
||||||
let count = ((fill_w / 22.0) as usize).min(6);
|
|
||||||
for k in 0..count {
|
|
||||||
let phase = ((anim_t * 1.6 + k as f32 * 0.27) % 1.0).clamp(0.0, 1.0);
|
|
||||||
let sx = fill_x - 16.0 - k as f32 * 18.0 - phase * 10.0;
|
|
||||||
let sy = bar_y - 6.0 - ((k as f32 * 1.9 + anim_t * 3.0).sin() * 4.5).abs();
|
|
||||||
let twinkle = 0.35 + 0.65 * ((anim_t * 5.0 + k as f32 * 1.7).sin() * 0.5 + 0.5);
|
|
||||||
if sx > bar_left + 4.0 {
|
|
||||||
let col = if k % 2 == 0 {
|
|
||||||
Color::rgb(0x9B, 0x84, 0xEC).scale_alpha(twinkle * 0.85)
|
|
||||||
} else {
|
|
||||||
Color::rgb(0x6C, 0xD4, 0xFF).scale_alpha(twinkle * 0.85)
|
|
||||||
};
|
|
||||||
ctx.dl().push_rect(Rect::from_xywh(sx.round(), sy.round(), 2.0, 2.0), 0.0, col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Ferris => {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0),
|
|
||||||
1.5,
|
|
||||||
Color::rgb(0xF7, 0x4C, 0x00),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Nyan => {
|
|
||||||
// Classic 6-stripe waving pixel rainbow trail!
|
|
||||||
let stripes = [
|
|
||||||
Color::rgb(0xFF, 0x26, 0x26),
|
|
||||||
Color::rgb(0xFF, 0x99, 0x00),
|
|
||||||
Color::rgb(0xFF, 0xEE, 0x00),
|
|
||||||
Color::rgb(0x33, 0xDD, 0x33),
|
|
||||||
Color::rgb(0x1E, 0x9E, 0xFF),
|
|
||||||
Color::rgb(0x7A, 0x44, 0xFF),
|
|
||||||
];
|
|
||||||
let seg_w = 10.0f32;
|
|
||||||
let max_trail = (fill_w - 6.0).max(0.0);
|
|
||||||
let num_segs = (max_trail / seg_w).ceil() as usize;
|
|
||||||
let wave_step = (anim_t * 8.0).floor() as i32;
|
|
||||||
for s in 0..num_segs {
|
|
||||||
let sx = bar_left + s as f32 * seg_w;
|
|
||||||
let sw = (fill_x - 6.0 - sx).min(seg_w);
|
|
||||||
if sw <= 0.5 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let dy = if ((s as i32 + wave_step) & 1) == 0 { -1.0 } else { 1.0 };
|
|
||||||
for (ci, &col) in stripes.iter().enumerate() {
|
|
||||||
let sy = bar_y - 11.0 + ci as f32 * 2.0 + dy;
|
|
||||||
ctx.dl()
|
|
||||||
.push_rect(Rect::from_xywh(sx, sy, sw + 0.5, 2.0), 0.0, col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the companion anchored cleanly at `(fill_x, bar_y)`
|
|
||||||
match style {
|
|
||||||
PlayerThumbStyle::Standard => {}
|
|
||||||
PlayerThumbStyle::Duck => {
|
|
||||||
let bob = if playing { (anim_t * 9.0).sin().abs() * -2.0 } else { 0.0 };
|
|
||||||
let sz = 32.0;
|
|
||||||
let r = Rect::from_xywh(fill_x - sz * 0.5, bar_y - sz + 3.0 + bob, sz, sz);
|
|
||||||
ctx.draw_icon(Icon::ThumbDuck, r, Color::WHITE);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Car => {
|
|
||||||
let vib = if playing { (anim_t * 28.0).sin() * 0.6 } else { 0.0 };
|
|
||||||
let w = 68.0;
|
|
||||||
let h = 21.0;
|
|
||||||
let r = Rect::from_xywh(fill_x - w * 0.52, bar_y - h + 2.0 + vib, w, h);
|
|
||||||
// Warm headlight beam ahead of the car when playing
|
|
||||||
if playing && r.right() < bar_right {
|
|
||||||
let beam_w = (bar_right - r.right()).min(26.0);
|
|
||||||
ctx.dl().push_gradient_rect(
|
|
||||||
Rect::from_xywh(r.right() - 2.0, bar_y - 10.0 + vib, beam_w, 8.0),
|
|
||||||
2.0,
|
|
||||||
css_rgba(255, 240, 160, 95),
|
|
||||||
css_rgba(255, 240, 160, 0),
|
|
||||||
Vec2::new(1.0, 0.0),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ctx.draw_icon(Icon::ThumbCar, r, Color::WHITE);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Claudik => {
|
|
||||||
let step = if playing { ((anim_t * 7.0).floor() as u32) & 1 } else { 0 };
|
|
||||||
let bob = if playing && step == 1 { -1.5 } else { 0.0 };
|
|
||||||
draw_claudik_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.5, step == 1);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Antigravity => {
|
|
||||||
let hover = if playing { (anim_t * 4.5).sin() * 2.2 - 3.5 } else { -2.5 };
|
|
||||||
draw_antigravity_sprite(ctx, Pos2::new(fill_x, bar_y + hover), 2.5, anim_t, true);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Ferris => {
|
|
||||||
let step = if playing { ((anim_t * 8.0).floor() as u32) & 1 } else { 0 };
|
|
||||||
let bob = if playing && step == 1 { -1.0 } else { 0.0 };
|
|
||||||
draw_ferris_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.2, step == 1);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Nyan => {
|
|
||||||
let step = if playing { ((anim_t * 9.0).floor() as u32) & 1 } else { 0 };
|
|
||||||
let bob = if playing && step == 1 { -1.5 } else { 0.0 };
|
|
||||||
draw_nyan_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.0, step == 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Draws the centered preview inside Settings -> «Вид плеера» card (`preview_r`).
|
|
||||||
pub fn render_thumb_preview(
|
|
||||||
ctx: &mut UiContext,
|
|
||||||
pal: &YmPalette,
|
|
||||||
style: PlayerThumbStyle,
|
|
||||||
preview_r: Rect,
|
|
||||||
time: f32,
|
|
||||||
) {
|
|
||||||
let cx = preview_r.center_x();
|
|
||||||
let cy = preview_r.center_y();
|
|
||||||
match style {
|
|
||||||
PlayerThumbStyle::Standard => {
|
|
||||||
let bar_w = 60.0;
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_center_size(Pos2::new(cx, cy), Vec2::new(bar_w, 5.0)),
|
|
||||||
2.5,
|
|
||||||
pal.border_control,
|
|
||||||
);
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(cx - bar_w * 0.5, cy - 2.5, bar_w * 0.52, 5.0),
|
|
||||||
2.5,
|
|
||||||
pal.yellow,
|
|
||||||
);
|
|
||||||
ctx.dl().push_circle(Pos2::new(cx, cy), 10.0, pal.yellow);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Duck => {
|
|
||||||
ctx.draw_icon(
|
|
||||||
Icon::ThumbDuck,
|
|
||||||
Rect::from_center_size(Pos2::new(cx, cy + 2.0), Vec2::splat(48.0)),
|
|
||||||
Color::WHITE,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Car => {
|
|
||||||
ctx.draw_icon(
|
|
||||||
Icon::ThumbCar,
|
|
||||||
Rect::from_center_size(Pos2::new(cx, cy + 4.0), Vec2::new(82.0, 26.0)),
|
|
||||||
Color::WHITE,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Claudik => {
|
|
||||||
draw_claudik_sprite(ctx, Pos2::new(cx, cy + 16.0), 3.6, false);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Antigravity => {
|
|
||||||
draw_antigravity_sprite(ctx, Pos2::new(cx - 2.0, cy + 16.0), 3.5, time, true);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Ferris => {
|
|
||||||
draw_ferris_sprite(ctx, Pos2::new(cx, cy + 15.0), 3.2, false);
|
|
||||||
}
|
|
||||||
PlayerThumbStyle::Nyan => {
|
|
||||||
// Mini rainbow preview behind Nyan Cat
|
|
||||||
let stripes = [
|
|
||||||
Color::rgb(0xFF, 0x26, 0x26),
|
|
||||||
Color::rgb(0xFF, 0x99, 0x00),
|
|
||||||
Color::rgb(0xFF, 0xEE, 0x00),
|
|
||||||
Color::rgb(0x33, 0xDD, 0x33),
|
|
||||||
Color::rgb(0x1E, 0x9E, 0xFF),
|
|
||||||
Color::rgb(0x7A, 0x44, 0xFF),
|
|
||||||
];
|
|
||||||
for (ci, &col) in stripes.iter().enumerate() {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(cx - 40.0, cy - 8.0 + ci as f32 * 2.5, 24.0, 2.5),
|
|
||||||
0.0,
|
|
||||||
col,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
draw_nyan_sprite(ctx, Pos2::new(cx + 8.0, cy + 12.0), 2.7, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Crisp pixel helper anchored at bottom-center `origin`, unit size `p` logical px.
|
|
||||||
#[inline]
|
|
||||||
fn px_rect(ctx: &mut UiContext, origin: Pos2, p: f32, gx: f32, gy: f32, gw: f32, gh: f32, col: Color) {
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh(
|
|
||||||
(origin.x + gx * p).round(),
|
|
||||||
(origin.y - gy * p).round(),
|
|
||||||
(gw * p).round().max(1.0),
|
|
||||||
(gh * p).round().max(1.0),
|
|
||||||
),
|
|
||||||
0.0,
|
|
||||||
col,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pixel-art Claudik (Claude Code terracotta buddy `#D97757`, matching user's reference!).
|
|
||||||
fn draw_claudik_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) {
|
|
||||||
let body = Color::rgb(0xD9, 0x77, 0x57);
|
|
||||||
let eye = Color::rgb(0x1B, 0x1D, 0x24);
|
|
||||||
// Main blocky head/body (10×6 pixels)
|
|
||||||
px_rect(ctx, origin, p, -5.0, 8.0, 10.0, 6.0, body);
|
|
||||||
// Little side pixel arms
|
|
||||||
let arm_y = if alt_step { 4.5 } else { 4.0 };
|
|
||||||
px_rect(ctx, origin, p, -6.5, arm_y, 1.5, 1.5, body);
|
|
||||||
px_rect(ctx, origin, p, 5.0, arm_y, 1.5, 1.5, body);
|
|
||||||
// Vertical dark eyes
|
|
||||||
px_rect(ctx, origin, p, -3.0, 6.5, 1.0, 2.0, eye);
|
|
||||||
px_rect(ctx, origin, p, 2.0, 6.5, 1.0, 2.0, eye);
|
|
||||||
// 4 cute little legs with walk alternation
|
|
||||||
let (l1, l2) = if alt_step { (1.4, 2.0) } else { (2.0, 1.4) };
|
|
||||||
px_rect(ctx, origin, p, -4.0, 2.0, 1.0, l1, body);
|
|
||||||
px_rect(ctx, origin, p, -2.0, 2.0, 1.0, l2, body);
|
|
||||||
px_rect(ctx, origin, p, 1.0, 2.0, 1.0, l1, body);
|
|
||||||
px_rect(ctx, origin, p, 3.0, 2.0, 1.0, l2, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pixel-art Antigravity cosmic violet cat-bot (`#9B84EC`) + tiny succulent pot & floating aura!
|
|
||||||
fn draw_antigravity_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, time: f32, with_plant: bool) {
|
|
||||||
let body = Color::rgb(0x9B, 0x84, 0xEC);
|
|
||||||
let hi = Color::rgb(0xC2, 0xB3, 0xFF);
|
|
||||||
let eye = Color::rgb(0x17, 0x18, 0x22);
|
|
||||||
// Soft cyan-violet anti-gravity glow underneath
|
|
||||||
let pulse = 0.55 + 0.35 * (time * 4.5).sin();
|
|
||||||
ctx.dl().push_rect(
|
|
||||||
Rect::from_xywh((origin.x - 4.0 * p).round(), (origin.y + 0.5 * p).round(), (8.0 * p).round(), (1.0 * p).round().max(2.0)),
|
|
||||||
2.0,
|
|
||||||
Color::rgb(0x52, 0xB6, 0xFF).scale_alpha(pulse * 0.65),
|
|
||||||
);
|
|
||||||
// Pointed cat ears
|
|
||||||
px_rect(ctx, origin, p, -5.0, 9.5, 1.5, 2.0, body);
|
|
||||||
px_rect(ctx, origin, p, -3.5, 8.5, 1.0, 1.0, body);
|
|
||||||
px_rect(ctx, origin, p, 3.5, 9.5, 1.5, 2.0, body);
|
|
||||||
px_rect(ctx, origin, p, 2.5, 8.5, 1.0, 1.0, body);
|
|
||||||
// Main body
|
|
||||||
px_rect(ctx, origin, p, -5.0, 7.5, 10.0, 5.5, body);
|
|
||||||
// Subtle top sheen
|
|
||||||
px_rect(ctx, origin, p, -2.5, 7.5, 5.0, 0.8, hi);
|
|
||||||
// Dark pixel eyes with tiny sparkle
|
|
||||||
px_rect(ctx, origin, p, -3.0, 6.0, 1.2, 2.0, eye);
|
|
||||||
px_rect(ctx, origin, p, 1.8, 6.0, 1.2, 2.0, eye);
|
|
||||||
// 4 floating legs
|
|
||||||
px_rect(ctx, origin, p, -4.0, 2.0, 1.0, 1.8, body);
|
|
||||||
px_rect(ctx, origin, p, -2.0, 2.0, 1.0, 1.8, body);
|
|
||||||
px_rect(ctx, origin, p, 1.0, 2.0, 1.0, 1.8, body);
|
|
||||||
px_rect(ctx, origin, p, 3.0, 2.0, 1.0, 1.8, body);
|
|
||||||
// Cute tiny potted cactus/succulent friend on the right (matching Screenshot 3!)
|
|
||||||
if with_plant {
|
|
||||||
px_rect(ctx, origin, p, 5.2, 1.8, 3.2, 1.2, Color::rgb(0x8D, 0x55, 0x2B));
|
|
||||||
px_rect(ctx, origin, p, 5.7, 0.8, 2.2, 0.8, Color::rgb(0x6E, 0x40, 0x1E));
|
|
||||||
px_rect(ctx, origin, p, 6.2, 4.4, 1.2, 2.6, Color::rgb(0x6D, 0xE8, 0x7A));
|
|
||||||
px_rect(ctx, origin, p, 7.6, 3.2, 0.9, 1.4, Color::rgb(0x52, 0xC9, 0x60));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pixel-art Ferris the Rust Crab (`#F74C00`) scuttling along the progress bar!
|
|
||||||
fn draw_ferris_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) {
|
|
||||||
let shell = Color::rgb(0xF7, 0x4C, 0x00);
|
|
||||||
let dark = Color::rgb(0xC2, 0x35, 0x00);
|
|
||||||
let white = Color::WHITE;
|
|
||||||
let pupil = Color::rgb(0x16, 0x16, 0x1A);
|
|
||||||
// Raised crab claws
|
|
||||||
let claw_dy = if alt_step { 0.7 } else { 0.0 };
|
|
||||||
px_rect(ctx, origin, p, -7.2, 7.5 + claw_dy, 2.2, 2.4, shell);
|
|
||||||
px_rect(ctx, origin, p, 5.0, 7.5 + claw_dy, 2.2, 2.4, shell);
|
|
||||||
px_rect(ctx, origin, p, -6.5, 5.2, 1.8, 1.4, dark);
|
|
||||||
px_rect(ctx, origin, p, 4.7, 5.2, 1.8, 1.4, dark);
|
|
||||||
// Spiky rounded crab carapace
|
|
||||||
px_rect(ctx, origin, p, -5.0, 7.2, 10.0, 5.0, shell);
|
|
||||||
px_rect(ctx, origin, p, -3.5, 8.2, 7.0, 1.2, shell);
|
|
||||||
// Googly eyes
|
|
||||||
px_rect(ctx, origin, p, -3.0, 6.0, 2.0, 2.0, white);
|
|
||||||
px_rect(ctx, origin, p, 1.0, 6.0, 2.0, 2.0, white);
|
|
||||||
px_rect(ctx, origin, p, -2.0, 5.5, 1.0, 1.2, pupil);
|
|
||||||
px_rect(ctx, origin, p, 2.0, 5.5, 1.0, 1.2, pupil);
|
|
||||||
// Cute smile
|
|
||||||
px_rect(ctx, origin, p, -1.0, 3.4, 2.0, 0.8, dark);
|
|
||||||
// Scuttling legs
|
|
||||||
let off = if alt_step { 0.5 } else { 0.0 };
|
|
||||||
px_rect(ctx, origin, p, -4.5 + off, 2.2, 1.2, 2.0, dark);
|
|
||||||
px_rect(ctx, origin, p, -2.0 - off, 2.2, 1.2, 2.0, dark);
|
|
||||||
px_rect(ctx, origin, p, 0.8 + off, 2.2, 1.2, 2.0, dark);
|
|
||||||
px_rect(ctx, origin, p, 3.3 - off, 2.2, 1.2, 2.0, dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pixel-art Nyan Cat zooming along the rainbow progress bar!
|
|
||||||
fn draw_nyan_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) {
|
|
||||||
let crust = Color::rgb(0xF6, 0xCC, 0x8F);
|
|
||||||
let icing = Color::rgb(0xFF, 0x99, 0xD6);
|
|
||||||
let sprinkle = Color::rgb(0xFF, 0x33, 0x88);
|
|
||||||
let cat = Color::rgb(0x9A, 0x9E, 0xA8);
|
|
||||||
let dark = Color::rgb(0x1C, 0x1E, 0x24);
|
|
||||||
let blush = Color::rgb(0xFF, 0x85, 0xA1);
|
|
||||||
// Tail wagging on left
|
|
||||||
let ty = if alt_step { 6.2 } else { 4.8 };
|
|
||||||
px_rect(ctx, origin, p, -8.0, ty, 2.5, 1.4, cat);
|
|
||||||
// Pop-tart body
|
|
||||||
px_rect(ctx, origin, p, -5.8, 8.6, 8.8, 6.8, crust);
|
|
||||||
px_rect(ctx, origin, p, -4.8, 7.6, 6.8, 4.8, icing);
|
|
||||||
// Sprinkles
|
|
||||||
px_rect(ctx, origin, p, -3.8, 6.6, 1.0, 1.0, sprinkle);
|
|
||||||
px_rect(ctx, origin, p, -1.5, 5.4, 1.0, 1.0, sprinkle);
|
|
||||||
px_rect(ctx, origin, p, 0.2, 6.8, 1.0, 1.0, sprinkle);
|
|
||||||
// Cat head on right
|
|
||||||
px_rect(ctx, origin, p, 1.2, 7.8, 5.4, 4.8, cat);
|
|
||||||
px_rect(ctx, origin, p, 1.5, 9.2, 1.5, 1.5, cat);
|
|
||||||
px_rect(ctx, origin, p, 4.8, 9.2, 1.5, 1.5, cat);
|
|
||||||
// Eyes & blush
|
|
||||||
px_rect(ctx, origin, p, 2.4, 6.4, 1.0, 1.2, dark);
|
|
||||||
px_rect(ctx, origin, p, 4.8, 6.4, 1.0, 1.2, dark);
|
|
||||||
px_rect(ctx, origin, p, 1.8, 5.0, 1.0, 0.9, blush);
|
|
||||||
px_rect(ctx, origin, p, 5.4, 5.0, 1.0, 0.9, blush);
|
|
||||||
// Tiny running paws
|
|
||||||
let paw_dx = if alt_step { 0.8 } else { 0.0 };
|
|
||||||
px_rect(ctx, origin, p, -4.8 + paw_dx, 2.0, 1.5, 1.8, cat);
|
|
||||||
px_rect(ctx, origin, p, -1.8 + paw_dx, 2.0, 1.5, 1.8, cat);
|
|
||||||
px_rect(ctx, origin, p, 1.6 + paw_dx, 2.0, 1.5, 1.8, cat);
|
|
||||||
px_rect(ctx, origin, p, 4.0 + paw_dx, 2.0, 1.5, 1.8, cat);
|
|
||||||
}
|
|
||||||
|
|
@ -339,9 +339,8 @@ 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,
|
||||||
|
|
@ -572,8 +571,6 @@ pub fn render_search(
|
||||||
is_liked: app.liked_ids.contains(&tr.id),
|
is_liked: app.liked_ids.contains(&tr.id),
|
||||||
is_disliked: app.disliked_ids.contains(&tr.id),
|
is_disliked: app.disliked_ids.contains(&tr.id),
|
||||||
is_downloaded: app.is_track_downloaded(&tr.id),
|
is_downloaded: app.is_track_downloaded(&tr.id),
|
||||||
is_downloading: app.is_track_downloading(&tr.id),
|
|
||||||
download_progress: app.track_download_progress(&tr.id),
|
|
||||||
menu_open: shell.is_track_menu_open(&tr.id),
|
menu_open: shell.is_track_menu_open(&tr.id),
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -729,9 +726,8 @@ 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 (idx, alb) in res.albums.iter().take(12).enumerate() {
|
for alb in res.albums.iter().take(12) {
|
||||||
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()
|
||||||
|
|
@ -741,9 +737,9 @@ pub fn render_search(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("s_alb", (idx, &alb.id)),
|
WidgetId::from_pair("s_alb", &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),
|
||||||
|
|
@ -753,12 +749,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,
|
title: alb.title.clone(),
|
||||||
});
|
});
|
||||||
} 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,
|
title: alb.title.clone(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
cx += card_w + 16.0;
|
cx += card_w + 16.0;
|
||||||
|
|
@ -780,7 +776,6 @@ 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()
|
||||||
|
|
@ -790,9 +785,9 @@ pub fn render_search(
|
||||||
ctx,
|
ctx,
|
||||||
pal,
|
pal,
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair("s_alb_grid", (idx, &alb.id)),
|
WidgetId::from_pair("s_alb_grid", &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),
|
||||||
|
|
@ -802,12 +797,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,
|
title: alb.title.clone(),
|
||||||
});
|
});
|
||||||
} 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,
|
title: alb.title.clone(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -836,16 +831,13 @@ 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 (idx, pl) in res.playlists.iter().take(12).enumerate() {
|
for pl in res.playlists.iter().take(12) {
|
||||||
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(
|
WidgetId::from_pair("s_pl", format!("{}_{}", pl.owner_uid, pl.kind)),
|
||||||
"s_pl",
|
|
||||||
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
|
||||||
),
|
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
&pl.owner_name,
|
&pl.owner_name,
|
||||||
|
|
@ -897,7 +889,7 @@ pub fn render_search(
|
||||||
covers,
|
covers,
|
||||||
WidgetId::from_pair(
|
WidgetId::from_pair(
|
||||||
"s_pl_grid",
|
"s_pl_grid",
|
||||||
(idx, format!("{}_{}", pl.owner_uid, pl.kind)),
|
format!("{}_{}", pl.owner_uid, pl.kind),
|
||||||
),
|
),
|
||||||
cr,
|
cr,
|
||||||
&pl.title,
|
&pl.title,
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,6 @@ fn make_track(
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -399,7 +398,6 @@ fn build_reference_matched_shell(
|
||||||
uid: 42,
|
uid: 42,
|
||||||
login: "marwy".into(),
|
login: "marwy".into(),
|
||||||
display_name: "Marwy".into(),
|
display_name: "Marwy".into(),
|
||||||
default_email: None,
|
|
||||||
has_plus: true,
|
has_plus: true,
|
||||||
avatar_uri: Some("test.local/avatar_marwy/%%".into()),
|
avatar_uri: Some("test.local/avatar_marwy/%%".into()),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@ fn make_base_shell(
|
||||||
uid: 1,
|
uid: 1,
|
||||||
login: "Marwy".into(),
|
login: "Marwy".into(),
|
||||||
display_name: "Marwy".into(),
|
display_name: "Marwy".into(),
|
||||||
default_email: Some("marwy@yandex.ru".into()),
|
|
||||||
has_plus: true,
|
has_plus: true,
|
||||||
avatar_uri: None,
|
avatar_uri: None,
|
||||||
});
|
});
|
||||||
|
|
@ -133,7 +132,6 @@ fn make_base_shell(
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
};
|
};
|
||||||
let track2 = Track {
|
let track2 = Track {
|
||||||
id: "t_2".into(),
|
id: "t_2".into(),
|
||||||
|
|
@ -159,7 +157,6 @@ fn make_base_shell(
|
||||||
r128_tp: None,
|
r128_tp: None,
|
||||||
derived_average_hex: None,
|
derived_average_hex: None,
|
||||||
derived_accent_hex: None,
|
derived_accent_hex: None,
|
||||||
fade: None,
|
|
||||||
};
|
};
|
||||||
let landing = demo_data::demo_landing();
|
let landing = demo_data::demo_landing();
|
||||||
let app = AppState::new_visual_test(
|
let app = AppState::new_visual_test(
|
||||||
|
|
@ -1676,932 +1673,3 @@ fn test_ext_15_opengl33_strict_shaders_and_renderer_backend() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ext_16_yandex_id_popup_and_words_card_visual_parity() {
|
|
||||||
use yandex_music_rs::api::models::{WordsCard, WordsCardSource};
|
|
||||||
use yandex_music_rs::engine::types::Pos2;
|
|
||||||
|
|
||||||
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. Dark Theme Yandex ID v2.79.0 Account Popup + Appearance Popover (`dark_profile_popup.png`)
|
|
||||||
{
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::LikedTracks,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::Ru,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
shell.shell.sidebar_profile_open = true;
|
|
||||||
shell.shell.sidebar_appearance_open = true;
|
|
||||||
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
for f in 1..3 {
|
|
||||||
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
|
|
||||||
}
|
|
||||||
let _ = img.save(out_dir.join("dark_profile_popup.png"));
|
|
||||||
|
|
||||||
// Verify `#1F1F24` dark Yandex ID card surface inside x=32..320, y=240..660
|
|
||||||
let mut card_bg_px = 0usize;
|
|
||||||
let mut bright_text_px = 0usize;
|
|
||||||
for y in 240..660 {
|
|
||||||
for x in 32..320 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
if (r as i32 - 0x1F).abs() <= 6
|
|
||||||
&& (g as i32 - 0x1F).abs() <= 6
|
|
||||||
&& (b as i32 - 0x24).abs() <= 6
|
|
||||||
{
|
|
||||||
card_bg_px += 1;
|
|
||||||
} else if r >= 220 && g >= 220 && b >= 225 {
|
|
||||||
bright_text_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
card_bg_px > 40_000,
|
|
||||||
"[dark_profile_popup] Expected Yandex ID #1F1F24 dark surface (got {} px)",
|
|
||||||
card_bg_px
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
bright_text_px > 1_200,
|
|
||||||
"[dark_profile_popup] Expected high-contrast #FAFAFF text/icons (got {} px)",
|
|
||||||
bright_text_px
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify Appearance submenu popover rendered to the right of the card (x=345..555)
|
|
||||||
let mut sub_bg_px = 0usize;
|
|
||||||
for y in 420..660 {
|
|
||||||
for x in 348..555 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
if (r as i32 - 0x2D).abs() <= 8
|
|
||||||
&& (g as i32 - 0x2D).abs() <= 8
|
|
||||||
&& (b as i32 - 0x34).abs() <= 8
|
|
||||||
{
|
|
||||||
sub_bg_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
sub_bg_px > 10_000,
|
|
||||||
"[dark_profile_popup] Expected Yandex ID #2D2D34 Appearance popover (got {} px)",
|
|
||||||
sub_bg_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. My Vibe official 5.129.0 `WordsCard` + `WordsCardPopoverDesktop` (`my_vibe_words_popover.png`)
|
|
||||||
{
|
|
||||||
// Static guard: fake AI Vibe-settings string MUST be completely gone from `src/views/my_vibe.rs`
|
|
||||||
let mv_src = std::fs::read_to_string(
|
|
||||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("src/views/my_vibe.rs"),
|
|
||||||
)
|
|
||||||
.expect("read src/views/my_vibe.rs");
|
|
||||||
assert!(
|
|
||||||
!mv_src.contains("Мою волну по настроению и характеру"),
|
|
||||||
"Fake AI Vibe-settings phrase must be removed from WordsCard in src/views/my_vibe.rs!"
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::MyVibe,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::Ru,
|
|
||||||
108.0,
|
|
||||||
);
|
|
||||||
shell.app.words_cards.insert(
|
|
||||||
"t_1".into(),
|
|
||||||
WordsCard {
|
|
||||||
id: "wc_test_1".into(),
|
|
||||||
track_id: "t_1".into(),
|
|
||||||
text: "Трек вдохновлён бразильским фонком и энергичными рейвами 2000-х".into(),
|
|
||||||
tags: vec!["FACT".into()],
|
|
||||||
action: None,
|
|
||||||
actions: vec![WordsCardSource {
|
|
||||||
title: "Подробнее об артисте".into(),
|
|
||||||
url: "https://music.yandex.ru".into(),
|
|
||||||
favicon_url: None,
|
|
||||||
}],
|
|
||||||
big_card_ids: Vec::new(),
|
|
||||||
feedback_state: None,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Warm up WordsCard layout (renders State B around cx~943, ai_y~732)
|
|
||||||
let before = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let click_pos = Pos2::new(943.0, 732.0);
|
|
||||||
// Simulate genuine left-click press + release on WordsCard to toggle WordsCardPopoverDesktop
|
|
||||||
shell.ui.input.pointer_pos = Some(click_pos);
|
|
||||||
shell.ui.input.left_down = true;
|
|
||||||
shell.ui.input.left_pressed = true;
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
shell.ui.input.left_down = false;
|
|
||||||
shell.ui.input.left_released = true;
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
let after = render_single_frame(&mut vk, &mut shell, 0.048);
|
|
||||||
|
|
||||||
let _ = after.save(out_dir.join("my_vibe_words_popover.png"));
|
|
||||||
|
|
||||||
// Verify WordsCardPopoverDesktop actually appeared above WordsCard (y=500..700, x=810..1075)
|
|
||||||
let popover_delta = region_mean_abs_diff(&before, &after, 810, 500, 1075, 700);
|
|
||||||
assert!(
|
|
||||||
popover_delta > 4.0,
|
|
||||||
"[my_vibe_words_popover] Clicking WordsCard did not open WordsCardPopoverDesktop (delta={:.2} RGB)",
|
|
||||||
popover_delta
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
!shell.app.vibe_modal_open,
|
|
||||||
"[my_vibe_words_popover] Clicking WordsCard MUST NOT open fake Vibe settings modal!"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Official 1-to-1 `VibeResetButton` unified pill + `0.1.0` version badge (`my_vibe_context_pill.png`)
|
|
||||||
{
|
|
||||||
use yandex_music_rs::app::APP_VERSION;
|
|
||||||
assert_eq!(
|
|
||||||
APP_VERSION,
|
|
||||||
env!("CARGO_PKG_VERSION"),
|
|
||||||
"APP_VERSION must match Cargo.toml"
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::MyVibe,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::En,
|
|
||||||
12.0,
|
|
||||||
);
|
|
||||||
if let Some(tr) = shell.app.queue.get_mut(0) {
|
|
||||||
tr.derived_average_hex = Some("#F56E00".into());
|
|
||||||
}
|
|
||||||
shell.app.is_vibe_active = false;
|
|
||||||
shell.app.context_name = "My Favorites".into();
|
|
||||||
shell.app.context_key = "likes".into();
|
|
||||||
shell.app.set_vibe_playback_for_test(true, 0.45, 0.35);
|
|
||||||
|
|
||||||
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
for f in 1..4 {
|
|
||||||
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.2);
|
|
||||||
}
|
|
||||||
let _ = img.save(out_dir.join("my_vibe_context_pill.png"));
|
|
||||||
|
|
||||||
// Verify bright electric yellow pixels (#FFFF00) inside top-center VibeResetButton pill (y=32..80, x=830..1060)
|
|
||||||
let mut pill_yellow_px = 0usize;
|
|
||||||
for y in 32..80 {
|
|
||||||
for x in 830..1060 {
|
|
||||||
if is_yandex_yellow(img.get_pixel(x, y).0) {
|
|
||||||
pill_yellow_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
pill_yellow_px >= 400,
|
|
||||||
"[my_vibe_context_pill] Expected electric yellow text + filled yellow close circle inside unified VibeResetButton pill, found {} yellow px",
|
|
||||||
pill_yellow_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
|
|
||||||
use yandex_music_rs::api::models::{
|
|
||||||
AlbumSummary, ConcertItem, NewReleaseItem, VibePickItem, VibePickTab, WordsBigCard,
|
|
||||||
WordsCard, WordsCardSource,
|
|
||||||
};
|
|
||||||
use yandex_music_rs::engine::WidgetId;
|
|
||||||
|
|
||||||
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. Official `For You` scrolled down: sticky frosted header + circular NewReleases + More Picks (`for_you_new_releases_picks.png`)
|
|
||||||
{
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::ForYou,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::En,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
let mk_album = |id: &str, title: &str, artist: &str| AlbumSummary {
|
|
||||||
id: id.into(),
|
|
||||||
title: title.into(),
|
|
||||||
version: None,
|
|
||||||
year: Some(2026),
|
|
||||||
cover_uri: None,
|
|
||||||
artists: vec![ArtistSummary {
|
|
||||||
id: format!("art_{id}"),
|
|
||||||
name: artist.into(),
|
|
||||||
cover_uri: None,
|
|
||||||
genres: vec![],
|
|
||||||
}],
|
|
||||||
track_count: 12,
|
|
||||||
genre: Some("electronic".into()),
|
|
||||||
is_explicit: false,
|
|
||||||
content_type: Some("album".into()),
|
|
||||||
};
|
|
||||||
shell.app.landing.rich_new_releases = vec![
|
|
||||||
NewReleaseItem {
|
|
||||||
album: mk_album("nr1", "Neon Horizon", "SALUKI"),
|
|
||||||
artist_cover_uri: None,
|
|
||||||
cover_color: Some("#3B4CA8".into()),
|
|
||||||
release_date: Some("2026-11-20".into()),
|
|
||||||
},
|
|
||||||
NewReleaseItem {
|
|
||||||
album: mk_album("nr2", "Velvet Pulse", "Mirele"),
|
|
||||||
artist_cover_uri: None,
|
|
||||||
cover_color: Some("#7B2D5F".into()),
|
|
||||||
release_date: Some("2026-11-18".into()),
|
|
||||||
},
|
|
||||||
NewReleaseItem {
|
|
||||||
album: mk_album("nr3", "Night Drive", "SLAVA MARLOW"),
|
|
||||||
artist_cover_uri: None,
|
|
||||||
cover_color: Some("#1E6B52".into()),
|
|
||||||
release_date: Some("2026-11-15".into()),
|
|
||||||
},
|
|
||||||
NewReleaseItem {
|
|
||||||
album: mk_album("nr4", "Solar Flare", "OG BLESS"),
|
|
||||||
artist_cover_uri: None,
|
|
||||||
cover_color: Some("#8F4A1E".into()),
|
|
||||||
release_date: Some("2026-11-12".into()),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
shell.app.landing.vibe_pick_tabs = vec![
|
|
||||||
VibePickTab {
|
|
||||||
title: "Mood".into(),
|
|
||||||
items: vec![
|
|
||||||
VibePickItem {
|
|
||||||
title: "Energetic".into(),
|
|
||||||
header: "Vibe".into(),
|
|
||||||
seeds: vec!["mood:energetic".into()],
|
|
||||||
color_hex: Some("#D94E2A".into()),
|
|
||||||
background_image_url: None,
|
|
||||||
image_url: None,
|
|
||||||
},
|
|
||||||
VibePickItem {
|
|
||||||
title: "Night Focus".into(),
|
|
||||||
header: "Vibe".into(),
|
|
||||||
seeds: vec!["mood:calm".into()],
|
|
||||||
color_hex: Some("#2F55A4".into()),
|
|
||||||
background_image_url: None,
|
|
||||||
image_url: None,
|
|
||||||
},
|
|
||||||
VibePickItem {
|
|
||||||
title: "Dreamy Synth".into(),
|
|
||||||
header: "Vibe".into(),
|
|
||||||
seeds: vec!["genre:electronic".into()],
|
|
||||||
color_hex: Some("#7C3AED".into()),
|
|
||||||
background_image_url: None,
|
|
||||||
image_url: None,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "Activity".into(),
|
|
||||||
items: vec![VibePickItem {
|
|
||||||
title: "Workout".into(),
|
|
||||||
header: "Vibe".into(),
|
|
||||||
seeds: vec!["activity:workout".into()],
|
|
||||||
color_hex: Some("#0F766E".into()),
|
|
||||||
background_image_url: None,
|
|
||||||
image_url: None,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
VibePickTab {
|
|
||||||
title: "Genres".into(),
|
|
||||||
items: vec![],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// Warm up layout so scroll content height is computed, then scroll to show New Releases + More Picks + sticky switcher
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
shell
|
|
||||||
.ui
|
|
||||||
.scrolls
|
|
||||||
.jump_to_y(WidgetId::new("foryou_page_scroll"), 860.0);
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.048);
|
|
||||||
let _ = img.save(out_dir.join("for_you_new_releases_picks.png"));
|
|
||||||
|
|
||||||
// Verify colored NewRelease cards / More Picks cards rendered non-flat rich pixels in content card
|
|
||||||
let mut colored_px = 0usize;
|
|
||||||
for y in 110..680 {
|
|
||||||
for x in 250..1240 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
let max_c = r.max(g).max(b);
|
|
||||||
let min_c = r.min(g).min(b);
|
|
||||||
if max_c.saturating_sub(min_c) >= 24 {
|
|
||||||
colored_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
colored_px > 5_000,
|
|
||||||
"[for_you_new_releases_picks] Expected colored New Releases / More Picks cards, found only {} chromatic px",
|
|
||||||
colored_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Official `My Collection` vertical feed (`my_collection_official.png`)
|
|
||||||
{
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::Collection,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::En,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
let extra_tracks = [
|
|
||||||
("c_1", "MONTAGEM TENTA", "KYOR", 141_000),
|
|
||||||
("c_2", "Midnight Sun", "SuperSolar", 184_000),
|
|
||||||
("c_3", "BANG A RANG", "GSTRNM", 100_000),
|
|
||||||
("c_4", "BOSS BITCH TEKK", "wharoxmane", 107_000),
|
|
||||||
("c_5", "Neon Rain", "Mirele", 192_000),
|
|
||||||
("c_6", "Skyline Pulse", "SALUKI", 168_000),
|
|
||||||
("c_7", "Electric Horizon", "SLAVA MARLOW", 155_000),
|
|
||||||
("c_8", "Deep Focus", "OG BLESS", 210_000),
|
|
||||||
];
|
|
||||||
shell.app.liked_tracks = extra_tracks
|
|
||||||
.iter()
|
|
||||||
.map(|(id, title, art, dur)| Track {
|
|
||||||
id: (*id).into(),
|
|
||||||
title: (*title).into(),
|
|
||||||
version: None,
|
|
||||||
artists: vec![ArtistSummary {
|
|
||||||
id: format!("ca_{id}"),
|
|
||||||
name: (*art).into(),
|
|
||||||
cover_uri: None,
|
|
||||||
genres: vec![],
|
|
||||||
}],
|
|
||||||
album_id: Some(format!("calb_{id}")),
|
|
||||||
album_title: Some((*title).into()),
|
|
||||||
duration_ms: *dur,
|
|
||||||
cover_uri: None,
|
|
||||||
is_explicit: false,
|
|
||||||
has_lossless: true,
|
|
||||||
has_lyrics: true,
|
|
||||||
chart_position: None,
|
|
||||||
chart_progress: None,
|
|
||||||
preview_url: None,
|
|
||||||
r128_i: None,
|
|
||||||
r128_tp: None,
|
|
||||||
derived_average_hex: None,
|
|
||||||
derived_accent_hex: None,
|
|
||||||
fade: None,
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
shell.app.liked_artists = ["SALUKI", "Mirele", "KYOR", "SuperSolar", "GSTRNM", "OG BLESS"]
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, name)| ArtistSummary {
|
|
||||||
id: format!("la_{i}"),
|
|
||||||
name: (*name).into(),
|
|
||||||
cover_uri: None,
|
|
||||||
genres: vec![],
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
let _ = img.save(out_dir.join("my_collection_official.png"));
|
|
||||||
|
|
||||||
// Verify pink-magenta colored "color" word in subtitle + crimson 3D heart icon present,
|
|
||||||
// and ZERO old yellow-bordered My Favorites hero card!
|
|
||||||
let mut pink_subtitle_px = 0usize;
|
|
||||||
for y in 75..125 {
|
|
||||||
for x in 250..520 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
if r > 170 && b > 100 && (r as u16) > (g as u16) + 50 {
|
|
||||||
pink_subtitle_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
pink_subtitle_px >= 15,
|
|
||||||
"[my_collection_official] Expected magenta-colored subtitle word 'color', found {} px",
|
|
||||||
pink_subtitle_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Official `ConcertsPage` (`concerts_official.png`)
|
|
||||||
{
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::Concerts,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::Ru,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
shell.app.concerts = vec![
|
|
||||||
ConcertItem {
|
|
||||||
id: "con_1".into(),
|
|
||||||
title: "SALUKI — Большой сольный концерт".into(),
|
|
||||||
artist_name: "SALUKI".into(),
|
|
||||||
city: "Москва".into(),
|
|
||||||
place: "VK Stadium".into(),
|
|
||||||
date: "14 дек, 20:00".into(),
|
|
||||||
cover_uri: None,
|
|
||||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
|
||||||
min_price: Some(2500),
|
|
||||||
currency: Some("RUB".into()),
|
|
||||||
cashback_percent: Some(15),
|
|
||||||
cashback_title: Some("Кешбэк 15%".into()),
|
|
||||||
cover_color: Some("#4C2A85".into()),
|
|
||||||
event_kind: Some("concert".into()),
|
|
||||||
},
|
|
||||||
ConcertItem {
|
|
||||||
id: "con_2".into(),
|
|
||||||
title: "Mirele — Акустический вечер".into(),
|
|
||||||
artist_name: "Mirele".into(),
|
|
||||||
city: "Санкт-Петербург".into(),
|
|
||||||
place: "A2 Green Concert".into(),
|
|
||||||
date: "21 дек, 19:30".into(),
|
|
||||||
cover_uri: None,
|
|
||||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
|
||||||
min_price: Some(1900),
|
|
||||||
currency: Some("RUB".into()),
|
|
||||||
cashback_percent: Some(10),
|
|
||||||
cashback_title: None,
|
|
||||||
cover_color: Some("#1D5B79".into()),
|
|
||||||
event_kind: Some("concert".into()),
|
|
||||||
},
|
|
||||||
ConcertItem {
|
|
||||||
id: "con_3".into(),
|
|
||||||
title: "SLAVA MARLOW — Live Tour".into(),
|
|
||||||
artist_name: "SLAVA MARLOW".into(),
|
|
||||||
city: "Казань".into(),
|
|
||||||
place: "Korston Club Hotel".into(),
|
|
||||||
date: "28 дек, 20:00".into(),
|
|
||||||
cover_uri: None,
|
|
||||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
|
||||||
min_price: Some(2200),
|
|
||||||
currency: Some("RUB".into()),
|
|
||||||
cashback_percent: Some(20),
|
|
||||||
cashback_title: None,
|
|
||||||
cover_color: Some("#8C2F39".into()),
|
|
||||||
event_kind: Some("concert".into()),
|
|
||||||
},
|
|
||||||
ConcertItem {
|
|
||||||
id: "con_4".into(),
|
|
||||||
title: "Электрофорез — Зимний сет".into(),
|
|
||||||
artist_name: "Электрофорез".into(),
|
|
||||||
city: "Москва".into(),
|
|
||||||
place: "Урбан".into(),
|
|
||||||
date: "5 янв, 20:00".into(),
|
|
||||||
cover_uri: None,
|
|
||||||
afisha_url: Some("https://afisha.yandex.ru".into()),
|
|
||||||
min_price: Some(1700),
|
|
||||||
currency: Some("RUB".into()),
|
|
||||||
cashback_percent: Some(10),
|
|
||||||
cashback_title: None,
|
|
||||||
cover_color: Some("#2D4F1E".into()),
|
|
||||||
event_kind: Some("concert".into()),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
let _ = img.save(out_dir.join("concerts_official.png"));
|
|
||||||
|
|
||||||
// Verify Top 3 poster cards (aspect 0.963, h~320px) + cashback pills + yellow price CTAs rendered cleanly
|
|
||||||
let mut poster_chromatic_px = 0usize;
|
|
||||||
for y in 160..540 {
|
|
||||||
for x in 250..1240 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
if r.max(g).max(b).saturating_sub(r.min(g).min(b)) >= 20 {
|
|
||||||
poster_chromatic_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
poster_chromatic_px > 10_000,
|
|
||||||
"[concerts_official] Expected Top 3 concert poster cards + cashback pills, found {} chromatic px",
|
|
||||||
poster_chromatic_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Official `WordsCardFullscreen` (`words_fullscreen_official.png`)
|
|
||||||
{
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::MyVibe,
|
|
||||||
ThemeMode::Dark,
|
|
||||||
Language::Ru,
|
|
||||||
108.0,
|
|
||||||
);
|
|
||||||
shell.app.words_cards.insert(
|
|
||||||
"t_1".into(),
|
|
||||||
WordsCard {
|
|
||||||
id: "wc_fs_1".into(),
|
|
||||||
track_id: "t_1".into(),
|
|
||||||
text: "MONTAGEM TENTA сочетает бразильский фонк и жёсткие хардстайл-кики.".into(),
|
|
||||||
tags: vec!["FACT".into()],
|
|
||||||
action: None,
|
|
||||||
actions: vec![],
|
|
||||||
big_card_ids: vec!["bc_1".into()],
|
|
||||||
feedback_state: None,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
shell.app.words_big_card_open = true;
|
|
||||||
shell.app.words_big_card_loading = false;
|
|
||||||
shell.app.words_big_card = Some(WordsBigCard {
|
|
||||||
id: "bc_1".into(),
|
|
||||||
text: "MONTAGEM TENTA (Hardstyle) — взрывной кроссовер бразильского фонка и европейского хардстайла с плотным саб-басом и стремительным ритмом.".into(),
|
|
||||||
actions: vec![WordsCardSource {
|
|
||||||
title: "Обсудить с Алисой AI".into(),
|
|
||||||
url: "https://alice.yandex.ru".into(),
|
|
||||||
favicon_url: None,
|
|
||||||
}],
|
|
||||||
});
|
|
||||||
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
let _ = img.save(out_dir.join("words_fullscreen_official.png"));
|
|
||||||
|
|
||||||
// Verify purple Alice ring (#8B5CF6) rendered inside the centered source pill
|
|
||||||
let mut alice_purple_px = 0usize;
|
|
||||||
for y in 360..600 {
|
|
||||||
for x in 560..960 {
|
|
||||||
let [r, g, b] = img.get_pixel(x, y).0;
|
|
||||||
if b > 160 && r > 90 && (b as u16) > (g as u16) + 50 {
|
|
||||||
alice_purple_px += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert!(
|
|
||||||
alice_purple_px >= 15,
|
|
||||||
"[words_fullscreen_official] Expected purple Alice AI icon inside source pill, found {} px",
|
|
||||||
alice_purple_px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ext_15_release_notes_modal_update_notification_and_download_ring() {
|
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
||||||
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
|
|
||||||
|
|
||||||
for theme in [ThemeMode::Dark, ThemeMode::Light] {
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::LikedTracks,
|
|
||||||
theme,
|
|
||||||
Language::Ru,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
if let Some(first_id) = shell.app.liked_tracks.first().map(|t| t.id.clone()) {
|
|
||||||
shell.app.downloading_track_ids.insert(first_id.clone());
|
|
||||||
shell.app.downloading_track_progress.insert(first_id, 0.45);
|
|
||||||
shell.app.download_batch_total = 2;
|
|
||||||
shell.app.download_batch_done = 0;
|
|
||||||
}
|
|
||||||
shell.app.available_update = Some(yandex_music_rs::api::models::UpdateInfo {
|
|
||||||
version: "9.9.9".into(),
|
|
||||||
html_url: "https://git.tatar/marwy/yandex-music-rs/releases/tag/v9.9.9".into(),
|
|
||||||
date: "2026-11-28".into(),
|
|
||||||
body: "## Новое\n- Тестовое обновление".into(),
|
|
||||||
});
|
|
||||||
shell.app.release_notes_modal_open = true;
|
|
||||||
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let img = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
assert!(img.width() == NATIVE_W && img.height() == NATIVE_H);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_ext_19_official_settings_sound_quality_equalizer_and_shortcuts_modals() {
|
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
|
||||||
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
|
|
||||||
|
|
||||||
for theme in [ThemeMode::Dark, ThemeMode::Light] {
|
|
||||||
let mut shell = make_base_shell(
|
|
||||||
rt.handle().clone(),
|
|
||||||
vk.gpu_name.clone(),
|
|
||||||
Route::Settings,
|
|
||||||
theme,
|
|
||||||
Language::Ru,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
shell.app.config.eq_enabled = true;
|
|
||||||
shell.app.config.eq_preamp = 1.15;
|
|
||||||
shell.app.eq_popover_open = true;
|
|
||||||
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
|
|
||||||
let img_qs = render_single_frame(&mut vk, &mut shell, 0.016);
|
|
||||||
assert!(img_qs.width() == NATIVE_W && img_qs.height() == NATIVE_H);
|
|
||||||
|
|
||||||
shell.app.config.eq_enabled = false;
|
|
||||||
shell.app.eq_popover_open = false;
|
|
||||||
shell.app.equalizer_modal_open = true;
|
|
||||||
let img_eq = render_single_frame(&mut vk, &mut shell, 0.032);
|
|
||||||
assert!(img_eq.width() == NATIVE_W && img_eq.height() == NATIVE_H);
|
|
||||||
|
|
||||||
shell.app.equalizer_modal_open = false;
|
|
||||||
shell.app.shortcuts_modal_open = true;
|
|
||||||
let img_sc = render_single_frame(&mut vk, &mut shell, 0.048);
|
|
||||||
assert!(img_sc.width() == NATIVE_W && img_sc.height() == NATIVE_H);
|
|
||||||
|
|
||||||
shell.app.shortcuts_modal_open = false;
|
|
||||||
for &style in yandex_music_rs::config::PlayerThumbStyle::ALL {
|
|
||||||
shell.app.config.player_thumb = style;
|
|
||||||
let img_th = render_single_frame(&mut vk, &mut shell, 0.064);
|
|
||||||
assert!(img_th.width() == NATIVE_W && img_th.height() == NATIVE_H);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regression: Fullscreen player must NOT leak the bottom PlayerBar companion on top of it!
|
|
||||||
shell.app.config.player_thumb = yandex_music_rs::config::PlayerThumbStyle::Claudik;
|
|
||||||
shell.app.fullscreen_open = true;
|
|
||||||
let img_fs_claudik = render_single_frame(&mut vk, &mut shell, 0.080);
|
|
||||||
shell.app.config.player_thumb = yandex_music_rs::config::PlayerThumbStyle::Standard;
|
|
||||||
let img_fs_std = render_single_frame(&mut vk, &mut shell, 0.080);
|
|
||||||
assert_eq!(
|
|
||||||
img_fs_claudik.as_raw(),
|
|
||||||
img_fs_std.as_raw(),
|
|
||||||
"Fullscreen player leaked bottom PlayerBar companion onto ZLayer::Popover!"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||