Added a sidebar to the main document window in macosapp that lists the layers in the current style and updates whenever the style changes or a layer is added or removed programmatically. Display an icon beside each layer in the sidebar that indicates the kind of layer. Double-click a layer or layers to toggle their visibility, which is an undoable action. Added a menu item and toolbar button to toggle the Layers sidebar. Added a context menu for toggling visibility of and deleting layers selected in the Layers sidebar. Checked in the original SVGs for layer icons.
39 lines
1.0 KiB
Objective-C
39 lines
1.0 KiB
Objective-C
#import "StyleLayerIconTransformer.h"
|
|
|
|
#import <Mapbox/Mapbox.h>
|
|
|
|
@implementation StyleLayerIconTransformer
|
|
|
|
+ (Class)transformedValueClass {
|
|
return [NSString class];
|
|
}
|
|
|
|
+ (BOOL)allowsReverseTransformation {
|
|
return NO;
|
|
}
|
|
|
|
- (id)transformedValue:(MGLStyleLayer *)layer {
|
|
if ([layer isKindOfClass:[MGLBackgroundStyleLayer class]]) {
|
|
return [NSImage imageNamed:@"background"];
|
|
}
|
|
if ([layer isKindOfClass:[MGLCircleStyleLayer class]]) {
|
|
return [NSImage imageNamed:@"circle"];
|
|
}
|
|
if ([layer isKindOfClass:[MGLFillStyleLayer class]]) {
|
|
return [NSImage imageNamed:@"fill"];
|
|
}
|
|
if ([layer isKindOfClass:[MGLLineStyleLayer class]]) {
|
|
return [NSImage imageNamed:@"NSListViewTemplate"];
|
|
}
|
|
if ([layer isKindOfClass:[MGLRasterStyleLayer class]]) {
|
|
return [[NSWorkspace sharedWorkspace] iconForFileType:@"jpg"];
|
|
}
|
|
if ([layer isKindOfClass:[MGLSymbolStyleLayer class]]) {
|
|
return [NSImage imageNamed:@"symbol"];
|
|
}
|
|
|
|
return nil;
|
|
}
|
|
|
|
@end
|