Render tiles flush to the right when left-resizing
Browse files at this commitb101f9b5f8acfb638f94962f76cbbb407d419664Parent: 34bcc6e1 changed file +47 -8
- src/layout/workspace.rs +47 -8
src/layout/workspace.rsmodified+47 -8
| @@ -1270,6 +1270,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1270 | 1270 | ||
| 1271 | let mut view_rect_ws = Rectangle::from_loc_and_size((self.view_pos(), 0), self.view_size); | 1271 | let mut view_rect_ws = Rectangle::from_loc_and_size((self.view_pos(), 0), self.view_size); |
| 1272 | for col in &mut self.columns { | 1272 | for col in &mut self.columns { |
| 1273 | + let col_width = col.width(); | ||
| 1274 | + | ||
| 1273 | let mut view_rect = view_rect_ws; | 1275 | let mut view_rect = view_rect_ws; |
| 1274 | view_rect.loc -= col.render_offset(); | 1276 | view_rect.loc -= col.render_offset(); |
| 1275 | if !col.is_fullscreen { | 1277 | if !col.is_fullscreen { |
| @@ -1278,6 +1280,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1278 | 1280 | ||
| 1279 | for tile in &mut col.tiles { | 1281 | for tile in &mut col.tiles { |
| 1280 | if tile.window().id() == window { | 1282 | if tile.window().id() == window { |
| 1283 | + view_rect.loc -= Column::render_offset_for_tile(tile, col_width, &self.options); | ||
| 1281 | tile.update(false, view_rect); | 1284 | tile.update(false, view_rect); |
| 1282 | tile.store_unmap_snapshot_if_empty(renderer, output_scale); | 1285 | tile.store_unmap_snapshot_if_empty(renderer, output_scale); |
| 1283 | return; | 1286 | return; |
| @@ -1286,7 +1289,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1286 | view_rect.loc.y -= tile.tile_size().h + self.options.gaps; | 1289 | view_rect.loc.y -= tile.tile_size().h + self.options.gaps; |
| 1287 | } | 1290 | } |
| 1288 | 1291 | ||
| 1289 | - view_rect_ws.loc.x -= col.width() + self.options.gaps; | 1292 | + view_rect_ws.loc.x -= col_width + self.options.gaps; |
| 1290 | } | 1293 | } |
| 1291 | } | 1294 | } |
| 1292 | 1295 | ||
| @@ -1802,9 +1805,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1802 | 1805 | ||
| 1803 | // Start with the active window since it's drawn on top. | 1806 | // Start with the active window since it's drawn on top. |
| 1804 | let col = &self.columns[self.active_column_idx]; | 1807 | let col = &self.columns[self.active_column_idx]; |
| 1808 | + let col_width = col.width(); | ||
| 1805 | let tile = &col.tiles[col.active_tile_idx]; | 1809 | let tile = &col.tiles[col.active_tile_idx]; |
| 1806 | let tile_pos = Point::from((-self.view_offset, col.tile_y(col.active_tile_idx))) | 1810 | let tile_pos = Point::from((-self.view_offset, col.tile_y(col.active_tile_idx))) |
| 1807 | + col.render_offset() | 1811 | + col.render_offset() |
| 1812 | + + Column::render_offset_for_tile(tile, col_width, &self.options) | ||
| 1808 | + tile.render_offset(); | 1813 | + tile.render_offset(); |
| 1809 | let first = iter::once((tile, tile_pos)); | 1814 | let first = iter::once((tile, tile_pos)); |
| 1810 | 1815 | ||
| @@ -1821,6 +1826,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1821 | 1826 | ||
| 1822 | let tile_pos = Point::from((-self.view_offset, y)) | 1827 | let tile_pos = Point::from((-self.view_offset, y)) |
| 1823 | + col.render_offset() | 1828 | + col.render_offset() |
| 1829 | + + Column::render_offset_for_tile(tile, col_width, &self.options) | ||
| 1824 | + tile.render_offset(); | 1830 | + tile.render_offset(); |
| 1825 | Some((tile, tile_pos)) | 1831 | Some((tile, tile_pos)) |
| 1826 | }); | 1832 | }); |
| @@ -1832,21 +1838,25 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1832 | .enumerate() | 1838 | .enumerate() |
| 1833 | // Keep track of column X position. | 1839 | // Keep track of column X position. |
| 1834 | .map(move |(col_idx, col)| { | 1840 | .map(move |(col_idx, col)| { |
| 1835 | - let rv = (col_idx, col, x); | 1841 | + let col_width = col.width(); |
| 1836 | - x += col.width() + self.options.gaps; | 1842 | + let rv = (col_idx, col, col_width, x); |
| 1843 | + x += col_width + self.options.gaps; | ||
| 1837 | rv | 1844 | rv |
| 1838 | }) | 1845 | }) |
| 1839 | - .filter_map(|(col_idx, col, x)| { | 1846 | + .filter_map(|(col_idx, col, col_width, x)| { |
| 1840 | if col_idx == self.active_column_idx { | 1847 | if col_idx == self.active_column_idx { |
| 1841 | // Active column comes before. | 1848 | // Active column comes before. |
| 1842 | return None; | 1849 | return None; |
| 1843 | } | 1850 | } |
| 1844 | 1851 | ||
| 1845 | - Some((col, x)) | 1852 | + Some((col, col_width, x)) |
| 1846 | }) | 1853 | }) |
| 1847 | - .flat_map(move |(col, x)| { | 1854 | + .flat_map(move |(col, col_width, x)| { |
| 1848 | zip(&col.tiles, col.tile_ys()).map(move |(tile, y)| { | 1855 | zip(&col.tiles, col.tile_ys()).map(move |(tile, y)| { |
| 1849 | - let tile_pos = Point::from((x, y)) + col.render_offset() + tile.render_offset(); | 1856 | + let tile_pos = Point::from((x, y)) |
| 1857 | + + col.render_offset() | ||
| 1858 | + + Column::render_offset_for_tile(tile, col_width, &self.options) | ||
| 1859 | + + tile.render_offset(); | ||
| 1850 | (tile, tile_pos) | 1860 | (tile, tile_pos) |
| 1851 | }) | 1861 | }) |
| 1852 | }); | 1862 | }); |
| @@ -2595,9 +2605,15 @@ impl<W: LayoutElement> Column<W> { | |||
| 2595 | view_rect.loc.y -= self.working_area.loc.y + self.options.gaps; | 2605 | view_rect.loc.y -= self.working_area.loc.y + self.options.gaps; |
| 2596 | } | 2606 | } |
| 2597 | 2607 | ||
| 2608 | + let col_width = self.width(); | ||
| 2609 | + | ||
| 2598 | for (tile_idx, tile) in self.tiles.iter_mut().enumerate() { | 2610 | for (tile_idx, tile) in self.tiles.iter_mut().enumerate() { |
| 2599 | let is_active = is_active && tile_idx == self.active_tile_idx; | 2611 | let is_active = is_active && tile_idx == self.active_tile_idx; |
| 2600 | - tile.update(is_active, view_rect); | 2612 | + |
| 2613 | + let mut tile_view_rect = view_rect; | ||
| 2614 | + tile_view_rect.loc -= Self::render_offset_for_tile(tile, col_width, &self.options); | ||
| 2615 | + tile.update(is_active, tile_view_rect); | ||
| 2616 | + | ||
| 2601 | view_rect.loc.y -= tile.tile_size().h + self.options.gaps; | 2617 | view_rect.loc.y -= tile.tile_size().h + self.options.gaps; |
| 2602 | } | 2618 | } |
| 2603 | } | 2619 | } |
| @@ -2612,6 +2628,29 @@ impl<W: LayoutElement> Column<W> { | |||
| 2612 | offset.to_i32_round() | 2628 | offset.to_i32_round() |
| 2613 | } | 2629 | } |
| 2614 | 2630 | ||
| 2631 | + // HACK: this should really be a &self method, but I need to use it while also iterating over | ||
| 2632 | + // &mut self.tiles... | ||
| 2633 | + // FIXME: this does not get applied for animations. | ||
| 2634 | + pub fn render_offset_for_tile( | ||
| 2635 | + tile: &Tile<W>, | ||
| 2636 | + col_width: i32, | ||
| 2637 | + options: &Options, | ||
| 2638 | + ) -> Point<i32, Logical> { | ||
| 2639 | + let tile_width = tile.tile_size().w; | ||
| 2640 | + | ||
| 2641 | + if options.center_focused_column == CenterFocusedColumn::Always { | ||
| 2642 | + return Point::from(((col_width - tile_width) / 2, 0)); | ||
| 2643 | + } | ||
| 2644 | + | ||
| 2645 | + if let Some(resize) = tile.window().interactive_resize_data() { | ||
| 2646 | + if resize.edges.contains(ResizeEdge::LEFT) { | ||
| 2647 | + return Point::from((col_width - tile_width, 0)); | ||
| 2648 | + } | ||
| 2649 | + } | ||
| 2650 | + | ||
| 2651 | + Point::from((0, 0)) | ||
| 2652 | + } | ||
| 2653 | + | ||
| 2615 | pub fn animate_move_from(&mut self, from_x_offset: i32) { | 2654 | pub fn animate_move_from(&mut self, from_x_offset: i32) { |
| 2616 | self.animate_move_from_with_config( | 2655 | self.animate_move_from_with_config( |
| 2617 | from_x_offset, | 2656 | from_x_offset, |