diff options
author | 2019-11-03 05:19:12 +0100 | |
---|---|---|
committer | 2019-11-03 05:19:12 +0100 | |
commit | 0ea911ae36bbde8c288f7ae1ba8a0049b696d7c4 (patch) | |
tree | 929cb493b674512520f1b6a92f86d7a09e5801f6 /winit | |
parent | de3c87b9a793c0d0799948e16ad1b14e5b4892ba (diff) | |
parent | 022dc0139b7437f167a8d3ae483bf8e83f1dab04 (diff) | |
download | iced-0ea911ae36bbde8c288f7ae1ba8a0049b696d7c4.tar.gz iced-0ea911ae36bbde8c288f7ae1ba8a0049b696d7c4.tar.bz2 iced-0ea911ae36bbde8c288f7ae1ba8a0049b696d7c4.zip |
Merge pull request #35 from hecrj/feature/scrollables
Scrollable widget
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; } |