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

Commit 063ace3

Browse files
committed
[ios, macos] #5626 - removed refs to mbgl and added convenient color methods on UIColor and NSColor
1 parent babeec1 commit 063ace3

19 files changed

+145
-66
lines changed

platform/darwin/src/MGLFillStyleLayer.mm

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#import "MGLFillStyleLayer.h"
22

33
#include "MGLStyleLayer_Private.hpp"
4-
54
#include <mbgl/style/layers/fill_layer.hpp>
65

76
@interface MGLFillStyleLayer() {
@@ -19,7 +18,7 @@ - (void)setLayer:(mbgl::style::Layer *)layer
1918
- (void)setFillColor:(MGLColor *)fillColor
2019
{
2120
_fillColor = fillColor;
22-
fillLayer->setFillColor(MGLColorFromColor(fillColor));
21+
fillLayer->setFillColor(fillColor.mbgl_color);
2322
[self updateStyleAndClasses];
2423
}
2524

platform/darwin/src/MGLStyle.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#import "MGLStyle.h"
22

3+
#import "MGLMapView_Private.hpp"
34
#import "MGLStyleLayer.h"
45
#import "MGLFillStyleLayer.h"
56
#import "MGLStyle_Private.hpp"
67
#import "MGLStyleLayer_Private.hpp"
8+
79
#import <mbgl/util/default_styles.hpp>
810
#include <mbgl/style/layers/fill_layer.hpp>
911
#include <mbgl/mbgl.hpp>
1012

1113
@interface MGLStyle()
1214
@property (nonatomic, weak) MGLMapView *mapView;
13-
@property (nonatomic) mbgl::Map *mbglMap;
1415
@end
1516

1617
@implementation MGLStyle
@@ -67,12 +68,11 @@ + (NSURL *)emeraldStyleURL {
6768

6869
- (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier
6970
{
70-
mbgl::style::Layer *layer = self.mbglMap->getLayer(identifier.UTF8String);
71+
mbgl::style::Layer *layer = self.mapView.mbglMap->getLayer(identifier.UTF8String);
7172
mbgl::style::FillLayer *fillLayer = reinterpret_cast<mbgl::style::FillLayer *>(layer);
7273
MGLFillStyleLayer *fillStyleLayer = [[MGLFillStyleLayer alloc] init];
7374
fillStyleLayer.layer = fillLayer;
7475
fillStyleLayer.mapView = self.mapView;
75-
fillStyleLayer.mbglMap = self.mbglMap;
7676
return fillStyleLayer;
7777
}
7878

platform/darwin/src/MGLStyleLayer.mm

+2-21
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,18 @@
22

33
#import "MGLTypes.h"
44
#import "MGLStyleLayer_Private.hpp"
5-
#include <mbgl/mbgl.hpp>
6-
7-
#if TARGET_OS_IPHONE
8-
#import <UIKit/UIKit.h>
9-
#else
10-
#import <Cocoa/Cocoa.h>
11-
#endif
5+
#import "MGLMapView_Private.hpp"
126

137
@interface MGLStyleLayer()
148
@property (nonatomic, weak) MGLMapView *mapView;
15-
@property (nonatomic) mbgl::Map *mbglMap;
169
@property (nonatomic) mbgl::style::Layer *layer;
1710
@end
1811

1912
@implementation MGLStyleLayer
2013

21-
mbgl::Color MGLColorFromColor(MGLColor *color)
22-
{
23-
if (!color)
24-
{
25-
return { 0, 0, 0, 0 };
26-
}
27-
CGFloat r, g, b, a;
28-
[color getRed:&r green:&g blue:&b alpha:&a];
29-
30-
return { (float)r, (float)g, (float)b, (float)a };
31-
}
32-
3314
- (void)updateStyleAndClasses
3415
{
35-
self.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes);
16+
self.mapView.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes);
3617
}
3718

3819
@end

platform/darwin/src/MGLStyleLayer_Private.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
#include <mbgl/mbgl.hpp>
77
#include <mbgl/util/chrono.hpp>
88

9+
#if TARGET_OS_IPHONE
10+
#import "UIColor+MGLAdditions.hpp"
11+
#else
12+
#import "NSColor+MGLAdditions.hpp"
13+
#endif
14+
915
@class MGLMapView;
1016

1117
@interface MGLStyleLayer (Private)
18+
1219
@property (nonatomic, weak) MGLMapView *mapView;
13-
@property (nonatomic) mbgl::Map *mbglMap;
1420
@property (nonatomic) mbgl::style::Layer *layer;
1521

16-
mbgl::Color MGLColorFromColor(MGLColor *color);
17-
1822
- (void)updateStyleAndClasses;
1923

2024
@end

platform/darwin/src/MGLStyle_Private.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77

88
@interface MGLStyle (Private)
99
@property (nonatomic, weak) MGLMapView *mapView;
10-
@property (nonatomic) mbgl::Map *mbglMap;
1110
@end

platform/darwin/src/MGLTypes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
#endif
1414

1515
#if TARGET_OS_IPHONE
16-
#define MGLColor UIColor
1716
@class UIColor;
17+
#define MGLColor UIColor
1818
#else
19-
#define MGLColor NSColor
2019
@class NSColor;
20+
#define MGLColor NSColor
2121
#endif
2222

2323
NS_ASSUME_NONNULL_BEGIN

platform/ios/ios.xcodeproj/project.pbxproj

+32-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
353933FE1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */; };
2323
353933FF1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */; };
2424
353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */; };
25+
35CE61821D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */; };
26+
35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */; };
27+
35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */; };
28+
35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */; };
2529
35D13AB71D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
2630
35D13AB81D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
2731
35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */; };
@@ -35,6 +39,8 @@
3539
35E0CFE91D3E53FE00188327 /* MGLStyle_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */; };
3640
35E0CFEA1D3E53FE00188327 /* MGLStyle_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */; };
3741
35E208A71D24210F00EC9A46 /* MGLNSDataAdditionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */; };
42+
35E79F201D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */; };
43+
35E79F211D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */; };
3844
4018B1C71CDC287F00F666AF /* MGLAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */; };
3945
4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */; };
4046
4018B1C91CDC288A00F666AF /* MGLAnnotationView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */; };
@@ -46,8 +52,8 @@
4652
40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; };
4753
554180421D2E97DE00012372 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; };
4854
DA0CD5901CF56F6A00A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */; };
49-
DA17BE301CC4BAC300402C41 /* MGLMapView_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */; };
50-
DA17BE311CC4BDAA00402C41 /* MGLMapView_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */; };
55+
DA17BE301CC4BAC300402C41 /* MGLMapView_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */; };
56+
DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */; };
5157
DA1DC96A1CB6C6B7006E619F /* MBXCustomCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1DC9671CB6C6B7006E619F /* MBXCustomCalloutView.m */; };
5258
DA1DC96B1CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1DC9691CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m */; };
5359
DA1DC9701CB6C6CE006E619F /* points.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DA1DC96C1CB6C6CE006E619F /* points.geojson */; };
@@ -362,13 +368,16 @@
362368
353933FA1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLRasterStyleLayer.h; sourceTree = "<group>"; };
363369
353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLSymbolStyleLayer.h; sourceTree = "<group>"; };
364370
353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationViewTests.m; sourceTree = "<group>"; };
371+
35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "UIColor+MGLAdditions.hpp"; sourceTree = "<group>"; };
372+
35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIColor+MGLAdditions.mm"; sourceTree = "<group>"; };
365373
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayer.h; sourceTree = "<group>"; };
366374
35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLStyleLayer.mm; sourceTree = "<group>"; };
367375
35D13AC11D3D19DD00AFB4E0 /* MGLFillStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFillStyleLayer.h; sourceTree = "<group>"; };
368376
35D13AC21D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFillStyleLayer.mm; sourceTree = "<group>"; };
369377
35E0CFE51D3E501500188327 /* MGLStyle_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyle_Private.hpp; sourceTree = "<group>"; };
370378
35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyle_Private.hpp; sourceTree = "<group>"; };
371379
35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNSDataAdditionsTests.m; sourceTree = "<group>"; };
380+
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyleLayer_Private.hpp; sourceTree = "<group>"; };
372381
4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView_Private.h; sourceTree = "<group>"; };
373382
4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAnnotationView.mm; sourceTree = "<group>"; };
374383
4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView.h; sourceTree = "<group>"; };
@@ -379,7 +388,7 @@
379388
40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = "<group>"; };
380389
554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
381390
DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; };
382-
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView_Internal.h; sourceTree = "<group>"; };
391+
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLMapView_Private.hpp; sourceTree = "<group>"; };
383392
DA1DC94A1CB6C1C2006E619F /* Mapbox GL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mapbox GL.app"; sourceTree = BUILT_PRODUCTS_DIR; };
384393
DA1DC9501CB6C1C2006E619F /* MBXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXAppDelegate.h; sourceTree = "<group>"; };
385394
DA1DC9531CB6C1C2006E619F /* MBXViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXViewController.h; sourceTree = "<group>"; };
@@ -605,10 +614,20 @@
605614
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */,
606615
35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */,
607616
353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */,
617+
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */,
608618
);
609619
name = Layers;
610620
sourceTree = "<group>";
611621
};
622+
35CE617F1D4165C2004F2359 /* Categories */ = {
623+
isa = PBXGroup;
624+
children = (
625+
35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */,
626+
35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */,
627+
);
628+
name = Categories;
629+
sourceTree = "<group>";
630+
};
612631
402E9DE21CD3A56500FD4519 /* Playground */ = {
613632
isa = PBXGroup;
614633
children = (
@@ -769,10 +788,11 @@
769788
DA8848331CBAFB2A00AB86E3 /* Kit */ = {
770789
isa = PBXGroup;
771790
children = (
791+
35CE617F1D4165C2004F2359 /* Categories */,
772792
DAD165841CF4D06B001FF4B9 /* Annotations */,
773793
DAD165851CF4D08B001FF4B9 /* Telemetry */,
774794
DA8848361CBAFB8500AB86E3 /* MGLMapView.h */,
775-
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */,
795+
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */,
776796
DA8848371CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h */,
777797
DA8848381CBAFB8500AB86E3 /* MGLMapView+MGLCustomStyleLayerAdditions.h */,
778798
DA737EE01D056A4E005BDA16 /* MGLMapViewDelegate.h */,
@@ -1039,6 +1059,7 @@
10391059
DA8847F01CBAFA5100AB86E3 /* MGLAnnotation.h in Headers */,
10401060
DA88483E1CBAFB8500AB86E3 /* MGLMapView+MGLCustomStyleLayerAdditions.h in Headers */,
10411061
4018B1CA1CDC288E00F666AF /* MGLAnnotationView.h in Headers */,
1062+
35E79F201D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */,
10421063
353933FB1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h in Headers */,
10431064
DA8847EF1CBAFA5100AB86E3 /* MGLAccountManager.h in Headers */,
10441065
DA8848511CBAFB9800AB86E3 /* MGLAPIClient.h in Headers */,
@@ -1051,9 +1072,10 @@
10511072
DA8848551CBAFB9800AB86E3 /* MGLLocationManager.h in Headers */,
10521073
DA88483F1CBAFB8500AB86E3 /* MGLUserLocation.h in Headers */,
10531074
DA88483D1CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h in Headers */,
1054-
DA17BE301CC4BAC300402C41 /* MGLMapView_Internal.h in Headers */,
1075+
DA17BE301CC4BAC300402C41 /* MGLMapView_Private.hpp in Headers */,
10551076
DAD165781CF4CDFF001FF4B9 /* MGLShapeCollection.h in Headers */,
10561077
DA88481E1CBAFA6200AB86E3 /* MGLMultiPoint_Private.h in Headers */,
1078+
35CE61821D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */,
10571079
DA35A29E1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */,
10581080
DA8847F71CBAFA5100AB86E3 /* MGLOverlay.h in Headers */,
10591081
DA35A2B11CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
@@ -1106,12 +1128,14 @@
11061128
DABFB8661CBE99E500D62B32 /* MGLPointAnnotation.h in Headers */,
11071129
DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */,
11081130
DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */,
1109-
DA17BE311CC4BDAA00402C41 /* MGLMapView_Internal.h in Headers */,
1131+
DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.hpp in Headers */,
11101132
DABFB86C1CBE99E500D62B32 /* MGLTypes.h in Headers */,
11111133
DABFB8691CBE99E500D62B32 /* MGLShape.h in Headers */,
11121134
DABFB8701CBE9A0F00D62B32 /* MGLMapView+IBAdditions.h in Headers */,
1135+
35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */,
11131136
DABFB8671CBE99E500D62B32 /* MGLPolygon.h in Headers */,
11141137
DABFB8651CBE99E500D62B32 /* MGLOverlay.h in Headers */,
1138+
35E79F211D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */,
11151139
DABFB8681CBE99E500D62B32 /* MGLPolyline.h in Headers */,
11161140
DABFB86F1CBE9A0F00D62B32 /* MGLMapView.h in Headers */,
11171141
353933F31D3FB753003F57D7 /* MGLCircleStyleLayer.h in Headers */,
@@ -1487,6 +1511,7 @@
14871511
DA88481A1CBAFA6200AB86E3 /* MGLAccountManager.m in Sources */,
14881512
DA8848271CBAFA6200AB86E3 /* MGLPolyline.mm in Sources */,
14891513
DA8848581CBAFB9800AB86E3 /* MGLMapboxEvents.m in Sources */,
1514+
35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */,
14901515
DA8848561CBAFB9800AB86E3 /* MGLLocationManager.m in Sources */,
14911516
);
14921517
runOnlyForDeploymentPostprocessing = 0;
@@ -1531,6 +1556,7 @@
15311556
DAA4E42F1CBB730400178DFB /* MGLCompactCalloutView.m in Sources */,
15321557
DAA4E4271CBB730400178DFB /* MGLTilePyramidOfflineRegion.mm in Sources */,
15331558
DAA4E41C1CBB730400178DFB /* MGLAccountManager.m in Sources */,
1559+
35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */,
15341560
DAA4E4241CBB730400178DFB /* MGLPolyline.mm in Sources */,
15351561
);
15361562
runOnlyForDeploymentPostprocessing = 0;

platform/ios/src/MGLAnnotationView.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "MGLAnnotationView.h"
22
#import "MGLAnnotationView_Private.h"
3+
#import "MGLMapView_Private.hpp"
34
#import "MGLAnnotation.h"
4-
#import "MGLMapView_Internal.h"
55

66
#import "NSBundle+MGLAdditions.h"
77

platform/ios/src/MGLMapView.mm

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "MGLMapView_Internal.h"
1+
#import "MGLMapView_Private.hpp"
22

33
#import <mbgl/platform/log.hpp>
44
#import <mbgl/gl/gl.hpp>
@@ -35,11 +35,13 @@
3535
#import "NSString+MGLAdditions.h"
3636
#import "NSProcessInfo+MGLAdditions.h"
3737
#import "NSException+MGLAdditions.h"
38+
#import "UIColor+MGLAdditions.hpp"
3839
#import "MGLUserLocationAnnotationView.h"
3940
#import "MGLUserLocation_Private.h"
4041
#import "MGLAnnotationImage_Private.h"
4142
#import "MGLAnnotationView_Private.h"
4243
#import "MGLStyle_Private.hpp"
44+
#import "MGLStyleLayer_Private.hpp"
4345
#import "MGLMapboxEvents.h"
4446
#import "MGLCompactCalloutView.h"
4547
#import "MGLAnnotationContainerView.h"
@@ -131,17 +133,6 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingState) {
131133
return { p1[0], p1[1], p2[0], p2[1] };
132134
}
133135

134-
mbgl::Color MGLColorObjectFromUIColor(UIColor *color)
135-
{
136-
if (!color)
137-
{
138-
return { 0, 0, 0, 0 };
139-
}
140-
CGFloat r, g, b, a;
141-
[color getRed:&r green:&g blue:&b alpha:&a];
142-
return { (float)r, (float)g, (float)b, (float)a };
143-
}
144-
145136
@interface MGLAnnotationAccessibilityElement : UIAccessibilityElement
146137

147138
@property (nonatomic) MGLAnnotationTag tag;
@@ -605,7 +596,6 @@ - (MGLStyle *)style
605596
{
606597
MGLStyle *style = [[MGLStyle alloc] init];
607598
style.mapView = self;
608-
style.mbglMap = _mbglMap;
609599
return style;
610600
}
611601

@@ -3056,15 +3046,15 @@ - (double)alphaForShapeAnnotation:(MGLShape *)annotation
30563046
UIColor *color = (_delegateHasStrokeColorsForShapeAnnotations
30573047
? [self.delegate mapView:self strokeColorForShapeAnnotation:annotation]
30583048
: self.tintColor);
3059-
return MGLColorObjectFromUIColor(color);
3049+
return color.mbgl_color;
30603050
}
30613051

