aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCopyTable.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-01-08 18:15:57 +0000
committerrowanbeentje <rowan@beent.je>2011-01-08 18:15:57 +0000
commitfd57610b1f3c8e1922b022b7ce6d5f31b6dd1207 (patch)
treed87df2d174ffd86735e996351489a40c9884099a /Source/SPCopyTable.m
parentcb7e20c63e7291dfd35202f27a897269da8732f9 (diff)
downloadsequelpro-fd57610b1f3c8e1922b022b7ce6d5f31b6dd1207.tar.gz
sequelpro-fd57610b1f3c8e1922b022b7ce6d5f31b6dd1207.tar.bz2
sequelpro-fd57610b1f3c8e1922b022b7ce6d5f31b6dd1207.zip
Improve column autosizing:
- Use the parent scrollview width rather than the table width to calculate available space; fixes issues with the table width reflecting the previous selected table - Take account of cell spacing and scrollbar width to avoid horizontal scrolling where possible
Diffstat (limited to 'Source/SPCopyTable.m')
-rw-r--r--Source/SPCopyTable.m8
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index 827672b5..cb7e08c5 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -698,6 +698,10 @@ NSInteger kBlobAsImageFile = 4;
NSUInteger columnWidth;
NSUInteger allColumnWidths = 0;
+ // Determine the available size
+ NSScrollView *parentScrollView = [[self superview] superview];
+ CGFloat visibleTableWidth = [parentScrollView bounds].size.width - [NSScroller scrollerWidth] - [columnDefinitions count] * 3.5;
+
for (NSDictionary *columnDefinition in columnDefinitions) {
if ([[NSThread currentThread] isCancelled]) return nil;
@@ -707,7 +711,7 @@ NSInteger kBlobAsImageFile = 4;
}
// Compare the column widths to the table width. If wider, narrow down wide columns as necessary
- if (allColumnWidths > [self bounds].size.width) {
+ if (allColumnWidths > visibleTableWidth) {
NSUInteger availableWidthToReduce = 0;
// Look for columns that are wider than the multi-column max
@@ -717,7 +721,7 @@ NSInteger kBlobAsImageFile = 4;
}
// Determine how much width can be reduced
- NSUInteger widthToReduce = allColumnWidths - [self bounds].size.width;
+ NSUInteger widthToReduce = allColumnWidths - visibleTableWidth;
if (availableWidthToReduce < widthToReduce) widthToReduce = availableWidthToReduce;
// Proportionally decrease the column sizes