Skip to content

Commit d05c9fb

Browse files
committed
timeline: use impl Into<Chain<T>> on set_chain
This removes the requirement for animation chains to have the `into()` method call before passing itself into `set_chain`.
1 parent ebb5707 commit d05c9fb

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

examples/counter/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Application for Counter {
8383
// cosmic-time assumes that the timeline is continuous. Try deleting it,
8484
// the height will animate smoothly from 300 to 150 right through keyframe `four`!
8585

86-
timeline.set_chain(animation.into()).start();
86+
timeline.set_chain(animation).start();
8787
// `Start` is very important! Your animation won't "start" without it.
8888
// Cosmic-time tries to be atomic, meaning that keyframes defined in the
8989
// same function call all start at the same time. Because there is process time

examples/pokedex/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl Pokemon {
271271
.loop_forever();
272272

273273
// println!("Animating wth ease: {ease:?}"); // Uncomment to see the type of easing
274-
timeline.set_chain(animation.into()).start();
274+
timeline.set_chain(animation).start();
275275

276276
Ok(Pokemon {
277277
timeline,

examples/stopwatch/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ impl Application for Stopwatch {
6666
self.state = State::Ticking {
6767
last_tick: Instant::now(),
6868
};
69-
self.timeline
70-
.set_chain(anim_to_destructive().into())
71-
.start();
69+
self.timeline.set_chain(anim_to_destructive()).start();
7270
}
7371
State::Ticking { .. } => {
7472
self.state = State::Idle;
75-
self.timeline.set_chain(anim_to_primary().into()).start();
73+
self.timeline.set_chain(anim_to_primary()).start();
7674
}
7775
},
7876
Message::Tick(now) => {

src/timeline.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ impl Timeline {
157157
}
158158

159159
/// Destructure keyframe into subtracks (via impl ExactSizeIterator) and add to timeline.
160-
pub fn set_chain<T>(&mut self, chain: Chain<T>) -> &mut Self
160+
pub fn set_chain<T>(&mut self, chain: impl Into<Chain<T>>) -> &mut Self
161161
where
162162
T: ExactSizeIterator<Item = Option<DurFrame>> + std::fmt::Debug,
163163
{
164+
let chain: Chain<T> = chain.into();
164165
let id = chain.id.clone();
165166
let repeat = chain.repeat;
166167
let mut tracks: Vec<Vec<DurFrame>> = Vec::new();

src/widget/toggler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use iced_native::text;
88
use iced_native::time::Duration;
99
use iced_native::widget::{self, Row, Text, Tree};
1010
use iced_native::{
11-
color, Alignment, Clipboard, Color, Element, Event, Layout, Length, Pixels, Point,
12-
Rectangle, Shell, Widget,
11+
color, Alignment, Clipboard, Color, Element, Event, Layout, Length, Pixels, Point, Rectangle,
12+
Shell, Widget,
1313
};
1414

1515
use crate::keyframes::{self, toggler::Chain};

0 commit comments

Comments
 (0)