feat: add window animations
This commit is contained in:
parent
a29937ebe8
commit
ce14169d6b
29 changed files with 6957 additions and 114 deletions
|
|
@ -131,6 +131,8 @@ pub struct ContainerNode {
|
|||
pub content_height: Cell<i32>,
|
||||
pub sum_factors: Cell<f64>,
|
||||
pub layout_scheduled: Cell<bool>,
|
||||
animate_next_layout: Cell<bool>,
|
||||
pub mono_transition_animation_pending: Cell<bool>,
|
||||
compute_render_positions_scheduled: Cell<bool>,
|
||||
num_children: NumCell<usize>,
|
||||
pub children: LinkedList<ContainerChild>,
|
||||
|
|
@ -238,6 +240,8 @@ impl ContainerNode {
|
|||
content_height: Cell::new(0),
|
||||
sum_factors: Cell::new(1.0),
|
||||
layout_scheduled: Cell::new(false),
|
||||
animate_next_layout: Cell::new(false),
|
||||
mono_transition_animation_pending: Cell::new(false),
|
||||
compute_render_positions_scheduled: Cell::new(false),
|
||||
num_children: NumCell::new(1),
|
||||
children,
|
||||
|
|
@ -436,6 +440,10 @@ impl ContainerNode {
|
|||
}
|
||||
|
||||
fn schedule_layout(self: &Rc<Self>) {
|
||||
if self.state.layout_animations_requested.get() || self.state.layout_animations_active.get()
|
||||
{
|
||||
self.animate_next_layout.set(true);
|
||||
}
|
||||
if !self.layout_scheduled.replace(true) {
|
||||
self.state.pending_container_layout.push(self.clone());
|
||||
}
|
||||
|
|
@ -467,6 +475,7 @@ impl ContainerNode {
|
|||
fn perform_layout(self: &Rc<Self>) {
|
||||
self.layout_scheduled.set(false);
|
||||
if self.num_children.get() == 0 {
|
||||
self.mono_transition_animation_pending.set(false);
|
||||
return;
|
||||
}
|
||||
if let Some(child) = self.mono_child.get() {
|
||||
|
|
@ -484,6 +493,7 @@ impl ContainerNode {
|
|||
self.damage();
|
||||
}
|
||||
}
|
||||
self.mono_transition_animation_pending.set(false);
|
||||
}
|
||||
|
||||
fn perform_mono_layout(self: &Rc<Self>, child: &ContainerChild) {
|
||||
|
|
@ -656,6 +666,7 @@ impl ContainerNode {
|
|||
op.child.factor.set(child_factor);
|
||||
self.sum_factors.set(sum_factors);
|
||||
// log::info!("pointer_move");
|
||||
self.state.suppress_animations_for_next_layout.set(true);
|
||||
self.schedule_layout_immediate();
|
||||
}
|
||||
}
|
||||
|
|
@ -816,6 +827,7 @@ impl ContainerNode {
|
|||
}
|
||||
}
|
||||
self.mono_child.set(child.clone());
|
||||
self.mono_transition_animation_pending.set(true);
|
||||
if child.is_some() {
|
||||
self.rebuild_tab_bar();
|
||||
} else {
|
||||
|
|
@ -1759,10 +1771,42 @@ enum SeatOpKind {
|
|||
|
||||
pub async fn container_layout(state: Rc<State>) {
|
||||
loop {
|
||||
let container = state.pending_container_layout.pop().await;
|
||||
if container.layout_scheduled.get() {
|
||||
container.perform_layout();
|
||||
let first = state.pending_container_layout.pop().await;
|
||||
let mut containers = vec![first];
|
||||
while let Some(container) = state.pending_container_layout.try_pop() {
|
||||
containers.push(container);
|
||||
}
|
||||
let mut animated = vec![];
|
||||
let mut immediate = vec![];
|
||||
for container in containers {
|
||||
if !container.layout_scheduled.get() {
|
||||
continue;
|
||||
}
|
||||
let animate = container.animate_next_layout.replace(false)
|
||||
&& !state.suppress_animations_for_next_layout.get();
|
||||
if animate {
|
||||
animated.push(container);
|
||||
} else {
|
||||
immediate.push(container);
|
||||
}
|
||||
}
|
||||
if !animated.is_empty() {
|
||||
let prev_active = state.layout_animations_active.replace(true);
|
||||
state.begin_layout_animation_batch();
|
||||
for container in animated {
|
||||
container.perform_layout();
|
||||
}
|
||||
state.finish_layout_animation_batch();
|
||||
state.layout_animations_active.set(prev_active);
|
||||
}
|
||||
if !immediate.is_empty() {
|
||||
let prev_active = state.layout_animations_active.replace(false);
|
||||
for container in immediate {
|
||||
container.perform_layout();
|
||||
}
|
||||
state.layout_animations_active.set(prev_active);
|
||||
}
|
||||
state.suppress_animations_for_next_layout.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2259,6 +2303,11 @@ impl ContainingNode for ContainerNode {
|
|||
}
|
||||
// log::info!("cnode_remove_child2");
|
||||
self.rebuild_tab_bar();
|
||||
if self.state.animations.enabled.get()
|
||||
&& !self.state.suppress_animations_for_next_layout.get()
|
||||
{
|
||||
self.animate_next_layout.set(true);
|
||||
}
|
||||
self.schedule_layout();
|
||||
self.cancel_seat_ops();
|
||||
self.child_removed.trigger();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue