feat: add a cover backdrop slider to the settings

The first range setting: its row draws a slider, and left and right
change it in steps of 10 while confirm still flips the toggles. Saved
as cover_backdrop in settings.toml, defaulting to the old fixed look.

Up to the default the cover fades in under the old overlay. Above it
the overlay thins as well, down to 0.55 on the left where the title and
progress sit, which kept them readable over a bright cover.
This commit is contained in:
Ansho Rei
2026-11-04 14:31:17 +01:00
parent 2e8b2e6a02
commit 341ae614e1
7 changed files with 219 additions and 16 deletions
+24 -1
View File
@@ -88,11 +88,25 @@ pub fn save(cfg: &Config) -> Result<()> {
}
/// Preferences. Kept apart from the login, so logging out does not reset them.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Settings {
/// Tint the UI with the colours of the playing track's cover.
pub album_art_colours: bool,
/// How strongly the cover shows behind the now-playing screen, 0 to 100.
pub cover_backdrop: u8,
}
/// The cover backdrop strength that looks like it did before it was a setting.
pub const COVER_BACKDROP_DEFAULT: u8 = 30;
impl Default for Settings {
fn default() -> Self {
Settings {
album_art_colours: false,
cover_backdrop: COVER_BACKDROP_DEFAULT,
}
}
}
fn settings_path() -> Option<PathBuf> {
@@ -193,12 +207,21 @@ mod tests {
let s: Settings = toml::from_str("").unwrap();
assert_eq!(s, Settings::default());
assert!(!s.album_art_colours);
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
}
#[test]
fn settings_from_before_the_backdrop_load_its_default() {
let s: Settings = toml::from_str("album_art_colours = true\n").unwrap();
assert!(s.album_art_colours);
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
}
#[test]
fn settings_round_trip() {
let s = Settings {
album_art_colours: true,
cover_backdrop: 70,
};
let back: Settings = toml::from_str(&toml::to_string(&s).unwrap()).unwrap();
assert_eq!(back, s);