From b4c82b5fd51b22efe803381e39c5026338daef55 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Sat, 6 Aug 2016 12:31:27 +0200 Subject: [PATCH] MacGui: use auto layout in the preferences window. --- macosx/English.lproj/Preferences.xib | 1233 ++++++++++++++------------ macosx/HBPreferencesController.m | 65 +- 2 files changed, 727 insertions(+), 571 deletions(-) diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index e56cbfa9d..a88b764c3 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -1,9 +1,9 @@ - - + + - - + + @@ -32,566 +32,705 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 3a60890ba..14f988db6 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -282,44 +282,61 @@ - (void) setPrefView: (id) sender { - NSView * view = fGeneralView; - if( sender ) + NSView *view = fGeneralView; + if (sender) { - NSString * identifier = [sender itemIdentifier]; - if( [identifier isEqualToString: TOOLBAR_AUDIO] ) + NSString *identifier = [sender itemIdentifier]; + if ([identifier isEqualToString:TOOLBAR_AUDIO]) + { view = fAudioView; - else if( [identifier isEqualToString: TOOLBAR_ADVANCED] ) + } + else if([identifier isEqualToString:TOOLBAR_ADVANCED]) + { view = fAdvancedView; - else; + } } - NSWindow * window = [self window]; - if( [window contentView] == view ) + NSWindow *window = self.window; + if (window.contentView == view) + { return; + } - NSRect windowRect = [window frame]; - CGFloat difference = ( [view frame].size.height - [[window contentView] frame].size.height ); - windowRect.origin.y -= difference; - windowRect.size.height += difference; + window.contentView = view; - [view setHidden: YES]; - [window setContentView: view]; - [window setFrame: windowRect display: YES animate: YES]; - [view setHidden: NO]; + if (window.isVisible) + { + view.hidden = YES; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + if ([context respondsToSelector:@selector(setAllowsImplicitAnimation:)]) + { + context.allowsImplicitAnimation = YES; + } + [window layoutIfNeeded]; + + } completionHandler:^{ + view.hidden = NO; + }]; + } - //set title label - if( sender ) - [window setTitle: [sender label]]; + // set title label + if (sender) + { + window.title = [sender label]; + } else { - NSToolbar * toolbar = [window toolbar]; - NSString * itemIdentifier = [toolbar selectedItemIdentifier]; - for( NSToolbarItem * item in [toolbar items] ) - if( [[item itemIdentifier] isEqualToString: itemIdentifier] ) + NSToolbar *toolbar = window.toolbar; + NSString *itemIdentifier = toolbar.selectedItemIdentifier; + for (NSToolbarItem *item in toolbar.items) + { + if ([item.itemIdentifier isEqualToString:itemIdentifier]) { - [window setTitle: [item label]]; + window.title = item.label; break; } + } } } -- 2.40.0