Files
notedeck/src/ui/anim.rs
William Casarin c4e0c710c9 actionbar: remove border on reply button, add expand animation
Signed-off-by: William Casarin <jb55@jb55.com>
2024-06-13 09:36:53 -07:00

20 lines
562 B
Rust

pub fn hover_expand(
ui: &mut egui::Ui,
id: egui::Id,
size: f32,
expand_size: f32,
anim_speed: f32,
) -> (egui::Rect, f32, egui::Response) {
// Allocate space for the profile picture with a fixed size
let default_size = size + expand_size;
let (rect, response) =
ui.allocate_exact_size(egui::vec2(default_size, default_size), egui::Sense::click());
let val = ui
.ctx()
.animate_bool_with_time(id, response.hovered(), anim_speed);
let size = size + val * expand_size;
(rect, size, response)
}