diff options
author | rowanbeentje <rowan@beent.je> | 2012-07-23 00:35:01 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-07-23 00:35:01 +0000 |
commit | ea1516eeb991cedd2ea8d86d65fef4b102996b2b (patch) | |
tree | d2c128b5ad0f68b974e3c5e2a44c1c49fd33ce7f /Source/SPTablesList.m | |
parent | 78b52f5a0cea1fc1d0c944f5408e7ef41d0ca2d6 (diff) | |
download | sequelpro-ea1516eeb991cedd2ea8d86d65fef4b102996b2b.tar.gz sequelpro-ea1516eeb991cedd2ea8d86d65fef4b102996b2b.tar.bz2 sequelpro-ea1516eeb991cedd2ea8d86d65fef4b102996b2b.zip |
- Add a new SPSplitView class, intended to replace all BWSplitViews and so allow us to remove BWToolKit. Supports constraints and animated collapsible subviews configured in code, fixes crashes and exceptions if a window is closed while animations are taking place or scheduled to take place.
- Replace the two vertical splitters in the table list (the filter splitter, and the table info splitter) with SPSplitView implementations as a test
- Add a helper method in the new SPDateAdditions
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r-- | Source/SPTablesList.m | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 441fdeab..7387044b 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -50,6 +50,7 @@ #ifndef SP_REFACTOR /* headers */ #import "SPWindowController.h" #import "SPAppController.h" +#import "SPSplitView.h" #endif #ifdef SP_REFACTOR @@ -131,29 +132,18 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (void)awakeFromNib { #ifndef SP_REFACTOR - // Collapse the table information pane if preference to do so is set - if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPTableInformationPanelCollapsed] boolValue] - && [tableListSplitView collapsibleSubview]) { - [tableInfoCollapseButton setNextState]; - [tableInfoCollapseButton setToolTip:NSLocalizedString(@"Show Table Information",@"Show Table Information")]; - [tableListSplitView setValue:[NSNumber numberWithFloat:[tableListSplitView collapsibleSubview].frame.size.height] forKey:@"uncollapsedSize"]; - [[tableListSplitView collapsibleSubview] setAutoresizesSubviews:NO]; - [[tableListSplitView collapsibleSubview] setFrameSize:NSMakeSize([tableListSplitView collapsibleSubview].frame.size.width, 0)]; - [tableListSplitView setCollapsibleSubviewCollapsed:YES]; - [[tableListSplitView collapsibleSubview] setAutoresizesSubviews:YES]; - } - else { - [tableInfoCollapseButton setToolTip:NSLocalizedString(@"Hide Table Information",@"Hide Table Information")]; - } - - // Start the table filter list collapsed - if ([tableListFilterSplitView collapsibleSubview]) { - [tableListFilterSplitView setValue:[NSNumber numberWithFloat:[tableListFilterSplitView collapsibleSubview].frame.size.height] forKey:@"uncollapsedSize"]; - // Set search bar view to the height of 1 instead of 0 to ensure that the view will be visible - // after opening a next connection window which has more than 20 tables - [[tableListFilterSplitView collapsibleSubview] setFrameSize:NSMakeSize([tableListFilterSplitView collapsibleSubview].frame.size.width, 1)]; - [tableListFilterSplitView setCollapsibleSubviewCollapsed:YES]; + + // Configure the table information pane + [tableListSplitView setCollapsibleSubviewIndex:1]; + + // Collapse the pane if the last state was collapsed + if ([[[NSUserDefaults standardUserDefaults] objectForKey:SPTableInformationPanelCollapsed] boolValue]) { + [tableListSplitView setCollapsibleSubviewCollapsed:YES animate:NO]; } + + // Configure the table list filter, starting it collapsed + [tableListFilterSplitView setCollapsibleSubviewIndex:0]; + [tableListFilterSplitView setCollapsibleSubviewCollapsed:YES animate:NO]; // Disable tab edit behaviour in the tables list [tablesListView setTabEditingDisabled:YES]; @@ -670,8 +660,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; { [tableListSplitView toggleCollapse:sender]; - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:([tableInfoCollapseButton state] == NSOffState)] forKey:SPTableInformationPanelCollapsed]; - [tableInfoCollapseButton setToolTip:([tableInfoCollapseButton state] == NSOffState) ? NSLocalizedString(@"Show Table Information", @"Show Table Information") : NSLocalizedString(@"Hide Table Information", @"Hide Table Information")]; + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[tableListSplitView isCollapsibleSubviewCollapsed]] forKey:SPTableInformationPanelCollapsed]; } #endif @@ -1807,7 +1796,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; */ - (void) showFilter { - if ([tableListFilterSplitView collapsibleSubviewIsCollapsed]) { + if ([tableListFilterSplitView isCollapsibleSubviewCollapsed]) { [tableListFilterSplitView performSelectorOnMainThread:@selector(toggleCollapse:) withObject:nil waitUntilDone:NO]; } } @@ -1818,7 +1807,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; */ - (void) hideFilter { - if (![tableListFilterSplitView collapsibleSubviewIsCollapsed]) { + if (![tableListFilterSplitView isCollapsibleSubviewCollapsed]) { [tableListFilterSplitView performSelectorOnMainThread:@selector(toggleCollapse:) withObject:nil waitUntilDone:NO]; } } @@ -2000,10 +1989,38 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; #pragma mark - #pragma mark SplitView Delegate Methods +/** + * Prevent the table info pane from being resized manually, by making the splitter + * not-selectable. + */ - (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex { - return (splitView == tableListSplitView ? NSZeroRect : proposedEffectiveRect); + if (splitView == (NSSplitView *)tableListSplitView || splitView == (NSSplitView *)tableListFilterSplitView) { + return NSZeroRect; + } + + return proposedEffectiveRect; } + +/** + * Never show the divider bar for the table list filter split view. + */ +- (BOOL)splitView:(NSSplitView *)splitView shouldHideDividerAtIndex:(NSInteger)dividerIndex +{ + if (splitView == (NSSplitView *)tableListFilterSplitView) { + return YES; + } + + // Because both the info pane split view and filter view split view use this class + // as a delegate, we now have to duplicate some logic in SPSplitView to match the + // default behaviour - thanks to the override above. + if (splitView == (NSSplitView *)tableListSplitView) { + return [tableListSplitView isSubviewCollapsed:[[tableListSplitView subviews] objectAtIndex:1]]; + } + + return NO; +} + #endif |