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
Support upright inward-opening panels on the right dock edge
Atharv Tambolif9c574e45cdc
diff --git a/crates/rf-win/src/dock/panel.rs b/crates/rf-win/src/dock/panel.rsindex bcad303c..da72c380 100644--- a/crates/rf-win/src/dock/panel.rs+++ b/crates/rf-win/src/dock/panel.rs@@ -5,7 +5,7 @@//! A panel is an ordinary (activatable) pop-up window of the dock process. The islands are never activated (see `island.rs`), a panel//! is: it takes the keyboard while it is open and gives it back to the window that had it when it closes.-use super::layout::{Rect, px};+use super::layout::{DockEdge, Rect, px};/// The gap between an island's visible glass and the panel above it, logical px.pub const GAP: f32 = 8.0;@@ -57,6 +57,26 @@ pub fn place(glass: Rect, size: (f32, f32), scale: f32, side: Side, work: Rect)Rect::from_xywh(left, top, w, h)}+/// Places a panel inward from the active dock edge, keeping the panel upright.+/// In a right-side dock the first and last islands align the panel to their top+/// and bottom respectively, just as they align left and right on the bottom dock.+pub fn place_on_edge(glass: Rect, size: (f32, f32), scale: f32, side: Side, work: Rect, edge: DockEdge) -> Rect {+ match edge {+ DockEdge::Bottom => place(glass, size, scale, side, work),+ DockEdge::Right => {+ let right = (glass.left - px(GAP, scale)).min(work.right).max(work.left + 1);+ let w = px(size.0, scale).clamp(1, right - work.left);+ let h = px(size.1, scale).clamp(1, work.height().max(1));+ let wanted = match side {+ Side::Left => glass.top,+ Side::Right => glass.bottom - h,+ };+ let top = wanted.clamp(work.top, (work.bottom - h).max(work.top));+ Rect::from_xywh(right - w, top, w, h)+ }+ }+}+/// What a click on a panel's button does.#[derive(Clone, Copy, Debug, PartialEq, Eq)]pub enum Toggle {@@ -463,6 +483,19 @@ mod tests {assert!(work.covers(&r));}+ #[test]+ fn right_edge_panels_open_inward_and_stay_upright() {+ let work = Rect::new(-1920, 0, -80, 1080);+ let top = Rect::new(-70, 12, -12, 180);+ let bottom = Rect::new(-70, 890, -12, 1068);+ let start = place_on_edge(top, (620.0, 680.0), 1.25, Side::Left, work, DockEdge::Right);+ let status = place_on_edge(bottom, (360.0, 400.0), 1.25, Side::Right, work, DockEdge::Right);+ assert_eq!(start, Rect::new(-855, 12, -80, 862));+ assert_eq!(status, Rect::new(-530, 568, -80, 1068));+ assert!(work.covers(&start));+ assert!(work.covers(&status));+ }+#[test]fn at_150_percent_the_numbers_scale_and_round_once_each() {// 2880x1620 at 150 %, taskbar 72 px: the glass is 495x72 at (18, 1548 - 15 - 72)