mirror of
https://github.com/Dummi26/musicdb.git
synced 2025-03-10 14:13:53 +01:00
space to play/pause
+ bugfix: when clearing queue, last song's title would still be shown. this is no longer the case
This commit is contained in:
parent
1eee22bb4b
commit
5161b5577d
@ -153,17 +153,17 @@ impl GuiElemTrait for CurrentSong {
|
|||||||
// redraw
|
// redraw
|
||||||
if self.config.redraw {
|
if self.config.redraw {
|
||||||
self.config.redraw = false;
|
self.config.redraw = false;
|
||||||
if let Some(song) = new_song {
|
|
||||||
let status_bar_text = info
|
|
||||||
.gui_config
|
|
||||||
.status_bar_text
|
|
||||||
.gen(&info.database, info.database.get_song(&song));
|
|
||||||
self.children[0]
|
self.children[0]
|
||||||
.try_as_mut::<AdvancedLabel>()
|
.try_as_mut::<AdvancedLabel>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.content = status_bar_text;
|
.content = if let Some(song) = new_song {
|
||||||
self.text_updated = Some(Instant::now());
|
self.text_updated = Some(Instant::now());
|
||||||
}
|
info.gui_config
|
||||||
|
.status_bar_text
|
||||||
|
.gen(&info.database, info.database.get_song(&song))
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(updated) = &self.text_updated {
|
if let Some(updated) = &self.text_updated {
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use musicdb_lib::data::queue::QueueContent;
|
use musicdb_lib::{data::queue::QueueContent, server::Command};
|
||||||
use speedy2d::{color::Color, dimen::Vec2, shape::Rectangle, Graphics2D};
|
use speedy2d::{
|
||||||
|
color::Color,
|
||||||
|
dimen::Vec2,
|
||||||
|
shape::Rectangle,
|
||||||
|
window::{KeyScancode, VirtualKeyCode},
|
||||||
|
Graphics2D,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
gui::{morph_rect, DrawInfo, GuiAction, GuiElem, GuiElemCfg, GuiElemTrait},
|
gui::{morph_rect, DrawInfo, GuiAction, GuiElem, GuiElemCfg, GuiElemTrait},
|
||||||
@ -83,7 +89,7 @@ impl GuiScreen {
|
|||||||
scroll_sensitivity_pages: f64,
|
scroll_sensitivity_pages: f64,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
config: config.w_keyboard_watch().w_mouse(),
|
config: config.w_keyboard_watch().w_mouse().w_keyboard_focus(),
|
||||||
children: vec![
|
children: vec![
|
||||||
GuiElem::new(notif_overlay),
|
GuiElem::new(notif_overlay),
|
||||||
GuiElem::new(StatusBar::new(
|
GuiElem::new(StatusBar::new(
|
||||||
@ -320,6 +326,25 @@ impl GuiElemTrait for GuiScreen {
|
|||||||
.get_timeout_val();
|
.get_timeout_val();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn key_focus(
|
||||||
|
&mut self,
|
||||||
|
modifiers: speedy2d::window::ModifiersState,
|
||||||
|
down: bool,
|
||||||
|
key: Option<speedy2d::window::VirtualKeyCode>,
|
||||||
|
scan: speedy2d::window::KeyScancode,
|
||||||
|
) -> Vec<GuiAction> {
|
||||||
|
if down && matches!(key, Some(VirtualKeyCode::Space)) {
|
||||||
|
vec![GuiAction::Build(Box::new(|db| {
|
||||||
|
vec![GuiAction::SendToServer(if db.playing {
|
||||||
|
Command::Pause
|
||||||
|
} else {
|
||||||
|
Command::Resume
|
||||||
|
})]
|
||||||
|
}))]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
Loading…
Reference in New Issue
Block a user