forge
Explore
Log in

Don't you dare go Hollow

Improve interactive resize end edge cases and animations

Browse files at this commit

94a9b48a0f7e474cb9c5422447a49f647d62e9bbIvan MolodetskikhParent: d776ab7
src/layout/mod.rsmodified+0 -2
@@ -77,8 +77,6 @@ pub type LayoutElementRenderSnapshot =
77 #[derive(Debug, Clone, Copy)]77 #[derive(Debug, Clone, Copy)]
78 pub struct InteractiveResizeData {78 pub struct InteractiveResizeData {
79 pub edges: ResizeEdge,79 pub edges: ResizeEdge,
80- pub original_view_offset: i32,
81- pub original_column_width: i32,
82 }80 }
83 81
84 pub trait LayoutElement {82 pub trait LayoutElement {
src/layout/workspace.rsmodified+27 -23
@@ -1255,35 +1255,34 @@ impl<W: LayoutElement> Workspace<W> {
1255 }1255 }
1256 }1256 }
1257 1257
1258- let col = &mut self.columns[col_idx];
1259- let tile = &mut col.tiles[tile_idx];
1260- let window = tile.window_mut();
1261-
1262- // If this was the last resize commit, this function will now return None. This way we can
1263- // animate the window into view after the last resize commit.
1264- let resize_still_ongoing = window.interactive_resize_data().is_some();
1265-
1266 if col_idx == self.active_column_idx {1258 if col_idx == self.active_column_idx {
1267 if let Some(resize) = resize {1259 if let Some(resize) = resize {
1268 // If this is an interactive resize commit of an active window, then we need to1260 // If this is an interactive resize commit of an active window, then we need to
1269 // either preserve the view offset or adjust it accordingly.1261 // either preserve the view offset or adjust it accordingly.
1270 let centered = self.options.center_focused_column == CenterFocusedColumn::Always;1262 let centered = self.options.center_focused_column == CenterFocusedColumn::Always;
1271 1263
1272- let width = col.width();1264+ let width = self.data[col_idx].width;
1273- if centered {1265+ let offset = if centered {
1274- self.view_offset =1266+ // FIXME: when view_offset becomes fractional, this can be made additive too.
1267+ let new_offset =
1275 -(self.working_area.size.w - width) / 2 - self.working_area.loc.x;1268 -(self.working_area.size.w - width) / 2 - self.working_area.loc.x;
1269+ new_offset - self.view_offset
1276 } else if resize.edges.contains(ResizeEdge::LEFT) {1270 } else if resize.edges.contains(ResizeEdge::LEFT) {
1277- self.view_offset =1271+ -offset
1278- resize.original_view_offset + width - resize.original_column_width;1272+ } else {
1279- }1273+ 0
1274+ };
1280 1275
1281- // We *could* compute the right offsets here to preserve the gesture but it's1276+ self.view_offset += offset;
1282- // pretty edge-case-y so it's fine to just cancel it.1277+ if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
1283- self.view_offset_adj = None;1278+ anim.offset(offset as f64);
1279+ } else {
1280+ // Don't bother with the gesture.
1281+ self.view_offset_adj = None;
1282+ }
1284 }1283 }
1285 1284
1286- if !resize_still_ongoing1285+ if self.interactive_resize.is_none()
1287 && !matches!(self.view_offset_adj, Some(ViewOffsetAdjustment::Gesture(_)))1286 && !matches!(self.view_offset_adj, Some(ViewOffsetAdjustment::Gesture(_)))
1288 {1287 {
1289 // We might need to move the view to ensure the resized window is still visible.1288 // We might need to move the view to ensure the resized window is still visible.
@@ -2216,6 +2215,10 @@ impl<W: LayoutElement> Workspace<W> {
2216 return;2215 return;
2217 }2216 }
2218 2217
2218+ if self.interactive_resize.is_some() {
2219+ return;
2220+ }
2221+
2219 let gesture = ViewGesture {2222 let gesture = ViewGesture {
2220 current_view_offset: self.view_offset as f64,2223 current_view_offset: self.view_offset as f64,
2221 tracker: SwipeTracker::new(),2224 tracker: SwipeTracker::new(),
@@ -2459,11 +2462,7 @@ impl<W: LayoutElement> Workspace<W> {
2459 let resize = InteractiveResize {2462 let resize = InteractiveResize {
2460 window,2463 window,
2461 original_window_size,2464 original_window_size,
2462- data: InteractiveResizeData {2465+ data: InteractiveResizeData { edges },
2463- edges,
2464- original_view_offset: self.view_offset,
2465- original_column_width: col.width(),
2466- },
2467 };2466 };
2468 self.interactive_resize = Some(resize);2467 self.interactive_resize = Some(resize);
2469 2468
@@ -2541,6 +2540,11 @@ impl<W: LayoutElement> Workspace<W> {
2541 if window != &resize.window {2540 if window != &resize.window {
2542 return;2541 return;
2543 }2542 }
2543+
2544+ // Animate the active window into view right away.
2545+ if self.columns[self.active_column_idx].contains(window) {
2546+ self.animate_view_offset_to_column(self.view_pos(), self.active_column_idx, None);
2547+ }
2544 }2548 }
2545 2549
2546 self.interactive_resize = None;2550 self.interactive_resize = None;