From b529530b782ed2c5f73282d2b7f95ee053e540b3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 7 Dec 2019 18:00:09 -0500 Subject: [PATCH] Restore keeping the original size of content views for pref panes. --- Source/PreferencesController.m | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/PreferencesController.m b/Source/PreferencesController.m index 8f863d7..4a69529 100644 --- a/Source/PreferencesController.m +++ b/Source/PreferencesController.m @@ -18,6 +18,8 @@ @implementation PreferencesController { NSView* _blankView; + + NSSize _generalSize, _fileAccessSize, _pathsSize; } /** @@ -32,6 +34,13 @@ return self; } +- (void)awakeFromNib +{ + _generalSize = self.generalPreferencesView.frame.size; + _fileAccessSize = self.fileAccessPreferencesView.frame.size; + _pathsSize = self.pathsPreferencesView.frame.size; +} + /** * Shows the preferences controller window */ @@ -87,12 +96,12 @@ */ - (IBAction)showGeneral:(id)sender { - [self _switchToView:self.generalPreferencesView forToolbarItem:self.generalPreferencesItem]; + [self _switchToView:self.generalPreferencesView resizeTo:_generalSize forToolbarItem:self.generalPreferencesItem]; } - (IBAction)showFileAccess:(id)sender { - [self _switchToView:self.fileAccessPreferencesView forToolbarItem:self.fileAccessPreferencesItem]; + [self _switchToView:self.fileAccessPreferencesView resizeTo:_fileAccessSize forToolbarItem:self.fileAccessPreferencesItem]; } /** @@ -100,7 +109,7 @@ */ - (IBAction)showPaths:(id)sender { - [self _switchToView:self.pathsPreferencesView forToolbarItem:self.pathsPreferencesItem]; + [self _switchToView:self.pathsPreferencesView resizeTo:_pathsSize forToolbarItem:self.pathsPreferencesItem]; } #pragma mark NSToolbar Delegate @@ -119,10 +128,12 @@ #pragma mark Private -- (void)_switchToView:(NSView*)contentView forToolbarItem:(NSToolbarItem*)item { +- (void)_switchToView:(NSView*)contentView + resizeTo:(NSSize)size + forToolbarItem:(NSToolbarItem*)item { if (self.window.contentView == contentView) return; - [self _resizeWindowToSize:contentView.frame.size]; + [self _resizeWindowToSize:size]; self.window.contentView = contentView; self.toolbar.selectedItemIdentifier = item.itemIdentifier; } -- 2.43.5