From 00f965de87ddb07805505a0b7ed3738e0da51a48 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 28 Dec 2021 17:22:48 +0100 Subject: [PATCH] Add Context::animate_bool_with_time Closes https://github.com/emilk/egui/discussions/984 --- egui/src/context.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/egui/src/context.rs b/egui/src/context.rs index 10790675..0553dc1a 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -767,8 +767,15 @@ impl Context { /// Calling this with `value = false` will always yield a number less than one, quickly going towards zero. /// /// The function will call [`Self::request_repaint()`] when appropriate. + /// + /// The animation time is taken from [`Style::animation_time`]. pub fn animate_bool(&self, id: Id, value: bool) -> f32 { let animation_time = self.style().animation_time; + self.animate_bool_with_time(id, value, animation_time) + } + + /// Like [`Self::animate_bool`] but allows you to control the animation time. + pub fn animate_bool_with_time(&self, id: Id, value: bool, animation_time: f32) -> f32 { let animated_value = self.animation_manager .lock()