feat: add window animations
This commit is contained in:
parent
a29937ebe8
commit
ce14169d6b
29 changed files with 6957 additions and 114 deletions
|
|
@ -31,6 +31,9 @@ use {
|
|||
};
|
||||
|
||||
tree_id!(FloatNodeId);
|
||||
|
||||
const COMMAND_MOVE_DELTA: i32 = 100;
|
||||
|
||||
pub struct FloatNode {
|
||||
pub id: FloatNodeId,
|
||||
pub state: Rc<State>,
|
||||
|
|
@ -153,6 +156,13 @@ impl FloatNode {
|
|||
_ => return,
|
||||
};
|
||||
let pos = self.position.get();
|
||||
let spawn_in_pending = {
|
||||
let data = child.tl_data();
|
||||
data.spawn_in_pending.get() && data.kind.is_app_window() && !data.is_fullscreen.get()
|
||||
};
|
||||
if spawn_in_pending && self.visible.get() {
|
||||
self.state.queue_spawn_in_animation(self.id.into(), pos);
|
||||
}
|
||||
let theme = &self.state.theme;
|
||||
let bw = theme.sizes.border_width.get();
|
||||
let cpos = Rect::new_sized_saturating(
|
||||
|
|
@ -363,6 +373,50 @@ impl FloatNode {
|
|||
y2 += y1 - pos.y1();
|
||||
}
|
||||
let new_pos = Rect::new_saturating(x1, y1, x2, y2);
|
||||
self.set_position(new_pos);
|
||||
}
|
||||
|
||||
pub fn move_by_direction(self: &Rc<Self>, direction: Direction) {
|
||||
let (dx, dy) = match direction {
|
||||
Direction::Left => (-COMMAND_MOVE_DELTA, 0),
|
||||
Direction::Down => (0, COMMAND_MOVE_DELTA),
|
||||
Direction::Up => (0, -COMMAND_MOVE_DELTA),
|
||||
Direction::Right => (COMMAND_MOVE_DELTA, 0),
|
||||
Direction::Unspecified => return,
|
||||
};
|
||||
self.set_position(self.position.get().move_(dx, dy));
|
||||
}
|
||||
|
||||
fn body_for_outer(&self, outer: Rect) -> Rect {
|
||||
let bw = self.state.theme.sizes.border_width.get();
|
||||
Rect::new_sized_saturating(
|
||||
outer.x1() + bw,
|
||||
outer.y1() + bw,
|
||||
outer.width() - 2 * bw,
|
||||
outer.height() - 2 * bw,
|
||||
)
|
||||
}
|
||||
|
||||
fn queue_position_animation(&self, old_pos: Rect, new_pos: Rect) {
|
||||
self.state
|
||||
.clone()
|
||||
.queue_tiled_animation(self.id.into(), old_pos, new_pos);
|
||||
let Some(child) = self.child.get() else {
|
||||
return;
|
||||
};
|
||||
self.state.clone().queue_tiled_animation(
|
||||
child.node_id(),
|
||||
self.body_for_outer(old_pos),
|
||||
self.body_for_outer(new_pos),
|
||||
);
|
||||
}
|
||||
|
||||
fn set_position(self: &Rc<Self>, new_pos: Rect) {
|
||||
let pos = self.position.get();
|
||||
if new_pos == pos {
|
||||
return;
|
||||
}
|
||||
self.queue_position_animation(pos, new_pos);
|
||||
self.position.set(new_pos);
|
||||
if self.visible.get() {
|
||||
self.state.damage(pos);
|
||||
|
|
@ -791,13 +845,7 @@ impl ContainingNode for FloatNode {
|
|||
let bw = theme.sizes.border_width.get();
|
||||
let (x, y) = (x - bw, y - bw);
|
||||
let pos = self.position.get();
|
||||
if pos.position() != (x, y) {
|
||||
let new_pos = pos.at_point(x, y);
|
||||
self.position.set(new_pos);
|
||||
self.state.damage(pos);
|
||||
self.state.damage(new_pos);
|
||||
self.schedule_layout();
|
||||
}
|
||||
self.set_position(pos.at_point(x, y));
|
||||
}
|
||||
|
||||
fn cnode_resize_child(
|
||||
|
|
@ -828,14 +876,7 @@ impl ContainingNode for FloatNode {
|
|||
y2 = (v + bw).max(y1 + bw + bw);
|
||||
}
|
||||
let new_pos = Rect::new_saturating(x1, y1, x2, y2);
|
||||
if new_pos != pos {
|
||||
self.position.set(new_pos);
|
||||
if self.visible.get() {
|
||||
self.state.damage(pos);
|
||||
self.state.damage(new_pos);
|
||||
}
|
||||
self.schedule_layout();
|
||||
}
|
||||
self.set_position(new_pos);
|
||||
}
|
||||
|
||||
fn cnode_pinned(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue