Add spawn-in window animations
This commit is contained in:
parent
7575f851fe
commit
18ffaef64d
6 changed files with 157 additions and 12 deletions
28
src/state.rs
28
src/state.rs
|
|
@ -4,6 +4,7 @@ use {
|
|||
allocator::BufferObject,
|
||||
animation::{
|
||||
AnimationCurve, AnimationState, AnimationTick, RetainedToplevel, expand_damage_rect,
|
||||
spawn_in_start_rect,
|
||||
},
|
||||
async_engine::{AsyncEngine, SpawnedFuture},
|
||||
backend::{
|
||||
|
|
@ -1516,6 +1517,33 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn queue_spawn_in_animation(
|
||||
self: &Rc<Self>,
|
||||
node_id: NodeId,
|
||||
target: Rect,
|
||||
retained: Option<Rc<RetainedToplevel>>,
|
||||
) {
|
||||
if !self.animations.enabled.get() || target.is_empty() {
|
||||
return;
|
||||
}
|
||||
let start = spawn_in_start_rect(target);
|
||||
let now = self.now_nsec();
|
||||
let started = self.animations.set_spawn_in(
|
||||
node_id,
|
||||
target,
|
||||
retained,
|
||||
now,
|
||||
self.animations.duration_ms.get(),
|
||||
);
|
||||
if started {
|
||||
self.damage(expand_damage_rect(
|
||||
start.union(target),
|
||||
self.theme.sizes.border_width.get().max(0),
|
||||
));
|
||||
self.ensure_animation_tick();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_animations_enabled(&self, enabled: bool) {
|
||||
if self.animations.enabled.replace(enabled) && !enabled {
|
||||
self.animations.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue