Impl hide text when "H" key is pressed
This commit is contained in:
parent
7616f1e3f2
commit
78da393fac
3 changed files with 59 additions and 36 deletions
|
@ -32,6 +32,8 @@ counter, and the filename currently being played
|
||||||
|
|
||||||
Note that presing the Escape key when the window is focused closes the program.
|
Note that presing the Escape key when the window is focused closes the program.
|
||||||
|
|
||||||
|
Also note that pressing the H key while displaying text will hide the text.
|
||||||
|
|
||||||
# Issues / TODO
|
# Issues / TODO
|
||||||
|
|
||||||
- [ ] UTF-8 Non-ascii font support
|
- [ ] UTF-8 Non-ascii font support
|
||||||
|
|
|
@ -68,6 +68,7 @@ pub struct MPDDisplay {
|
||||||
timer: f64,
|
timer: f64,
|
||||||
length: f64,
|
length: f64,
|
||||||
text_bg_mesh: Option<Mesh>,
|
text_bg_mesh: Option<Mesh>,
|
||||||
|
hide_text: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MPDDisplay {
|
impl MPDDisplay {
|
||||||
|
@ -95,6 +96,7 @@ impl MPDDisplay {
|
||||||
timer: 0.0,
|
timer: 0.0,
|
||||||
length: 0.0,
|
length: 0.0,
|
||||||
text_bg_mesh: None,
|
text_bg_mesh: None,
|
||||||
|
hide_text: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,6 +506,7 @@ impl EventHandler for MPDDisplay {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.hide_text {
|
||||||
self.notice_text.draw(ctx, DrawParam::default())?;
|
self.notice_text.draw(ctx, DrawParam::default())?;
|
||||||
|
|
||||||
if self.is_valid && self.is_initialized {
|
if self.is_valid && self.is_initialized {
|
||||||
|
@ -549,6 +552,7 @@ impl EventHandler for MPDDisplay {
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
graphics::present(ctx)
|
graphics::present(ctx)
|
||||||
}
|
}
|
||||||
|
@ -588,6 +592,21 @@ impl EventHandler for MPDDisplay {
|
||||||
self.password_entered = true;
|
self.password_entered = true;
|
||||||
//log(format!("Entered \"{}\"", self.opts.password.as_ref().unwrap_or(&String::new())));
|
//log(format!("Entered \"{}\"", self.opts.password.as_ref().unwrap_or(&String::new())));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if keycode == event::KeyCode::H {
|
||||||
|
self.hide_text = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn key_up_event(
|
||||||
|
&mut self,
|
||||||
|
_ctx: &mut Context,
|
||||||
|
keycode: event::KeyCode,
|
||||||
|
_keymods: event::KeyMods,
|
||||||
|
) {
|
||||||
|
if keycode == event::KeyCode::H {
|
||||||
|
self.hide_text = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ fn main() -> Result<(), String> {
|
||||||
}
|
}
|
||||||
if state == ElementState::Pressed {
|
if state == ElementState::Pressed {
|
||||||
display.key_down_event(ctx, keycode, modifiers_state.into(), false);
|
display.key_down_event(ctx, keycode, modifiers_state.into(), false);
|
||||||
|
} else {
|
||||||
|
display.key_up_event(ctx, keycode, modifiers_state.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event::winit_event::WindowEvent::Resized(phys_size) => {
|
event::winit_event::WindowEvent::Resized(phys_size) => {
|
||||||
|
|
Loading…
Reference in a new issue