aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-07-26 00:01:10 +0000
committerrowanbeentje <rowan@beent.je>2012-07-26 00:01:10 +0000
commit4cd351c7f3302207103ddfa4374da15cab6840a2 (patch)
tree1203a5ebff162395286402be8031bb757565f359 /Source
parent6deec9586fa0057e286f250b86d2e88c409c3181 (diff)
downloadsequelpro-4cd351c7f3302207103ddfa4374da15cab6840a2.tar.gz
sequelpro-4cd351c7f3302207103ddfa4374da15cab6840a2.tar.bz2
sequelpro-4cd351c7f3302207103ddfa4374da15cab6840a2.zip
- Replace the collapsible BWSplitView on the Query pane with a SPSplitView configured from code
- Replace the other NSSplitView on the Query pane with an equivalent SPSplitView to allow easier constraint management - Fix SPSplitView collapsible subview resizing to only amend the collapsible subview's autoresizing mask along the axis of the split view, leaving the other axis untouched to avoid problems with subviews not correctly picking up window resize changes when they were collapsed
Diffstat (limited to 'Source')
-rw-r--r--Source/SPCustomQuery.h20
-rw-r--r--Source/SPCustomQuery.m64
-rw-r--r--Source/SPSplitView.m28
-rw-r--r--Source/SPTablesList.h9
4 files changed, 36 insertions, 85 deletions
diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h
index f643b795..8c25cf60 100644
--- a/Source/SPCustomQuery.h
+++ b/Source/SPCustomQuery.h
@@ -49,23 +49,14 @@
#define SP_HISTORY_SAVE_MENUITEM_TAG 300001
#define SP_HISTORY_CLEAR_MENUITEM_TAG 300002
-#ifndef SP_REFACTOR
@class SPCopyTable;
@class SPQueryFavoriteManager;
@class SPDataStorage;
-@class BWSplitView;
+@class SPSplitView;
@class SPFieldEditorController;
@class SPMySQLConnection;
@class SPMySQLFastStreamingResult;
@class SPTextView;
-#else
-@class SPCopyTable;
-@class SPQueryFavoriteManager;
-@class SPDataStorage;
-@class SPFieldEditorController;
-@class SPMySQLConnection
-@class SPMySQLFastStreamingResult;
-#endif
@interface SPCustomQuery : NSObject
#ifdef SP_REFACTOR
@@ -106,7 +97,6 @@
IBOutlet id valueTextField;
IBOutlet id runSelectionButton;
IBOutlet id runAllButton;
- IBOutlet id multipleLineEditingButton;
IBOutlet NSMenuItem *runSelectionMenuItem;
IBOutlet NSMenuItem *runAllMenuItem;
@@ -133,11 +123,8 @@
#endif
IBOutlet NSButton *queryInfoButton;
-#ifndef SP_REFACTOR
- IBOutlet BWSplitView *queryInfoPaneSplitView;
-#else
- IBOutlet NSSplitView *queryInfoPaneSplitView;
-#endif
+ IBOutlet SPSplitView *queryInfoPaneSplitView;
+ IBOutlet SPSplitView *queryEditorSplitView;
SPFieldEditorController *fieldEditor;
@@ -234,7 +221,6 @@
- (IBAction)copyQueryHistory:(id)sender;
- (IBAction)clearQueryHistory:(id)sender;
- (IBAction)showCompletionList:(id)sender;
-- (IBAction)toggleQueryInfoPaneCollapse:(NSButton *)sender;
// Query actions
- (void)performQueries:(NSArray *)queries withCallback:(SEL)customQueryCallbackMethod;
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 1d92c88b..ef4faa17 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -54,6 +54,7 @@
#import "SPAlertSheets.h"
#import "SPCopyTable.h"
#import "SPGeometryDataView.h"
+#import "SPSplitView.h"
#import "SPTextView.h"
#import "RegexKitLite.h"
#ifndef SP_REFACTOR /* headers */
@@ -522,16 +523,6 @@
return (NSFontPanelSizeModeMask|NSFontPanelCollectionModeMask);
}
-/**
- * Toggle whether the query info pane is visible.
- */
-- (IBAction)toggleQueryInfoPaneCollapse:(NSButton *)sender
-{
- [queryInfoPaneSplitView toggleCollapse:sender];
-
- [sender setToolTip:([sender state] == NSOffState) ? NSLocalizedString(@"Show Query Information", @"Show Query Information") : NSLocalizedString(@"Hide Query Information", @"Hide Query Information")];
-}
-
#pragma mark -
#pragma mark Query actions
@@ -1349,12 +1340,10 @@
#ifndef SP_REFACTOR /* show/hide errror view */
// Show or hide the error area if necessary
- if ([errorsString length] && [queryInfoPaneSplitView collapsibleSubviewCollapsed]) {
- [queryInfoButton setState:NSOnState];
- [self toggleQueryInfoPaneCollapse:queryInfoButton];
- } else if (![errorsString length] && ![queryInfoPaneSplitView collapsibleSubviewCollapsed]) {
- [queryInfoButton setState:NSOffState];
- [self toggleQueryInfoPaneCollapse:queryInfoButton];
+ if ([errorsString length] && [queryInfoPaneSplitView isCollapsibleSubviewCollapsed]) {
+ [queryInfoPaneSplitView toggleCollapse:self];
+ } else if (![errorsString length] && ![queryInfoPaneSplitView isCollapsibleSubviewCollapsed]) {
+ [queryInfoPaneSplitView toggleCollapse:self];
}
#else
if ( [errorsString length] > 0 )
@@ -2742,7 +2731,7 @@
#ifndef SP_REFACTOR /* splitview delegate methods */
/**
- * Tells the splitView that it can collapse views
+ * Tells the split views that they can collapse views
*/
- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview
{
@@ -2750,26 +2739,6 @@
}
/**
- * Defines max position of splitView
- */
-- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset
-{
- if (sender != queryInfoPaneSplitView) return (offset == 0) ? (proposedMax - 100) : (proposedMax - 73);
-
- return proposedMax;
-}
-
-/**
- * Defines min position of splitView
- */
-- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset
-{
- if (sender != queryInfoPaneSplitView) return proposedMin + 100;
-
- return proposedMin;
-}
-
-/**
* The query information pane cannot be resized.
*/
- (NSRect)splitView:(NSSplitView *)splitView effectiveRect:(NSRect)proposedEffectiveRect forDrawnRect:(NSRect)drawnRect ofDividerAtIndex:(NSInteger)dividerIndex
@@ -3902,6 +3871,14 @@
[queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG];
[queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG];
+ // Set up the split views
+ [queryEditorSplitView setMinSize:100 ofSubviewAtIndex:0];
+ [queryEditorSplitView setMinSize:100 ofSubviewAtIndex:1];
+
+ [queryInfoPaneSplitView setCollapsibleSubviewIndex:1];
+ [queryInfoPaneSplitView setCollapsibleSubviewCollapsed:YES animate:NO];
+
+
#ifndef SP_REFACTOR
// Set the structure and index view's vertical gridlines if required
[customQueryView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
@@ -3921,19 +3898,6 @@
[prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL];
#endif
- // Collapse the query information pane
- if ([queryInfoPaneSplitView collapsibleSubview]) {
- queryInfoPanePaddingHeight = [[queryInfoPaneSplitView collapsibleSubview] frame].size.height - [errorTextScrollView frame].size.height;
-
- [queryInfoButton setNextState];
- [queryInfoButton setToolTip:NSLocalizedString(@"Show Query Information", @"Show Query Information")];
-
- [queryInfoPaneSplitView setValue:[NSNumber numberWithFloat:[queryInfoPaneSplitView collapsibleSubview].frame.size.height] forKey:@"uncollapsedSize"];
- [[queryInfoPaneSplitView collapsibleSubview] setAutoresizesSubviews:NO];
- [[queryInfoPaneSplitView collapsibleSubview] setFrameSize:NSMakeSize([queryInfoPaneSplitView collapsibleSubview].frame.size.width, 0)];
- [queryInfoPaneSplitView setCollapsibleSubviewCollapsed:YES];
- [[queryInfoPaneSplitView collapsibleSubview] setAutoresizesSubviews:YES];
- }
}
#pragma mark -
diff --git a/Source/SPSplitView.m b/Source/SPSplitView.m
index f3c9b175..d86a259e 100644
--- a/Source/SPSplitView.m
+++ b/Source/SPSplitView.m
@@ -53,7 +53,7 @@
NSView *wrappedView;
}
-- (id)initReplacingView:(NSView *)aView;
+- (id)initReplacingView:(NSView *)aView inVerticalSplitView:(BOOL)verticalSplitView;
- (void)restoreOriginalView;
@end
@@ -211,7 +211,7 @@
// If collapsing, ensure the original view is wrapped in a helper view to avoid
// animation resizes of the contained view. (Uncollapses will already be wrapped.)
if (![viewToAnimate isMemberOfClass:[SPSplitViewHelperView class]]) {
- [[[SPSplitViewHelperView alloc] initReplacingView:viewToAnimate] autorelease];
+ [[[SPSplitViewHelperView alloc] initReplacingView:viewToAnimate inVerticalSplitView:[self isVertical]] autorelease];
viewToAnimate = [[self subviews] objectAtIndex:collapsibleSubviewIndex];
}
@@ -1008,24 +1008,34 @@
* specified view, adding it as a subview to maintain the same appearance, and then
* can be animated without affecting the contained view.
*/
-- (id)initReplacingView:(NSView *)aView
+- (id)initReplacingView:(NSView *)aView inVerticalSplitView:(BOOL)verticalSplitView
{
self = [super initWithFrame:[aView frame]];
if (!self) return nil;
+ NSUInteger wrappedResizeMask = [wrappedView autoresizingMask];
+
// Retain the wrapped view while this view exists
wrappedView = [aView retain];
// Copy over the autoresizing mask from the wrapped view to this view, to keep the same
// draw appearance during the resize.
- [self setAutoresizingMask:[wrappedView autoresizingMask]];
-
- // Set the wrapped view to flexible margin, edge dependent on view ordering
- if ([[[wrappedView superview] subviews] indexOfObject:wrappedView]) {
- [wrappedView setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
+ [self setAutoresizingMask:wrappedResizeMask];
+
+ // Amend the wrapped view's autoresize mask. Keep the autosizing across the breadth of
+ // the split view, but amend the autosizing along the lengthwise axis of the split view
+ // so that no sizing occurs, only a flexible margin to allow resizing
+ if (verticalSplitView) {
+ wrappedResizeMask &= ~NSViewMinXMargin;
+ wrappedResizeMask &= ~NSViewWidthSizable;
+ wrappedResizeMask |= NSViewMaxXMargin;
} else {
- [wrappedView setAutoresizingMask:NSViewMaxXMargin | NSViewMaxYMargin];
+ wrappedResizeMask &= ~NSViewMaxYMargin;
+ wrappedResizeMask &= ~NSViewHeightSizable;
+ wrappedResizeMask |= NSViewMinYMargin;
+
}
+ [wrappedView setAutoresizingMask:wrappedResizeMask];
// Swap the views
[[wrappedView superview] replaceSubview:wrappedView with:self];
diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h
index 2ddb8375..172fff67 100644
--- a/Source/SPTablesList.h
+++ b/Source/SPTablesList.h
@@ -44,15 +44,6 @@
@class SQLSidebarViewController;
#endif
-@interface NSObject (BWSplitView)
-
-- (NSView *)collapsibleSubview;
-- (IBAction)toggleCollapse:(id)sender;
-- (BOOL)collapsibleSubviewIsCollapsed;
-- (void)setCollapsibleSubviewCollapsed:(BOOL)flag;
-
-@end
-
@interface SPTablesList : NSObject
#ifdef SP_REFACTOR
<NSTextFieldDelegate>