maximize-sidebar (#50)
This commit is contained in:
parent
4bf968fd68
commit
23db0a3fa2
1 changed files with 28 additions and 0 deletions
|
|
@ -579,6 +579,12 @@ struct VerticalTabsSidebar: View {
|
|||
SidebarTopScrim(height: trafficLightPadding + 20)
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
.overlay(alignment: .top) {
|
||||
// Double-click the sidebar title-bar area to zoom the
|
||||
// window, matching the panel top-bar behaviour.
|
||||
DoubleClickZoomView()
|
||||
.frame(height: trafficLightPadding)
|
||||
}
|
||||
.background(Color.clear)
|
||||
.modifier(ClearScrollBackground())
|
||||
}
|
||||
|
|
@ -1920,6 +1926,28 @@ private struct SidebarTabDropDelegate: DropDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
/// AppKit-level double-click handler for the sidebar title-bar area.
|
||||
/// Uses NSView hit-testing so it isn't swallowed by the SwiftUI ScrollView underneath.
|
||||
private struct DoubleClickZoomView: NSViewRepresentable {
|
||||
func makeNSView(context: Context) -> NSView {
|
||||
DoubleClickZoomNSView()
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSView, context: Context) {}
|
||||
|
||||
private final class DoubleClickZoomNSView: NSView {
|
||||
override var mouseDownCanMoveWindow: Bool { true }
|
||||
override func hitTest(_ point: NSPoint) -> NSView? { self }
|
||||
override func mouseDown(with event: NSEvent) {
|
||||
if event.clickCount == 2 {
|
||||
window?.zoom(nil)
|
||||
} else {
|
||||
super.mouseDown(with: event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct MiddleClickCapture: NSViewRepresentable {
|
||||
let onMiddleClick: () -> Void
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue