Merge pull request #2140 from blazra/master
Improve `TextEditor` slow scrolling behavior with touchpads
This commit is contained in:
commit
0b2c9db228
2 changed files with 22 additions and 14 deletions
|
|
@ -85,6 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Incorrect unit in `system::Information`. [#2223](https://github.com/iced-rs/iced/pull/2223)
|
- Incorrect unit in `system::Information`. [#2223](https://github.com/iced-rs/iced/pull/2223)
|
||||||
- `size_hint` not being called from `element::Map`. [#2224](https://github.com/iced-rs/iced/pull/2224)
|
- `size_hint` not being called from `element::Map`. [#2224](https://github.com/iced-rs/iced/pull/2224)
|
||||||
- `size_hint` not being called from `element::Explain`. [#2225](https://github.com/iced-rs/iced/pull/2225)
|
- `size_hint` not being called from `element::Explain`. [#2225](https://github.com/iced-rs/iced/pull/2225)
|
||||||
|
- Slow touch scrolling for `TextEditor` widget. [#2140](https://github.com/iced-rs/iced/pull/2140)
|
||||||
|
|
||||||
Many thanks to...
|
Many thanks to...
|
||||||
|
|
||||||
|
|
@ -93,6 +94,7 @@ Many thanks to...
|
||||||
- @arslee07
|
- @arslee07
|
||||||
- @AustinMReppert
|
- @AustinMReppert
|
||||||
- @avsaase
|
- @avsaase
|
||||||
|
- @blazra
|
||||||
- @brianch
|
- @brianch
|
||||||
- @bungoboingo
|
- @bungoboingo
|
||||||
- @Calastrophe
|
- @Calastrophe
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,7 @@ struct State<Highlighter: text::Highlighter> {
|
||||||
is_focused: bool,
|
is_focused: bool,
|
||||||
last_click: Option<mouse::Click>,
|
last_click: Option<mouse::Click>,
|
||||||
drag_click: Option<mouse::click::Kind>,
|
drag_click: Option<mouse::click::Kind>,
|
||||||
|
partial_scroll: f32,
|
||||||
highlighter: RefCell<Highlighter>,
|
highlighter: RefCell<Highlighter>,
|
||||||
highlighter_settings: Highlighter::Settings,
|
highlighter_settings: Highlighter::Settings,
|
||||||
highlighter_format_address: usize,
|
highlighter_format_address: usize,
|
||||||
|
|
@ -310,6 +311,7 @@ where
|
||||||
is_focused: false,
|
is_focused: false,
|
||||||
last_click: None,
|
last_click: None,
|
||||||
drag_click: None,
|
drag_click: None,
|
||||||
|
partial_scroll: 0.0,
|
||||||
highlighter: RefCell::new(Highlighter::new(
|
highlighter: RefCell::new(Highlighter::new(
|
||||||
&self.highlighter_settings,
|
&self.highlighter_settings,
|
||||||
)),
|
)),
|
||||||
|
|
@ -404,6 +406,14 @@ where
|
||||||
|
|
||||||
shell.publish(on_edit(action));
|
shell.publish(on_edit(action));
|
||||||
}
|
}
|
||||||
|
Update::Scroll(lines) => {
|
||||||
|
let lines = lines + state.partial_scroll;
|
||||||
|
state.partial_scroll = lines.fract();
|
||||||
|
|
||||||
|
shell.publish(on_edit(Action::Scroll {
|
||||||
|
lines: lines as i32,
|
||||||
|
}));
|
||||||
|
}
|
||||||
Update::Unfocus => {
|
Update::Unfocus => {
|
||||||
state.is_focused = false;
|
state.is_focused = false;
|
||||||
state.drag_click = None;
|
state.drag_click = None;
|
||||||
|
|
@ -577,6 +587,7 @@ where
|
||||||
|
|
||||||
enum Update {
|
enum Update {
|
||||||
Click(mouse::Click),
|
Click(mouse::Click),
|
||||||
|
Scroll(f32),
|
||||||
Unfocus,
|
Unfocus,
|
||||||
Release,
|
Release,
|
||||||
Action(Action),
|
Action(Action),
|
||||||
|
|
@ -630,21 +641,16 @@ impl Update {
|
||||||
mouse::Event::WheelScrolled { delta }
|
mouse::Event::WheelScrolled { delta }
|
||||||
if cursor.is_over(bounds) =>
|
if cursor.is_over(bounds) =>
|
||||||
{
|
{
|
||||||
action(Action::Scroll {
|
Some(Update::Scroll(match delta {
|
||||||
lines: match delta {
|
mouse::ScrollDelta::Lines { y, .. } => {
|
||||||
mouse::ScrollDelta::Lines { y, .. } => {
|
if y.abs() > 0.0 {
|
||||||
if y.abs() > 0.0 {
|
y.signum() * -(y.abs() * 4.0).max(1.0)
|
||||||
(y.signum() * -(y.abs() * 4.0).max(1.0))
|
} else {
|
||||||
as i32
|
0.0
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mouse::ScrollDelta::Pixels { y, .. } => {
|
}
|
||||||
(-y / 4.0) as i32
|
mouse::ScrollDelta::Pixels { y, .. } => -y / 4.0,
|
||||||
}
|
}))
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue