Revert "macOS: use same ResetZoomAccessoryView (#14028)"

This reverts commit 15ff186f65, reversing
changes made to 1abd53ee53.
This commit is contained in:
Lukas
2026-08-26 22:44:12 +02:00
parent d9840f3c8f
commit b6ac6e1d47

View File

@@ -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)
@@ -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