Add Context::animate_bool_with_time

Closes https://github.com/emilk/egui/discussions/984
This commit is contained in:
Emil Ernerfeldt 2021-12-28 17:22:48 +01:00
parent 811b974003
commit 00f965de87

View file

@ -767,8 +767,15 @@ impl Context {
/// Calling this with `value = false` will always yield a number less than one, quickly going towards zero. /// 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 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 { pub fn animate_bool(&self, id: Id, value: bool) -> f32 {
let animation_time = self.style().animation_time; 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 = let animated_value =
self.animation_manager self.animation_manager
.lock() .lock()