From 1aab26e3157db787eefe9df7318d3eee009ca802 Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Tue, 3 Jan 2017 10:25:17 +0100 Subject: Implement MGLForegroundStyleLayer.sourceIdentifier (#7570) * [ios, macos] sourceIdentifier accessor methods * [ios, macos] generate style code --- platform/darwin/src/MGLLineStyleLayer.mm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'platform/darwin/src/MGLLineStyleLayer.mm') diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 48164ed0c8..ab58a35f7f 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -61,6 +61,13 @@ namespace mbgl { super.rawLayer = rawLayer; } +- (NSString *)sourceIdentifier +{ + MGLAssertStyleLayerIsValid(); + + return @(self.rawLayer->getSourceID().c_str()); +} + - (NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); -- cgit v1.2.1 From d5d6bcee0f2f11cfccb3cc8ee7bc90c4f0ac74e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Tue, 3 Jan 2017 01:42:15 -0800 Subject: [ios, macos] Keep style attribute NSValue categories near enum declarations Eliminated the separate NSValue+MGLStyleLayerAddition files, moving the categories into their respective style layer headers to be closer to the enumeration declarations. --- platform/darwin/src/MGLLineStyleLayer.mm | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'platform/darwin/src/MGLLineStyleLayer.mm') diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index ab58a35f7f..ae838af0a8 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -342,4 +342,38 @@ namespace mbgl { } +@end + +@implementation NSValue (MGLLineStyleLayerAdditions) + ++ (NSValue *)valueWithMGLLineCap:(MGLLineCap)lineCap { + return [NSValue value:&lineCap withObjCType:@encode(MGLLineCap)]; +} + +- (MGLLineCap)MGLLineCapValue { + MGLLineCap lineCap; + [self getValue:&lineCap]; + return lineCap; +} + ++ (NSValue *)valueWithMGLLineJoin:(MGLLineJoin)lineJoin { + return [NSValue value:&lineJoin withObjCType:@encode(MGLLineJoin)]; +} + +- (MGLLineJoin)MGLLineJoinValue { + MGLLineJoin lineJoin; + [self getValue:&lineJoin]; + return lineJoin; +} + ++ (NSValue *)valueWithMGLLineTranslateAnchor:(MGLLineTranslateAnchor)lineTranslateAnchor { + return [NSValue value:&lineTranslateAnchor withObjCType:@encode(MGLLineTranslateAnchor)]; +} + +- (MGLLineTranslateAnchor)MGLLineTranslateAnchorValue { + MGLLineTranslateAnchor lineTranslateAnchor; + [self getValue:&lineTranslateAnchor]; + return lineTranslateAnchor; +} + @end -- cgit v1.2.1 From bf8d037fca3a5e76818f2cd546e783814f046019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 6 Jan 2017 12:29:03 -0800 Subject: =?UTF-8?q?[ios,=20macos]=20-translate=20=E2=86=92=20-translation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/darwin/src/MGLLineStyleLayer.mm | 42 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'platform/darwin/src/MGLLineStyleLayer.mm') diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index ae838af0a8..7d0d5ba6a5 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -23,9 +23,9 @@ namespace mbgl { { MGLLineJoinMiter, "miter" }, }); - MBGL_DEFINE_ENUM(MGLLineTranslateAnchor, { - { MGLLineTranslateAnchorMap, "map" }, - { MGLLineTranslateAnchorViewport, "viewport" }, + MBGL_DEFINE_ENUM(MGLLineTranslationAnchor, { + { MGLLineTranslationAnchorMap, "map" }, + { MGLLineTranslationAnchorViewport, "viewport" }, }); } @@ -299,32 +299,42 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineTranslate:(MGLStyleValue *)lineTranslate { +- (void)setLineTranslation:(MGLStyleValue *)lineTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(lineTranslate); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(lineTranslation); self.rawLayer->setLineTranslate(mbglValue); } -- (MGLStyleValue *)lineTranslate { +- (MGLStyleValue *)lineTranslation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getLineTranslate() ?: self.rawLayer->getDefaultLineTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { + +- (void)setLineTranslate:(MGLStyleValue *)lineTranslate { + NSAssert(NO, @"Use -setLineTranslation: instead."); +} + +- (void)setLineTranslationAnchor:(MGLStyleValue *)lineTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineTranslateAnchor); + auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineTranslationAnchor); self.rawLayer->setLineTranslateAnchor(mbglValue); } -- (MGLStyleValue *)lineTranslateAnchor { +- (MGLStyleValue *)lineTranslationAnchor { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getLineTranslateAnchor() ?: self.rawLayer->getDefaultLineTranslateAnchor(); - return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); +} + + +- (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { + NSAssert(NO, @"Use -setLineTranslationAnchor: instead."); } - (void)setLineWidth:(MGLStyleValue *)lineWidth { @@ -366,14 +376,14 @@ namespace mbgl { return lineJoin; } -+ (NSValue *)valueWithMGLLineTranslateAnchor:(MGLLineTranslateAnchor)lineTranslateAnchor { - return [NSValue value:&lineTranslateAnchor withObjCType:@encode(MGLLineTranslateAnchor)]; ++ (NSValue *)valueWithMGLLineTranslationAnchor:(MGLLineTranslationAnchor)lineTranslationAnchor { + return [NSValue value:&lineTranslationAnchor withObjCType:@encode(MGLLineTranslationAnchor)]; } -- (MGLLineTranslateAnchor)MGLLineTranslateAnchorValue { - MGLLineTranslateAnchor lineTranslateAnchor; - [self getValue:&lineTranslateAnchor]; - return lineTranslateAnchor; +- (MGLLineTranslationAnchor)MGLLineTranslationAnchorValue { + MGLLineTranslationAnchor lineTranslationAnchor; + [self getValue:&lineTranslationAnchor]; + return lineTranslationAnchor; } @end -- cgit v1.2.1 From 85fc75db8ddb5e045d5612fb38925535a8bb1804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 12 Jan 2017 14:17:20 -0800 Subject: [ios, macos] Fixed nilling out predicate --- platform/darwin/src/MGLLineStyleLayer.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/darwin/src/MGLLineStyleLayer.mm') diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 7d0d5ba6a5..f3b9f22df9 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -87,7 +87,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); } - (NSPredicate *)predicate -- cgit v1.2.1 From 4d5036616f85ff87ffe9042739872b1a080015b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 12 Jan 2017 16:48:17 -0800 Subject: [ios, macos] Rewrote style layer tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced the style layer integration tests with unit tests. Test conversion of style values to property values and vice versa, not just round-tripping. Test the initial state and null-resetting of each null-resettable property. Test NSValue additions for style attribute enumerations. Test properties common to all style layer classes. Test MGLStyle’s source and layer collections. Eviscerated implementations of unavailable style layer properties corresponding to style specification properties that were renamed. Implemented corresponding getters to prevent ivars from being autosynthesized for these unavailable properties. Added a missing bridging header to the iOS test project. --- platform/darwin/src/MGLLineStyleLayer.mm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'platform/darwin/src/MGLLineStyleLayer.mm') diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index f3b9f22df9..f6884fad15 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -238,9 +238,11 @@ namespace mbgl { return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } - - (void)setLineDasharray:(MGLStyleValue *> *)lineDasharray { - NSAssert(NO, @"Use -setLineDashPattern: instead."); +} + +- (MGLStyleValue *> *)lineDasharray { + return self.lineDashPattern; } - (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { @@ -313,9 +315,11 @@ namespace mbgl { return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - - (void)setLineTranslate:(MGLStyleValue *)lineTranslate { - NSAssert(NO, @"Use -setLineTranslation: instead."); +} + +- (MGLStyleValue *)lineTranslate { + return self.lineTranslation; } - (void)setLineTranslationAnchor:(MGLStyleValue *)lineTranslationAnchor { @@ -332,9 +336,11 @@ namespace mbgl { return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } - - (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { - NSAssert(NO, @"Use -setLineTranslationAnchor: instead."); +} + +- (MGLStyleValue *)lineTranslateAnchor { + return self.lineTranslationAnchor; } - (void)setLineWidth:(MGLStyleValue *)lineWidth { -- cgit v1.2.1