diff --git a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift index 695bd16d4..737d146f1 100644 --- a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift @@ -136,7 +136,6 @@ class TerminalWindow: NSWindow { resetZoomAccessory.layoutAttribute = .right resetZoomAccessory.view = NSHostingView(rootView: ResetZoomAccessoryView( viewModel: viewModel, - isInToolbar: true, action: { [weak self] in guard let self else { return } self.terminalController?.splitZoom(self) @@ -158,7 +157,7 @@ class TerminalWindow: NSWindow { // Setup the accessory view for tabs that shows our keyboard shortcuts, // zoomed state, etc. Note I tried to use SwiftUI here but ran into issues - // where buttons were not clickable. + // where buttons were not clickable on macOS 15. tabColorIndicator.rootView = TabColorIndicatorView(tabColor: tabColor) let stackView = NSStackView() @@ -198,8 +197,14 @@ class TerminalWindow: NSWindow { super.close() } + override func becomeKey() { + super.becomeKey() + resetZoomTabButton.contentTintColor = .controlAccentColor + } + override func resignKey() { super.resignKey() + resetZoomTabButton.contentTintColor = .secondaryLabelColor tabTitleEditor.finishEditing(commit: true) } @@ -364,16 +369,19 @@ class TerminalWindow: NSWindow { } } - private lazy var resetZoomTabButton: NSView = generateResetZoomButton() + private lazy var resetZoomTabButton: NSButton = generateResetZoomButton() - private func generateResetZoomButton() -> NSView { - let button = NSHostingView(rootView: ResetZoomAccessoryView( - viewModel: viewModel, - isInToolbar: false, - action: { [weak self] in - guard let self else { return } - self.terminalController?.splitZoom(self) - })) + private func generateResetZoomButton() -> NSButton { + let button = NSButton() + button.isHidden = true + button.target = terminalController + button.action = #selector(TerminalController.splitZoom(_:)) + button.isBordered = false + button.allowsExpansionToolTips = true + button.toolTip = "Reset Zoom" + button.contentTintColor = isMainWindow ? .controlAccentColor : .secondaryLabelColor + button.state = .on + button.image = NSImage(named: "ResetZoom") button.frame = NSRect(x: 0, y: 0, width: 20, height: 20) button.translatesAutoresizingMaskIntoConstraints = false button.widthAnchor.constraint(equalToConstant: 20).isActive = true @@ -633,36 +641,27 @@ extension TerminalWindow { struct ResetZoomAccessoryView: View { @ObservedObject var viewModel: ViewModel - let isInToolbar: Bool let action: () -> Void var body: some View { if viewModel.isSurfaceZoomed { - if isInToolbar { - VStack { - button - Spacer() + VStack { + Button(action: action) { + Image("ResetZoom") + .foregroundColor(viewModel.isMainWindow ? .accentColor : .secondary) } - // With a toolbar, the window title is taller, so we need more padding - // to properly align. - .padding(.top, viewModel.accessoryTopPadding) - // We always need space at the end of the titlebar - .padding(.trailing, 10) - } else { - button + .buttonStyle(.plain) + .help("Reset Split Zoom") + .frame(width: 20, height: 20) + Spacer() } + // With a toolbar, the window title is taller, so we need more padding + // to properly align. + .padding(.top, viewModel.accessoryTopPadding) + // We always need space at the end of the titlebar + .padding(.trailing, 10) } } - - var button: some View { - Button(action: action) { - Image("ResetZoom") - .foregroundColor(viewModel.isMainWindow ? .accentColor : .secondary) - } - .buttonStyle(.plain) - .help("Reset Split Zoom") - .frame(width: 20, height: 20) - } } /// A pill-shaped button that displays update status and provides access to update actions. @@ -677,6 +676,7 @@ extension TerminalWindow { .padding(.trailing, viewModel.accessoryTopPadding) } } + } /// A small circle indicator displayed in the tab accessory view that shows