30623052
- (mbgl::Color)fillColorForPolygonAnnotation:(MGLPolygon *)annotation
30633053
{
30643054
UIColor *color = (_delegateHasFillColorsForShapeAnnotations
30653055
? [self.delegate mapView:self fillColorForPolygonAnnotation:annotation]
30663056
: self.tintColor);
3067-
return MGLColorObjectFromUIColor(color);
3057+
return color.mbgl_color;
30683058
}
30693059

30703060
- (CGFloat)lineWidthForPolylineAnnotation:(MGLPolyline *)annotation
@@ -5164,4 +5154,9 @@ - (void)setCustomStyleLayersNeedDisplay
51645154
_mbglMap->update(mbgl::Update::Repaint);
51655155
}
51665156

5157+
// TODO: TBD Temporary way of accessing mbglMap while runtime styling is being developed.
5158+
- (mbgl::Map *)mbglMap {
5159+
return _mbglMap;
5160+
}
5161+
51675162
@end

platform/ios/src/MGLMapView_Internal.h renamed to platform/ios/src/MGLMapView_Private.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#import <Mapbox/Mapbox.h>
22

3+
#include <mbgl/mbgl.hpp>
4+
35
/// Minimum size of an annotation’s accessibility element.
46
extern const CGSize MGLAnnotationAccessibilityElementMinimumSize;
57

@@ -11,6 +13,9 @@ extern const CGSize MGLAnnotationAccessibilityElementMinimumSize;
1113
/** Triggers another render pass even when it is not necessary. */
1214
- (void)setNeedsGLDisplay;
1315

16+
// TODO: TBD Temporary way of accessing mbglMap while runtime styling is being developed.
17+
- (mbgl::Map *)mbglMap;
18+
1419
/** Returns whether the map view is currently loading or processing any assets required to render the map */
1520
- (BOOL)isFullyLoaded;
1621

0 commit comments

Comments
 (0)