2022-08-17 01:20:06 +10:00
|
|
|
use simple_logger::SimpleLogger;
|
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
|
|
|
|
2023-06-20 04:46:38 +10:00
|
|
|
#[path = "util/fill.rs"]
|
|
|
|
mod fill;
|
|
|
|
|
2022-08-17 01:20:06 +10:00
|
|
|
fn main() {
|
|
|
|
SimpleLogger::new().init().unwrap();
|
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
2023-06-20 04:46:38 +10:00
|
|
|
let window = WindowBuilder::new()
|
2022-08-17 01:20:06 +10:00
|
|
|
.with_title("Touchpad gestures")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
println!("Only supported on macOS at the moment.");
|
|
|
|
|
|
|
|
event_loop.run(move |event, _, control_flow| {
|
|
|
|
*control_flow = ControlFlow::Wait;
|
|
|
|
|
|
|
|
if let Event::WindowEvent { event, .. } = event {
|
|
|
|
match event {
|
|
|
|
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
|
|
|
WindowEvent::TouchpadMagnify { delta, .. } => {
|
|
|
|
if delta > 0.0 {
|
2023-01-27 15:18:58 +11:00
|
|
|
println!("Zoomed in {delta}");
|
2022-08-17 01:20:06 +10:00
|
|
|
} else {
|
2023-01-27 15:18:58 +11:00
|
|
|
println!("Zoomed out {delta}");
|
2022-08-17 01:20:06 +10:00
|
|
|
}
|
|
|
|
}
|
2023-01-22 03:35:07 +11:00
|
|
|
WindowEvent::SmartMagnify { .. } => {
|
|
|
|
println!("Smart zoom");
|
|
|
|
}
|
2022-08-17 01:20:06 +10:00
|
|
|
WindowEvent::TouchpadRotate { delta, .. } => {
|
|
|
|
if delta > 0.0 {
|
2023-01-27 15:18:58 +11:00
|
|
|
println!("Rotated counterclockwise {delta}");
|
2022-08-17 01:20:06 +10:00
|
|
|
} else {
|
2023-01-27 15:18:58 +11:00
|
|
|
println!("Rotated clockwise {delta}");
|
2022-08-17 01:20:06 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
2023-06-20 04:46:38 +10:00
|
|
|
} else if let Event::RedrawRequested(_) = event {
|
|
|
|
fill::fill_window(&window);
|
2022-08-17 01:20:06 +10:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|