Scroll changes volume when mouse is on volume %
This commit is contained in:
committed by
Henrik Friedrichsen
parent
8c710f67ce
commit
d949a7c02b
@@ -61,6 +61,13 @@ impl StatusBar {
|
|||||||
PlayerEvent::Stopped | PlayerEvent::FinishedTrack => indicators.2,
|
PlayerEvent::Stopped | PlayerEvent::FinishedTrack => indicators.2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn volume_display(&self) -> String {
|
||||||
|
format!(
|
||||||
|
" [{}%]",
|
||||||
|
(self.spotify.volume() as f64 / 65535_f64 * 100.0).round() as u16
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View for StatusBar {
|
impl View for StatusBar {
|
||||||
@@ -137,10 +144,7 @@ impl View for StatusBar {
|
|||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
let volume = format!(
|
let volume = self.volume_display();
|
||||||
" [{}%]",
|
|
||||||
(self.spotify.volume() as f64 / 65535_f64 * 100.0).round() as u16
|
|
||||||
);
|
|
||||||
|
|
||||||
printer.with_color(style_bar_bg, |printer| {
|
printer.with_color(style_bar_bg, |printer| {
|
||||||
printer.print((0, 0), &"┉".repeat(printer.size.x));
|
printer.print((0, 0), &"┉".repeat(printer.size.x));
|
||||||
@@ -200,6 +204,7 @@ impl View for StatusBar {
|
|||||||
} = event
|
} = event
|
||||||
{
|
{
|
||||||
let position = position - offset;
|
let position = position - offset;
|
||||||
|
let volume_len = self.volume_display().len();
|
||||||
|
|
||||||
if position.y == 0 {
|
if position.y == 0 {
|
||||||
if event == MouseEvent::WheelUp {
|
if event == MouseEvent::WheelUp {
|
||||||
@@ -219,6 +224,24 @@ impl View for StatusBar {
|
|||||||
self.spotify.seek(new as u32);
|
self.spotify.seek(new as u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if self.last_size.x - position.x < volume_len {
|
||||||
|
if event == MouseEvent::WheelUp {
|
||||||
|
let volume = self
|
||||||
|
.spotify
|
||||||
|
.volume()
|
||||||
|
.saturating_add(crate::spotify::VOLUME_PERCENT);
|
||||||
|
|
||||||
|
self.spotify.set_volume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if event == MouseEvent::WheelDown {
|
||||||
|
let volume = self
|
||||||
|
.spotify
|
||||||
|
.volume()
|
||||||
|
.saturating_sub(crate::spotify::VOLUME_PERCENT);
|
||||||
|
|
||||||
|
self.spotify.set_volume(volume);
|
||||||
|
}
|
||||||
} else if event == MouseEvent::Press(MouseButton::Left) {
|
} else if event == MouseEvent::Press(MouseButton::Left) {
|
||||||
self.queue.toggleplayback();
|
self.queue.toggleplayback();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user