From 4b190616bbbd303113d19445ec112b12fcb78931 Mon Sep 17 00:00:00 2001 From: zX3no Date: Sat, 13 Aug 2022 10:56:20 +0930 Subject: [PATCH] fix: queue header showing while log messages are displayed --- gonk/src/main.rs | 4 +--- gonk/src/queue.rs | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/gonk/src/main.rs b/gonk/src/main.rs index 37046146..0e75deb1 100644 --- a/gonk/src/main.rs +++ b/gonk/src/main.rs @@ -304,11 +304,9 @@ fn main() { playlist::delete(&mut playlist, true); } } - KeyCode::Char('u') if mode == Mode::Browser => { + KeyCode::Char('u') if mode == Mode::Browser || mode == Mode::Playlist => { let folder = gonk_database::get_music_folder().to_string(); scan_handle = Some(gonk_database::scan(folder)); - } - KeyCode::Char('u') if mode == Mode::Playlist => { playlist.playlists = Index::from(gonk_database::playlists()); } KeyCode::Char('q') => match player.seek_by(-10.0) { diff --git a/gonk/src/queue.rs b/gonk/src/queue.rs index 696c35fe..ab6abcee 100644 --- a/gonk/src/queue.rs +++ b/gonk/src/queue.rs @@ -84,7 +84,9 @@ pub fn draw(queue: &mut Queue, player: &mut Player, f: &mut Frame, event: Option let row_bounds = draw_body(queue, player, f, chunks[1]); - draw_seeker(player, f, chunks[2]); + if log::message().is_none() { + draw_seeker(player, f, chunks[2]); + } //Don't handle mouse input when the queue is empty. if player.songs.is_empty() { @@ -204,7 +206,17 @@ fn draw_body( f: &mut Frame, area: Rect, ) -> Option<(usize, usize)> { - if player.songs.is_empty() && log::message().is_none() { + if log::message().is_some() && player.songs.is_empty() { + f.render_widget( + Block::default() + .border_type(BorderType::Rounded) + .borders(Borders::LEFT | Borders::RIGHT | Borders::BOTTOM), + area, + ); + return None; + } + + if player.songs.is_empty() { f.render_widget( Block::default() .border_type(BorderType::Rounded) @@ -324,18 +336,13 @@ fn draw_body( } fn draw_seeker(player: &mut Player, f: &mut Frame, area: Rect) { - let block = if player.songs.is_empty() { - Block::default() - .border_type(BorderType::Rounded) - .borders(Borders::BOTTOM | Borders::LEFT | Borders::RIGHT) - } else { - Block::default() - .border_type(BorderType::Rounded) - .borders(Borders::ALL) - }; - - if log::message().is_some() || player.songs.is_empty() { - return f.render_widget(block, area); + if player.songs.is_empty() { + return f.render_widget( + Block::default() + .border_type(BorderType::Rounded) + .borders(Borders::BOTTOM | Borders::LEFT | Borders::RIGHT), + area, + ); } let elapsed = player.elapsed().as_secs_f64(); @@ -358,7 +365,11 @@ fn draw_seeker(player: &mut Player, f: &mut Frame, area: Rect) { f.render_widget( Gauge::default() - .block(block) + .block( + Block::default() + .border_type(BorderType::Rounded) + .borders(Borders::ALL), + ) .gauge_style(Style::default().fg(COLORS.seeker)) .ratio(ratio as f64) .label(seeker),