ui: use egui default line-scroll baseline and test fast touchpad scaling

This commit is contained in:
batistalucasv committed 2026-11-11 13:57:51 -03:00
1 parent 278aae7235
commit 0c488934e0
2 files changed
+10 -1

No files matched your search

+2 -1
View File
@@ -302,7 +302,8 @@ impl WordApp {
ctx.set_zoom_factor(zoom);
}
// Mouse-wheel line scroll speed (#6146): scales egui's own scroll areas.
let target_line_speed = 40.0 * self.ui.scroll_speed.wheel_factor();
let base_line_speed = egui::InputOptions::default().line_scroll_speed;
let target_line_speed = base_line_speed * self.ui.scroll_speed.wheel_factor();
if (ctx.options(|o| o.input_options.line_scroll_speed) - target_line_speed).abs() > 1e-4 {
ctx.options_mut(|o| o.input_options.line_scroll_speed = target_line_speed);
}
+8
View File
@@ -8193,6 +8193,14 @@ fn touchpad_and_mouse_scroll_speed_scaling_and_preferences() {
assert_eq!(dy[1], -10.0, "Ctrl+wheel zoom delta is NOT scaled");
assert_eq!(dy[2], -1.0, "Line deltas are NOT scaled by touchpad factor");
// Fast touchpad setting scales raw_input_hook point deltas by the Fast factor.
a.ui.touchpad_scroll_speed = crate::scroll::ScrollSpeed::Fast;
let mut raw_fast = egui::RawInput { events: vec![wheel_event(egui::MouseWheelUnit::Point, -10.0, false)], ..Default::default() };
a.raw_input_hook(&ctx, &mut raw_fast);
if let egui::Event::MouseWheel { delta, .. } = &raw_fast.events[0] {
assert_eq!(delta.y, -10.0 * crate::scroll::ScrollSpeed::Fast.touchpad_factor());
}
// 2. Commands ui.touchpadScrollSpeed and ui.scrollSpeed set the preferences.
let r = a.run("ui.touchpadScrollSpeed", json!({"value": "fast"})).unwrap();
assert_eq!(r["touchpadScrollSpeed"], "fast");