Skip to content

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.

Sidebar pin button: follows the sidebar text size, as far from the row edge as from its top and bottom

ishiichan-dayo35b8099bc6de
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index 02dc257e..7a0c24fa 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -4472,11 +4472,25 @@ impl Workspace {
let s = cx.global::<crate::settings::Settings>();
(s.sidebar_compact, s.sidebar_text_percent)
};
+ // the sidebar's own text size as a scale (1 when it follows the window's), for the text and the pin button beside it
+ let text_scale = if text_percent == 0 { 1. } else { f32::from(text_percent.clamp(75, 125)) / 100. };
+ // (Explorer's measures: its navigation pane's rows 32 px apart; 8 px less in a compact sidebar)
+ let row_h = sidebar_row_height(if metrics && !rail { 32. } else if windows_theme || rail { 36. } else { 32. }, compact);
let pin_target = if pin_indicator && !rail && windows_theme {
target.path().map(Path::to_path_buf)
} else {
None
};
+ // the pin button: 28 px, 24 with Explorer's measures (so that the row stays 32 px), with the sidebar's text size, never
+ // taller than the row's room inside its padding (4 px a side, 2 px in a compact row, where its hover touched the row's edges;
+ // a larger button made its row taller than the others), and as far from the row's right edge as from its top and bottom (it
+ // stood 8 px in). Even sizes keep the button and its icon on whole pixels when they are centred (odd ones landed on half
+ // pixels and looked shifted).
+ let even = |v: f32| (v / 2.).round() * 2.;
+ let pin_box = even(if metrics { 24. } else { 28. } * text_scale).min(row_h - if compact { 4. } else { 8. });
+ let pin_gap = (row_h - pin_box) / 2.;
+ let pin_icon = even(16. * text_scale);
+ let pin_at_edge = pin_target.is_some();
let pin_label = label.clone();
let pin_id = id.clone();
// a USB stick's or a disc's row: "Güvenle çıkar" at its end, as in Explorer's navigation pane
@@ -4529,9 +4543,8 @@ impl Workspace {
.id(id)
// A row of the scrolling sidebar never shrinks: squeezed to its least height, a drive's second line ran into the next row.
.flex_shrink_0()
- // (Explorer's measures: its navigation pane's rows 32 px apart and its 12 px text; 8 px less in a compact sidebar)
- .min_h(px(sidebar_row_height(if metrics && !rail { 32. } else if windows_theme || rail { 36. } else { 32. }, compact)))
- .when(windows_theme, |d| d.pl(if rail { px(8.) } else { px(24.) }).pr_2())
+ .min_h(px(row_h))
+ .when(windows_theme, |d| d.pl(if rail { px(8.) } else { px(24.) }).pr(if pin_at_edge { px(pin_gap) } else { px(8.) }))
.when(!windows_theme, |d| d.px_2())
.when(!compact, |d| d.py_1())
.gap(if windows_theme { px(4.) } else { px(8.) })
@@ -4542,8 +4555,7 @@ impl Workspace {
// the sidebar's own text size (Settings > Appearance), as a share of the usual: 12 px with Explorer's measures, otherwise
// `text_sm`'s 14 px on 20 px lines
.when(text_percent != 0, |d| {
- let k = f32::from(text_percent.clamp(75, 125)) / 100.;
- if metrics { d.text_size(px(12. * k)) } else { d.text_size(px(14. * k)).line_height(px((20. * k).round())) }
+ if metrics { d.text_size(px(12. * text_scale)) } else { d.text_size(px(14. * text_scale)).line_height(px((20. * text_scale).round())) }
})
.relative()
.when(fluent, |d| d.bg(p.selection).child(theme::selection_pill(p)))
@@ -4605,8 +4617,7 @@ impl Workspace {
d.child(
div()
.id((pin_id.clone(), "unpin"))
- // (smaller with Explorer's measures, so that the row stays 32 px)
- .size(px(if metrics { 24. } else { 28. }))
+ .size(px(pin_box))
.flex()
.items_center()
.justify_center()
@@ -4618,7 +4629,7 @@ impl Workspace {
}))
.child(
Icon::new(L::Pin)
- .size(px(16.))
+ .size(px(pin_icon))
.text_color(p.text_tertiary)
.rotate(radians(-0.35)),
),