|
|
@@ -18,6 +18,8 @@ enum FilePreviewService {
|
|
|
final class FilePreviewOverlayView: NSView, AppearanceRefreshable {
|
|
|
var onDismiss: (() -> Void)?
|
|
|
|
|
|
+ override var mouseDownCanMoveWindow: Bool { false }
|
|
|
+
|
|
|
private let urls: [URL]
|
|
|
private var currentIndex = 0
|
|
|
private var securityAccess: [URL: Bool] = [:]
|
|
|
@@ -66,19 +68,30 @@ final class FilePreviewOverlayView: NSView, AppearanceRefreshable {
|
|
|
}
|
|
|
|
|
|
func present(in parent: NSView) {
|
|
|
- guard superview == nil else { return }
|
|
|
- parent.addSubview(self)
|
|
|
- NSLayoutConstraint.activate([
|
|
|
- leadingAnchor.constraint(equalTo: parent.leadingAnchor),
|
|
|
- trailingAnchor.constraint(equalTo: parent.trailingAnchor),
|
|
|
- topAnchor.constraint(equalTo: parent.topAnchor),
|
|
|
- bottomAnchor.constraint(equalTo: parent.bottomAnchor),
|
|
|
- ])
|
|
|
- alphaValue = 0
|
|
|
- NSAnimationContext.runAnimationGroup { context in
|
|
|
- context.duration = 0.2
|
|
|
- animator().alphaValue = 1
|
|
|
+ if superview == nil {
|
|
|
+ parent.addSubview(self)
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
+ leadingAnchor.constraint(equalTo: parent.leadingAnchor),
|
|
|
+ trailingAnchor.constraint(equalTo: parent.trailingAnchor),
|
|
|
+ topAnchor.constraint(equalTo: parent.topAnchor),
|
|
|
+ bottomAnchor.constraint(equalTo: parent.bottomAnchor),
|
|
|
+ ])
|
|
|
+ alphaValue = 0
|
|
|
+ NSAnimationContext.runAnimationGroup { context in
|
|
|
+ context.duration = 0.2
|
|
|
+ animator().alphaValue = 1
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ parent.addSubview(self, positioned: .above, relativeTo: nil)
|
|
|
+ alphaValue = 1
|
|
|
}
|
|
|
+ window?.makeFirstResponder(nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func hitTest(_ point: NSPoint) -> NSView? {
|
|
|
+ let hit = super.hitTest(point)
|
|
|
+ if hit != nil { return hit }
|
|
|
+ return bounds.contains(point) ? self : nil
|
|
|
}
|
|
|
|
|
|
func dismiss(animated: Bool = true) {
|
|
|
@@ -253,6 +266,8 @@ final class FilePreviewOverlayView: NSView, AppearanceRefreshable {
|
|
|
private final class FileToolbarButton: NSControl, AppearanceRefreshable {
|
|
|
var onClick: (() -> Void)?
|
|
|
|
|
|
+ override var acceptsFirstResponder: Bool { false }
|
|
|
+
|
|
|
private let iconView = NSImageView()
|
|
|
|
|
|
init(symbolName: String, accessibilityLabel: String) {
|