pub len: usize,
pub width: usize,
pub height: usize,
+ pub orig_w: usize,
+ pub orig_h: usize,
pub osd_tex: Texture<'a>,
pub empty_tex: Texture<'a>,
}
let mut osd_tex = texture_creator.create_texture_streaming(PixelFormatEnum::RGBA8888, width as u32, OSD_HEIGHT as u32).expect("failed to create RGBA texture");
osd_tex.set_blend_mode(BlendMode::Blend);
- Self { pool, osd_tex, empty_tex, first_ts: 0, last_ts: 0, ts_valid: false, len, width, height, queue: VecDeque::with_capacity(len) }
+ Self { pool, osd_tex, empty_tex, first_ts: 0, last_ts: 0, ts_valid: false, len, width, height, orig_w, orig_h, queue: VecDeque::with_capacity(len) }
}
fn flush(&mut self) {
osd: OSD,
show_osd: Option<bool>,
+ zoom_mode: bool,
+
#[cfg(feature="debug")]
logfile: File,
}
osd: OSD::new(),
show_osd: None,
+ zoom_mode: false,
+
#[cfg(feature="debug")]
logfile: File::create("debug.log").expect("'debug.log' should be available for writing"),
}
if let Event::MouseWheel {direction: MouseWheelDirection::Normal, x: 0, y, ..} = event {
self.seek(10, y > 0, dmx, disp_queue)?;
}
+ if self.zoom_mode {
+ if let Event::KeyDown {keycode: Some(keycode), ..} = event {
+ let orig_w = disp_queue.orig_w as u32;
+ let orig_h = disp_queue.orig_h as u32;
+ let (sc_num, sc_den) = match keycode {
+ Keycode::Num1 | Keycode::Kp1 => (1, 1),
+ Keycode::Num2 | Keycode::Kp2 => (2, 1),
+ Keycode::Num3 | Keycode::Kp3 => (3, 1),
+ Keycode::Num5 | Keycode::Kp5 => (1, 2),
+ Keycode::Period | Keycode::KpPeriod => (3, 2),
+ _ => (0, 0)
+ };
+ if sc_num != 0 {
+ let win = canvas.window_mut();
+ let new_w = orig_w * sc_num / sc_den;
+ let new_h = orig_h * sc_num / sc_den;
+ match win.set_size(new_w, new_h) {
+ Ok(()) => {},
+ Err(sdl2::IntegerOrSdlError::IntegerOverflows(errstr, _)) => {
+ println!("error resizing window: {errstr}");
+ },
+ Err(sdl2::IntegerOrSdlError::SdlError(errstr)) => {
+ println!("error resizing window: {errstr}");
+ },
+ }
+ } else {
+ println!(" wrong zoom modifier!");
+ }
+ self.zoom_mode = false;
+ continue;
+ }
+ }
if let Event::KeyDown {keycode: Some(keycode), keymod, ..} = event {
match keycode {
Keycode::Escape => {
dmx.set_options(&[NAOption{name: FORCE_SEEK_OPTION, value: NAValue::Bool(!force_seek)}]);
}
},
+ Keycode::Z if keymod.contains(Mod::RSHIFTMOD) || keymod.contains(Mod::LSHIFTMOD) => {
+ self.zoom_mode = !self.no_sdl_scale;
+ },
_ => {},
};
if !self.paused && !self.quiet {
let mut event_pump = self.sdl_context.event_pump().expect("should be able to create event pump");
let mut last_disp = Instant::now();
let mut has_data = true;
+ self.zoom_mode = false;
'main: loop {
self.seeked = false;
let ret = self.handle_events(&mut event_pump, &mut canvas, &mut dmx, &mut disp_q);