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

Commit

Permalink
[ios, macos] #5626 - removed refs to mbgl and added convenient color …
Browse files Browse the repository at this point in the history
…methods on UIColor and NSColor
  • Loading branch information
frederoni committed Jul 21, 2016
1 parent babeec1 commit 063ace3
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 66 deletions.
3 changes: 1 addition & 2 deletions platform/darwin/src/MGLFillStyleLayer.mm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import "MGLFillStyleLayer.h"

#include "MGLStyleLayer_Private.hpp"

#include <mbgl/style/layers/fill_layer.hpp>

@interface MGLFillStyleLayer() {
Expand All @@ -19,7 +18,7 @@ - (void)setLayer:(mbgl::style::Layer *)layer
- (void)setFillColor:(MGLColor *)fillColor
{
_fillColor = fillColor;
fillLayer->setFillColor(MGLColorFromColor(fillColor));
fillLayer->setFillColor(fillColor.mbgl_color);
[self updateStyleAndClasses];
}

Expand Down
6 changes: 3 additions & 3 deletions platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#import "MGLStyle.h"

#import "MGLMapView_Private.hpp"
#import "MGLStyleLayer.h"
#import "MGLFillStyleLayer.h"
#import "MGLStyle_Private.hpp"
#import "MGLStyleLayer_Private.hpp"

#import <mbgl/util/default_styles.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/mbgl.hpp>

@interface MGLStyle()
@property (nonatomic, weak) MGLMapView *mapView;
@property (nonatomic) mbgl::Map *mbglMap;
@end

@implementation MGLStyle
Expand Down Expand Up @@ -67,12 +68,11 @@ + (NSURL *)emeraldStyleURL {

- (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier
{
mbgl::style::Layer *layer = self.mbglMap->getLayer(identifier.UTF8String);
mbgl::style::Layer *layer = self.mapView.mbglMap->getLayer(identifier.UTF8String);
mbgl::style::FillLayer *fillLayer = reinterpret_cast<mbgl::style::FillLayer *>(layer);
MGLFillStyleLayer *fillStyleLayer = [[MGLFillStyleLayer alloc] init];
fillStyleLayer.layer = fillLayer;
fillStyleLayer.mapView = self.mapView;
fillStyleLayer.mbglMap = self.mbglMap;
return fillStyleLayer;
}

Expand Down
23 changes: 2 additions & 21 deletions platform/darwin/src/MGLStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,18 @@

#import "MGLTypes.h"
#import "MGLStyleLayer_Private.hpp"
#include <mbgl/mbgl.hpp>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#import "MGLMapView_Private.hpp"

@interface MGLStyleLayer()
@property (nonatomic, weak) MGLMapView *mapView;
@property (nonatomic) mbgl::Map *mbglMap;
@property (nonatomic) mbgl::style::Layer *layer;
@end

@implementation MGLStyleLayer

mbgl::Color MGLColorFromColor(MGLColor *color)
{
if (!color)
{
return { 0, 0, 0, 0 };
}
CGFloat r, g, b, a;
[color getRed:&r green:&g blue:&b alpha:&a];

return { (float)r, (float)g, (float)b, (float)a };
}

- (void)updateStyleAndClasses
{
self.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes);
self.mapView.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes);
}

@end
10 changes: 7 additions & 3 deletions platform/darwin/src/MGLStyleLayer_Private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
#include <mbgl/mbgl.hpp>
#include <mbgl/util/chrono.hpp>

#if TARGET_OS_IPHONE
#import "UIColor+MGLAdditions.hpp"
#else
#import "NSColor+MGLAdditions.hpp"
#endif

@class MGLMapView;

@interface MGLStyleLayer (Private)

@property (nonatomic, weak) MGLMapView *mapView;
@property (nonatomic) mbgl::Map *mbglMap;
@property (nonatomic) mbgl::style::Layer *layer;

mbgl::Color MGLColorFromColor(MGLColor *color);

- (void)updateStyleAndClasses;

@end
1 change: 0 additions & 1 deletion platform/darwin/src/MGLStyle_Private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

@interface MGLStyle (Private)
@property (nonatomic, weak) MGLMapView *mapView;
@property (nonatomic) mbgl::Map *mbglMap;
@end
4 changes: 2 additions & 2 deletions platform/darwin/src/MGLTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#endif

#if TARGET_OS_IPHONE
#define MGLColor UIColor
@class UIColor;
#define MGLColor UIColor
#else
#define MGLColor NSColor
@class NSColor;
#define MGLColor NSColor
#endif

NS_ASSUME_NONNULL_BEGIN
Expand Down
38 changes: 32 additions & 6 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
353933FE1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */; };
353933FF1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */; };
353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */; };
35CE61821D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */; };
35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */; };
35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */; };
35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */; };
35D13AB71D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
35D13AB81D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */; };
Expand All @@ -35,6 +39,8 @@
35E0CFE91D3E53FE00188327 /* MGLStyle_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */; };
35E0CFEA1D3E53FE00188327 /* MGLStyle_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */; };
35E208A71D24210F00EC9A46 /* MGLNSDataAdditionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */; };
35E79F201D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */; };
35E79F211D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */; };
4018B1C71CDC287F00F666AF /* MGLAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */; };
4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */; };
4018B1C91CDC288A00F666AF /* MGLAnnotationView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */; };
Expand All @@ -46,8 +52,8 @@
40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; };
554180421D2E97DE00012372 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; };
DA0CD5901CF56F6A00A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */; };
DA17BE301CC4BAC300402C41 /* MGLMapView_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */; };
DA17BE311CC4BDAA00402C41 /* MGLMapView_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */; };
DA17BE301CC4BAC300402C41 /* MGLMapView_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */; };
DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.hpp in Headers */ = {isa = PBXBuildFile; fileRef = DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */; };
DA1DC96A1CB6C6B7006E619F /* MBXCustomCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1DC9671CB6C6B7006E619F /* MBXCustomCalloutView.m */; };
DA1DC96B1CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1DC9691CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m */; };
DA1DC9701CB6C6CE006E619F /* points.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DA1DC96C1CB6C6CE006E619F /* points.geojson */; };
Expand Down Expand Up @@ -362,13 +368,16 @@
353933FA1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLRasterStyleLayer.h; sourceTree = "<group>"; };
353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLSymbolStyleLayer.h; sourceTree = "<group>"; };
353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationViewTests.m; sourceTree = "<group>"; };
35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "UIColor+MGLAdditions.hpp"; sourceTree = "<group>"; };
35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIColor+MGLAdditions.mm"; sourceTree = "<group>"; };
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayer.h; sourceTree = "<group>"; };
35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLStyleLayer.mm; sourceTree = "<group>"; };
35D13AC11D3D19DD00AFB4E0 /* MGLFillStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFillStyleLayer.h; sourceTree = "<group>"; };
35D13AC21D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFillStyleLayer.mm; sourceTree = "<group>"; };
35E0CFE51D3E501500188327 /* MGLStyle_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyle_Private.hpp; sourceTree = "<group>"; };
35E0CFE81D3E53FE00188327 /* MGLStyle_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyle_Private.hpp; sourceTree = "<group>"; };
35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNSDataAdditionsTests.m; sourceTree = "<group>"; };
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLStyleLayer_Private.hpp; sourceTree = "<group>"; };
4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView_Private.h; sourceTree = "<group>"; };
4018B1C41CDC277F00F666AF /* MGLAnnotationView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAnnotationView.mm; sourceTree = "<group>"; };
4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView.h; sourceTree = "<group>"; };
Expand All @@ -379,7 +388,7 @@
40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = "<group>"; };
554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; };
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView_Internal.h; sourceTree = "<group>"; };
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MGLMapView_Private.hpp; sourceTree = "<group>"; };
DA1DC94A1CB6C1C2006E619F /* Mapbox GL.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mapbox GL.app"; sourceTree = BUILT_PRODUCTS_DIR; };
DA1DC9501CB6C1C2006E619F /* MBXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXAppDelegate.h; sourceTree = "<group>"; };
DA1DC9531CB6C1C2006E619F /* MBXViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -605,10 +614,20 @@
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */,
35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */,
353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */,
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.hpp */,
);
name = Layers;
sourceTree = "<group>";
};
35CE617F1D4165C2004F2359 /* Categories */ = {
isa = PBXGroup;
children = (
35CE61801D4165D9004F2359 /* UIColor+MGLAdditions.hpp */,
35CE61811D4165D9004F2359 /* UIColor+MGLAdditions.mm */,
);
name = Categories;
sourceTree = "<group>";
};
402E9DE21CD3A56500FD4519 /* Playground */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -769,10 +788,11 @@
DA8848331CBAFB2A00AB86E3 /* Kit */ = {
isa = PBXGroup;
children = (
35CE617F1D4165C2004F2359 /* Categories */,
DAD165841CF4D06B001FF4B9 /* Annotations */,
DAD165851CF4D08B001FF4B9 /* Telemetry */,
DA8848361CBAFB8500AB86E3 /* MGLMapView.h */,
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Internal.h */,
DA17BE2F1CC4BAC300402C41 /* MGLMapView_Private.hpp */,
DA8848371CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h */,
DA8848381CBAFB8500AB86E3 /* MGLMapView+MGLCustomStyleLayerAdditions.h */,
DA737EE01D056A4E005BDA16 /* MGLMapViewDelegate.h */,
Expand Down Expand Up @@ -1039,6 +1059,7 @@
DA8847F01CBAFA5100AB86E3 /* MGLAnnotation.h in Headers */,
DA88483E1CBAFB8500AB86E3 /* MGLMapView+MGLCustomStyleLayerAdditions.h in Headers */,
4018B1CA1CDC288E00F666AF /* MGLAnnotationView.h in Headers */,
35E79F201D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */,
353933FB1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h in Headers */,
DA8847EF1CBAFA5100AB86E3 /* MGLAccountManager.h in Headers */,
DA8848511CBAFB9800AB86E3 /* MGLAPIClient.h in Headers */,
Expand All @@ -1051,9 +1072,10 @@
DA8848551CBAFB9800AB86E3 /* MGLLocationManager.h in Headers */,
DA88483F1CBAFB8500AB86E3 /* MGLUserLocation.h in Headers */,
DA88483D1CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h in Headers */,
DA17BE301CC4BAC300402C41 /* MGLMapView_Internal.h in Headers */,
DA17BE301CC4BAC300402C41 /* MGLMapView_Private.hpp in Headers */,
DAD165781CF4CDFF001FF4B9 /* MGLShapeCollection.h in Headers */,
DA88481E1CBAFA6200AB86E3 /* MGLMultiPoint_Private.h in Headers */,
35CE61821D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */,
DA35A29E1CC9E94C00E826B2 /* MGLCoordinateFormatter.h in Headers */,
DA8847F71CBAFA5100AB86E3 /* MGLOverlay.h in Headers */,
DA35A2B11CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
Expand Down Expand Up @@ -1106,12 +1128,14 @@
DABFB8661CBE99E500D62B32 /* MGLPointAnnotation.h in Headers */,
DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */,
DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */,
DA17BE311CC4BDAA00402C41 /* MGLMapView_Internal.h in Headers */,
DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.hpp in Headers */,
DABFB86C1CBE99E500D62B32 /* MGLTypes.h in Headers */,
DABFB8691CBE99E500D62B32 /* MGLShape.h in Headers */,
DABFB8701CBE9A0F00D62B32 /* MGLMapView+IBAdditions.h in Headers */,
35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.hpp in Headers */,
DABFB8671CBE99E500D62B32 /* MGLPolygon.h in Headers */,
DABFB8651CBE99E500D62B32 /* MGLOverlay.h in Headers */,
35E79F211D41266300957B9E /* MGLStyleLayer_Private.hpp in Headers */,
DABFB8681CBE99E500D62B32 /* MGLPolyline.h in Headers */,
DABFB86F1CBE9A0F00D62B32 /* MGLMapView.h in Headers */,
353933F31D3FB753003F57D7 /* MGLCircleStyleLayer.h in Headers */,
Expand Down Expand Up @@ -1487,6 +1511,7 @@
DA88481A1CBAFA6200AB86E3 /* MGLAccountManager.m in Sources */,
DA8848271CBAFA6200AB86E3 /* MGLPolyline.mm in Sources */,
DA8848581CBAFB9800AB86E3 /* MGLMapboxEvents.m in Sources */,
35CE61841D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */,
DA8848561CBAFB9800AB86E3 /* MGLLocationManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1531,6 +1556,7 @@
DAA4E42F1CBB730400178DFB /* MGLCompactCalloutView.m in Sources */,
DAA4E4271CBB730400178DFB /* MGLTilePyramidOfflineRegion.mm in Sources */,
DAA4E41C1CBB730400178DFB /* MGLAccountManager.m in Sources */,
35CE61851D4165D9004F2359 /* UIColor+MGLAdditions.mm in Sources */,
DAA4E4241CBB730400178DFB /* MGLPolyline.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion platform/ios/src/MGLAnnotationView.mm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "MGLAnnotationView.h"
#import "MGLAnnotationView_Private.h"
#import "MGLMapView_Private.hpp"
#import "MGLAnnotation.h"
#import "MGLMapView_Internal.h"

#import "NSBundle+MGLAdditions.h"

Expand Down
25 changes: 10 additions & 15 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "MGLMapView_Internal.h"
#import "MGLMapView_Private.hpp"

#import <mbgl/platform/log.hpp>
#import <mbgl/gl/gl.hpp>
Expand Down Expand Up @@ -35,11 +35,13 @@
#import "NSString+MGLAdditions.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "NSException+MGLAdditions.h"
#import "UIColor+MGLAdditions.hpp"
#import "MGLUserLocationAnnotationView.h"
#import "MGLUserLocation_Private.h"
#import "MGLAnnotationImage_Private.h"
#import "MGLAnnotationView_Private.h"
#import "MGLStyle_Private.hpp"
#import "MGLStyleLayer_Private.hpp"
#import "MGLMapboxEvents.h"
#import "MGLCompactCalloutView.h"
#import "MGLAnnotationContainerView.h"
Expand Down Expand Up @@ -131,17 +133,6 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingState) {
return { p1[0], p1[1], p2[0], p2[1] };
}

mbgl::Color MGLColorObjectFromUIColor(UIColor *color)
{
if (!color)
{
return { 0, 0, 0, 0 };
}
CGFloat r, g, b, a;
[color getRed:&r green:&g blue:&b alpha:&a];
return { (float)r, (float)g, (float)b, (float)a };
}

@interface MGLAnnotationAccessibilityElement : UIAccessibilityElement

@property (nonatomic) MGLAnnotationTag tag;
Expand Down Expand Up @@ -605,7 +596,6 @@ - (MGLStyle *)style
{
MGLStyle *style = [[MGLStyle alloc] init];
style.mapView = self;
style.mbglMap = _mbglMap;
return style;
}

Expand Down Expand Up @@ -3056,15 +3046,15 @@ - (double)alphaForShapeAnnotation:(MGLShape *)annotation
UIColor *color = (_delegateHasStrokeColorsForShapeAnnotations
? [self.delegate mapView:self strokeColorForShapeAnnotation:annotation]
: self.tintColor);
return MGLColorObjectFromUIColor(color);
return color.mbgl_color;
}

- (mbgl::Color)fillColorForPolygonAnnotation:(MGLPolygon *)annotation
{
UIColor *color = (_delegateHasFillColorsForShapeAnnotations
? [self.delegate mapView:self fillColorForPolygonAnnotation:annotation]
: self.tintColor);
return MGLColorObjectFromUIColor(color);
return color.mbgl_color;
}

- (CGFloat)lineWidthForPolylineAnnotation:(MGLPolyline *)annotation
Expand Down Expand Up @@ -5164,4 +5154,9 @@ - (void)setCustomStyleLayersNeedDisplay
_mbglMap->update(mbgl::Update::Repaint);
}

// TODO: TBD Temporary way of accessing mbglMap while runtime styling is being developed.
- (mbgl::Map *)mbglMap {
return _mbglMap;
}

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#import <Mapbox/Mapbox.h>

#include <mbgl/mbgl.hpp>

/// Minimum size of an annotation’s accessibility element.
extern const CGSize MGLAnnotationAccessibilityElementMinimumSize;

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

// TODO: TBD Temporary way of accessing mbglMap while runtime styling is being developed.
- (mbgl::Map *)mbglMap;

/** Returns whether the map view is currently loading or processing any assets required to render the map */
- (BOOL)isFullyLoaded;

Expand Down
Loading

0 comments on commit 063ace3

Please sign in to comment.