diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-03-11 16:15:46 -0700 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2019-03-14 12:59:45 -0700 |
commit | a801237ec789093abbf04df2a572a068dd87279a (patch) | |
tree | 4c14280508f7ab3db4233ea2b71393dc8c0f0f98 | |
parent | 57334407473a31ff43baa645dafd2f5e1bd910fb (diff) | |
download | qtlocation-mapboxgl-a801237ec789093abbf04df2a572a068dd87279a.tar.gz |
[ios, macos] Add MGLAttributedExpression class.
-rw-r--r-- | platform/darwin/src/MGLAttributedExpression.h | 22 | ||||
-rw-r--r-- | platform/darwin/src/MGLAttributedExpression.m | 43 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 12 | ||||
-rw-r--r-- | platform/macos/macos.xcodeproj/project.pbxproj | 8 |
4 files changed, 85 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLAttributedExpression.h b/platform/darwin/src/MGLAttributedExpression.h new file mode 100644 index 0000000000..329bd54cfd --- /dev/null +++ b/platform/darwin/src/MGLAttributedExpression.h @@ -0,0 +1,22 @@ +#import "MGLFoundation.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NSString * MGLAttributedExpressionKey NS_EXTENSIBLE_STRING_ENUM; + +FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontNamesAttribute; +FOUNDATION_EXTERN MGL_EXPORT MGLAttributedExpressionKey const MGLFontSizeAttribute; + +@interface MGLAttributedExpression : NSObject + +@property (strong, nonatomic) NSExpression *expression; +@property (strong, nonatomic, readonly) NSDictionary<MGLAttributedExpressionKey, id> *attributes; + +- (instancetype)initWithExpression:(NSExpression *)expression; +- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nullable NSDictionary <MGLAttributedExpressionKey, id> *)attrs; + ++ (instancetype)initWithExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString*> *)fontNames fontSize:(nullable NSNumber *)fontSize; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLAttributedExpression.m b/platform/darwin/src/MGLAttributedExpression.m new file mode 100644 index 0000000000..3f7cd4f303 --- /dev/null +++ b/platform/darwin/src/MGLAttributedExpression.m @@ -0,0 +1,43 @@ +#import "MGLAttributedExpression.h" +#import "MGLLoggingConfiguration_Private.h" + +const MGLAttributedExpressionKey MGLFontNamesAttribute = @""; +const MGLAttributedExpressionKey MGLFontSizeAttribute = @""; + +@implementation MGLAttributedExpression + +- (instancetype)initWithExpression:(NSExpression *)expression { + self = [self initWithExpression:expression attributes:nil]; + return self; +} + ++ (instancetype)initWithExpression:(NSExpression *)expression fontNames:(nullable NSArray<NSString *> *)fontNames fontSize:(nullable NSNumber *)fontSize { + MGLAttributedExpression *attributedExpression; + + NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; + + if (fontNames && fontNames.count > 0) { + [attrs setObject:fontNames forKey:MGLFontNamesAttribute]; + } + + if (fontSize) { + [attrs setObject:fontSize forKey:MGLFontSizeAttribute]; + } + + attributedExpression = [[self alloc] initWithExpression:expression attributes:attrs]; + return attributedExpression; +} + +- (instancetype)initWithExpression:(NSExpression *)expression attributes:(NSDictionary<MGLAttributedExpressionKey,id> *)attrs { + if (self = [super init]) + { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + _expression = expression; + _attributes = attrs; + + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); + } + return self; +} + +@end diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 51e9ba19b0..534c40b17d 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -57,6 +57,10 @@ 1FCAE2A520B872A400C577DD /* MGLLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FCAE2A120B872A400C577DD /* MGLLocationManager.m */; }; 1FCAE2A820B88B3800C577DD /* MGLLocationManager_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FCAE2A620B88B3800C577DD /* MGLLocationManager_Private.h */; }; 1FCAE2A920B88B3800C577DD /* MGLLocationManager_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FCAE2A620B88B3800C577DD /* MGLLocationManager_Private.h */; }; + 1FF48587223710BE00F19727 /* MGLAttributedExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF48585223710BE00F19727 /* MGLAttributedExpression.h */; }; + 1FF48588223710BE00F19727 /* MGLAttributedExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF48585223710BE00F19727 /* MGLAttributedExpression.h */; }; + 1FF48589223710BE00F19727 /* MGLAttributedExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF48586223710BE00F19727 /* MGLAttributedExpression.m */; }; + 1FF4858A223710BE00F19727 /* MGLAttributedExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF48586223710BE00F19727 /* MGLAttributedExpression.m */; }; 30E578171DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; }; 30E578181DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; }; 30E578191DAA855E0050F07E /* UIImage+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 30E578121DAA7D690050F07E /* UIImage+MGLAdditions.mm */; }; @@ -887,6 +891,8 @@ 1FDB00C921F8F15000D21389 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = cs; path = cs.lproj/Foundation.stringsdict; sourceTree = "<group>"; }; 1FDB00CA21F8F15100D21389 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; }; 1FDB00CB21F8F15300D21389 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = cs; path = cs.lproj/Localizable.stringsdict; sourceTree = "<group>"; }; + 1FF48585223710BE00F19727 /* MGLAttributedExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLAttributedExpression.h; sourceTree = "<group>"; }; + 1FF48586223710BE00F19727 /* MGLAttributedExpression.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLAttributedExpression.m; sourceTree = "<group>"; }; 20DABE861DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Foundation.strings"; sourceTree = "<group>"; }; 20DABE881DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; }; 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+MGLAdditions.h"; path = "src/UIImage+MGLAdditions.h"; sourceTree = SOURCE_ROOT; }; @@ -2086,6 +2092,8 @@ DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */, DAF0D8171DFE6B2800B28378 /* MGLAttributionInfo_Private.h */, DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */, + 1FF48585223710BE00F19727 /* MGLAttributedExpression.h */, + 1FF48586223710BE00F19727 /* MGLAttributedExpression.m */, 556660C91E1BF3A900E2C41B /* MGLFoundation.h */, 558DE79E1E5615E400C7916D /* MGLFoundation_Private.h */, 558DE79F1E5615E400C7916D /* MGLFoundation.mm */, @@ -2502,6 +2510,7 @@ 30E578171DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */, 96036A01200565C700510F3D /* NSOrthography+MGLAdditions.h in Headers */, 1F7454961ECD450D00021D39 /* MGLLight_Private.h in Headers */, + 1FF48587223710BE00F19727 /* MGLAttributedExpression.h in Headers */, DAD1656C1CF41981001FF4B9 /* MGLFeature.h in Headers */, 40EDA1C01CFE0E0200D9EA68 /* MGLAnnotationContainerView.h in Headers */, 9620BB381E69FE1700705A1D /* MGLSDKUpdateChecker.h in Headers */, @@ -2658,6 +2667,7 @@ 353AFA151D65AB17005A69F4 /* NSDate+MGLAdditions.h in Headers */, AC518E00201BB55A00EBC820 /* MGLTelemetryConfig.h in Headers */, 3510FFFA1D6DCC4700F413B2 /* NSCompoundPredicate+MGLAdditions.h in Headers */, + 1FF48588223710BE00F19727 /* MGLAttributedExpression.h in Headers */, DA72620C1DEEE3480043BB89 /* MGLOpenGLStyleLayer.h in Headers */, 35CE61831D4165D9004F2359 /* UIColor+MGLAdditions.h in Headers */, 96E516F32000597100A02306 /* NSDictionary+MGLAdditions.h in Headers */, @@ -3267,6 +3277,7 @@ DA8848291CBAFA6200AB86E3 /* MGLStyle.mm in Sources */, 357FE2DF1E02D2B20068B753 /* NSCoder+MGLAdditions.mm in Sources */, 40834BF81FE05E1800C1BD0D /* NSData+MMEGZIP.m in Sources */, + 1FF48589223710BE00F19727 /* MGLAttributedExpression.m in Sources */, DA88481C1CBAFA6200AB86E3 /* MGLGeometry.mm in Sources */, 558DE7A21E5615E400C7916D /* MGLFoundation.mm in Sources */, 40834BE91FE05E1800C1BD0D /* MMECommonEventData.m in Sources */, @@ -3404,6 +3415,7 @@ 3510FFF31D6D9D8C00F413B2 /* NSExpression+MGLAdditions.mm in Sources */, 40834C0C1FE05E1800C1BD0D /* NSData+MMEGZIP.m in Sources */, DAA4E4321CBB730400178DFB /* MGLMapView.mm in Sources */, + 1FF4858A223710BE00F19727 /* MGLAttributedExpression.m in Sources */, 40834BFD1FE05E1800C1BD0D /* MMECommonEventData.m in Sources */, DAA4E41E1CBB730400178DFB /* MGLMapCamera.mm in Sources */, FA68F14E1E9D656600F9F6C2 /* MGLFillExtrusionStyleLayer.mm in Sources */, diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 739a388e6e..9d2ba65b5f 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -29,6 +29,8 @@ 1F95931B1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */; }; 1F9EF4061FBA1B0E0063FBB0 /* mapbox_helmet.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1F9EF4051FBA1B0D0063FBB0 /* mapbox_helmet.pdf */; }; 1FC481852098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */; }; + 1FF4858D2237235300F19727 /* MGLAttributedExpression.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF4858B2237235200F19727 /* MGLAttributedExpression.m */; }; + 1FF4858E2237235300F19727 /* MGLAttributedExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF4858C2237235200F19727 /* MGLAttributedExpression.h */; }; 3508EC641D749D39009B0EE4 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3508EC651D749D39009B0EE4 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */; }; 3526EABD1DF9B19800006B43 /* MGLCodingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3526EABC1DF9B19800006B43 /* MGLCodingTests.mm */; }; @@ -343,6 +345,8 @@ 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSPredicate+MGLPrivateAdditions.h"; sourceTree = "<group>"; }; 1FDB00CC21F8F1FD00D21389 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; }; 1FDB00CD21F8F1FF00D21389 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; }; + 1FF4858B2237235200F19727 /* MGLAttributedExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAttributedExpression.m; sourceTree = "<group>"; }; + 1FF4858C2237235200F19727 /* MGLAttributedExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributedExpression.h; sourceTree = "<group>"; }; 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLAdditions.h"; sourceTree = "<group>"; }; 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSExpression+MGLAdditions.mm"; sourceTree = "<group>"; }; 3526EABC1DF9B19800006B43 /* MGLCodingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLCodingTests.mm; path = ../../darwin/test/MGLCodingTests.mm; sourceTree = "<group>"; }; @@ -1204,6 +1208,8 @@ DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */, DAF0D8151DFE6B1800B28378 /* MGLAttributionInfo_Private.h */, DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */, + 1FF4858C2237235200F19727 /* MGLAttributedExpression.h */, + 1FF4858B2237235200F19727 /* MGLAttributedExpression.m */, 556660C51E1BEA0100E2C41B /* MGLFoundation.h */, 558DE7A41E56161C00C7916D /* MGLFoundation_Private.h */, 558DE7A51E56161C00C7916D /* MGLFoundation.mm */, @@ -1276,6 +1282,7 @@ DAE6C38D1CC31E2A00DB3429 /* MGLOfflineRegion_Private.h in Headers */, DA7DC9831DED647F0027472F /* MGLRasterTileSource_Private.h in Headers */, 747ABE5B219B2BDB00523B67 /* MGLBackgroundStyleLayer_Private.h in Headers */, + 1FF4858E2237235300F19727 /* MGLAttributedExpression.h in Headers */, 1753ED401E53CE6100A9FD90 /* MGLConversion.h in Headers */, 747ABE59219B2BDB00523B67 /* MGLFillExtrusionStyleLayer_Private.h in Headers */, DA8F259C1D51CB000010E6B5 /* MGLStyleValue_Private.h in Headers */, @@ -1653,6 +1660,7 @@ 352742821D4C243B00A1ECE6 /* MGLSource.mm in Sources */, DAE6C3881CC31E2A00DB3429 /* MGLMapCamera.mm in Sources */, DA6408D81DA4E5DA00908C90 /* MGLVectorStyleLayer.m in Sources */, + 1FF4858D2237235300F19727 /* MGLAttributedExpression.m in Sources */, DA8F25B31D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm in Sources */, DAE6C3911CC31E2A00DB3429 /* MGLPolygon.mm in Sources */, 35C6DF851E214C0400ACA483 /* MGLDistanceFormatter.m in Sources */, |