forge
Explore
Log in

Don't you dare go Hollow

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

Browse files at this commit

a9f0f4d44f911400ab26d3375dbc2a4015ebb7e5Ivan MolodetskikhParent: e3101ce
Will be needed for offsetting to fix the resize cancel issue.
src/layout/scrolling.rsmodified+21 -14
@@ -176,7 +176,7 @@ pub struct Column<W: LayoutElement> {
176176 tab_indicator: TabIndicator,
177177
178178 /// Animation of the render offset during window swapping.
179- move_animation: Option<Animation>,
179+ move_animation: Option<MoveAnimation>,
180180
181181 /// Latest known view size for this column's workspace.
182182 view_size: Size<f64, Logical>,
@@ -254,6 +254,12 @@ pub enum ScrollDirection {
254254 Right,
255255 }
256256
257+#[derive(Debug)]
258+struct MoveAnimation {
259+ anim: Animation,
260+ from: f64,
261+}
262+
257263 impl<W: LayoutElement> ScrollingSpace<W> {
258264 pub fn new(
259265 view_size: Size<f64, Logical>,
@@ -3878,8 +3884,8 @@ impl<W: LayoutElement> Column<W> {
38783884 }
38793885
38803886 pub fn advance_animations(&mut self) {
3881- if let Some(anim) = &mut self.move_animation {
3882- if anim.is_done() {
3887+ if let Some(move_) = &mut self.move_animation {
3888+ if move_.anim.is_done() {
38833889 self.move_animation = None;
38843890 }
38853891 }
@@ -3944,8 +3950,8 @@ impl<W: LayoutElement> Column<W> {
39443950 pub fn render_offset(&self) -> Point<f64, Logical> {
39453951 let mut offset = Point::from((0., 0.));
39463952
3947- if let Some(anim) = &self.move_animation {
3948- offset.x += anim.value();
3953+ if let Some(move_) = &self.move_animation {
3954+ offset.x += move_.from * move_.anim.value();
39493955 }
39503956
39513957 offset
@@ -3963,15 +3969,16 @@ impl<W: LayoutElement> Column<W> {
39633969 from_x_offset: f64,
39643970 config: niri_config::Animation,
39653971 ) {
3966- let current_offset = self.move_animation.as_ref().map_or(0., Animation::value);
3967-
3968- self.move_animation = Some(Animation::new(
3969- self.clock.clone(),
3970- from_x_offset + current_offset,
3971- 0.,
3972- 0.,
3973- config,
3974- ));
3972+ let current_offset = self
3973+ .move_animation
3974+ .as_ref()
3975+ .map_or(0., |move_| move_.from * move_.anim.value());
3976+
3977+ let anim = Animation::new(self.clock.clone(), 1., 0., 0., config);
3978+ self.move_animation = Some(MoveAnimation {
3979+ anim,
3980+ from: from_x_offset + current_offset,
3981+ });
39753982 }
39763983
39773984 pub fn contains(&self, window: &W::Id) -> bool {