Skip to content

Commit

Permalink
#63: Change one outstanding UI issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed May 9, 2018
1 parent 1a958fa commit 1318bce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/SPTableContent.h
Expand Up @@ -102,6 +102,7 @@ typedef NS_ENUM(NSInteger, SPTableContentFilterSource) {

IBOutlet SPTableContentFilterController *filterControllerInstance;
IBOutlet SPFilterTableController *filterTableController;
BOOL scrollViewHasRubberbandScrolling;
#endif
SPMySQLConnection *mySQLConnection;

Expand Down
14 changes: 13 additions & 1 deletion Source/SPTableContent.m
Expand Up @@ -247,6 +247,8 @@ - (void)awakeFromNib

[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
Expand Down Expand Up @@ -3417,7 +3419,7 @@ - (void)updateFilterRuleEditorSize:(CGFloat)requestedHeight animate:(BOOL)animat
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];
Expand All @@ -3442,6 +3444,16 @@ - (void)updateFilterRuleEditorSize:(CGFloat)requestedHeight animate:(BOOL)animat
[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
Expand Down
7 changes: 7 additions & 0 deletions Source/SPTableContentFilterController.h
Expand Up @@ -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
*
Expand Down
5 changes: 5 additions & 0 deletions Source/SPTableContentFilterController.m
Expand Up @@ -735,6 +735,11 @@ - (void)addFilterExpression
[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];
Expand Down

0 comments on commit 1318bce

Please sign in to comment.