Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[macos] Name custom style in toolbar
Browse files Browse the repository at this point in the history
Display the custom style’s name in the Style toolbar button.
  • Loading branch information
1ec5 committed Nov 28, 2016
1 parent 992726a commit f611355
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions platform/macos/app/Base.lproj/MapDocument.xib
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
7 changes: 5 additions & 2 deletions platform/macos/app/MapDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,13 @@ - (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem {
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];
Expand Down

0 comments on commit f611355

Please sign in to comment.