diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-01-02 15:54:17 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-01-07 14:37:53 -0800 |
commit | 80df3090ecc92a4c04890222928f352aaf467b27 (patch) | |
tree | 2963df50f43edc3e09a75c1df868b2f8bf3d69ae | |
parent | 428c0fdf70d08dfe433058a66a61bf9c4fb93d9d (diff) | |
download | qtlocation-mapboxgl-80df3090ecc92a4c04890222928f352aaf467b27.tar.gz |
[ios, macos] Split NSValue+MGLStyleEnumAttributeAdditions category per style layer type
Also renamed the file to have a slightly more wieldy name.
15 files changed, 387 insertions, 391 deletions
diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index cbe38ff6ba..4ead778c03 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -3,7 +3,7 @@ const iOS = os === 'iOS'; const macOS = os === 'macOS'; const cocoaPrefix = iOS ? 'UI' : 'NS'; - const types = locals.types; + const layers = locals.layers; const renamedProperties = locals.renamedProperties; -%> <!-- @@ -227,8 +227,8 @@ object is a member of one of the following subclasses of `MGLStyleLayer`: In style JSON | In the SDK --------------|----------- -<% for (const type of types) { -%> -`<%- type %>` | `MGL<%- camelize(type) %>StyleLayer` +<% for (const layer of layers) { -%> +`<%- layer.type %>` | `MGL<%- camelize(layer.type) %>StyleLayer` <% } -%> You configure layout and paint attributes by setting properties on these style diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index a656b48dd3..98ee1a83f7 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -368,32 +368,32 @@ global.mbglType = function(property) { const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true }); const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true}); const testLayers = ejs.compile(fs.readFileSync('platform/darwin/test/MGLStyleLayerTests.m.ejs', 'utf8'), { strict: true}); -const categoryH = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs', 'utf8'), { strict: true}); -const categoryM = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs', 'utf8'), { strict: true}); +const categoryH = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleLayerAdditions.h.ejs', 'utf8'), { strict: true}); +const categoryM = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm.ejs', 'utf8'), { strict: true}); const guideMD = ejs.compile(fs.readFileSync('platform/darwin/docs/guides/For Style Authors.md.ejs', 'utf8'), { strict: true }); -const layers = Object.keys(spec.layer.type.values).map((type) => { - const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => { +const layers = _(spec.layer.type.values).map((value, layerType) => { + const layoutProperties = Object.keys(spec[`layout_${layerType}`]).reduce((memo, name) => { if (name !== 'visibility') { - spec[`layout_${type}`][name].name = name; - memo.push(spec[`layout_${type}`][name]); + spec[`layout_${layerType}`][name].name = name; + memo.push(spec[`layout_${layerType}`][name]); } return memo; }, []); - const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => { - spec[`paint_${type}`][name].name = name; - memo.push(spec[`paint_${type}`][name]); + const paintProperties = Object.keys(spec[`paint_${layerType}`]).reduce((memo, name) => { + spec[`paint_${layerType}`][name].name = name; + memo.push(spec[`paint_${layerType}`][name]); return memo; }, []); return { - doc: spec.layer.type.values[type].doc, - type: type, + doc: spec.layer.type.values[layerType].doc, + type: layerType, layoutProperties: _.sortBy(layoutProperties, ['name']), paintProperties: _.sortBy(paintProperties, ['name']), }; -}); +}).sortBy(['type']).value(); function duplicatePlatformDecls(src) { // Look for a documentation comment that contains “MGLColor” and the @@ -414,22 +414,21 @@ ${macosComment}${decl} }); } -var allLayoutProperties = []; -var allPaintProperties = []; -var allTypes = []; -var allRenamedProperties = {}; +let enumPropertiesByLayerType = {}; +var renamedPropertiesByLayerType = {}; -for (let layer of layers) { - allLayoutProperties.push(layer.layoutProperties); - allPaintProperties.push(layer.paintProperties); - allTypes.push(layer.type); +for (var layer of layers) { let properties = _.concat(layer.layoutProperties, layer.paintProperties); - layer.containsEnumerationProperties = _.some(properties, prop => prop.type === "enum"); + let enumProperties = _.filter(properties, prop => prop.type === 'enum'); + if (enumProperties.length) { + enumPropertiesByLayerType[layer.type] = enumProperties; + layer.containsEnumerationProperties = true; + } let renamedProperties = {}; _.assign(renamedProperties, _.filter(properties, prop => 'original' in prop || 'getter' in prop)); if (!_.isEmpty(renamedProperties)) { - allRenamedProperties[layer.type] = renamedProperties; + renamedPropertiesByLayerType[layer.type] = renamedProperties; } fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`, duplicatePlatformDecls(layerH(layer))); @@ -437,23 +436,20 @@ for (let layer of layers) { fs.writeFileSync(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.m`, testLayers(layer)); } -fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h`, categoryH({ - layoutProperties: _.flatten(allLayoutProperties), - paintProperties: _.flatten(allPaintProperties), - types: allTypes +fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleLayerAdditions.h`, categoryH({ + enumPropertiesByLayerType: enumPropertiesByLayerType, })); -fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm`, categoryM({ - layoutProperties: _.flatten(allLayoutProperties), - paintProperties: _.flatten(allPaintProperties) +fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm`, categoryM({ + enumPropertiesByLayerType: enumPropertiesByLayerType, })); fs.writeFileSync(`platform/ios/docs/guides/For Style Authors.md`, guideMD({ os: 'iOS', - renamedProperties: allRenamedProperties, - types: allTypes, + renamedProperties: renamedPropertiesByLayerType, + layers: layers, })); fs.writeFileSync(`platform/macos/docs/guides/For Style Authors.md`, guideMD({ os: 'macOS', - renamedProperties: allRenamedProperties, - types: allTypes, + renamedProperties: renamedPropertiesByLayerType, + layers: layers, })); diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index e35c0d8008..2c3de3fb74 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -4,7 +4,6 @@ #import "NSValue+MGLStyleAttributeAdditions.h" #import "MGLTypes.h" -#import "MGLLineStyleLayer.h" #import <mbgl/util/enum.hpp> #if TARGET_OS_IPHONE diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs deleted file mode 100644 index c078ac7d02..0000000000 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs +++ /dev/null @@ -1,66 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. - -<% -const types = locals.types; -const layoutProperties = locals.layoutProperties; -const paintProperties = locals.paintProperties; --%> -#import <Foundation/Foundation.h> - -<% if (types) { -%> -<% for (const type of types) { -%> -#import "MGL<%- camelize(type) %>StyleLayer.h" -<% } -%> -<% } -%> - -NS_ASSUME_NONNULL_BEGIN - -/** - Methods for round-tripping values for Mapbox style layer enumeration values. -*/ -@interface NSValue (MGLStyleEnumAttributeAdditions) - -#pragma mark Working with Style Layer Enumeration Attribute Values - -<% if (layoutProperties.length) { -%> -<% for (const property of layoutProperties) { -%> -<% if (property.type == "enum") { -%> -/** - Creates a new value object containing the given `MGL<%- camelize(property.name) %>` enumeration. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %>; - -/** - The `MGL<%- camelize(property.name) %>` enumeration representation of the value. -*/ -@property (readonly) MGL<%- camelize(property.name) %> MGL<%- camelize(property.name) %>Value; - -<% } -%> -<% } -%> -<% } -%> -<% if (paintProperties.length) { -%> -<% for (const property of paintProperties) { -%> -<% if (property.type == "enum") { -%> -/** - Creates a new value object containing the given `MGL<%- camelize(property.name) %>` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %>; - -/** - The `MGL<%- camelize(property.name) %>` enumeration representation of the value. -*/ -@property (readonly) MGL<%- camelize(property.name) %> MGL<%- camelize(property.name) %>Value; - -<% } -%> -<% } -%> -<% } -%> -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs deleted file mode 100644 index fab278aac8..0000000000 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs +++ /dev/null @@ -1,46 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -<% -const type = locals.type; -const layoutProperties = locals.layoutProperties; -const paintProperties = locals.paintProperties; --%> - -#import "NSValue+MGLStyleEnumAttributeAdditions.h" - -@implementation NSValue (MGLStyleEnumAttributeAdditions) - -<% if (layoutProperties.length) { -%> -<% for (const property of layoutProperties) { -%> -<% if (property.type == "enum") { -%> -+ (NSValue *)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %> { - return [NSValue value:&<%- objCName(property) %> withObjCType:@encode(MGL<%- camelize(property.name) %>)]; -} - -- (MGL<%- camelize(property.name) %>)MGL<%- camelize(property.name) %>Value { - MGL<%- camelize(property.name) %> value; - [self getValue:&value]; - return value; -} - -<% } -%> -<% } -%> -<% } -%> -<% if (paintProperties.length) { -%> -<% for (const property of paintProperties) { -%> -<% if (property.type == "enum") { -%> -+ (NSValue *)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %> { -return [NSValue value:&<%- objCName(property) %> withObjCType:@encode(MGL<%- camelize(property.name) %>)]; -} - -- (MGL<%- camelize(property.name) %>)MGL<%- camelize(property.name) %>Value { - MGL<%- camelize(property.name) %> value; - [self getValue:&value]; - return value; -} - -<% } -%> -<% } -%> -<% } -%> - -@end diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.h index 3387ce8188..92fda42d76 100644 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h +++ b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.h @@ -3,230 +3,259 @@ #import <Foundation/Foundation.h> +#import "MGLCircleStyleLayer.h" #import "MGLFillStyleLayer.h" #import "MGLLineStyleLayer.h" #import "MGLSymbolStyleLayer.h" -#import "MGLCircleStyleLayer.h" -#import "MGLRasterStyleLayer.h" -#import "MGLBackgroundStyleLayer.h" NS_ASSUME_NONNULL_BEGIN /** - Methods for round-tripping values for Mapbox style layer enumeration values. -*/ -@interface NSValue (MGLStyleEnumAttributeAdditions) + Methods for wrapping an enumeration value for a style layer attribute in an + `MGLCircleStyleLayer` object and unwrapping its raw value. + */ +@interface NSValue (MGLCircleStyleLayerAdditions) + +#pragma mark Working with Circle Style Layer Attribute Values + +/** + Creates a new value object containing the given `MGLCirclePitchScale` enumeration. -#pragma mark Working with Style Layer Enumeration Attribute Values + @param circlePitchScale The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale; + +/** + The `MGLCirclePitchScale` enumeration representation of the value. + */ +@property (readonly) MGLCirclePitchScale MGLCirclePitchScaleValue; + +/** + Creates a new value object containing the given `MGLCircleTranslateAnchor` enumeration. + + @param circleTranslateAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor; + +/** + The `MGLCircleTranslateAnchor` enumeration representation of the value. + */ +@property (readonly) MGLCircleTranslateAnchor MGLCircleTranslateAnchorValue; + +@end + +/** + Methods for wrapping an enumeration value for a style layer attribute in an + `MGLFillStyleLayer` object and unwrapping its raw value. + */ +@interface NSValue (MGLFillStyleLayerAdditions) + +#pragma mark Working with Fill Style Layer Attribute Values + +/** + Creates a new value object containing the given `MGLFillTranslateAnchor` enumeration. + + @param fillTranslateAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor; + +/** + The `MGLFillTranslateAnchor` enumeration representation of the value. + */ +@property (readonly) MGLFillTranslateAnchor MGLFillTranslateAnchorValue; + +@end + +/** + Methods for wrapping an enumeration value for a style layer attribute in an + `MGLLineStyleLayer` object and unwrapping its raw value. + */ +@interface NSValue (MGLLineStyleLayerAdditions) + +#pragma mark Working with Line Style Layer Attribute Values /** Creates a new value object containing the given `MGLLineCap` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param lineCap The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLLineCap:(MGLLineCap)lineCap; /** The `MGLLineCap` enumeration representation of the value. -*/ + */ @property (readonly) MGLLineCap MGLLineCapValue; /** Creates a new value object containing the given `MGLLineJoin` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param lineJoin The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLLineJoin:(MGLLineJoin)lineJoin; /** The `MGLLineJoin` enumeration representation of the value. -*/ + */ @property (readonly) MGLLineJoin MGLLineJoinValue; /** + Creates a new value object containing the given `MGLLineTranslateAnchor` enumeration. + + @param lineTranslateAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGLLineTranslateAnchor:(MGLLineTranslateAnchor)lineTranslateAnchor; + +/** + The `MGLLineTranslateAnchor` enumeration representation of the value. + */ +@property (readonly) MGLLineTranslateAnchor MGLLineTranslateAnchorValue; + +@end + +/** + Methods for wrapping an enumeration value for a style layer attribute in an + `MGLSymbolStyleLayer` object and unwrapping its raw value. + */ +@interface NSValue (MGLSymbolStyleLayerAdditions) + +#pragma mark Working with Symbol Style Layer Attribute Values + +/** Creates a new value object containing the given `MGLIconRotationAlignment` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param iconRotationAlignment The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLIconRotationAlignment:(MGLIconRotationAlignment)iconRotationAlignment; /** The `MGLIconRotationAlignment` enumeration representation of the value. -*/ + */ @property (readonly) MGLIconRotationAlignment MGLIconRotationAlignmentValue; /** Creates a new value object containing the given `MGLIconTextFit` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param iconTextFit The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLIconTextFit:(MGLIconTextFit)iconTextFit; /** The `MGLIconTextFit` enumeration representation of the value. -*/ + */ @property (readonly) MGLIconTextFit MGLIconTextFitValue; /** Creates a new value object containing the given `MGLSymbolPlacement` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param symbolPlacement The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLSymbolPlacement:(MGLSymbolPlacement)symbolPlacement; /** The `MGLSymbolPlacement` enumeration representation of the value. -*/ + */ @property (readonly) MGLSymbolPlacement MGLSymbolPlacementValue; /** Creates a new value object containing the given `MGLTextAnchor` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextAnchor:(MGLTextAnchor)textAnchor; /** The `MGLTextAnchor` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextAnchor MGLTextAnchorValue; /** Creates a new value object containing the given `MGLTextJustification` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textJustification The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextJustification:(MGLTextJustification)textJustification; /** The `MGLTextJustification` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextJustification MGLTextJustificationValue; /** Creates a new value object containing the given `MGLTextPitchAlignment` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textPitchAlignment The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextPitchAlignment:(MGLTextPitchAlignment)textPitchAlignment; /** The `MGLTextPitchAlignment` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextPitchAlignment MGLTextPitchAlignmentValue; /** Creates a new value object containing the given `MGLTextRotationAlignment` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textRotationAlignment The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextRotationAlignment:(MGLTextRotationAlignment)textRotationAlignment; /** The `MGLTextRotationAlignment` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextRotationAlignment MGLTextRotationAlignmentValue; /** Creates a new value object containing the given `MGLTextTransform` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textTransform The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextTransform:(MGLTextTransform)textTransform; /** The `MGLTextTransform` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextTransform MGLTextTransformValue; /** - Creates a new value object containing the given `MGLFillTranslateAnchor` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor; - -/** - The `MGLFillTranslateAnchor` enumeration representation of the value. -*/ -@property (readonly) MGLFillTranslateAnchor MGLFillTranslateAnchorValue; - -/** - Creates a new value object containing the given `MGLLineTranslateAnchor` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGLLineTranslateAnchor:(MGLLineTranslateAnchor)lineTranslateAnchor; - -/** - The `MGLLineTranslateAnchor` enumeration representation of the value. -*/ -@property (readonly) MGLLineTranslateAnchor MGLLineTranslateAnchorValue; + Creates a new value object containing the given `MGLIconTranslateAnchor` enumeration. -/** - Creates a new value object containing the given `MGLIconTranslateAnchor` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param iconTranslateAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLIconTranslateAnchor:(MGLIconTranslateAnchor)iconTranslateAnchor; /** The `MGLIconTranslateAnchor` enumeration representation of the value. -*/ + */ @property (readonly) MGLIconTranslateAnchor MGLIconTranslateAnchorValue; /** - Creates a new value object containing the given `MGLTextTranslateAnchor` structure. + Creates a new value object containing the given `MGLTextTranslateAnchor` enumeration. - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ + @param textTranslateAnchor The value for the new object. + @return A new value object that contains the enumeration value. + */ + (instancetype)valueWithMGLTextTranslateAnchor:(MGLTextTranslateAnchor)textTranslateAnchor; /** The `MGLTextTranslateAnchor` enumeration representation of the value. -*/ + */ @property (readonly) MGLTextTranslateAnchor MGLTextTranslateAnchorValue; -/** - Creates a new value object containing the given `MGLCirclePitchScale` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale; - -/** - The `MGLCirclePitchScale` enumeration representation of the value. -*/ -@property (readonly) MGLCirclePitchScale MGLCirclePitchScaleValue; - -/** - Creates a new value object containing the given `MGLCircleTranslateAnchor` structure. - - @param type The value for the new object. - @return A new value object that contains the style enumeration type. -*/ -+ (instancetype)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor; - -/** - The `MGLCircleTranslateAnchor` enumeration representation of the value. -*/ -@property (readonly) MGLCircleTranslateAnchor MGLCircleTranslateAnchorValue; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSValue+MGLStyleLayerAdditions.h.ejs b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.h.ejs new file mode 100644 index 0000000000..d998e232ec --- /dev/null +++ b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.h.ejs @@ -0,0 +1,44 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. +<% +const enumPropertiesByLayerType = locals.enumPropertiesByLayerType; +-%> + +#import <Foundation/Foundation.h> + +<% for (let layerType of Object.getOwnPropertyNames(enumPropertiesByLayerType)) { -%> +#import "MGL<%- camelize(layerType) %>StyleLayer.h" +<% } -%> + +NS_ASSUME_NONNULL_BEGIN + +<% for (let layerType in enumPropertiesByLayerType) { -%> +<% if (enumPropertiesByLayerType.hasOwnProperty(layerType)) { -%> +/** + Methods for wrapping an enumeration value for a style layer attribute in an + `MGL<%- camelize(layerType) %>StyleLayer` object and unwrapping its raw value. + */ +@interface NSValue (MGL<%- camelize(layerType) %>StyleLayerAdditions) + +#pragma mark Working with <%- camelize(layerType) %> Style Layer Attribute Values + +<% for (let property of enumPropertiesByLayerType[layerType]) { -%> +/** + Creates a new value object containing the given `MGL<%- camelize(property.name) %>` enumeration. + + @param <%- objCName(property) %> The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %>; + +/** + The `MGL<%- camelize(property.name) %>` enumeration representation of the value. + */ +@property (readonly) MGL<%- camelize(property.name) %> MGL<%- camelize(property.name) %>Value; + +<% } -%> +@end + +<% } -%> +<% } -%> +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm index db91408c5a..efa3a01215 100644 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm @@ -1,18 +1,56 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "NSValue+MGLStyleEnumAttributeAdditions.h" +#import "NSValue+MGLStyleLayerAdditions.h" -@implementation NSValue (MGLStyleEnumAttributeAdditions) +@implementation NSValue (MGLCircleStyleLayerAdditions) + ++ (NSValue *)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale { + return [NSValue value:&circlePitchScale withObjCType:@encode(MGLCirclePitchScale)]; +} + +- (MGLCirclePitchScale)MGLCirclePitchScaleValue { + MGLCirclePitchScale circlePitchScale; + [self getValue:&circlePitchScale]; + return circlePitchScale; +} + ++ (NSValue *)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor { + return [NSValue value:&circleTranslateAnchor withObjCType:@encode(MGLCircleTranslateAnchor)]; +} + +- (MGLCircleTranslateAnchor)MGLCircleTranslateAnchorValue { + MGLCircleTranslateAnchor circleTranslateAnchor; + [self getValue:&circleTranslateAnchor]; + return circleTranslateAnchor; +} + +@end + +@implementation NSValue (MGLFillStyleLayerAdditions) + ++ (NSValue *)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor { + return [NSValue value:&fillTranslateAnchor withObjCType:@encode(MGLFillTranslateAnchor)]; +} + +- (MGLFillTranslateAnchor)MGLFillTranslateAnchorValue { + MGLFillTranslateAnchor fillTranslateAnchor; + [self getValue:&fillTranslateAnchor]; + return fillTranslateAnchor; +} + +@end + +@implementation NSValue (MGLLineStyleLayerAdditions) + (NSValue *)valueWithMGLLineCap:(MGLLineCap)lineCap { return [NSValue value:&lineCap withObjCType:@encode(MGLLineCap)]; } - (MGLLineCap)MGLLineCapValue { - MGLLineCap value; - [self getValue:&value]; - return value; + MGLLineCap lineCap; + [self getValue:&lineCap]; + return lineCap; } + (NSValue *)valueWithMGLLineJoin:(MGLLineJoin)lineJoin { @@ -20,19 +58,33 @@ } - (MGLLineJoin)MGLLineJoinValue { - MGLLineJoin value; - [self getValue:&value]; - return value; + 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 + +@implementation NSValue (MGLSymbolStyleLayerAdditions) + + (NSValue *)valueWithMGLIconRotationAlignment:(MGLIconRotationAlignment)iconRotationAlignment { return [NSValue value:&iconRotationAlignment withObjCType:@encode(MGLIconRotationAlignment)]; } - (MGLIconRotationAlignment)MGLIconRotationAlignmentValue { - MGLIconRotationAlignment value; - [self getValue:&value]; - return value; + MGLIconRotationAlignment iconRotationAlignment; + [self getValue:&iconRotationAlignment]; + return iconRotationAlignment; } + (NSValue *)valueWithMGLIconTextFit:(MGLIconTextFit)iconTextFit { @@ -40,9 +92,9 @@ } - (MGLIconTextFit)MGLIconTextFitValue { - MGLIconTextFit value; - [self getValue:&value]; - return value; + MGLIconTextFit iconTextFit; + [self getValue:&iconTextFit]; + return iconTextFit; } + (NSValue *)valueWithMGLSymbolPlacement:(MGLSymbolPlacement)symbolPlacement { @@ -50,9 +102,9 @@ } - (MGLSymbolPlacement)MGLSymbolPlacementValue { - MGLSymbolPlacement value; - [self getValue:&value]; - return value; + MGLSymbolPlacement symbolPlacement; + [self getValue:&symbolPlacement]; + return symbolPlacement; } + (NSValue *)valueWithMGLTextAnchor:(MGLTextAnchor)textAnchor { @@ -60,9 +112,9 @@ } - (MGLTextAnchor)MGLTextAnchorValue { - MGLTextAnchor value; - [self getValue:&value]; - return value; + MGLTextAnchor textAnchor; + [self getValue:&textAnchor]; + return textAnchor; } + (NSValue *)valueWithMGLTextJustification:(MGLTextJustification)textJustification { @@ -70,9 +122,9 @@ } - (MGLTextJustification)MGLTextJustificationValue { - MGLTextJustification value; - [self getValue:&value]; - return value; + MGLTextJustification textJustification; + [self getValue:&textJustification]; + return textJustification; } + (NSValue *)valueWithMGLTextPitchAlignment:(MGLTextPitchAlignment)textPitchAlignment { @@ -80,9 +132,9 @@ } - (MGLTextPitchAlignment)MGLTextPitchAlignmentValue { - MGLTextPitchAlignment value; - [self getValue:&value]; - return value; + MGLTextPitchAlignment textPitchAlignment; + [self getValue:&textPitchAlignment]; + return textPitchAlignment; } + (NSValue *)valueWithMGLTextRotationAlignment:(MGLTextRotationAlignment)textRotationAlignment { @@ -90,9 +142,9 @@ } - (MGLTextRotationAlignment)MGLTextRotationAlignmentValue { - MGLTextRotationAlignment value; - [self getValue:&value]; - return value; + MGLTextRotationAlignment textRotationAlignment; + [self getValue:&textRotationAlignment]; + return textRotationAlignment; } + (NSValue *)valueWithMGLTextTransform:(MGLTextTransform)textTransform { @@ -100,70 +152,30 @@ } - (MGLTextTransform)MGLTextTransformValue { - MGLTextTransform value; - [self getValue:&value]; - return value; -} - -+ (NSValue *)valueWithMGLFillTranslateAnchor:(MGLFillTranslateAnchor)fillTranslateAnchor { -return [NSValue value:&fillTranslateAnchor withObjCType:@encode(MGLFillTranslateAnchor)]; -} - -- (MGLFillTranslateAnchor)MGLFillTranslateAnchorValue { - MGLFillTranslateAnchor value; - [self getValue:&value]; - return value; -} - -+ (NSValue *)valueWithMGLLineTranslateAnchor:(MGLLineTranslateAnchor)lineTranslateAnchor { -return [NSValue value:&lineTranslateAnchor withObjCType:@encode(MGLLineTranslateAnchor)]; -} - -- (MGLLineTranslateAnchor)MGLLineTranslateAnchorValue { - MGLLineTranslateAnchor value; - [self getValue:&value]; - return value; + MGLTextTransform textTransform; + [self getValue:&textTransform]; + return textTransform; } + (NSValue *)valueWithMGLIconTranslateAnchor:(MGLIconTranslateAnchor)iconTranslateAnchor { -return [NSValue value:&iconTranslateAnchor withObjCType:@encode(MGLIconTranslateAnchor)]; + return [NSValue value:&iconTranslateAnchor withObjCType:@encode(MGLIconTranslateAnchor)]; } - (MGLIconTranslateAnchor)MGLIconTranslateAnchorValue { - MGLIconTranslateAnchor value; - [self getValue:&value]; - return value; + MGLIconTranslateAnchor iconTranslateAnchor; + [self getValue:&iconTranslateAnchor]; + return iconTranslateAnchor; } + (NSValue *)valueWithMGLTextTranslateAnchor:(MGLTextTranslateAnchor)textTranslateAnchor { -return [NSValue value:&textTranslateAnchor withObjCType:@encode(MGLTextTranslateAnchor)]; + return [NSValue value:&textTranslateAnchor withObjCType:@encode(MGLTextTranslateAnchor)]; } - (MGLTextTranslateAnchor)MGLTextTranslateAnchorValue { - MGLTextTranslateAnchor value; - [self getValue:&value]; - return value; + MGLTextTranslateAnchor textTranslateAnchor; + [self getValue:&textTranslateAnchor]; + return textTranslateAnchor; } -+ (NSValue *)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale { -return [NSValue value:&circlePitchScale withObjCType:@encode(MGLCirclePitchScale)]; -} - -- (MGLCirclePitchScale)MGLCirclePitchScaleValue { - MGLCirclePitchScale value; - [self getValue:&value]; - return value; -} - -+ (NSValue *)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor { -return [NSValue value:&circleTranslateAnchor withObjCType:@encode(MGLCircleTranslateAnchor)]; -} - -- (MGLCircleTranslateAnchor)MGLCircleTranslateAnchorValue { - MGLCircleTranslateAnchor value; - [self getValue:&value]; - return value; -} - - @end + diff --git a/platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm.ejs b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm.ejs new file mode 100644 index 0000000000..758fb66546 --- /dev/null +++ b/platform/darwin/src/NSValue+MGLStyleLayerAdditions.mm.ejs @@ -0,0 +1,28 @@ +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. +<% +const enumPropertiesByLayerType = locals.enumPropertiesByLayerType; +-%> + +#import "NSValue+MGLStyleLayerAdditions.h" + +<% for (let layerType in enumPropertiesByLayerType) { -%> +<% if (enumPropertiesByLayerType.hasOwnProperty(layerType)) { -%> +@implementation NSValue (MGL<%- camelize(layerType) %>StyleLayerAdditions) + +<% for (let property of enumPropertiesByLayerType[layerType]) { -%> ++ (NSValue *)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %> { + return [NSValue value:&<%- objCName(property) %> withObjCType:@encode(MGL<%- camelize(property.name) %>)]; +} + +- (MGL<%- camelize(property.name) %>)MGL<%- camelize(property.name) %>Value { + MGL<%- camelize(property.name) %> <%- objCName(property) %>; + [self getValue:&<%- objCName(property) %>]; + return <%- objCName(property) %>; +} + +<% } -%> +<% } -%> +@end + +<% } -%> diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index 96a0661af6..d35d4e5af0 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -176,12 +176,12 @@ object is a member of one of the following subclasses of `MGLStyleLayer`: In style JSON | In the SDK --------------|----------- +`background` | `MGLBackgroundStyleLayer` +`circle` | `MGLCircleStyleLayer` `fill` | `MGLFillStyleLayer` `line` | `MGLLineStyleLayer` -`symbol` | `MGLSymbolStyleLayer` -`circle` | `MGLCircleStyleLayer` `raster` | `MGLRasterStyleLayer` -`background` | `MGLBackgroundStyleLayer` +`symbol` | `MGLSymbolStyleLayer` You configure layout and paint attributes by setting properties on these style layer objects. The property names generally correspond to the style JSON @@ -200,6 +200,14 @@ In style JSON | In Objective-C | In Swift --------------|----------------|--------- `line-dasharray` | `MGLLineStyleLayer.lineDashPattern` | `MGLLineStyleLayer.lineDashPattern` +### Raster style layers + +In style JSON | In Objective-C | In Swift +--------------|----------------|--------- +`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` +`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` +`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` + ### Symbol style layers In style JSON | In Objective-C | In Swift @@ -221,14 +229,6 @@ In style JSON | In Objective-C | In Swift `text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional` `text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation` -### Raster style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` -`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` -`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` - ## Setting attribute values Each property representing a layout or paint attribute is set to an diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 8d96bcf497..07e15fa6a1 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -133,10 +133,10 @@ 4018B1C91CDC288A00F666AF /* MGLAnnotationView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C31CDC277F00F666AF /* MGLAnnotationView_Private.h */; }; 4018B1CA1CDC288E00F666AF /* MGLAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4018B1CB1CDC288E00F666AF /* MGLAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4032C5BF1DE1FC780062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4032C5C01DE1FC780062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4032C5C11DE1FC7E0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */; }; - 4032C5C21DE1FC7E0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */; }; + 4032C5BF1DE1FC780062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleLayerAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4032C5C01DE1FC780062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleLayerAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4032C5C11DE1FC7E0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleLayerAdditions.mm */; }; + 4032C5C21DE1FC7E0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleLayerAdditions.mm */; }; 404326891D5B9B27007111BD /* MGLAnnotationContainerView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404326881D5B9B1A007111BD /* MGLAnnotationContainerView_Private.h */; }; 4049C29D1DB6CD6C00B3F799 /* MGLPointCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4049C29E1DB6CD6C00B3F799 /* MGLPointCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -591,10 +591,10 @@ 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>"; }; 402E9DE01CD2C76200FD4519 /* Mapbox.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Mapbox.playground; sourceTree = "<group>"; }; - 4032C5B71DE1EBB90062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = "NSValue+MGLStyleEnumAttributeAdditions.h.ejs"; sourceTree = "<group>"; }; - 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleEnumAttributeAdditions.h"; sourceTree = "<group>"; }; - 4032C5BC1DE1FAFC0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = "NSValue+MGLStyleEnumAttributeAdditions.mm.ejs"; sourceTree = "<group>"; }; - 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleEnumAttributeAdditions.mm"; sourceTree = "<group>"; }; + 4032C5B71DE1EBB90062E8BD /* NSValue+MGLStyleLayerAdditions.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = "NSValue+MGLStyleLayerAdditions.h.ejs"; sourceTree = "<group>"; }; + 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleLayerAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleLayerAdditions.h"; sourceTree = "<group>"; }; + 4032C5BC1DE1FAFC0062E8BD /* NSValue+MGLStyleLayerAdditions.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = "NSValue+MGLStyleLayerAdditions.mm.ejs"; sourceTree = "<group>"; }; + 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleLayerAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleLayerAdditions.mm"; sourceTree = "<group>"; }; 404326881D5B9B1A007111BD /* MGLAnnotationContainerView_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView_Private.h; sourceTree = "<group>"; }; 4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCollection.h; sourceTree = "<group>"; }; 4049C29C1DB6CD6C00B3F799 /* MGLPointCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLPointCollection.mm; sourceTree = "<group>"; }; @@ -927,8 +927,8 @@ 35599DB81D46AD7F0048254D /* Categories */ = { isa = PBXGroup; children = ( - 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */, - 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */, + 4032C5B81DE1EE7D0062E8BD /* NSValue+MGLStyleLayerAdditions.h */, + 4032C5BD1DE1FC690062E8BD /* NSValue+MGLStyleLayerAdditions.mm */, 350098DA1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h */, 350098DB1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.mm */, ); @@ -1266,8 +1266,8 @@ DA8F25BA1D51D2570010E6B5 /* MGLStyleLayer.h.ejs */, DA8F25BB1D51D2570010E6B5 /* MGLStyleLayer.mm.ejs */, DA8F25B91D51D2570010E6B5 /* MGLStyleLayerTests.m.ejs */, - 4032C5B71DE1EBB90062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */, - 4032C5BC1DE1FAFC0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */, + 4032C5B71DE1EBB90062E8BD /* NSValue+MGLStyleLayerAdditions.h.ejs */, + 4032C5BC1DE1FAFC0062E8BD /* NSValue+MGLStyleLayerAdditions.mm.ejs */, ); name = "Foundation Templates"; path = ../../darwin/src; @@ -1527,7 +1527,7 @@ DA88488B1CBB037E00AB86E3 /* SMCalloutView.h in Headers */, DA8847FE1CBAFA5100AB86E3 /* MGLTypes.h in Headers */, DA8847F11CBAFA5100AB86E3 /* MGLGeometry.h in Headers */, - 4032C5BF1DE1FC780062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */, + 4032C5BF1DE1FC780062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */, DA8848221CBAFA6200AB86E3 /* MGLOfflineRegion_Private.h in Headers */, 35136D4C1D4277FC00C20EFD /* MGLSource.h in Headers */, 3566C76C1D4A8DFA008152BC /* MGLRasterSource.h in Headers */, @@ -1570,7 +1570,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 4032C5C01DE1FC780062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */, + 4032C5C01DE1FC780062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */, 35B82BF91D6C5F8400B1B721 /* NSPredicate+MGLAdditions.h in Headers */, DA35A2CA1CCAAAD200E826B2 /* NSValue+MGLAdditions.h in Headers */, 350098BC1D480108004B2AF0 /* MGLVectorSource.h in Headers */, @@ -2047,7 +2047,7 @@ DA8848301CBAFA6200AB86E3 /* NSProcessInfo+MGLAdditions.m in Sources */, 353AFA161D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 35D13AC51D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm in Sources */, - 4032C5C11DE1FC7E0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */, + 4032C5C11DE1FC7E0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */, DA8848241CBAFA6200AB86E3 /* MGLOfflineStorage.mm in Sources */, DA88482A1CBAFA6200AB86E3 /* MGLTilePyramidOfflineRegion.mm in Sources */, 4049C29F1DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */, @@ -2123,7 +2123,7 @@ DAA4E4231CBB730400178DFB /* MGLPolygon.mm in Sources */, 353AFA171D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */, 35D13AC61D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm in Sources */, - 4032C5C21DE1FC7E0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */, + 4032C5C21DE1FC7E0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */, DAA4E42A1CBB730400178DFB /* NSProcessInfo+MGLAdditions.m in Sources */, DAA4E4211CBB730400178DFB /* MGLOfflineStorage.mm in Sources */, 4049C2A01DB6CD6C00B3F799 /* MGLPointCollection.mm in Sources */, diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index 69c718ddea..f931201dfb 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -52,6 +52,6 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[]; #import "MGLUserLocation.h" #import "MGLUserLocationAnnotationView.h" #import "NSValue+MGLAdditions.h" -#import "NSValue+MGLStyleEnumAttributeAdditions.h" +#import "NSValue+MGLStyleLayerAdditions.h" #import "MGLStyleValue.h" #import "MGLAttributionInfo.h" diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md index ceefbcb6ec..003cc516cd 100644 --- a/platform/macos/docs/guides/For Style Authors.md +++ b/platform/macos/docs/guides/For Style Authors.md @@ -164,12 +164,12 @@ object is a member of one of the following subclasses of `MGLStyleLayer`: In style JSON | In the SDK --------------|----------- +`background` | `MGLBackgroundStyleLayer` +`circle` | `MGLCircleStyleLayer` `fill` | `MGLFillStyleLayer` `line` | `MGLLineStyleLayer` -`symbol` | `MGLSymbolStyleLayer` -`circle` | `MGLCircleStyleLayer` `raster` | `MGLRasterStyleLayer` -`background` | `MGLBackgroundStyleLayer` +`symbol` | `MGLSymbolStyleLayer` You configure layout and paint attributes by setting properties on these style layer objects. The property names generally correspond to the style JSON @@ -188,6 +188,14 @@ In style JSON | In Objective-C | In Swift --------------|----------------|--------- `line-dasharray` | `MGLLineStyleLayer.lineDashPattern` | `MGLLineStyleLayer.lineDashPattern` +### Raster style layers + +In style JSON | In Objective-C | In Swift +--------------|----------------|--------- +`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` +`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` +`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` + ### Symbol style layers In style JSON | In Objective-C | In Swift @@ -209,14 +217,6 @@ In style JSON | In Objective-C | In Swift `text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional` `text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation` -### Raster style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` -`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` -`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` - ## Setting attribute values Each property representing a layout or paint attribute is set to an diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 3b26d59af8..9aaf23efdf 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -44,8 +44,8 @@ 35C5D84A1D6DD66D00E95907 /* NSCompoundPredicate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35C5D8461D6DD66D00E95907 /* NSCompoundPredicate+MGLAdditions.mm */; }; 35D65C5A1D65AD5500722C23 /* NSDate+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35D65C581D65AD5500722C23 /* NSDate+MGLAdditions.h */; }; 35D65C5B1D65AD5500722C23 /* NSDate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D65C591D65AD5500722C23 /* NSDate+MGLAdditions.mm */; }; - 4032C5C51DE1FE930062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4032C5C61DE1FE9B0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */; }; + 4032C5C51DE1FE930062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleLayerAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4032C5C61DE1FE9B0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleLayerAdditions.mm */; }; 4049C2A51DB6CE7F00B3F799 /* MGLPointCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 4049C2A11DB6CE7800B3F799 /* MGLPointCollection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4049C2AD1DB8020600B3F799 /* MGLPointCollection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4049C2A71DB6D09B00B3F799 /* MGLPointCollection.mm */; }; 408AA85B1DAEECFE00022900 /* MGLShape_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 408AA85A1DAEECF100022900 /* MGLShape_Private.h */; }; @@ -293,10 +293,10 @@ 35C5D84B1D6DD75B00E95907 /* MGLPredicateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLPredicateTests.mm; path = ../../darwin/test/MGLPredicateTests.mm; sourceTree = "<group>"; }; 35D65C581D65AD5500722C23 /* NSDate+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+MGLAdditions.h"; sourceTree = "<group>"; }; 35D65C591D65AD5500722C23 /* NSDate+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDate+MGLAdditions.mm"; sourceTree = "<group>"; }; - 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleEnumAttributeAdditions.h"; sourceTree = "<group>"; }; - 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "NSValue+MGLStyleEnumAttributeAdditions.h.ejs"; sourceTree = "<group>"; }; - 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleEnumAttributeAdditions.mm"; sourceTree = "<group>"; }; - 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "NSValue+MGLStyleEnumAttributeAdditions.mm.ejs"; sourceTree = "<group>"; }; + 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleLayerAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleLayerAdditions.h"; sourceTree = "<group>"; }; + 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleLayerAdditions.h.ejs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "NSValue+MGLStyleLayerAdditions.h.ejs"; sourceTree = "<group>"; }; + 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleLayerAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleLayerAdditions.mm"; sourceTree = "<group>"; }; + 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleLayerAdditions.mm.ejs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "NSValue+MGLStyleLayerAdditions.mm.ejs"; sourceTree = "<group>"; }; 4049C2A11DB6CE7800B3F799 /* MGLPointCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCollection.h; sourceTree = "<group>"; }; 4049C2A71DB6D09B00B3F799 /* MGLPointCollection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLPointCollection.mm; sourceTree = "<group>"; }; 405C03961DB0004E001AC280 /* NSImage+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSImage+MGLAdditions.h"; sourceTree = "<group>"; }; @@ -560,8 +560,8 @@ 352742791D4C235C00A1ECE6 /* Categories */ = { isa = PBXGroup; children = ( - 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h */, - 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm */, + 4032C5B91DE1EEBA0062E8BD /* NSValue+MGLStyleLayerAdditions.h */, + 4032C5C31DE1FE810062E8BD /* NSValue+MGLStyleLayerAdditions.mm */, DA8F25A61D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.h */, DA8F25A71D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm */, ); @@ -737,8 +737,8 @@ DA8F25B61D51D2240010E6B5 /* MGLStyleLayer.h.ejs */, DA8F25B71D51D2240010E6B5 /* MGLStyleLayer.mm.ejs */, DA8F25B51D51D2240010E6B5 /* MGLStyleLayerTests.m.ejs */, - 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */, - 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */, + 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleLayerAdditions.h.ejs */, + 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleLayerAdditions.mm.ejs */, ); name = "Foundation Templates"; path = ../../darwin/src; @@ -1000,7 +1000,7 @@ 352742781D4C220900A1ECE6 /* MGLStyleValue.h in Headers */, DAE6C35E1CC31E0400DB3429 /* MGLMultiPoint.h in Headers */, 35602BFF1D3EA9B40050646F /* MGLStyleLayer_Private.h in Headers */, - 4032C5C51DE1FE930062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h in Headers */, + 4032C5C51DE1FE930062E8BD /* NSValue+MGLStyleLayerAdditions.h in Headers */, DAF0D8161DFE6B1800B28378 /* MGLAttributionInfo_Private.h in Headers */, DAE6C3971CC31E2A00DB3429 /* NSBundle+MGLAdditions.h in Headers */, DAED385F1D62CED700D7640F /* NSURL+MGLAdditions.h in Headers */, @@ -1274,7 +1274,7 @@ DAE6C3931CC31E2A00DB3429 /* MGLShape.mm in Sources */, 352742861D4C244700A1ECE6 /* MGLRasterSource.mm in Sources */, DAE6C39D1CC31E2A00DB3429 /* NSString+MGLAdditions.m in Sources */, - 4032C5C61DE1FE9B0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm in Sources */, + 4032C5C61DE1FE9B0062E8BD /* NSValue+MGLStyleLayerAdditions.mm in Sources */, 3598195A1E02F611008FC139 /* NSCoder+MGLAdditions.mm in Sources */, DAE6C3941CC31E2A00DB3429 /* MGLStyle.mm in Sources */, DAE6C3871CC31E2A00DB3429 /* MGLGeometry.mm in Sources */, diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h index 524ff1a93a..1c2b291745 100644 --- a/platform/macos/src/Mapbox.h +++ b/platform/macos/src/Mapbox.h @@ -48,6 +48,6 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[]; #import "MGLTilePyramidOfflineRegion.h" #import "MGLTypes.h" #import "NSValue+MGLAdditions.h" -#import "NSValue+MGLStyleEnumAttributeAdditions.h" +#import "NSValue+MGLStyleLayerAdditions.h" #import "MGLStyleValue.h" #import "MGLAttributionInfo.h" |