Skip to content

Commit

Permalink
Revert "Add TouchPhase to Scroll"
Browse files Browse the repository at this point in the history
This reverts commit 6cdd0c8.
  • Loading branch information
sampettersson committed Apr 8, 2023
1 parent c3b3fef commit c432309
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
7 changes: 2 additions & 5 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::atomic::{AtomicBool, Ordering};

use egui::{Key, TouchPhase};
use egui::Key;

use super::*;

Expand Down Expand Up @@ -434,10 +434,7 @@ pub fn install_canvas_events(runner_container: &mut AppRunnerContainer) -> Resul
.input
.raw
.events
.push(egui::Event::Scroll {
delta,
phase: TouchPhase::Move
});
.push(egui::Event::Scroll(delta));
}

runner_lock.needs_repaint.repaint_asap();
Expand Down
23 changes: 5 additions & 18 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ impl State {
consumed: egui_ctx.wants_pointer_input(),
}
}
WindowEvent::MouseWheel { delta, phase, .. } => {
self.on_mouse_wheel(*delta, *phase);
WindowEvent::MouseWheel { delta, .. } => {
self.on_mouse_wheel(*delta);
EventResponse {
repaint: true,
consumed: egui_ctx.wants_pointer_input(),
Expand Down Expand Up @@ -548,7 +548,7 @@ impl State {
}
}

fn on_mouse_wheel(&mut self, delta: winit::event::MouseScrollDelta, phase: winit::event::TouchPhase) {
fn on_mouse_wheel(&mut self, delta: winit::event::MouseScrollDelta) {
let delta = match delta {
winit::event::MouseScrollDelta::LineDelta(x, y) => {
let points_per_scroll_line = 50.0; // Scroll speed decided by consensus: https://github.com/emilk/egui/issues/461
Expand All @@ -559,13 +559,6 @@ impl State {
}
};

let phase = match phase {
winit::event::TouchPhase::Started => egui::TouchPhase::Start,
winit::event::TouchPhase::Moved => egui::TouchPhase::Move,
winit::event::TouchPhase::Ended => egui::TouchPhase::End,
winit::event::TouchPhase::Cancelled => egui::TouchPhase::Cancel,
};

if self.egui_input.modifiers.ctrl || self.egui_input.modifiers.command {
// Treat as zoom instead:
let factor = (delta.y / 200.0).exp();
Expand All @@ -575,15 +568,9 @@ impl State {
// Note: one Mac we already get horizontal scroll events when shift is down.
self.egui_input
.events
.push(egui::Event::Scroll {
delta: egui::vec2(delta.x + delta.y, 0.0),
phase
});
.push(egui::Event::Scroll(egui::vec2(delta.x + delta.y, 0.0)));
} else {
self.egui_input.events.push(egui::Event::Scroll {
delta,
phase
});
self.egui_input.events.push(egui::Event::Scroll(delta));
}
}

Expand Down
5 changes: 1 addition & 4 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,7 @@ pub enum Event {
/// as when swiping down on a touch-screen or track-pad with natural scrolling.
///
/// Shift-scroll should result in horizontal scrolling (it is up to the integrations to do this).
Scroll {
delta: Vec2,
phase: TouchPhase
},
Scroll(Vec2),

/// Zoom scale factor this frame (e.g. from ctrl-scroll or pinch gesture).
/// * `zoom = 1`: no change.
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/input_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl InputState {
keys_down.remove(key);
}
}
Event::Scroll { delta, .. } => {
Event::Scroll(delta) => {
scroll_delta += *delta;
}
Event::Zoom(factor) => {
Expand Down

0 comments on commit c432309

Please sign in to comment.