From 1318bce4cd58d8aaa31c6c386c6b709713e1dde9 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 9 May 2018 20:19:12 +0200 Subject: #63: Change one outstanding UI issue --- Source/SPTableContent.h | 1 + Source/SPTableContent.m | 14 +++++++++++++- Source/SPTableContentFilterController.h | 7 +++++++ Source/SPTableContentFilterController.m | 5 +++++ 4 files changed, 26 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index c8f7100a..a670c69a 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -102,6 +102,7 @@ typedef NS_ENUM(NSInteger, SPTableContentFilterSource) { IBOutlet SPTableContentFilterController *filterControllerInstance; IBOutlet SPFilterTableController *filterTableController; + BOOL scrollViewHasRubberbandScrolling; #endif SPMySQLConnection *mySQLConnection; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 7a48dccf..40133b71 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -247,6 +247,8 @@ static void *TableContentKVOContext = &TableContentKVOContext; [filterTableController setTarget:self]; [filterTableController setAction:@selector(filterTable:)]; + //TODO This is only needed for 10.6 compatibility + scrollViewHasRubberbandScrolling = [[[filterControllerInstance view] enclosingScrollView] respondsToSelector:@selector(setVerticalScrollElasticity:)]; // Add observers for document task activity [[NSNotificationCenter defaultCenter] addObserver:self @@ -3417,7 +3419,7 @@ static void *TableContentKVOContext = &TableContentKVOContext; NSRect contentViewRect = [contentAreaContainer frame]; CGFloat availableHeight = contentViewRect.size.height; //the rule editor can ask for about one-third of the available space before we have it use it's scrollbar - CGFloat givenHeight = MIN(requestedHeight + 1,(availableHeight / 3)); + CGFloat givenHeight = MIN(requestedHeight + 1,(availableHeight / 3)); // +1 is the SPFillView at the bottom // abort if the size didn't really change NSRect ruleEditorRect = [filterRuleEditorContainer frame]; @@ -3442,6 +3444,16 @@ static void *TableContentKVOContext = &TableContentKVOContext; [tableContentContainer setFrameSize:tableContentRect.size]; [filterRuleEditorContainer setFrame:ruleEditorRect]; } + + //disable rubberband scrolling as long as there is nothing to scroll + if(scrollViewHasRubberbandScrolling) { + NSScrollView *filterControllerScroller = [[filterControllerInstance view] enclosingScrollView]; + if (givenHeight > requestedHeight) { // note that givenHeight + 1 == requestedHeight in order to avoid scroll + [filterControllerScroller setVerticalScrollElasticity:NSScrollElasticityNone]; + } else { + [filterControllerScroller setVerticalScrollElasticity:NSScrollElasticityAutomatic]; + } + } } - (void)filterRuleEditorPreferredSizeChanged:(NSNotification *)notification diff --git a/Source/SPTableContentFilterController.h b/Source/SPTableContentFilterController.h index 3d4029d6..32aeec00 100644 --- a/Source/SPTableContentFilterController.h +++ b/Source/SPTableContentFilterController.h @@ -56,6 +56,13 @@ NSString * const SPTableContentFilterHeightChangedNotification; SEL action; } +/** + * Returns the rule editor view that is managed by this object + * + * SHOULD be called on the UI thread, or results may be inconsistent! + */ +- (NSRuleEditor *)view; + /** * Makes the first NSTextField found in the rule editor the first responder * diff --git a/Source/SPTableContentFilterController.m b/Source/SPTableContentFilterController.m index bdddad42..c8efa952 100644 --- a/Source/SPTableContentFilterController.m +++ b/Source/SPTableContentFilterController.m @@ -735,6 +735,11 @@ static void _addIfNotNil(NSMutableArray *array, id toAdd); [filterRuleEditor insertRowAtIndex:0 withType:NSRuleEditorRowTypeSimple asSubrowOfRow:-1 animate:NO]; } +- (NSRuleEditor *)view +{ + return filterRuleEditor; +} + - (NSString *)sqlWhereExpressionWithBinary:(BOOL)isBINARY error:(NSError **)err { NSMutableString *filterString = [[NSMutableString alloc] init]; -- cgit v1.2.3