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

Commit

Permalink
[ios, macos] -translate → -translation
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Jan 7, 2017
1 parent 17b3ec1 commit bf8d037
Show file tree
Hide file tree
Showing 17 changed files with 361 additions and 217 deletions.
20 changes: 11 additions & 9 deletions platform/darwin/scripts/generate-style-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,18 @@ global.describeValue = function (value, property, layerType) {
if (units) {
units = ` ${units}`.replace(/pixel/, 'point');
}
if (property.name.indexOf('padding') !== -1) {
if (value[0] === 0 && value[1] === 0 && value[2] === 0 && value[3] === 0) {
return 'an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`';
}
return 'an `NSValue` object containing an `NSEdgeInsets` or `UIEdgeInsets` struct set to' + ` ${value[0]}${units} on the top, ${value[3]}${units} on the left, ${value[2]}${units} on the bottom, and ${value[1]}${units} on the right`;
}
if (property.name.indexOf('offset') !== -1 || property.name.indexOf('translate') !== -1) {
return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} from the left and ${value[1]}${units} from the top`;
switch (arrayType(property)) {
case 'padding':
if (value[0] === 0 && value[1] === 0 && value[2] === 0 && value[3] === 0) {
return 'an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`';
}
return 'an `NSValue` object containing an `NSEdgeInsets` or `UIEdgeInsets` struct set to' + ` ${value[0]}${units} on the top, ${value[3]}${units} on the left, ${value[2]}${units} on the bottom, and ${value[1]}${units} on the right`;
case 'offset':
case 'translate':
return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} from the left and ${value[1]}${units} from the top`;
default:
return 'the array `' + value.join('`, `') + '`';
}
return 'the array `' + value.join('`, `') + '`';
default:
throw new Error(`unknown type for ${property.name}`);
}
Expand Down
20 changes: 16 additions & 4 deletions platform/darwin/scripts/style-spec-cocoa-conventions-v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,29 @@
"text-size": "text-font-size"
},
"paint_circle": {
"circle-pitch-scale": "circle-scale-alignment"
"circle-pitch-scale": "circle-scale-alignment",
"circle-translate": "circle-translation",
"circle-translate-anchor": "circle-translation-anchor"
},
"paint_fill": {
"fill-antialias": "is-fill-antialiased",
"fill-translate": "fill-translation",
"fill-translate-anchor": "fill-translation-anchor"
},
"paint_raster": {
"raster-brightness-min": "minimum-raster-brightness",
"raster-brightness-max": "maximum-raster-brightness",
"raster-hue-rotate": "raster-hue-rotation"
},
"paint_line": {
"line-dasharray": "line-dash-pattern"
"line-dasharray": "line-dash-pattern",
"line-translate": "line-translation",
"line-translate-anchor": "line-translation-anchor"
},
"paint_fill": {
"fill-antialias": "is-fill-antialiased"
"paint_symbol": {
"icon-translate": "icon-translation",
"icon-translate-anchor": "icon-translation-anchor",
"text-translate": "text-translation",
"text-translate-anchor": "text-translation-anchor"
}
}
40 changes: 26 additions & 14 deletions platform/darwin/src/MGLCircleStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ typedef NS_ENUM(NSUInteger, MGLCircleScaleAlignment) {
/**
Controls the translation reference point.
Values of this type are used in the `MGLCircleStyleLayer.circleTranslateAnchor`
Values of this type are used in the `MGLCircleStyleLayer.circleTranslationAnchor`
property.
*/
typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) {
/**
The circle is translated relative to the map.
*/
MGLCircleTranslateAnchorMap,
MGLCircleTranslationAnchorMap,
/**
The circle is translated relative to the viewport.
*/
MGLCircleTranslateAnchorViewport,
MGLCircleTranslationAnchorViewport,
};

/**
Expand Down Expand Up @@ -153,20 +153,32 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
`NSValue` object containing a `CGVector` struct set to 0 points from the left
and 0 points from the top. Set this property to `nil` to reset it to the
default value.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-circle-circle-translate"><code>circle-translate</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslate;
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslation;

@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslate __attribute__((unavailable("Use circleTranslation instead.")));

/**
Controls the translation reference point.
The default value of this property is an `MGLStyleValue` object containing an
`NSValue` object containing `MGLCircleTranslateAnchorMap`. Set this property to
`nil` to reset it to the default value.
`NSValue` object containing `MGLCircleTranslationAnchorMap`. Set this property
to `nil` to reset it to the default value.
This property is only applied to the style if `circleTranslate` is non-`nil`.
This property is only applied to the style if `circleTranslation` is non-`nil`.
Otherwise, it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-circle-circle-translate-anchor"><code>circle-translate-anchor</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslateAnchor;
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslationAnchor;

@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslateAnchor __attribute__((unavailable("Use circleTranslationAnchor instead.")));

@end

Expand All @@ -192,17 +204,17 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) {
@property (readonly) MGLCircleScaleAlignment MGLCircleScaleAlignmentValue;

/**
Creates a new value object containing the given `MGLCircleTranslateAnchor` enumeration.
Creates a new value object containing the given `MGLCircleTranslationAnchor` enumeration.
@param circleTranslateAnchor The value for the new object.
@param circleTranslationAnchor The value for the new object.
@return A new value object that contains the enumeration value.
*/
+ (instancetype)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor;
+ (instancetype)valueWithMGLCircleTranslationAnchor:(MGLCircleTranslationAnchor)circleTranslationAnchor;

/**
The `MGLCircleTranslateAnchor` enumeration representation of the value.
The `MGLCircleTranslationAnchor` enumeration representation of the value.
*/
@property (readonly) MGLCircleTranslateAnchor MGLCircleTranslateAnchorValue;
@property (readonly) MGLCircleTranslationAnchor MGLCircleTranslationAnchorValue;

@end

Expand Down
42 changes: 26 additions & 16 deletions platform/darwin/src/MGLCircleStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
{ MGLCircleScaleAlignmentViewport, "viewport" },
});

MBGL_DEFINE_ENUM(MGLCircleTranslateAnchor, {
{ MGLCircleTranslateAnchorMap, "map" },
{ MGLCircleTranslateAnchorViewport, "viewport" },
MBGL_DEFINE_ENUM(MGLCircleTranslationAnchor, {
{ MGLCircleTranslationAnchorMap, "map" },
{ MGLCircleTranslationAnchorViewport, "viewport" },
});

}
Expand Down Expand Up @@ -206,32 +206,42 @@ - (void)setCirclePitchScale:(MGLStyleValue<NSValue *> *)circlePitchScale {
NSAssert(NO, @"Use -setCircleScaleAlignment: instead.");
}

- (void)setCircleTranslate:(MGLStyleValue<NSValue *> *)circleTranslate {
- (void)setCircleTranslation:(MGLStyleValue<NSValue *> *)circleTranslation {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(circleTranslate);
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(circleTranslation);
self.rawLayer->setCircleTranslate(mbglValue);
}

- (MGLStyleValue<NSValue *> *)circleTranslate {
- (MGLStyleValue<NSValue *> *)circleTranslation {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getCircleTranslate() ?: self.rawLayer->getDefaultCircleTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}

- (void)setCircleTranslateAnchor:(MGLStyleValue<NSValue *> *)circleTranslateAnchor {

- (void)setCircleTranslate:(MGLStyleValue<NSValue *> *)circleTranslate {
NSAssert(NO, @"Use -setCircleTranslation: instead.");
}

- (void)setCircleTranslationAnchor:(MGLStyleValue<NSValue *> *)circleTranslationAnchor {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslateAnchor>().toEnumPropertyValue(circleTranslateAnchor);
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toEnumPropertyValue(circleTranslationAnchor);
self.rawLayer->setCircleTranslateAnchor(mbglValue);
}

- (MGLStyleValue<NSValue *> *)circleTranslateAnchor {
- (MGLStyleValue<NSValue *> *)circleTranslationAnchor {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getCircleTranslateAnchor() ?: self.rawLayer->getDefaultCircleTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslateAnchor>().toEnumStyleValue(propertyValue);
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toEnumStyleValue(propertyValue);
}


- (void)setCircleTranslateAnchor:(MGLStyleValue<NSValue *> *)circleTranslateAnchor {
NSAssert(NO, @"Use -setCircleTranslationAnchor: instead.");
}


Expand All @@ -249,14 +259,14 @@ - (MGLCircleScaleAlignment)MGLCircleScaleAlignmentValue {
return circleScaleAlignment;
}

+ (NSValue *)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor {
return [NSValue value:&circleTranslateAnchor withObjCType:@encode(MGLCircleTranslateAnchor)];
+ (NSValue *)valueWithMGLCircleTranslationAnchor:(MGLCircleTranslationAnchor)circleTranslationAnchor {
return [NSValue value:&circleTranslationAnchor withObjCType:@encode(MGLCircleTranslationAnchor)];
}

- (MGLCircleTranslateAnchor)MGLCircleTranslateAnchorValue {
MGLCircleTranslateAnchor circleTranslateAnchor;
[self getValue:&circleTranslateAnchor];
return circleTranslateAnchor;
- (MGLCircleTranslationAnchor)MGLCircleTranslationAnchorValue {
MGLCircleTranslationAnchor circleTranslationAnchor;
[self getValue:&circleTranslationAnchor];
return circleTranslationAnchor;
}

@end
38 changes: 25 additions & 13 deletions platform/darwin/src/MGLFillStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ NS_ASSUME_NONNULL_BEGIN
/**
Controls the translation reference point.
Values of this type are used in the `MGLFillStyleLayer.fillTranslateAnchor`
Values of this type are used in the `MGLFillStyleLayer.fillTranslationAnchor`
property.
*/
typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) {
typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
/**
The fill is translated relative to the map.
*/
MGLFillTranslateAnchorMap,
MGLFillTranslationAnchorMap,
/**
The fill is translated relative to the viewport.
*/
MGLFillTranslateAnchorViewport,
MGLFillTranslationAnchorViewport,
};

/**
Expand Down Expand Up @@ -127,20 +127,32 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) {
`NSValue` object containing a `CGVector` struct set to 0 points from the left
and 0 points from the top. Set this property to `nil` to reset it to the
default value.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-fill-fill-translate"><code>fill-translate</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslate;
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslation;

@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslate __attribute__((unavailable("Use fillTranslation instead.")));

/**
Controls the translation reference point.
The default value of this property is an `MGLStyleValue` object containing an
`NSValue` object containing `MGLFillTranslateAnchorMap`. Set this property to
`NSValue` object containing `MGLFillTranslationAnchorMap`. Set this property to
`nil` to reset it to the default value.
This property is only applied to the style if `fillTranslate` is non-`nil`.
This property is only applied to the style if `fillTranslation` is non-`nil`.
Otherwise, it is ignored.
This attribute corresponds to the <a
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-fill-fill-translate-anchor"><code>fill-translate-anchor</code></a>
layout property in the Mapbox Style Specification.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslateAnchor;
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslationAnchor;

@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *fillTranslateAnchor __attribute__((unavailable("Use fillTranslationAnchor instead.")));

@end

Expand All @@ -153,17 +165,17 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) {
#pragma mark Working with Fill Style Layer Attribute Values

/**
Creates a new value object containing the given `MGLFillTranslateAnchor` enumeration.
Creates a new value object containing the given `MGLFillTranslationAnchor` enumeration.
@param fillTranslateAnchor The value for the new object.
@param fillTranslationAnchor The value for the new object.
@return A new value object that contains the enumeration value.
*/
+ (instancetype)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor;
+ (instancetype)valueWithMGLFillTranslationAnchor:(MGLFillTranslationAnchor)fillTranslationAnchor;

/**
The `MGLFillTranslateAnchor` enumeration representation of the value.
The `MGLFillTranslationAnchor` enumeration representation of the value.
*/
@property (readonly) MGLFillTranslateAnchor MGLFillTranslateAnchorValue;
@property (readonly) MGLFillTranslationAnchor MGLFillTranslationAnchorValue;

@end

Expand Down
42 changes: 26 additions & 16 deletions platform/darwin/src/MGLFillStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <mbgl/style/layers/fill_layer.hpp>
namespace mbgl {

MBGL_DEFINE_ENUM(MGLFillTranslateAnchor, {
{ MGLFillTranslateAnchorMap, "map" },
{ MGLFillTranslateAnchorViewport, "viewport" },
MBGL_DEFINE_ENUM(MGLFillTranslationAnchor, {
{ MGLFillTranslationAnchorMap, "map" },
{ MGLFillTranslationAnchorViewport, "viewport" },
});

}
Expand Down Expand Up @@ -201,47 +201,57 @@ - (void)setFillPattern:(MGLStyleValue<NSString *> *)fillPattern {
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}

- (void)setFillTranslate:(MGLStyleValue<NSValue *> *)fillTranslate {
- (void)setFillTranslation:(MGLStyleValue<NSValue *> *)fillTranslation {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(fillTranslate);
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(fillTranslation);
self.rawLayer->setFillTranslate(mbglValue);
}

- (MGLStyleValue<NSValue *> *)fillTranslate {
- (MGLStyleValue<NSValue *> *)fillTranslation {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getFillTranslate() ?: self.rawLayer->getDefaultFillTranslate();
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
}

- (void)setFillTranslateAnchor:(MGLStyleValue<NSValue *> *)fillTranslateAnchor {

- (void)setFillTranslate:(MGLStyleValue<NSValue *> *)fillTranslate {
NSAssert(NO, @"Use -setFillTranslation: instead.");
}

- (void)setFillTranslationAnchor:(MGLStyleValue<NSValue *> *)fillTranslationAnchor {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslateAnchor>().toEnumPropertyValue(fillTranslateAnchor);
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toEnumPropertyValue(fillTranslationAnchor);
self.rawLayer->setFillTranslateAnchor(mbglValue);
}

- (MGLStyleValue<NSValue *> *)fillTranslateAnchor {
- (MGLStyleValue<NSValue *> *)fillTranslationAnchor {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getFillTranslateAnchor() ?: self.rawLayer->getDefaultFillTranslateAnchor();
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslateAnchor>().toEnumStyleValue(propertyValue);
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toEnumStyleValue(propertyValue);
}


- (void)setFillTranslateAnchor:(MGLStyleValue<NSValue *> *)fillTranslateAnchor {
NSAssert(NO, @"Use -setFillTranslationAnchor: instead.");
}


@end

@implementation NSValue (MGLFillStyleLayerAdditions)

+ (NSValue *)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor {
return [NSValue value:&fillTranslateAnchor withObjCType:@encode(MGLFillTranslateAnchor)];
+ (NSValue *)valueWithMGLFillTranslationAnchor:(MGLFillTranslationAnchor)fillTranslationAnchor {
return [NSValue value:&fillTranslationAnchor withObjCType:@encode(MGLFillTranslationAnchor)];
}

- (MGLFillTranslateAnchor)MGLFillTranslateAnchorValue {
MGLFillTranslateAnchor fillTranslateAnchor;
[self getValue:&fillTranslateAnchor];
return fillTranslateAnchor;
- (MGLFillTranslationAnchor)MGLFillTranslationAnchorValue {
MGLFillTranslationAnchor fillTranslationAnchor;
[self getValue:&fillTranslationAnchor];
return fillTranslationAnchor;
}

@end
Loading

0 comments on commit bf8d037

Please sign in to comment.