fix: align titlebar icons with traffic-light buttons (#1754)
The titlebar control icons (sidebar, notifications, new tab) were vertically misaligned — centered within the full titlebar+tab-bar area instead of the titlebar alone. Use the close button's superview height as the true titlebar height so the icons sit at the same vertical center as the traffic lights, matching the behavior of apps like Slack.
This commit is contained in:
parent
730d64b943
commit
0fa7160de8
1 changed files with 16 additions and 3 deletions
|
|
@ -881,9 +881,22 @@ final class TitlebarControlsAccessoryViewController: NSTitlebarAccessoryViewCont
|
|||
contentSize = cachedFittingSize ?? .zero
|
||||
|
||||
guard contentSize.width > 0, contentSize.height > 0 else { return }
|
||||
let titlebarHeight = view.window.map { window in
|
||||
window.frame.height - window.contentLayoutRect.height
|
||||
} ?? contentSize.height
|
||||
// Use the traffic-light close button's superview height as the true
|
||||
// titlebar height. This excludes the tab bar so the icons align with
|
||||
// the traffic-light buttons (like Slack does) instead of centering in
|
||||
// the full non-content area which includes the tab strip.
|
||||
let titlebarHeight: CGFloat = {
|
||||
if let window = view.window,
|
||||
let closeButton = window.standardWindowButton(.closeButton),
|
||||
let titlebarView = closeButton.superview,
|
||||
titlebarView.frame.height > 0 {
|
||||
return titlebarView.frame.height
|
||||
}
|
||||
// Fallback: derive from the window geometry.
|
||||
return view.window.map { window in
|
||||
window.frame.height - window.contentLayoutRect.height
|
||||
} ?? contentSize.height
|
||||
}()
|
||||
let containerHeight = max(contentSize.height, titlebarHeight)
|
||||
let yOffset = max(0, (containerHeight - contentSize.height) / 2.0)
|
||||
let nextLayoutSnapshot = TitlebarControlsLayoutSnapshot(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue