[macos] Name custom style in toolbar

Display the custom style’s name in the Style toolbar button.
This commit is contained in:
Minh Nguyễn
2016-11-25 17:25:31 -08:00
committed by Minh Nguyễn
parent 992726ab49
commit f611355912
2 changed files with 6 additions and 2 deletions

View File

@@ -26,6 +26,7 @@
<objectController objectClassName="MGLStyle" id="Xji-k6-iQ4" userLabel="Style Object Controller">
<declaredKeys>
<string>layers</string>
<string>name</string>
</declaredKeys>
<connections>
<binding destination="jxx-uM-ZTC" name="contentObject" keyPath="selection.style" id="60N-aU-tgJ"/>

View File

@@ -865,10 +865,13 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
NSPopUpButton *popUpButton = (NSPopUpButton *)toolbarItem.view;
NSUInteger index = self.indexOfStyleInToolbarItem;
if (index == NSNotFound) {
[popUpButton addItemWithTitle:@"Custom"];
index = [popUpButton numberOfItems] - 1;
index = -1;
}
[popUpButton selectItemAtIndex:index];
if (index == -1) {
NSString *name = self.mapView.style.name;
popUpButton.title = name ?: @"Custom";
}
}
if (action == @selector(toggleLayers:)) {
BOOL isShown = ![self.splitView isSubviewCollapsed:self.splitView.arrangedSubviews.firstObject];