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:
parent
610f619a35
commit
7c1a84c413
@ -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()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user