Hide main title when covered by tabs
parent
85beda9c49
commit
12a01c0460
|
|
@ -25,6 +25,16 @@ class TerminalToolbar: NSToolbar, NSToolbarDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var titleIsHidden: Bool {
|
||||||
|
get {
|
||||||
|
titleTextField.isHidden
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
titleTextField.isHidden = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override init(identifier: NSToolbar.Identifier) {
|
override init(identifier: NSToolbar.Identifier) {
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ class TerminalWindow: NSWindow {
|
||||||
// This is required because the removeTitlebarAccessoryViewController hook does not
|
// This is required because the removeTitlebarAccessoryViewController hook does not
|
||||||
// catch the creation of a new window by "tearing off" a tab from a tabbed window.
|
// catch the creation of a new window by "tearing off" a tab from a tabbed window.
|
||||||
if let tabGroup = self.tabGroup, tabGroup.windows.count < 2 {
|
if let tabGroup = self.tabGroup, tabGroup.windows.count < 2 {
|
||||||
hideCustomTabBarViews()
|
resetCustomTabBarViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
super.becomeKey()
|
super.becomeKey()
|
||||||
|
|
@ -538,17 +538,22 @@ class TerminalWindow: NSWindow {
|
||||||
let isTabBar = titlebarAccessoryViewControllers[index].identifier == Self.TabBarController
|
let isTabBar = titlebarAccessoryViewControllers[index].identifier == Self.TabBarController
|
||||||
super.removeTitlebarAccessoryViewController(at: index)
|
super.removeTitlebarAccessoryViewController(at: index)
|
||||||
if (isTabBar) {
|
if (isTabBar) {
|
||||||
hideCustomTabBarViews()
|
resetCustomTabBarViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be called immediately after the tab bar is disabled.
|
// To be called immediately after the tab bar is disabled.
|
||||||
private func hideCustomTabBarViews() {
|
private func resetCustomTabBarViews() {
|
||||||
// Hide the window buttons backdrop.
|
// Hide the window buttons backdrop.
|
||||||
windowButtonsBackdrop?.isHidden = true
|
windowButtonsBackdrop?.isHidden = true
|
||||||
|
|
||||||
// Hide the window drag handle.
|
// Hide the window drag handle.
|
||||||
windowDragHandle?.isHidden = true
|
windowDragHandle?.isHidden = true
|
||||||
|
|
||||||
|
// Reenable the main toolbar title
|
||||||
|
if let toolbar = toolbar as? TerminalToolbar {
|
||||||
|
toolbar.titleIsHidden = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func pushTabsToTitlebar(_ tabBarController: NSTitlebarAccessoryViewController) {
|
private func pushTabsToTitlebar(_ tabBarController: NSTitlebarAccessoryViewController) {
|
||||||
|
|
@ -557,6 +562,11 @@ class TerminalWindow: NSWindow {
|
||||||
generateToolbar()
|
generateToolbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The main title conflicts with titlebar tabs, so hide it
|
||||||
|
if let toolbar = toolbar as? TerminalToolbar {
|
||||||
|
toolbar.titleIsHidden = true
|
||||||
|
}
|
||||||
|
|
||||||
// HACK: wait a tick before doing anything, to avoid edge cases during startup... :/
|
// HACK: wait a tick before doing anything, to avoid edge cases during startup... :/
|
||||||
// If we don't do this then on launch windows with restored state with tabs will end
|
// If we don't do this then on launch windows with restored state with tabs will end
|
||||||
// up with messed up tab bars that don't show all tabs.
|
// up with messed up tab bars that don't show all tabs.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue