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
Allow marquee selection from empty scroll viewport space
sunzhaozheng538563d460b5
diff --git a/macos/Sources/RustyFiles/SelectionMarquee.swift b/macos/Sources/RustyFiles/SelectionMarquee.swiftindex 0d5dab8a..400eddd4 100644--- a/macos/Sources/RustyFiles/SelectionMarquee.swift+++ b/macos/Sources/RustyFiles/SelectionMarquee.swift@@ -18,8 +18,10 @@ final class SelectionMarquee: NSView {static func track(from event: NSEvent, in view: NSView, update: (NSRect) -> Void) -> Bool {guard let window = view.window else { return false }let origin = view.convert(event.locationInWindow, from: nil)- let overlay = SelectionMarquee(frame: view.bounds)- overlay.autoresizingMask = [.width, .height]+ // The visible clip can extend past the document, including the empty area+ // where a drag starts. Draw across the viewport, not just over the items.+ let host = view.enclosingScrollView?.contentView ?? view+ let overlay = SelectionMarquee(frame: .zero)var lastDrag: NSEvent?var lastRect: NSRect?defer { overlay.removeFromSuperview() }@@ -32,19 +34,24 @@ final class SelectionMarquee: NSView {if lastDrag == nil {guard hypot(point.x - origin.x, point.y - origin.y) >= 3 else { continue }window.makeFirstResponder(view)- view.addSubview(overlay, positioned: .above, relativeTo: nil)+ overlay.frame = host.bounds+ host.addSubview(overlay, positioned: .above, relativeTo: nil)}if next.type == .leftMouseDragged { _ = view.autoscroll(with: next) }let end = view.convert(next.locationInWindow, from: nil)let rect = NSRect(x: min(origin.x, end.x), y: min(origin.y, end.y),width: max(abs(end.x - origin.x), 1), height: max(abs(end.y - origin.y), 1))+ overlay.frame = host.bounds+ let box = overlay.convert(rect, from: view)+ if overlay.box != box {+ overlay.box = box+ overlay.needsDisplay = true+ }if lastRect != rect {lastRect = rect- overlay.box = overlay.convert(rect, from: view)- overlay.needsDisplay = trueupdate(rect)- window.displayIfNeeded()}+ window.displayIfNeeded()if next.type == .leftMouseUp || NSEvent.pressedMouseButtons & 1 == 0 { return true }lastDrag = next}diff --git a/macos/Sources/RustyFiles/Swipe.swift b/macos/Sources/RustyFiles/Swipe.swiftindex 913f467f..e8d58625 100644--- a/macos/Sources/RustyFiles/Swipe.swift+++ b/macos/Sources/RustyFiles/Swipe.swift@@ -62,6 +62,19 @@ final class SwipeScrollView: NSScrollView {onSwipe?(back)}+ override func hitTest(_ point: NSPoint) -> NSView? {+ let hit = super.hitTest(point)+ // Insets and unused space beyond the collection's frame belong to the clip view.+ // Route only a left press there to the collection's background selection handler.+ if hit === contentView || hit === self,+ contentView.frame.contains(convert(point, from: superview)),+ NSApp.currentEvent?.type == .leftMouseDown,+ let tiles = documentView as? TileCollectionView {+ return tiles+ }+ return hit+ }+override func menu(for event: NSEvent) -> NSMenu? {emptyMenu?() ?? super.menu(for: event)}