diff --git a/examples/counter.rs b/examples/counter.rs index 8ef3d2a..6948de5 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -13,12 +13,12 @@ fn main() -> gooey::Result { Resize::width(Lp::points(100), Label::new(label)) .and(Button::new("+").on_click(counter.with_clone(|counter| { move |_| { - counter.set(counter.get() + 1); + *counter.lock() += 1; } }))) .and(Button::new("-").on_click(counter.with_clone(|counter| { move |_| { - counter.set(counter.get() - 1); + *counter.lock() -= 1; } }))), ) diff --git a/src/animation.rs b/src/animation.rs index 7622a68..54b0068 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -210,11 +210,11 @@ where fn update(&self, percent: f32) { self.change .dynamic - .set(self.start.lerp(&self.change.new_value, percent)); + .update(self.start.lerp(&self.change.new_value, percent)); } fn finish(&self) { - self.change.dynamic.set(self.change.new_value.clone()); + self.change.dynamic.update(self.change.new_value.clone()); } } @@ -606,7 +606,7 @@ impl Animate for Duration { } /// Performs a linear interpolation between two values. -pub trait LinearInterpolate { +pub trait LinearInterpolate: PartialEq { /// Interpolate linearly between `self` and `target` using `percent`. #[must_use] fn lerp(&self, target: &Self, percent: f32) -> Self; diff --git a/src/value.rs b/src/value.rs index 2366d3a..b93a540 100644 --- a/src/value.rs +++ b/src/value.rs @@ -136,7 +136,7 @@ impl Dynamic { /// equal to the currently stored value. pub fn update(&self, new_value: T) where - T: Eq, + T: PartialEq, { self.0.map_mut(|value, changed| { if *value == new_value { diff --git a/src/widgets/button.rs b/src/widgets/button.rs index c4c0d48..8ab76ad 100644 --- a/src/widgets/button.rs +++ b/src/widgets/button.rs @@ -108,7 +108,7 @@ impl Button { .spawn(); } (true, Some(dynamic)) => { - dynamic.set(background_color); + dynamic.update(background_color); self.background_color_animation.clear(); } (_, None) => { diff --git a/src/window.rs b/src/window.rs index d36eba0..8cd1cc1 100644 --- a/src/window.rs +++ b/src/window.rs @@ -736,8 +736,6 @@ where ) { match event { WindowCommand::Redraw => { - // TODO we should attempt to batch redraw events so that we're - // not constantly sending them from animations. window.set_needs_redraw(); } }