diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-12-27 11:58:20 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-10-26 12:32:44 -0700 |
commit | c3b17357f91f768ba7b0fa17254bbd7cccdb8300 (patch) | |
tree | 55f7e442fa77979e5f15b52ebf3b724e24e87e95 /platform/macos/app/MapDocument.m | |
parent | ab3547a21614605f8acef606226b33c874b4c2dd (diff) | |
download | qtlocation-mapboxgl-c3b17357f91f768ba7b0fa17254bbd7cccdb8300.tar.gz |
[macos] Layer filter editorupstream/1ec5-predicate-editor
Added a Layer Filter panel to the bottom of the macosapp document window that edits the selected layer’s predicate. Subclassed NSPredicateEditorRowTemplate to allow for arbitrary key paths in a single template and also to represent an aggregate value as a token field.
Diffstat (limited to 'platform/macos/app/MapDocument.m')
-rw-r--r-- | platform/macos/app/MapDocument.m | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index feef53062b..5c69dbe0c0 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -55,7 +55,8 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio @property (weak) IBOutlet NSArrayController *styleLayersArrayController; @property (weak) IBOutlet NSTableView *styleLayersTableView; @property (weak) IBOutlet NSMenu *mapViewContextMenu; -@property (weak) IBOutlet NSSplitView *splitView; +@property (weak) IBOutlet NSSplitView *styleLayersSplitView; +@property (weak) IBOutlet NSSplitView *predicateSplitView; @end @@ -108,9 +109,10 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio NSPressGestureRecognizer *pressGestureRecognizer = [[NSPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePressGesture:)]; [self.mapView addGestureRecognizer:pressGestureRecognizer]; - - [self.splitView setPosition:0 ofDividerAtIndex:0]; - + + [self.styleLayersSplitView setPosition:0 ofDividerAtIndex:0]; + [self.predicateSplitView setPosition:DBL_MAX ofDividerAtIndex:0]; + [self applyPendingState]; } @@ -306,10 +308,10 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio Show or hide the Layers sidebar. */ - (IBAction)toggleLayers:(id)sender { - BOOL isShown = ![self.splitView isSubviewCollapsed:self.splitView.arrangedSubviews.firstObject]; + BOOL isShown = ![self.styleLayersSplitView isSubviewCollapsed:self.styleLayersSplitView.arrangedSubviews.firstObject]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { context.allowsImplicitAnimation = YES; - [self.splitView setPosition:isShown ? 0 : 100 ofDividerAtIndex:0]; + [self.styleLayersSplitView setPosition:isShown ? 0 : 100 ofDividerAtIndex:0]; [self.window.toolbar validateVisibleItems]; } completionHandler:nil]; } @@ -402,6 +404,17 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.styleLayersArrayController removeObjectsAtArrangedObjectIndexes:indices]; } +/** + Show or hide the Layer Filter pane. + */ +- (IBAction)toggleLayerFilter:(id)sender { + BOOL isShown = ![self.predicateSplitView isSubviewCollapsed:self.predicateSplitView.arrangedSubviews.lastObject]; + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + context.allowsImplicitAnimation = YES; + [self.predicateSplitView setPosition:isShown ? DBL_MAX : self.mapView.frame.size.height - 100 ofDividerAtIndex:0]; + } completionHandler:nil]; +} + - (IBAction)setLabelLanguage:(NSMenuItem *)sender { _isLocalizingLabels = sender.tag; [self reload:sender]; @@ -901,7 +914,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio return YES; } if (menuItem.action == @selector(toggleLayers:)) { - BOOL isShown = ![self.splitView isSubviewCollapsed:self.splitView.arrangedSubviews.firstObject]; + BOOL isShown = ![self.styleLayersSplitView isSubviewCollapsed:self.styleLayersSplitView.arrangedSubviews.firstObject]; menuItem.title = isShown ? @"Hide Layers" : @"Show Layers"; return YES; } @@ -921,6 +934,11 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (menuItem.action == @selector(deleteStyleLayers:)) { return self.styleLayersTableView.clickedRow >= 0 || self.styleLayersTableView.selectedRow >= 0; } + if (menuItem.action == @selector(toggleLayerFilter:)) { + BOOL isShown = ![self.predicateSplitView isSubviewCollapsed:self.predicateSplitView.arrangedSubviews.lastObject]; + menuItem.title = isShown ? @"Hide Layer Filter" : @"Show Layer Filter"; + return YES; + } if (menuItem.action == @selector(setLabelLanguage:)) { menuItem.state = menuItem.tag == _isLocalizingLabels ? NSOnState: NSOffState; if (menuItem.tag) { @@ -1079,7 +1097,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } } if (action == @selector(toggleLayers:)) { - BOOL isShown = ![self.splitView isSubviewCollapsed:self.splitView.arrangedSubviews.firstObject]; + BOOL isShown = ![self.styleLayersSplitView isSubviewCollapsed:self.styleLayersSplitView.arrangedSubviews.firstObject]; [(NSButton *)toolbarItem.view setState:isShown ? NSOnState : NSOffState]; } return NO; |