A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Use leftover bottom row height in desktop icon grid
jokwa1354db9592e3d77
diff --git a/crates/rf-core/src/desktop/grid.rs b/crates/rf-core/src/desktop/grid.rsindex d37d80ae..44ac1939 100644--- a/crates/rf-core/src/desktop/grid.rs+++ b/crates/rf-core/src/desktop/grid.rs@@ -143,17 +143,30 @@ pub struct Grid {pub metrics: GridMetrics,pub cols: u32,pub rows: u32,+ work_size: (u32, u32),}impl Grid {/// `work`: the part of the monitor the icons may use, in the monitor's own coordinates.pub fn new(work: Rect, metrics: GridMetrics) -> Grid {let (w, h) = (work.width().max(0) as u32, work.height().max(0) as u32);+ let cols = w.checked_div(metrics.pitch_x).unwrap_or(0);+ let mut rows = h.checked_div(metrics.pitch_y).unwrap_or(0);+ // If leftover height below the last full row still fits a single-line icon tile (at least ~80% of pitch_y and icon_px),+ // include that bottom row instead of leaving a large gap above the taskbar or dock.+ if metrics.pitch_y > 0 && cols > 0 {+ let rem = h % metrics.pitch_y;+ let min_row_h = (metrics.pitch_y * 4 / 5).max(metrics.icon_px);+ if rem >= min_row_h {+ rows += 1;+ }+ }Grid {origin: (work.left, work.top),metrics,- cols: w.checked_div(metrics.pitch_x).unwrap_or(0),- rows: h.checked_div(metrics.pitch_y).unwrap_or(0),+ cols,+ rows,+ work_size: (w, h),}}pub fn len(&self) -> usize {@@ -209,8 +222,8 @@ impl Grid {let (cx, cy) = if align_to_grid { ((rx + px / 2).div_euclid(px), (ry + py / 2).div_euclid(py)) } else { (rx.div_euclid(px), ry.div_euclid(py)) };let col = cx.clamp(0, self.cols as i32 - 1);let row = cy.clamp(0, self.rows as i32 - 1);- let inside = cx == col && cy == row;- let (dx, dy) = if align_to_grid || !inside { (0, 0) } else { (rx - col * px, ry - row * py) };+ let in_work = rx >= 0 && ry >= 0 && rx < self.work_size.0 as i32 && ry < self.work_size.1 as i32;+ let (dx, dy) = if align_to_grid || !in_work { (0, 0) } else { (rx - col * px, ry - row * py) };Some((Cell { col: col as u32, row: row as u32 }, dx, dy))}}@@ -368,4 +381,18 @@ mod tests {assert_eq!(g.snap(5000, 5000, true), Some((Cell::new(2, 1), 0, 0)));assert_eq!(g.snap(5000, 10, false), Some((Cell::new(2, 0), 0, 0)));}++ #[test]+ fn bottom_row_uses_leftover_work_area_that_fits_a_tile_and_free_drag_reaches_bottom() {+ // 1920x1027 work area (e.g. 53 px dock) with Small icons and {46, 76, 88} spacing -> pitch_y = 74, leftover = 65 px.+ let m = metrics_spaced(IconSize::Small, 100, Some(Spacing { icon: 46, x: 76, y: 88 }));+ assert_eq!(m.pitch_y, 74);+ let g = Grid::new(Rect::new(0, 0, 1920, 1027), m);+ assert_eq!(g.rows, 14, "leftover 65 px fits a 1-line small icon tile above the dock");++ // Free placement in the bottom margin inside the work area preserves the offset rather than snapping back to 0.+ let g_free = Grid::new(Rect::new(0, 0, 225, 175), metrics(IconSize::Medium, 100));+ assert_eq!(g_free.rows, 2);+ assert_eq!(g_free.snap(10, 160, false), Some((Cell::new(0, 1), 10, 85)));+ }}