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
Make floating sidebar (rail-peek) respect HyperGlass surface wash
Konstantin Pertsev3e1f6669fa79
diff --git a/crates/rf-app/src/theme.rs b/crates/rf-app/src/theme.rsindex 35dc7287..42614220 100644--- a/crates/rf-app/src/theme.rs+++ b/crates/rf-app/src/theme.rs@@ -208,9 +208,9 @@ impl Palette {// At the strength made for Mica they hid two thirds of it in the dark theme (too black), so the default is half// of that; the HyperGlass "surface wash" setting moves it either way.(p.window_bg.a, p.content_bg.a) = glass_washes(p.dark, crate::settings::hg_surface());+ p.sidebar_bg.a = 0.0;if explorer_look {p.titlebar_bg.a = 0.0;- p.sidebar_bg.a = 0.0;p.address_bg = Hsla { a: glass_bar_wash(crate::settings::hg_surface()), ..p.card_bg };p.toolbar_bg = Hsla { a: glass_bar_wash(crate::settings::hg_surface()), ..p.card_bg };}diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 3325230b..714908fc 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -5731,6 +5731,21 @@ const RAIL_IN_MS: u64 = 130;fn rail_peek_width(full: f32, shown: f32) -> f32 {(RAIL_W + (full - RAIL_W) * shown).max(RAIL_W)}++/// How far the floating sidebar (`rail-peek`) extends past the rail over the content area.+fn rail_peek_overlap(full: f32, shown: f32) -> f32 {+ (rail_peek_width(full, shown) - RAIL_W).max(0.)+}++/// Background of the floating sidebar (`rail-peek`): over HyperGlass it keeps `content_bg`'s surface wash so the glass shows through;+/// over Mica / Solid it stays opaque (`sampled` from the rail, or opaque `content_bg`) so the content underneath does not bleed through.+fn rail_peek_bg_color(glass_on: bool, sampled: Option<Hsla>, content_bg: Hsla) -> Hsla {+ if glass_on {+ content_bg+ } else {+ sampled.unwrap_or(Hsla { a: 1., ..content_bg })+ }+}const RAIL_SNAP: f32 = 120.;const SIDEBAR_MAX: f32 = 420.;const PREVIEW_MIN: f32 = 220.;@@ -6259,6 +6274,7 @@ impl Workspace {}self.glass_hwnd = hwnd;self.glass_dark = Some(dark);+ self.rail_peek_bg = None;// this is a window the user works in: its glass may freeze while it is not in front, if the setting is on (a dock island or a// menu never does)rf_win::glass::set_freezable(hwnd, true);@@ -6590,7 +6606,7 @@ impl Render for Workspace {.w(px(full_w))// (the sidebar inside keeps its full width while the panel's own width moves: nothing in it is laid out anew).overflow_hidden()- .bg(self.rail_peek_bg.unwrap_or(Hsla { a: 1., ..p.content_bg }))+ .bg(rail_peek_bg_color(glass_on, self.rail_peek_bg, p.content_bg)).border_r_1().border_color(p.border).rounded_r(theme::RADIUS)@@ -6617,12 +6633,13 @@ impl Render for Workspace {Animation::new(std::time::Duration::from_millis(ms)).with_easing(move |t| rf_win::dock::spring::curve_with(t, bounce)),move |el, t| {let shown = if opening { t } else { 1.0 - t };- // (the width alone moves: the panel is matte from its first frame, nothing shows through it on the way)+ // (the width alone moves: over Mica/Solid the panel is matte; over HyperGlass the rail and overlapped content are hidden/clipped)el.w(px(rail_peek_width(full_w, shown)))},).into_any_element()});+ let glass_peek = glass_on && peek.is_some();// (the status bar is the content panel's: the window less the sidebar when it is shown, and the panel's margin)let strip_bar_w = (surface == crate::transfer_view::Surface::Strip).then(|| (f32::from(window.viewport_size().width) - content_side_used - 10.0).max(0.0));let cards = (surface == crate::transfer_view::Surface::Card)@@ -7147,8 +7164,8 @@ impl Render for Workspace {.h_full().relative().flex_shrink_0()- .when(windows_theme, |d| d.border_r_1().border_color(p.divider))- .child(s)+ .when(windows_theme && !glass_peek, |d| d.border_r_1().border_color(p.divider))+ .child(div().h_full().when(glass_peek, |d| d.opacity(0.)).child(s)).child(resize_handle("sidebar-resize", ResizeSidebar, false))// on the rail, hovering opens the full sidebar over the content.on_hover(cx.listener(|this, h: &bool, window, cx| {@@ -7171,8 +7188,8 @@ impl Render for Workspace {// drawn after the list and the preview, so it lies over them.children(peek.map(|d| deferred(d).with_priority(1)))}))- .child(- div()+ .child({+ let content_card = div().flex_1().min_w_0().h_full()@@ -7247,8 +7264,46 @@ impl Render for Workspace {_ => {}}}))- }),- ),+ });+ if glass_peek {+ let full_w = self.sidebar_w;+ let opening = peek_wanted;+ let serial = self.rail_peek_serial;+ let clip_box = div().id("content-peek-clip").absolute().top_0().bottom_0().right_0().overflow_hidden();+ let inner_box = h_flex().id("content-peek-inner").absolute().top_0().bottom_0().right_0().child(content_card);+ // Clip the overlapped strip of the content card so HyperGlass shows cleanly behind the translucent peek panel+ // instead of text/lenses bleeding through, without changing the content card's layout width.+ let clipped = if crate::settings::animations() {+ let (ms, bounce) = if opening { (RAIL_OUT_MS, RAIL_BOUNCE) } else { (RAIL_IN_MS, 0.0) };+ let inner_el = inner_box.left_0().with_animation(+ ("content-peek-inner", serial as usize),+ Animation::new(std::time::Duration::from_millis(ms)).with_easing(move |t| rf_win::dock::spring::curve_with(t, bounce)),+ move |el, t| {+ let shown = if opening { t } else { 1.0 - t };+ el.left(px(-rail_peek_overlap(full_w, shown)))+ },+ );+ clip_box+ .left_0()+ .child(inner_el)+ .with_animation(+ ("content-peek-clip", serial as usize),+ Animation::new(std::time::Duration::from_millis(ms)).with_easing(move |t| rf_win::dock::spring::curve_with(t, bounce)),+ move |el, t| {+ let shown = if opening { t } else { 1.0 - t };+ el.left(px(rail_peek_overlap(full_w, shown)))+ },+ )+ .into_any_element()+ } else {+ let overlap = rail_peek_overlap(full_w, 1.0);+ clip_box.left(px(overlap)).child(inner_box.left(px(-overlap))).into_any_element()+ };+ div().flex_1().min_w_0().h_full().relative().child(clipped).into_any_element()+ } else {+ content_card.into_any_element()+ }+ }),).when(!windows_theme && !compact, |d| d.child(div().h(px(8.))))// Last children = painted on top.@@ -7405,7 +7460,7 @@ mod launch_tests {#[cfg(test)]mod rail_peek_tests {- use super::{RAIL_W, rail_peek_width};+ use super::{RAIL_W, rail_peek_bg_color, rail_peek_overlap, rail_peek_width};/// The sidebar that comes out of the rail: from the rail's own width to the full one, a little past it while the spring swings,/// and never narrower than the rail.@@ -7417,6 +7472,33 @@ mod rail_peek_tests {assert_eq!(rail_peek_width(240.0, -0.2), RAIL_W);assert!(rail_peek_width(240.0, 0.5) > RAIL_W && rail_peek_width(240.0, 0.5) < 240.0);}++ #[test]+ fn rail_peek_uses_glass_wash_over_hyperglass_and_opaque_over_other_backdrops() {+ let mut content_bg: gpui_kit::Hsla = gpui_kit::rgb(0x141414).into();+ content_bg.a = 0.22;+ let sampled: gpui_kit::Hsla = gpui_kit::rgb(0x2A3B4C).into();++ // Over HyperGlass: keeps content_bg's translucent surface wash even if a stale sampled color was present.+ assert_eq!(rail_peek_bg_color(true, None, content_bg), content_bg);+ assert_eq!(rail_peek_bg_color(true, Some(sampled), content_bg), content_bg);++ // Over Mica / Solid: uses the sampled rail color when available, or opaque content_bg otherwise.+ assert_eq!(rail_peek_bg_color(false, Some(sampled), content_bg), sampled);+ let fallback = rail_peek_bg_color(false, None, content_bg);+ assert_eq!(fallback.a, 1.0);+ assert_eq!(fallback.h, content_bg.h);+ assert_eq!(fallback.s, content_bg.s);+ assert_eq!(fallback.l, content_bg.l);+ }++ #[test]+ fn rail_peek_overlap_matches_extension_beyond_rail() {+ assert_eq!(rail_peek_overlap(240.0, 0.0), 0.0);+ assert_eq!(rail_peek_overlap(240.0, -0.2), 0.0);+ assert_eq!(rail_peek_overlap(240.0, 1.0), 240.0 - RAIL_W);+ assert_eq!(rail_peek_overlap(240.0, 0.5), rail_peek_width(240.0, 0.5) - RAIL_W);+ }}/// The stops of Tab in a window, in order.