diff options
author | 2019-11-03 05:19:12 +0100 | |
---|---|---|
committer | 2019-11-03 05:19:12 +0100 | |
commit | 0ea911ae36bbde8c288f7ae1ba8a0049b696d7c4 (patch) | |
tree | 929cb493b674512520f1b6a92f86d7a09e5801f6 /winit/src | |
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 'winit/src')
-rw-r--r-- | winit/src/application.rs | 33 |
1 files changed, 32 insertions, 1 deletions
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; } |