Hide tab bar view using the view controller’s hidden property (10.12)

For users on an OS earlier than 10.12, the tab bar will always be visible, even when configured to not show for windows with only a single document (tab).
This commit is contained in:
Allan Odgaard
2018-11-07 15:15:01 +07:00
parent 6aaa1df99b
commit e830f6600c

View File

@@ -78,6 +78,7 @@ static void show_command_error (std::string const& message, oak::uuid_t const& u
std::map<std::string, std::string> _documentSCMVariables;
std::vector<std::string> _documentScopeAttributes; // attr.os-version, attr.untitled / attr.rev-path + kSettingsScopeAttributesKey
}
@property (nonatomic) NSTitlebarAccessoryViewController* titlebarViewController;
@property (nonatomic) ProjectLayoutView* layoutView;
@property (nonatomic) OakTabBarView* tabBarView;
@property (nonatomic) OakDocumentView* documentView;
@@ -188,11 +189,11 @@ static NSArray* const kObservedKeyPaths = @[ @"arrayController.arrangedObjects.p
self.window.delegate = self;
self.window.releasedWhenClosed = NO;
NSTitlebarAccessoryViewController* viewController = [[NSTitlebarAccessoryViewController alloc] init];
_titlebarViewController = [[NSTitlebarAccessoryViewController alloc] init];
self.tabBarView.frameSize = self.tabBarView.intrinsicContentSize;
viewController.view = self.tabBarView;
viewController.fullScreenMinHeight = NSHeight(self.tabBarView.frame);
[self.window addTitlebarAccessoryViewController:viewController];
_titlebarViewController.view = self.tabBarView;
_titlebarViewController.fullScreenMinHeight = NSHeight(self.tabBarView.frame);
[self.window addTitlebarAccessoryViewController:_titlebarViewController];
[LicenseManager.sharedInstance decorateWindow:self.window];
@@ -367,6 +368,12 @@ static NSArray* const kObservedKeyPaths = @[ @"arrayController.arrangedObjects.p
self.oldWindowFrame = self.newWindowFrame = NSZeroRect;
self.layoutView.fileBrowserOnRight = !self.layoutView.fileBrowserOnRight;
}
if(@available(macos 10.12, *))
{
BOOL disableTabBarCollapsingKey = [NSUserDefaults.standardUserDefaults boolForKey:kUserDefaultsDisableTabBarCollapsingKey];
self.titlebarViewController.hidden = !disableTabBarCollapsingKey && self.documents.count <= 1;
}
}
- (void)applicationDidBecomeActiveNotification:(NSNotification*)aNotification
@@ -1460,6 +1467,12 @@ static NSArray* const kObservedKeyPaths = @[ @"arrayController.arrangedObjects.p
[self.tabBarView setSelectedTabIndex:MIN(_selectedTabIndex, _documents.count-1)];
}
if(@available(macos 10.12, *))
{
BOOL disableTabBarCollapsingKey = [NSUserDefaults.standardUserDefaults boolForKey:kUserDefaultsDisableTabBarCollapsingKey];
self.titlebarViewController.hidden = !disableTabBarCollapsingKey && self.documents.count <= 1;
}
[self updateFileBrowserStatus:self];
[self updateTouchBarButtons];
[[self class] scheduleSessionBackup:self];