From f0ae9a0c38c2532220a7460916604914db94c078 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 24 Mar 2024 05:03:09 +0100 Subject: Use `Catalog` approach for all widgets --- widget/src/scrollable.rs | 131 +++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 66 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index c03bbb7d..84e9ac15 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -12,8 +12,8 @@ use crate::core::widget; use crate::core::widget::operation::{self, Operation}; use crate::core::widget::tree::{self, Tree}; use crate::core::{ - Background, Border, Clipboard, Color, Element, Layout, Length, Pixels, - Point, Rectangle, Shell, Size, Theme, Vector, Widget, + self, Background, Border, Clipboard, Color, Element, Layout, Length, + Pixels, Point, Rectangle, Shell, Size, Theme, Vector, Widget, }; use crate::runtime::Command; @@ -28,7 +28,8 @@ pub struct Scrollable< Theme = crate::Theme, Renderer = crate::Renderer, > where - Renderer: crate::core::Renderer, + Theme: Catalog, + Renderer: core::Renderer, { id: Option, width: Length, @@ -36,20 +37,18 @@ pub struct Scrollable< direction: Direction, content: Element<'a, Message, Theme, Renderer>, on_scroll: Option Message + 'a>>, - style: Style<'a, Theme>, + class: Theme::Class<'a>, } impl<'a, Message, Theme, Renderer> Scrollable<'a, Message, Theme, Renderer> where - Renderer: crate::core::Renderer, + Theme: Catalog, + Renderer: core::Renderer, { /// Creates a new vertical [`Scrollable`]. pub fn new( content: impl Into>, - ) -> Self - where - Theme: DefaultStyle + 'a, - { + ) -> Self { Self::with_direction(content, Direction::default()) } @@ -57,18 +56,6 @@ where pub fn with_direction( content: impl Into>, direction: Direction, - ) -> Self - where - Theme: DefaultStyle + 'a, - { - Self::with_direction_and_style(content, direction, Theme::default_style) - } - - /// Creates a new [`Scrollable`] with the given [`Direction`] and style. - pub fn with_direction_and_style( - content: impl Into>, - direction: Direction, - style: impl Fn(&Theme, Status) -> Appearance + 'a, ) -> Self { let content = content.into(); @@ -91,7 +78,7 @@ where direction, content, on_scroll: None, - style: Box::new(style), + class: Theme::default(), } } @@ -121,12 +108,21 @@ where self } - /// Sets the style of the [`Scrollable`] . - pub fn style( - mut self, - style: impl Fn(&Theme, Status) -> Appearance + 'a, - ) -> Self { - self.style = Box::new(style); + /// Sets the style of this [`Scrollable`]. + #[must_use] + pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self + where + Theme::Class<'a>: From>, + { + self.class = (Box::new(style) as StyleFn<'a, Theme>).into(); + self + } + + /// Sets the style class of the [`Scrollable`]. + #[cfg(feature = "advanced")] + #[must_use] + pub fn class(mut self, class: impl Into>) -> Self { + self.class = class.into(); self } } @@ -237,7 +233,8 @@ pub enum Alignment { impl<'a, Message, Theme, Renderer> Widget for Scrollable<'a, Message, Theme, Renderer> where - Renderer: crate::core::Renderer, + Theme: Catalog, + Renderer: core::Renderer, { fn tag(&self) -> tree::Tag { tree::Tag::of::() @@ -651,7 +648,7 @@ where tree: &Tree, renderer: &mut Renderer, theme: &Theme, - style: &renderer::Style, + defaults: &renderer::Style, layout: Layout<'_>, cursor: mouse::Cursor, _viewport: &Rectangle, @@ -701,13 +698,9 @@ where Status::Active }; - let appearance = (self.style)(theme, status); + let style = theme.style(&self.class, status); - container::draw_background( - renderer, - &appearance.container, - layout.bounds(), - ); + container::draw_background(renderer, &style.container, layout.bounds()); // Draw inner content if scrollbars.active() { @@ -719,7 +712,7 @@ where &tree.children[0], renderer, theme, - style, + defaults, content_layout, cursor, &Rectangle { @@ -782,7 +775,7 @@ where if let Some(scrollbar) = scrollbars.y { draw_scrollbar( renderer, - appearance.vertical_scrollbar, + style.vertical_scrollbar, &scrollbar, ); } @@ -790,14 +783,14 @@ where if let Some(scrollbar) = scrollbars.x { draw_scrollbar( renderer, - appearance.horizontal_scrollbar, + style.horizontal_scrollbar, &scrollbar, ); } if let (Some(x), Some(y)) = (scrollbars.x, scrollbars.y) { let background = - appearance.gap.or(appearance.container.background); + style.gap.or(style.container.background); if let Some(background) = background { renderer.fill_quad( @@ -821,7 +814,7 @@ where &tree.children[0], renderer, theme, - style, + defaults, content_layout, cursor, &Rectangle { @@ -916,8 +909,8 @@ impl<'a, Message, Theme, Renderer> for Element<'a, Message, Theme, Renderer> where Message: 'a, - Theme: 'a, - Renderer: 'a + crate::core::Renderer, + Theme: 'a + Catalog, + Renderer: 'a + core::Renderer, { fn from( text_input: Scrollable<'a, Message, Theme, Renderer>, @@ -1570,9 +1563,9 @@ pub enum Status { /// The appearance of a scrolable. #[derive(Debug, Clone, Copy)] -pub struct Appearance { - /// The [`container::Appearance`] of a scrollable. - pub container: container::Appearance, +pub struct Style { + /// The [`container::Style`] of a scrollable. + pub container: container::Style, /// The vertical [`Scrollbar`] appearance. pub vertical_scrollbar: Scrollbar, /// The horizontal [`Scrollbar`] appearance. @@ -1601,29 +1594,35 @@ pub struct Scroller { pub border: Border, } -/// The style of a [`Scrollable`]. -pub type Style<'a, Theme> = Box Appearance + 'a>; +/// The theme catalog of a [`Scrollable`]. +pub trait Catalog { + /// The item class of the [`Catalog`]. + type Class<'a>; -/// The default style of a [`Scrollable`]. -pub trait DefaultStyle { - /// Returns the default style of a [`Scrollable`]. - fn default_style(&self, status: Status) -> Appearance; + /// The default class produced by the [`Catalog`]. + fn default<'a>() -> Self::Class<'a>; + + /// The [`Style`] of a class with the given status. + fn style(&self, class: &Self::Class<'_>, status: Status) -> Style; } -impl DefaultStyle for Theme { - fn default_style(&self, status: Status) -> Appearance { - default(self, status) +/// A styling function for a [`Scrollable`]. +pub type StyleFn<'a, Theme> = Box Style + 'a>; + +impl Catalog for Theme { + type Class<'a> = StyleFn<'a, Self>; + + fn default<'a>() -> Self::Class<'a> { + Box::new(default) } -} -impl DefaultStyle for Appearance { - fn default_style(&self, _status: Status) -> Appearance { - *self + fn style(&self, class: &Self::Class<'_>, status: Status) -> Style { + class(self, status) } } /// The default style of a [`Scrollable`]. -pub fn default(theme: &Theme, status: Status) -> Appearance { +pub fn default(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); let scrollbar = Scrollbar { @@ -1636,8 +1635,8 @@ pub fn default(theme: &Theme, status: Status) -> Appearance { }; match status { - Status::Active => Appearance { - container: container::Appearance::default(), + Status::Active => Style { + container: container::Style::default(), vertical_scrollbar: scrollbar, horizontal_scrollbar: scrollbar, gap: None, @@ -1654,8 +1653,8 @@ pub fn default(theme: &Theme, status: Status) -> Appearance { ..scrollbar }; - Appearance { - container: container::Appearance::default(), + Style { + container: container::Style::default(), vertical_scrollbar: if is_vertical_scrollbar_hovered { hovered_scrollbar } else { @@ -1681,8 +1680,8 @@ pub fn default(theme: &Theme, status: Status) -> Appearance { ..scrollbar }; - Appearance { - container: container::Appearance::default(), + Style { + container: container::Style::default(), vertical_scrollbar: if is_vertical_scrollbar_dragged { dragged_scrollbar } else { -- cgit From b05e61f5c8ae61c9f3c7cc08cded53901ebbccfd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 3 Apr 2024 21:07:54 +0200 Subject: Redesign `iced_wgpu` layering architecture --- widget/src/scrollable.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 84e9ac15..668c5372 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -651,7 +651,7 @@ where defaults: &renderer::Style, layout: Layout<'_>, cursor: mouse::Cursor, - _viewport: &Rectangle, + viewport: &Rectangle, ) { let state = tree.state.downcast_ref::(); @@ -767,8 +767,8 @@ where renderer.with_layer( Rectangle { - width: bounds.width + 2.0, - height: bounds.height + 2.0, + width: (bounds.width + 2.0).min(viewport.width), + height: (bounds.height + 2.0).min(viewport.height), ..bounds }, |renderer| { -- cgit From 67e181ce7bad516d2ff8fc34c989af2435fdc7b4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 23 Apr 2024 02:29:04 +0200 Subject: Fix clip bounds with nested `scrollable` widgets --- widget/src/scrollable.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 668c5372..626cd07f 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -659,6 +659,10 @@ where let content_layout = layout.children().next().unwrap(); let content_bounds = content_layout.bounds(); + let Some(visible_bounds) = bounds.intersection(viewport) else { + return; + }; + let scrollbars = Scrollbars::new(state, self.direction, bounds, content_bounds); @@ -704,7 +708,7 @@ where // Draw inner content if scrollbars.active() { - renderer.with_layer(bounds, |renderer| { + renderer.with_layer(visible_bounds, |renderer| { renderer.with_translation( Vector::new(-translation.x, -translation.y), |renderer| { @@ -767,9 +771,9 @@ where renderer.with_layer( Rectangle { - width: (bounds.width + 2.0).min(viewport.width), - height: (bounds.height + 2.0).min(viewport.height), - ..bounds + width: (visible_bounds.width + 2.0).min(viewport.width), + height: (visible_bounds.height + 2.0).min(viewport.height), + ..visible_bounds }, |renderer| { if let Some(scrollbar) = scrollbars.y { -- cgit From fdcec0319757d2f87c82787eab34c6bef8c5a799 Mon Sep 17 00:00:00 2001 From: Daniel <101683475+Koranir@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:45:44 +1000 Subject: Don't consume unused scroll events (#2397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial Commit * Update scrollable.rs * Use `let _ = ` instead of `_ =` for consistency --------- Co-authored-by: Héctor Ramón Jiménez --- widget/src/scrollable.rs | 84 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 39 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 626cd07f..cdc143a2 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -435,15 +435,17 @@ where state.scroll(delta, self.direction, bounds, content_bounds); - notify_on_scroll( + event_status = if notify_on_scroll( state, &self.on_scroll, bounds, content_bounds, shell, - ); - - event_status = event::Status::Captured; + ) { + event::Status::Captured + } else { + event::Status::Ignored + }; } Event::Touch(event) if state.scroll_area_touched_at.is_some() @@ -481,7 +483,8 @@ where state.scroll_area_touched_at = Some(cursor_position); - notify_on_scroll( + // TODO: bubble up touch movements if not consumed. + let _ = notify_on_scroll( state, &self.on_scroll, bounds, @@ -516,7 +519,7 @@ where content_bounds, ); - notify_on_scroll( + let _ = notify_on_scroll( state, &self.on_scroll, bounds, @@ -554,7 +557,7 @@ where state.y_scroller_grabbed_at = Some(scroller_grabbed_at); - notify_on_scroll( + let _ = notify_on_scroll( state, &self.on_scroll, bounds, @@ -587,7 +590,7 @@ where content_bounds, ); - notify_on_scroll( + let _ = notify_on_scroll( state, &self.on_scroll, bounds, @@ -625,7 +628,7 @@ where state.x_scroller_grabbed_at = Some(scroller_grabbed_at); - notify_on_scroll( + let _ = notify_on_scroll( state, &self.on_scroll, bounds, @@ -965,51 +968,54 @@ pub fn scroll_to( Command::widget(operation::scrollable::scroll_to(id.0, offset)) } +/// Returns [`true`] if the viewport actually changed. fn notify_on_scroll( state: &mut State, on_scroll: &Option Message + '_>>, bounds: Rectangle, content_bounds: Rectangle, shell: &mut Shell<'_, Message>, -) { - if let Some(on_scroll) = on_scroll { - if content_bounds.width <= bounds.width - && content_bounds.height <= bounds.height - { - return; - } +) -> bool { + if content_bounds.width <= bounds.width + && content_bounds.height <= bounds.height + { + return false; + } - let viewport = Viewport { - offset_x: state.offset_x, - offset_y: state.offset_y, - bounds, - content_bounds, - }; + let viewport = Viewport { + offset_x: state.offset_x, + offset_y: state.offset_y, + bounds, + content_bounds, + }; - // Don't publish redundant viewports to shell - if let Some(last_notified) = state.last_notified { - let last_relative_offset = last_notified.relative_offset(); - let current_relative_offset = viewport.relative_offset(); + // Don't publish redundant viewports to shell + if let Some(last_notified) = state.last_notified { + let last_relative_offset = last_notified.relative_offset(); + let current_relative_offset = viewport.relative_offset(); - let last_absolute_offset = last_notified.absolute_offset(); - let current_absolute_offset = viewport.absolute_offset(); + let last_absolute_offset = last_notified.absolute_offset(); + let current_absolute_offset = viewport.absolute_offset(); - let unchanged = |a: f32, b: f32| { - (a - b).abs() <= f32::EPSILON || (a.is_nan() && b.is_nan()) - }; + let unchanged = |a: f32, b: f32| { + (a - b).abs() <= f32::EPSILON || (a.is_nan() && b.is_nan()) + }; - if unchanged(last_relative_offset.x, current_relative_offset.x) - && unchanged(last_relative_offset.y, current_relative_offset.y) - && unchanged(last_absolute_offset.x, current_absolute_offset.x) - && unchanged(last_absolute_offset.y, current_absolute_offset.y) - { - return; - } + if unchanged(last_relative_offset.x, current_relative_offset.x) + && unchanged(last_relative_offset.y, current_relative_offset.y) + && unchanged(last_absolute_offset.x, current_absolute_offset.x) + && unchanged(last_absolute_offset.y, current_absolute_offset.y) + { + return false; } + } + if let Some(on_scroll) = on_scroll { shell.publish(on_scroll(viewport)); - state.last_notified = Some(viewport); } + state.last_notified = Some(viewport); + + true } #[derive(Debug, Clone, Copy)] -- cgit From 4cd45643d7d2aa83212162f17a9b28ddae4a9340 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 25 Apr 2024 06:05:00 +0200 Subject: Introduce `opaque` widget helper --- widget/src/scrollable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index cdc143a2..10e81cee 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -857,7 +857,7 @@ where if (mouse_over_x_scrollbar || mouse_over_y_scrollbar) || state.scrollers_grabbed() { - mouse::Interaction::Idle + mouse::Interaction::None } else { let translation = state.translation(self.direction, bounds, content_bounds); -- cgit From eb49567791015be7f329d7d57d5f8c388abecd96 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 26 Apr 2024 01:19:49 +0200 Subject: Capture scrollbar events in a `scrollable` before content events --- widget/src/scrollable.rs | 284 +++++++++++++++++++++++------------------------ 1 file changed, 142 insertions(+), 142 deletions(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 10e81cee..f0a042cd 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -350,6 +350,148 @@ where let (mouse_over_y_scrollbar, mouse_over_x_scrollbar) = scrollbars.is_mouse_over(cursor); + if let Some(scroller_grabbed_at) = state.y_scroller_grabbed_at { + match event { + Event::Mouse(mouse::Event::CursorMoved { .. }) + | Event::Touch(touch::Event::FingerMoved { .. }) => { + if let Some(scrollbar) = scrollbars.y { + let Some(cursor_position) = cursor.position() else { + return event::Status::Ignored; + }; + + state.scroll_y_to( + scrollbar.scroll_percentage_y( + scroller_grabbed_at, + cursor_position, + ), + bounds, + content_bounds, + ); + + let _ = notify_on_scroll( + state, + &self.on_scroll, + bounds, + content_bounds, + shell, + ); + + return event::Status::Captured; + } + } + _ => {} + } + } else if mouse_over_y_scrollbar { + match event { + Event::Mouse(mouse::Event::ButtonPressed( + mouse::Button::Left, + )) + | Event::Touch(touch::Event::FingerPressed { .. }) => { + let Some(cursor_position) = cursor.position() else { + return event::Status::Ignored; + }; + + if let (Some(scroller_grabbed_at), Some(scrollbar)) = ( + scrollbars.grab_y_scroller(cursor_position), + scrollbars.y, + ) { + state.scroll_y_to( + scrollbar.scroll_percentage_y( + scroller_grabbed_at, + cursor_position, + ), + bounds, + content_bounds, + ); + + state.y_scroller_grabbed_at = Some(scroller_grabbed_at); + + let _ = notify_on_scroll( + state, + &self.on_scroll, + bounds, + content_bounds, + shell, + ); + } + + return event::Status::Captured; + } + _ => {} + } + } + + if let Some(scroller_grabbed_at) = state.x_scroller_grabbed_at { + match event { + Event::Mouse(mouse::Event::CursorMoved { .. }) + | Event::Touch(touch::Event::FingerMoved { .. }) => { + let Some(cursor_position) = cursor.position() else { + return event::Status::Ignored; + }; + + if let Some(scrollbar) = scrollbars.x { + state.scroll_x_to( + scrollbar.scroll_percentage_x( + scroller_grabbed_at, + cursor_position, + ), + bounds, + content_bounds, + ); + + let _ = notify_on_scroll( + state, + &self.on_scroll, + bounds, + content_bounds, + shell, + ); + } + + return event::Status::Captured; + } + _ => {} + } + } else if mouse_over_x_scrollbar { + match event { + Event::Mouse(mouse::Event::ButtonPressed( + mouse::Button::Left, + )) + | Event::Touch(touch::Event::FingerPressed { .. }) => { + let Some(cursor_position) = cursor.position() else { + return event::Status::Ignored; + }; + + if let (Some(scroller_grabbed_at), Some(scrollbar)) = ( + scrollbars.grab_x_scroller(cursor_position), + scrollbars.x, + ) { + state.scroll_x_to( + scrollbar.scroll_percentage_x( + scroller_grabbed_at, + cursor_position, + ), + bounds, + content_bounds, + ); + + state.x_scroller_grabbed_at = Some(scroller_grabbed_at); + + let _ = notify_on_scroll( + state, + &self.on_scroll, + bounds, + content_bounds, + shell, + ); + + return event::Status::Captured; + } + } + _ => {} + } + } + let mut event_status = { let cursor = match cursor_over_scrollable { Some(cursor_position) @@ -501,148 +643,6 @@ where _ => {} } - if let Some(scroller_grabbed_at) = state.y_scroller_grabbed_at { - match event { - Event::Mouse(mouse::Event::CursorMoved { .. }) - | Event::Touch(touch::Event::FingerMoved { .. }) => { - if let Some(scrollbar) = scrollbars.y { - let Some(cursor_position) = cursor.position() else { - return event::Status::Ignored; - }; - - state.scroll_y_to( - scrollbar.scroll_percentage_y( - scroller_grabbed_at, - cursor_position, - ), - bounds, - content_bounds, - ); - - let _ = notify_on_scroll( - state, - &self.on_scroll, - bounds, - content_bounds, - shell, - ); - - event_status = event::Status::Captured; - } - } - _ => {} - } - } else if mouse_over_y_scrollbar { - match event { - Event::Mouse(mouse::Event::ButtonPressed( - mouse::Button::Left, - )) - | Event::Touch(touch::Event::FingerPressed { .. }) => { - let Some(cursor_position) = cursor.position() else { - return event::Status::Ignored; - }; - - if let (Some(scroller_grabbed_at), Some(scrollbar)) = ( - scrollbars.grab_y_scroller(cursor_position), - scrollbars.y, - ) { - state.scroll_y_to( - scrollbar.scroll_percentage_y( - scroller_grabbed_at, - cursor_position, - ), - bounds, - content_bounds, - ); - - state.y_scroller_grabbed_at = Some(scroller_grabbed_at); - - let _ = notify_on_scroll( - state, - &self.on_scroll, - bounds, - content_bounds, - shell, - ); - } - - event_status = event::Status::Captured; - } - _ => {} - } - } - - if let Some(scroller_grabbed_at) = state.x_scroller_grabbed_at { - match event { - Event::Mouse(mouse::Event::CursorMoved { .. }) - | Event::Touch(touch::Event::FingerMoved { .. }) => { - let Some(cursor_position) = cursor.position() else { - return event::Status::Ignored; - }; - - if let Some(scrollbar) = scrollbars.x { - state.scroll_x_to( - scrollbar.scroll_percentage_x( - scroller_grabbed_at, - cursor_position, - ), - bounds, - content_bounds, - ); - - let _ = notify_on_scroll( - state, - &self.on_scroll, - bounds, - content_bounds, - shell, - ); - } - - event_status = event::Status::Captured; - } - _ => {} - } - } else if mouse_over_x_scrollbar { - match event { - Event::Mouse(mouse::Event::ButtonPressed( - mouse::Button::Left, - )) - | Event::Touch(touch::Event::FingerPressed { .. }) => { - let Some(cursor_position) = cursor.position() else { - return event::Status::Ignored; - }; - - if let (Some(scroller_grabbed_at), Some(scrollbar)) = ( - scrollbars.grab_x_scroller(cursor_position), - scrollbars.x, - ) { - state.scroll_x_to( - scrollbar.scroll_percentage_x( - scroller_grabbed_at, - cursor_position, - ), - bounds, - content_bounds, - ); - - state.x_scroller_grabbed_at = Some(scroller_grabbed_at); - - let _ = notify_on_scroll( - state, - &self.on_scroll, - bounds, - content_bounds, - shell, - ); - - event_status = event::Status::Captured; - } - } - _ => {} - } - } - event_status } -- cgit From 6d4155a5488da5b7fa3fd314f98c8f28c7202bd4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 26 Apr 2024 01:44:03 +0200 Subject: Fix `Shift` scrolling for `scrollable` on macOS Apparently, macOS inverts the scrolling axes automatically now. Was this a thing before, or did an update just break user space? --- widget/src/scrollable.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'widget/src/scrollable.rs') diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index f0a042cd..6fc00f87 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -564,7 +564,9 @@ where let delta = match delta { mouse::ScrollDelta::Lines { x, y } => { // TODO: Configurable speed/friction (?) - let movement = if state.keyboard_modifiers.shift() { + let movement = if !cfg!(target_os = "macos") // macOS automatically inverts the axes when Shift is pressed + && state.keyboard_modifiers.shift() + { Vector::new(y, x) } else { Vector::new(x, y) -- cgit