feat: add a setting to hide the controls bar

Settings has a Show controls bar toggle, on by default and saved as
show_hint_bar. Off, the hint bar goes from the browse and now-playing
screens and the content takes its height. The login screen keeps it,
since the controls are not known yet there and Settings is out of reach.

The bar is where the version shows, so while it is off Settings lists
the version instead.
This commit is contained in:
Ansho Rei
2026-11-04 17:18:16 +01:00
parent a5d51cf044
commit ab42814302
7 changed files with 71 additions and 7 deletions
+51 -4
View File
@@ -117,7 +117,7 @@ impl Section {
}
}
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
enum Target {
Album(String),
Artist(String),
@@ -131,6 +131,9 @@ enum Target {
enum Setting {
AlbumArtColours,
CoverBackdrop,
ShowHintBar,
/// The version, listed while the hint bar that normally shows it is off.
Version,
}
/// How long the UI takes to change from one palette to the next.
@@ -352,6 +355,7 @@ impl App {
fn start(&mut self) {
self.render_backdrop();
self.ui.set_show_hint_bar(self.settings.show_hint_bar);
let labels: Vec<SharedString> = SECTIONS.iter().map(|s| s.label().into()).collect();
self.ui.set_sections(ModelRc::new(VecModel::from(labels)));
@@ -913,8 +917,9 @@ impl App {
fn toggle_setting(&mut self, setting: Setting) {
match setting {
Setting::AlbumArtColours => self.settings.album_art_colours = !self.settings.album_art_colours,
Setting::ShowHintBar => self.settings.show_hint_bar = !self.settings.show_hint_bar,
// A range: left and right change it, confirm does nothing.
Setting::CoverBackdrop => return,
Setting::CoverBackdrop | Setting::Version => return,
}
self.settings_changed();
}
@@ -929,7 +934,7 @@ impl App {
}
self.settings.cover_backdrop = v;
}
Setting::AlbumArtColours => return,
Setting::AlbumArtColours | Setting::ShowHintBar | Setting::Version => return,
}
self.settings_changed();
}
@@ -948,6 +953,7 @@ impl App {
}
}
self.render_backdrop();
self.ui.set_show_hint_bar(self.settings.show_hint_bar);
self.update_theme();
}
@@ -1476,6 +1482,7 @@ impl App {
match target {
Some(Target::Song(_)) => h(Control::Activate, "Play"),
Some(Target::Setting(Setting::CoverBackdrop)) => h(Control::Seek, "Adjust"),
Some(Target::Setting(Setting::Version)) => {}
Some(Target::Setting(_)) => h(Control::Activate, "Change"),
Some(_) => h(Control::Activate, "Open"),
None if self.current_page().is_some_and(|p| p.error.is_some()) => {
@@ -2222,7 +2229,7 @@ fn song_entry(s: &Song, index: usize) -> Entry {
fn settings_data(s: &Settings) -> PageData {
let on_off = |on: bool| if on { "On" } else { "Off" }.to_string();
PageData {
let mut data = PageData {
entries: vec![
Entry {
title: "Colours from album art".to_string(),
@@ -2248,9 +2255,33 @@ fn settings_data(s: &Settings) -> PageData {
show_art: false,
target: Target::Setting(Setting::CoverBackdrop),
},
Entry {
title: "Show controls bar".to_string(),
subtitle: "The buttons for each screen and the version, at the bottom".to_string(),
detail: on_off(s.show_hint_bar),
number: String::new(),
cover: None,
round: false,
show_art: false,
target: Target::Setting(Setting::ShowHintBar),
},
],
..Default::default()
};
// The bar is where the version normally shows.
if !s.show_hint_bar {
data.entries.push(Entry {
title: "Version".to_string(),
subtitle: String::new(),
detail: concat!("remus ", env!("CARGO_PKG_VERSION")).to_string(),
number: String::new(),
cover: None,
round: false,
show_art: false,
target: Target::Setting(Setting::Version),
});
}
data
}
/// One step of the volume, kept within 0 to 100.
@@ -2474,6 +2505,22 @@ mod tests {
assert_ne!(a, c);
}
#[test]
fn version_is_listed_in_settings_only_while_the_bar_is_hidden() {
let has_version = |show_hint_bar: bool| {
let s = Settings {
show_hint_bar,
..Settings::default()
};
settings_data(&s)
.entries
.iter()
.any(|e| e.target == Target::Setting(Setting::Version))
};
assert!(!has_version(true));
assert!(has_version(false));
}
#[test]
fn volume_steps_stay_in_range() {
assert_eq!(step_volume(50, true), 55);
+7
View File
@@ -99,6 +99,9 @@ pub struct Settings {
pub volume: u8,
/// Muted, keeping `volume` for when it is unmuted.
pub muted: bool,
/// The bar with the button hints and the version. The login screen shows
/// it regardless.
pub show_hint_bar: bool,
}
/// The cover backdrop strength that looks like it did before it was a setting.
@@ -111,6 +114,7 @@ impl Default for Settings {
cover_backdrop: COVER_BACKDROP_DEFAULT,
volume: 100,
muted: false,
show_hint_bar: true,
}
}
}
@@ -216,6 +220,7 @@ mod tests {
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
assert_eq!(s.volume, 100);
assert!(!s.muted);
assert!(s.show_hint_bar);
}
#[test]
@@ -223,6 +228,7 @@ mod tests {
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);
assert!(s.show_hint_bar);
}
#[test]
@@ -232,6 +238,7 @@ mod tests {
cover_backdrop: 70,
volume: 35,
muted: true,
show_hint_bar: false,
};
let back: Settings = toml::from_str(&toml::to_string(&s).unwrap()).unwrap();
assert_eq!(back, s);