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
Wheel click starts the locked auto-scroll in lists and Settings
gelenmedya3d017acce397
diff --git a/crates/rf-app/src/folder_view.rs b/crates/rf-app/src/folder_view.rsindex b99aeddb..ca4e9804 100644--- a/crates/rf-app/src/folder_view.rs+++ b/crates/rf-app/src/folder_view.rs@@ -836,6 +836,8 @@ pub struct FolderView {scroll: UniformListScrollHandle,// Inactive tabs leave the element tree, but their settings scroll position lives with the pane.settings_scroll: ScrollHandle,+ /// A wheel click's auto-scroll while it runs (see [`FolderView::begin_autoscroll`]).+ autoscroll: Option<AutoScroll>,pub focus: FocusHandle,/// Re-select this name after the next load (e.g. after going up a level).reselect: Option<String>,@@ -1127,6 +1129,7 @@ impl FolderView {_load_task: None,scroll: UniformListScrollHandle::new(),settings_scroll: ScrollHandle::new(),+ autoscroll: None,focus: cx.focus_handle(),reselect: None,menu_after_load: None,@@ -5344,6 +5347,59 @@ impl FolderView {}/// A middle click on a folder opens it in a new tab, in every view (issue 245: only Details did).+ /// A wheel click (on empty space, a file, or a Settings page) starts the locked auto-scroll of Windows' lists: the list scrolls by+ /// how far the pointer is above or below the spot of the click, until the next click or a key (Discord, 2026-12-01: "Apps should+ /// enable locked auto-scrolling"). Held and moved, it ends when the wheel is let go. A wheel click on a folder still opens it in a+ /// new tab (it stops the press before it gets here). Not in the Columns view (it scrolls sideways) or the pages of their own.+ fn begin_autoscroll(&mut self, at: Point<Pixels>, window: &mut Window, cx: &mut Context<Self>) {+ if self.autoscroll.take().is_some() {+ cx.notify();+ return;+ }+ let handle = match self.location() {+ Location::Settings => self.settings_scroll.clone(),+ Location::Home | Location::DiskUsage(_) | Location::Downloads | Location::RecycleBin => return,+ _ if self.view_mode == ViewMode::Columns => return,+ _ => self.scroll.0.borrow().base_handle.clone(),+ };+ if handle.max_offset().y <= px(0.) {+ return;+ }+ cx.stop_propagation();+ self.autoscroll = Some(AutoScroll { anchor: at, handle, began: Instant::now() });+ cx.notify();+ cx.spawn_in(window, async move |this, cx| {+ loop {+ cx.background_executor().timer(Duration::from_millis(16)).await;+ if !this.update_in(cx, |v, window, cx| v.autoscroll_tick(window, cx)).unwrap_or(false) {+ break;+ }+ }+ })+ .detach();+ }++ /// One frame of the auto-scroll: false when it has ended.+ fn autoscroll_tick(&mut self, window: &mut Window, cx: &mut Context<Self>) -> bool {+ let Some(a) = &self.autoscroll else { return false };+ let step = autoscroll_step(f32::from(window.mouse_position().y - a.anchor.y));+ if step != 0. {+ let (off, max) = (a.handle.offset(), a.handle.max_offset());+ let y = (f32::from(off.y) - step).clamp(-f32::from(max.y), 0.);+ if (y - f32::from(off.y)).abs() > f32::EPSILON {+ a.handle.set_offset(point(off.x, px(y)));+ cx.notify();+ }+ }+ true+ }++ fn end_autoscroll(&mut self, cx: &mut Context<Self>) {+ if self.autoscroll.take().is_some() {+ cx.notify();+ }+ }+fn middle_open(&mut self, vi: usize, cx: &mut Context<Self>) {let Some(&ei) = self.visible.get(vi) else { return };if self.entries[ei as usize].is_dir() {@@ -8128,8 +8184,13 @@ impl Render for FolderView {let bg = this.selected.is_empty();this.show_context_menu(bg, window, cx)}))- .on_key_down(cx.listener(|this, ev: &KeyDownEvent, _, cx| this.on_typeahead(ev, cx)))+ .on_key_down(cx.listener(|this, ev: &KeyDownEvent, _, cx| {+ // a key ends a wheel click's auto-scroll (and still does its own job)+ this.end_autoscroll(cx);+ this.on_typeahead(ev, cx)+ })).on_key_up(cx.listener(|this, ev: &KeyUpEvent, _, cx| this.on_key_up(ev, cx)))+ .on_mouse_down(MouseButton::Middle, cx.listener(|this, ev: &MouseDownEvent, window, cx| this.begin_autoscroll(ev.position, window, cx))).on_mouse_down(MouseButton::Navigate(NavigationDirection::Back),cx.listener(|this, _: &MouseDownEvent, _, cx| this.back(cx)),@@ -8138,10 +8199,77 @@ impl Render for FolderView {MouseButton::Navigate(NavigationDirection::Forward),cx.listener(|this, _: &MouseDownEvent, _, cx| this.forward(cx)),)+ .relative().child(content)+ .when_some(self.autoscroll.as_ref().map(|a| a.anchor), |d, anchor| d.child(autoscroll_layer(anchor, &p, cx)))}}+/// A wheel click's auto-scroll (see [`FolderView::begin_autoscroll`]).+struct AutoScroll {+ /// Where the wheel was clicked, in the window.+ anchor: Point<Pixels>,+ handle: ScrollHandle,+ began: Instant,+}++/// How far the list moves in one frame (16 ms) for the pointer `dy` pixels below the spot of the wheel click (above: negative). Still+/// within a small circle around it, then faster the farther the pointer goes, with a ceiling.+pub(crate) fn autoscroll_step(dy: f32) -> f32 {+ const STILL: f32 = 12.;+ let d = dy.abs() - STILL;+ if d <= 0. { 0. } else { dy.signum() * (d * 0.06 + d * d * 0.0004).min(120.) }+}++/// Over the view while the auto-scroll runs: the mark at the spot of the wheel click, and a layer that takes the next press (any+/// button) to end it, so that press does nothing else. A wheel held and moved ends it on its release.+fn autoscroll_layer(anchor: Point<Pixels>, p: &Palette, cx: &mut Context<FolderView>) -> AnyElement {+ let mark = deferred(+ anchored().position(point(anchor.x - px(14.), anchor.y - px(14.))).child(+ div()+ .size(px(28.))+ .flex()+ .items_center()+ .justify_center()+ .rounded_full()+ .bg(p.card_bg)+ .border_1()+ .border_color(p.border)+ .shadow_md()+ .child(Icon::new(L::ChevronsUpDown).size(px(16.)).text_color(p.text_secondary)),+ ),+ );+ div()+ .id("autoscroll-layer")+ .absolute()+ .inset_0()+ .occlude()+ .cursor(CursorStyle::ResizeUpDown)+ .on_mouse_down(MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| {+ cx.stop_propagation();+ this.end_autoscroll(cx)+ }))+ .on_mouse_down(MouseButton::Right, cx.listener(|this, _: &MouseDownEvent, _, cx| {+ cx.stop_propagation();+ this.end_autoscroll(cx)+ }))+ .on_mouse_down(MouseButton::Middle, cx.listener(|this, _: &MouseDownEvent, _, cx| {+ cx.stop_propagation();+ this.end_autoscroll(cx)+ }))+ // held and moved (not a quick click): the scroll ends with the release, as in Windows' lists+ .on_mouse_up(MouseButton::Middle, cx.listener(|this, ev: &MouseUpEvent, _, cx| {+ if let Some(a) = &this.autoscroll {+ let moved = (ev.position.y - a.anchor.y).abs() > px(24.) || (ev.position.x - a.anchor.x).abs() > px(24.);+ if moved && a.began.elapsed() > Duration::from_millis(350) {+ this.end_autoscroll(cx);+ }+ }+ }))+ .child(mark)+ .into_any_element()+}+#[allow(dead_code)]fn _assert_category_used(_: Category) {}@@ -8863,3 +8991,17 @@ mod recent_time_width_tests {assert_eq!(recent_time_width(400.0), 260.);}}++#[cfg(test)]+mod autoscroll_tests {+ #[test]+ fn the_list_stands_still_near_the_spot_and_runs_faster_farther_away() {+ assert_eq!(super::autoscroll_step(0.), 0.);+ assert_eq!(super::autoscroll_step(10.), 0.);+ assert_eq!(super::autoscroll_step(-10.), 0.);+ let (near, far) = (super::autoscroll_step(40.), super::autoscroll_step(200.));+ assert!(near > 0. && far > near, "{near} {far}");+ assert_eq!(super::autoscroll_step(-200.), -far, "above: the same speed upwards");+ assert!(super::autoscroll_step(5000.) <= 120.);+ }+}