use sdl2::event::{Event, WindowEvent};
use sdl2::keyboard::Keycode;
+use sdl2::mouse::MouseButton;
use sdl2::render::{Canvas, Texture, TextureCreator};
use sdl2::pixels::PixelFormatEnum;
use sdl2::video::{Window, WindowContext};
}
debug_log!(self; {format!(" prefilling done, frames {}-{} audio {}", disp_queue.start, disp_queue.end, self.acontrol.get_fill())});
}
+ fn toggle_pause(&mut self) {
+ self.paused = !self.paused;
+ if self.paused {
+ self.vsystem.enable_screen_saver();
+ self.tkeep.set_ts();
+ } else {
+ self.vsystem.disable_screen_saver();
+ self.tkeep.set_time();
+ }
+ if self.paused {
+ self.acontrol.pause();
+ } else {
+ self.acontrol.resume();
+ }
+ }
fn handle_events(&mut self, event_pump: &mut sdl2::EventPump, canvas: &mut Canvas<Window>, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> bool {
for event in event_pump.poll_iter() {
if let Event::Quit {..} = event {
canvas.copy(disp_queue.get_last_texture(&self.osd), None, None).unwrap();
canvas.present();
}
+ if let Event::MouseButtonDown {mouse_btn: MouseButton::Right, ..} = event {
+ self.toggle_pause();
+ }
if let Event::KeyDown {keycode: Some(keycode), ..} = event {
match keycode {
Keycode::Escape | Keycode::Q => {
Keycode::Down => { self.seek(60, false, dmx, disp_queue); },
Keycode::PageUp => { self.seek(600, true, dmx, disp_queue); },
Keycode::PageDown => { self.seek(600, false, dmx, disp_queue); },
- Keycode::Space => {
- self.paused = !self.paused;
- if self.paused {
- self.vsystem.enable_screen_saver();
- self.tkeep.set_ts();
- } else {
- self.vsystem.disable_screen_saver();
- self.tkeep.set_time();
- }
- if self.paused {
- self.acontrol.pause();
- } else {
- self.acontrol.resume();
- }
- },
+ Keycode::Space => { self.toggle_pause(); },
Keycode::Plus | Keycode::KpPlus => {
self.volume = (self.volume + 10).min(MAX_VOLUME);
if !self.mute {