diff options
Diffstat (limited to '')
-rw-r--r-- | winit/Cargo.toml | 2 | ||||
-rw-r--r-- | winit/src/application.rs | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/winit/Cargo.toml b/winit/Cargo.toml index fa5d6adf..c8227ac4 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -9,5 +9,5 @@ repository = "https://github.com/hecrj/iced" [dependencies] iced_native = { version = "0.1.0-alpha", path = "../native" } -winit = { version = "0.20.0-alpha3", git = "https://github.com/hecrj/winit", branch = "redraw-requested-2.0" } +winit = { version = "0.20.0-alpha3", git = "https://github.com/rust-windowing/winit", rev = "709808eb4e69044705fcb214bcc30556db761405"} log = "0.4" diff --git a/winit/src/application.rs b/winit/src/application.rs index 418ee3c4..c8748199 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -68,7 +68,8 @@ pub trait Application { &renderer, ); - let messages = user_interface.update(events.drain(..)); + let messages = + user_interface.update(&renderer, events.drain(..)); if messages.is_empty() { primitive = user_interface.draw(&mut renderer); @@ -122,6 +123,7 @@ pub trait Application { .. } => match window_event { WindowEvent::CursorMoved { position, .. } => { + // TODO: Remove when renderer supports HiDPI let physical_position = position.to_physical(window.hidpi_factor()); @@ -136,6 +138,35 @@ pub trait Application { state: conversion::button_state(state), })); } + WindowEvent::MouseWheel { delta, .. } => match delta { + winit::event::MouseScrollDelta::LineDelta( + delta_x, + delta_y, + ) => { + events.push(Event::Mouse( + mouse::Event::WheelScrolled { + delta: mouse::ScrollDelta::Lines { + x: delta_x, + y: delta_y, + }, + }, + )); + } + winit::event::MouseScrollDelta::PixelDelta(position) => { + // TODO: Remove when renderer supports HiDPI + let physical_position = + position.to_physical(window.hidpi_factor()); + + events.push(Event::Mouse( + mouse::Event::WheelScrolled { + delta: mouse::ScrollDelta::Pixels { + x: physical_position.x as f32, + y: physical_position.y as f32, + }, + }, + )); + } + }, WindowEvent::CloseRequested => { *control_flow = ControlFlow::Exit; } |