From 719c073fc67c87d6b2da1bc01b74751d3f5e59f0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 25 Oct 2019 03:47:34 +0200 Subject: Draft `Scrollable` widget (no clipping yet!) --- winit/src/application.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 418ee3c4..870f4868 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -136,6 +136,17 @@ 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_x, delta_y }, + )); + } + _ => {} + }, WindowEvent::CloseRequested => { *control_flow = ControlFlow::Exit; } -- cgit From 2b23e0986c532dbacd89ccd73bb603db558cbdaf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 28 Oct 2019 04:28:21 +0100 Subject: Implement text clipping (caching still broken) --- winit/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'winit') 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" -- cgit From 9dabbf78857c3a60583227d3aa2fa6e030f085d0 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 29 Oct 2019 03:34:21 +0100 Subject: Provide `Renderer` to `Widget::on_event` This allows us to implement configurable event processing that adapts to different rendering strategies. --- winit/src/application.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 870f4868..855968aa 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); -- cgit From bd5d871eb6630bc8f987d72c771032f878fb91b6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 29 Oct 2019 19:00:46 +0100 Subject: Handle touchpad scroll events --- winit/src/application.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 855968aa..c8748199 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -123,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()); @@ -143,10 +144,28 @@ pub trait Application { delta_y, ) => { events.push(Event::Mouse( - mouse::Event::WheelScrolled { delta_x, delta_y }, + 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; -- cgit