diff --git a/platform/macos/app/Base.lproj/MapDocument.xib b/platform/macos/app/Base.lproj/MapDocument.xib index e147ba83d..4ba8f0a3a 100644 --- a/platform/macos/app/Base.lproj/MapDocument.xib +++ b/platform/macos/app/Base.lproj/MapDocument.xib @@ -27,6 +27,7 @@ layers name + reversedLayers @@ -38,7 +39,7 @@ visible - + diff --git a/platform/macos/app/MGLStyle+MBXAdditions.h b/platform/macos/app/MGLStyle+MBXAdditions.h new file mode 100644 index 000000000..dcaf42af2 --- /dev/null +++ b/platform/macos/app/MGLStyle+MBXAdditions.h @@ -0,0 +1,7 @@ +#import + +@interface MGLStyle (MBXAdditions) + +@property (nonatomic, strong) NS_ARRAY_OF(__kindof MGLStyleLayer *) *reversedLayers; + +@end diff --git a/platform/macos/app/MGLStyle+MBXAdditions.m b/platform/macos/app/MGLStyle+MBXAdditions.m new file mode 100644 index 000000000..be571d8b3 --- /dev/null +++ b/platform/macos/app/MGLStyle+MBXAdditions.m @@ -0,0 +1,42 @@ +#import "MGLStyle+MBXAdditions.h" + +@implementation MGLStyle (MBXAdditions) + ++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingReversedLayers { + return [NSSet setWithObject:@"layers"]; +} + +- (NS_ARRAY_OF(__kindof MGLStyleLayer *) *)reversedLayers { + return self.layers.reverseObjectEnumerator.allObjects; +} + +- (void)setReversedLayers:(NS_ARRAY_OF(__kindof MGLStyleLayer *) *)reversedLayers { + self.layers = reversedLayers.reverseObjectEnumerator.allObjects; +} + +- (NSUInteger)countOfReversedLayers { + return self.layers.count; +} + +- (id)objectInReversedLayersAtIndex:(NSUInteger)index { + NSArray *layers = self.layers; + return layers[layers.count - 1 - index]; +} + +- (void)getReversedLayers:(__kindof MGLStyleLayer **)buffer range:(NSRange)inRange { + NSArray *layers = self.layers; + for (NSUInteger i = inRange.location; i < NSMaxRange(inRange); i++) { + MGLStyleLayer *styleLayer = layers[layers.count - 1 - i]; + buffer[i] = styleLayer; + } +} + +- (void)insertObject:(__kindof MGLStyleLayer *)object inReversedLayersAtIndex:(NSUInteger)index { + [self insertLayer:object atIndex:self.layers.count - index]; +} + +- (void)removeObjectFromReversedLayersAtIndex:(NSUInteger)index { + [self removeLayer:[self objectInReversedLayersAtIndex:index]]; +} + +@end diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 705ebb8a4..f00f773bf 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -4,6 +4,7 @@ #import "LimeGreenStyleLayer.h" #import "DroppedPinAnnotation.h" +#import "MGLStyle+MBXAdditions.h" #import "MGLVectorSource+MBXAdditions.h" #import @@ -256,7 +257,7 @@ NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id ) *MBXFlattenedShapes(NS_ARRAY_OF(id