diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-12-08 13:14:52 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-12-09 09:35:21 -0800 |
commit | 82856fd08b0b50902c72a56b5fe640447c94609e (patch) | |
tree | 8d1ecf2ae64db34cb295790fc122c8accb11d1ed /platform/darwin | |
parent | 3b2a4216a2e3929a557dbddd0d239758641c285f (diff) | |
download | qtlocation-mapboxgl-82856fd08b0b50902c72a56b5fe640447c94609e.tar.gz |
[darwin, android] SDK bindings for circle-stroke properties
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLCircleStyleLayer.h | 32 | ||||
-rw-r--r-- | platform/darwin/src/MGLCircleStyleLayer.mm | 42 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 2 | ||||
-rw-r--r-- | platform/darwin/test/MGLCircleStyleLayerTests.m | 12 |
4 files changed, 87 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 2d88a664ba..8c95b72123 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -94,6 +94,38 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleRadius; +#if TARGET_OS_IPHONE +/** + The stroke color of the circle. + + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + */ +@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *circleStrokeColor; +#else +/** + The stroke color of the circle. + + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + */ +@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *circleStrokeColor; +#endif + +/** + The opacity of the circle's stroke. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleStrokeOpacity; + +/** + The width of the circle's stroke. Strokes are placed outside of the `circleRadius`. + + This property is measured in points. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleStrokeWidth; + /** The geometry's offset. diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 91f91a7bcd..781682d4d1 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -187,6 +187,48 @@ namespace mbgl { return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } +- (void)setCircleStrokeColor:(MGLStyleValue<MGLColor *> *)circleStrokeColor { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(circleStrokeColor); + _rawLayer->setCircleStrokeColor(mbglValue); +} + +- (MGLStyleValue<MGLColor *> *)circleStrokeColor { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = _rawLayer->getCircleStrokeColor() ?: _rawLayer->getDefaultCircleStrokeColor(); + return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue); +} + +- (void)setCircleStrokeOpacity:(MGLStyleValue<NSNumber *> *)circleStrokeOpacity { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleStrokeOpacity); + _rawLayer->setCircleStrokeOpacity(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)circleStrokeOpacity { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = _rawLayer->getCircleStrokeOpacity() ?: _rawLayer->getDefaultCircleStrokeOpacity(); + return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); +} + +- (void)setCircleStrokeWidth:(MGLStyleValue<NSNumber *> *)circleStrokeWidth { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleStrokeWidth); + _rawLayer->setCircleStrokeWidth(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)circleStrokeWidth { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = _rawLayer->getCircleStrokeWidth() ?: _rawLayer->getDefaultCircleStrokeWidth(); + return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); +} + - (void)setCircleTranslate:(MGLStyleValue<NSValue *> *)circleTranslate { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index c89912c1ff..82d8a2561c 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -14,7 +14,7 @@ #import "MGLStyleValue_Private.h" #import "MGL<%- camelize(type) %>StyleLayer.h" -#include <mbgl/style/layers/<%- type %>_layer.hpp> +#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp> <% if (containsEnumerationProperties) { -%> namespace mbgl { diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.m b/platform/darwin/test/MGLCircleStyleLayerTests.m index 432d3ffa79..6f90f2c247 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.m +++ b/platform/darwin/test/MGLCircleStyleLayerTests.m @@ -21,6 +21,9 @@ layer.circleOpacity = [MGLRuntimeStylingHelper testNumber]; layer.circlePitchScale = [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]; layer.circleRadius = [MGLRuntimeStylingHelper testNumber]; + layer.circleStrokeColor = [MGLRuntimeStylingHelper testColor]; + layer.circleStrokeOpacity = [MGLRuntimeStylingHelper testNumber]; + layer.circleStrokeWidth = [MGLRuntimeStylingHelper testNumber]; layer.circleTranslate = [MGLRuntimeStylingHelper testOffset]; layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]; @@ -32,6 +35,9 @@ XCTAssert([gLayer.circlePitchScale isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.circleStrokeColor, [MGLRuntimeStylingHelper testColor]); + XCTAssertEqualObjects(gLayer.circleStrokeOpacity, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.circleStrokeWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffset]); XCTAssert([gLayer.circleTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); @@ -41,6 +47,9 @@ layer.circleOpacity = [MGLRuntimeStylingHelper testNumberFunction]; layer.circlePitchScale = [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]; layer.circleRadius = [MGLRuntimeStylingHelper testNumberFunction]; + layer.circleStrokeColor = [MGLRuntimeStylingHelper testColorFunction]; + layer.circleStrokeOpacity = [MGLRuntimeStylingHelper testNumberFunction]; + layer.circleStrokeWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.circleTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]; @@ -49,6 +58,9 @@ XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnumFunction:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); XCTAssertEqualObjects(gLayer.circleRadius, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.circleStrokeColor, [MGLRuntimeStylingHelper testColorFunction]); + XCTAssertEqualObjects(gLayer.circleStrokeOpacity, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.circleStrokeWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffsetFunction]); XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); } |