diff --git a/src/main.rs b/src/main.rs index 8819401..cfda8a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -185,7 +185,7 @@ fn main() { let status = ui::statusbar::StatusBar::new( queue.clone(), - spotify.clone(), + library.clone(), cfg.use_nerdfont.unwrap_or(false), ); diff --git a/src/ui/statusbar.rs b/src/ui/statusbar.rs index 52b4ff9..5a12e0a 100644 --- a/src/ui/statusbar.rs +++ b/src/ui/statusbar.rs @@ -8,21 +8,26 @@ use cursive::vec::Vec2; use cursive::Printer; use unicode_width::UnicodeWidthStr; +use library::Library; use queue::{Queue, RepeatSetting}; use spotify::{PlayerEvent, Spotify}; pub struct StatusBar { queue: Arc, spotify: Arc, + library: Arc, last_size: Vec2, use_nerdfont: bool, } impl StatusBar { - pub fn new(queue: Arc, spotify: Arc, use_nerdfont: bool) -> StatusBar { + pub fn new(queue: Arc, library: Arc, use_nerdfont: bool) -> StatusBar { + let spotify = queue.get_spotify(); + StatusBar { queue, spotify, + library, last_size: Vec2::new(0, 0), use_nerdfont, } @@ -96,8 +101,7 @@ impl View for StatusBar { RepeatSetting::RepeatPlaylist => "[R] ", RepeatSetting::RepeatTrack => "[R1] ", } - } - .to_string(); + }; let shuffle = if self.queue.get_shuffle() { if self.use_nerdfont { @@ -107,8 +111,7 @@ impl View for StatusBar { } } else { "" - } - .to_string(); + }; printer.with_color(style_bar_bg, |printer| { printer.print((0, 0), &"┉".repeat(printer.size.x)); @@ -124,8 +127,20 @@ impl View for StatusBar { elapsed.as_secs() % 60 ); - let right = - repeat + &shuffle + &format!("{} / {} ", formatted_elapsed, t.duration_str()); + let saved = if self.library.is_saved_track(t) { + if self.use_nerdfont { + "\u{f62b} " + } else { + "✓ " + } + } else { + "" + }; + + let right = repeat.to_string() + + shuffle + + saved + + &format!("{} / {} ", formatted_elapsed, t.duration_str()); let offset = HAlign::Right.get_offset(right.width(), printer.size.x); printer.with_color(style, |printer| { @@ -138,7 +153,7 @@ impl View for StatusBar { printer.print((0, 0), &"━".repeat(duration_width + 1)); }); } else { - let right = repeat + &shuffle; + let right = repeat.to_string() + shuffle; let offset = HAlign::Right.get_offset(right.width(), printer.size.x); printer.with_color(style, |printer| {