summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyleLayer.h.ejs
blob: e29ea4611d3b174c0e1d4924ac16a4ed9cc6a53b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<%
  const doc = locals.doc;
  const type = locals.type;
  const layoutProperties = locals.layoutProperties;
  const paintProperties = locals.paintProperties;
  const enumProperties = locals.enumProperties;
-%>
// This file is generated.
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.

#import "MGLFoundation.h"
#import "MGLStyleValue.h"
#import "MGL<%-
(type === 'background' ? '' :
 (type === 'raster' ? 'Foreground' :
  'Vector'))
%>StyleLayer.h"

NS_ASSUME_NONNULL_BEGIN

<% for (const property of layoutProperties) { -%>
<% if (property.type == "enum") { -%>
/**
<%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %>

 Values of this type are used in the `MGL<%- camelize(type) %>StyleLayer.<%- camelizeWithLeadingLowercase(property.name) %>`
 property.
 */
typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) {
<% for (const value in property.values) { -%>
    /**
<%- propertyDoc(property.name, property.values[value], type, 'enum').wrap(80, 4+1) %>
     */
    MGL<%- camelize(property.name) %><%- camelize(value) %>,
<% } -%>
};

<% } -%>
<% } -%>
<% for (const property of paintProperties) { -%>
<% if (property.type == "enum") { -%>
/**
<%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %>

 Values of this type are used in the `MGL<%- camelize(type) %>StyleLayer.<%- camelizeWithLeadingLowercase(property.name) %>`
 property.
 */
typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) {
<% for (const value in property.values) { -%>
    /**
<%- propertyDoc(property.name, property.values[value], type, 'enum').wrap(80, 4+1) %>
     */
    MGL<%- camelize(property.name) %><%- camelize(value) %>,
<% } -%>
};

<% } -%>
<% } -%>
<% if (type == 'background') { -%>
/**
<%- doc.wrap(80, 1) %>
 */
<% } else { -%>
/**
<%- doc.wrap(80, 1) %>

 You can access an existing <%- type %> style layer using the
 `-[MGLStyle layerWithIdentifier:]` method if you know its identifier;
 otherwise, find it using the `MGLStyle.layers` property. You can also create a
 new <%- type %> style layer and add it to the style using a method such as
 `-[MGLStyle addLayer:]`.

 ### Example

 ```swift
 ```
 */
<% } -%>
MGL_EXPORT
@interface MGL<%- camelize(type) %>StyleLayer : MGL<%-
(type === 'background' ? '' :
 (type === 'raster' ? 'Foreground' :
  'Vector'))
%>StyleLayer
<% if (type === 'background') { -%>

/**
Returns a <%- type %> style layer initialized with an identifier.

After initializing and configuring the style layer, add it to a map view’s
style using the `-[MGLStyle addLayer:]` or
`-[MGLStyle insertLayer:belowLayer:]` method.

@param identifier A string that uniquely identifies the source in the style to
which it is added.
*/
- (instancetype)initWithIdentifier:(NSString *)identifier;
<% } else { -%>

/**
 Returns a <%- type %> style layer initialized with an identifier and source.

 After initializing and configuring the style layer, add it to a map view’s
 style using the `-[MGLStyle addLayer:]` or
 `-[MGLStyle insertLayer:belowLayer:]` method.

 @param identifier A string that uniquely identifies the source in the style to
    which it is added.
 @param source The source from which to obtain the data to style. If the source
    has not yet been added to the current style, the behavior is undefined.
 @return An initialized foreground style layer.
 */
- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source;
<% } -%>

<% if (layoutProperties.length) { -%>
#pragma mark - Accessing the Layout Attributes

<% for (const property of layoutProperties) { -%>
/**
<%- propertyDoc(property.name, property, type, 'layout').wrap(80, 1) %>
 */
@property (nonatomic<% if (!property.required) { %>, null_resettable<% } if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>;

<% if (property.original) { %>
@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead.")));

<% } -%>
<% } -%>
<% } -%>
<% if (paintProperties.length) { -%>
#pragma mark - Accessing the Paint Attributes

<% for (const property of paintProperties) { -%>
/**
<%- propertyDoc(property.name, property, type, 'paint').wrap(80, 1) %>
 */
@property (nonatomic<% if (!property.required) { %>, null_resettable<% } if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>;

<% if (property["transition"]) { -%>
/**
 The transition affecting any changes to this layer’s `<%- camelizeWithLeadingLowercase(property.name) %>` property.

 This property corresponds to the `<%- originalPropertyName(property) %>-transition` property in the style JSON file format.
*/
@property (nonatomic) MGLTransition <%- camelizeWithLeadingLowercase(property.name) %>Transition;

<% } -%>
<% if (property.original) { -%>
@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead.")));

<% } -%>
<% } -%>
<% } -%>
@end

<% if (enumProperties) { -%>
/**
 Methods for wrapping an enumeration value for a style layer attribute in an
 `MGL<%- camelize(type) %>StyleLayer` object and unwrapping its raw value.
 */
@interface NSValue (MGL<%- camelize(type) %>StyleLayerAdditions)

#pragma mark Working with <%- camelize(type) %> Style Layer Attribute Values

<% for (let property of enumProperties) { -%>
/**
 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