Skip to content

Commit

Permalink
fix: queue header showing while log messages are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
zX3no committed Aug 13, 2022
1 parent 7059504 commit 4b19061
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
4 changes: 1 addition & 3 deletions gonk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
41 changes: 26 additions & 15 deletions gonk/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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),
Expand Down

0 comments on commit 4b19061

Please sign in to comment.