diff options
author | 2024-06-14 01:47:39 +0200 | |
---|---|---|
committer | 2024-06-14 01:47:39 +0200 | |
commit | a25b1af45690bdd8e1cbb20ee3a5b1c4342de455 (patch) | |
tree | 432044cf682dd73d1019a2f964749e78db178865 /widget/src/scrollable.rs | |
parent | e6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (diff) | |
download | iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.tar.gz iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.tar.bz2 iced-a25b1af45690bdd8e1cbb20ee3a5b1c4342de455.zip |
Replace `Command` with a new `Task` API with chain support
Diffstat (limited to '')
-rw-r--r-- | widget/src/scrollable.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 6fc00f87..c3d08223 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -15,7 +15,7 @@ use crate::core::{ self, Background, Border, Clipboard, Color, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size, Theme, Vector, Widget, }; -use crate::runtime::Command; +use crate::runtime::{Action, Task}; pub use operation::scrollable::{AbsoluteOffset, RelativeOffset}; @@ -295,7 +295,7 @@ where tree: &mut Tree, layout: Layout<'_>, renderer: &Renderer, - operation: &mut dyn Operation<Message>, + operation: &mut dyn Operation<()>, ) { let state = tree.state.downcast_mut::<State>(); @@ -952,22 +952,18 @@ impl From<Id> for widget::Id { } } -/// Produces a [`Command`] that snaps the [`Scrollable`] with the given [`Id`] +/// Produces a [`Task`] that snaps the [`Scrollable`] with the given [`Id`] /// to the provided `percentage` along the x & y axis. -pub fn snap_to<Message: 'static>( - id: Id, - offset: RelativeOffset, -) -> Command<Message> { - Command::widget(operation::scrollable::snap_to(id.0, offset)) +pub fn snap_to<T>(id: Id, offset: RelativeOffset) -> Task<T> { + Task::effect(Action::widget(operation::scrollable::snap_to(id.0, offset))) } -/// Produces a [`Command`] that scrolls the [`Scrollable`] with the given [`Id`] +/// Produces a [`Task`] that scrolls the [`Scrollable`] with the given [`Id`] /// to the provided [`AbsoluteOffset`] along the x & y axis. -pub fn scroll_to<Message: 'static>( - id: Id, - offset: AbsoluteOffset, -) -> Command<Message> { - Command::widget(operation::scrollable::scroll_to(id.0, offset)) +pub fn scroll_to<T>(id: Id, offset: AbsoluteOffset) -> Task<T> { + Task::effect(Action::widget(operation::scrollable::scroll_to( + id.0, offset, + ))) } /// Returns [`true`] if the viewport actually changed. |