layout/scrolling: Normalize column X move anim from 1 to 0

Will be needed for offsetting to fix the resize cancel issue.
This commit is contained in:
Ivan Molodetskikh
2025-08-14 15:18:18 +03:00
parent e3101ced70
commit a9f0f4d44f
+20 -13
View File
@@ -176,7 +176,7 @@ pub struct Column<W: LayoutElement> {
tab_indicator: TabIndicator, tab_indicator: TabIndicator,
/// Animation of the render offset during window swapping. /// Animation of the render offset during window swapping.
move_animation: Option<Animation>, move_animation: Option<MoveAnimation>,
/// Latest known view size for this column's workspace. /// Latest known view size for this column's workspace.
view_size: Size<f64, Logical>, view_size: Size<f64, Logical>,
@@ -254,6 +254,12 @@ pub enum ScrollDirection {
Right, Right,
} }
#[derive(Debug)]
struct MoveAnimation {
anim: Animation,
from: f64,
}
impl<W: LayoutElement> ScrollingSpace<W> { impl<W: LayoutElement> ScrollingSpace<W> {
pub fn new( pub fn new(
view_size: Size<f64, Logical>, view_size: Size<f64, Logical>,
@@ -3878,8 +3884,8 @@ impl<W: LayoutElement> Column<W> {
} }
pub fn advance_animations(&mut self) { pub fn advance_animations(&mut self) {
if let Some(anim) = &mut self.move_animation { if let Some(move_) = &mut self.move_animation {
if anim.is_done() { if move_.anim.is_done() {
self.move_animation = None; self.move_animation = None;
} }
} }
@@ -3944,8 +3950,8 @@ impl<W: LayoutElement> Column<W> {
pub fn render_offset(&self) -> Point<f64, Logical> { pub fn render_offset(&self) -> Point<f64, Logical> {
let mut offset = Point::from((0., 0.)); let mut offset = Point::from((0., 0.));
if let Some(anim) = &self.move_animation { if let Some(move_) = &self.move_animation {
offset.x += anim.value(); offset.x += move_.from * move_.anim.value();
} }
offset offset
@@ -3963,15 +3969,16 @@ impl<W: LayoutElement> Column<W> {
from_x_offset: f64, from_x_offset: f64,
config: niri_config::Animation, config: niri_config::Animation,
) { ) {
let current_offset = self.move_animation.as_ref().map_or(0., Animation::value); let current_offset = self
.move_animation
.as_ref()
.map_or(0., |move_| move_.from * move_.anim.value());
self.move_animation = Some(Animation::new( let anim = Animation::new(self.clock.clone(), 1., 0., 0., config);
self.clock.clone(), self.move_animation = Some(MoveAnimation {
from_x_offset + current_offset, anim,
0., from: from_x_offset + current_offset,
0., });
config,
));
} }
pub fn contains(&self, window: &W::Id) -> bool { pub fn contains(&self, window: &W::Id) -> bool {