feat: title bar hover to show/hide

- Title bar hidden by default (titleVisibility + titlebarAppearsTransparent)
- Mouse enter top 28pt area: show title bar
- Mouse exit: hide title bar
- Decouple title visibility from toolbar state
This commit is contained in:
yumoqing 2026-06-30 23:27:14 +08:00
parent 610f619a35
commit 7c1a84c413

View File

@ -319,18 +319,35 @@ struct PlayerContentView: View {
}
}
.onAppear {
// toolbar
NSApplication.shared.windows.first?.titleVisibility = .hidden
//
if let win = NSApplication.shared.windows.first {
win.titleVisibility = .hidden
win.titlebarAppearsTransparent = true
}
}
.onChange(of: showToolbar) { _, newValue in
// /toolbar
NSApplication.shared.windows.first?.titleVisibility = newValue ? .visible : .hidden
if newValue {
resetHideTimer()
} else {
hideTimer?.invalidate()
}
}
.overlay(alignment: .top) {
// 退
Color.clear
.frame(height: 28)
.contentShape(Rectangle())
.onHover { hovering in
let win = NSApplication.shared.windows.first
if hovering {
win?.titleVisibility = .visible
win?.titlebarAppearsTransparent = false
} else {
win?.titleVisibility = .hidden
win?.titlebarAppearsTransparent = true
}
}
}
.onDisappear {
hideTimer?.invalidate()
}