-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLLight autogenerate scripts #9260
Changes from 3 commits
6cde1a4
d2153a6
ed30f15
009063e
ca29d6d
91a6983
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
// This file is generated. | ||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. | ||
|
||
#import <CoreLocation/CoreLocation.h> | ||
|
||
#import "MGLFoundation.h" | ||
#import "MGLStyleValue.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
|
||
/** Options to specify extruded geometries are lit relative to the map or viewport. */ | ||
/** | ||
Whether extruded geometries are lit relative to the map or viewport. | ||
*/ | ||
typedef NS_ENUM(NSUInteger, MGLLightAnchor) { | ||
/** The position of the light source is aligned to the rotation of the map. */ | ||
/** | ||
The position of the light source is aligned to the rotation of the map. | ||
*/ | ||
MGLLightAnchorMap, | ||
/** The position of the light source is aligned to the rotation of the viewport. */ | ||
MGLLightAnchorViewport | ||
/** | ||
The position of the light source is aligned to the rotation of the | ||
viewport. | ||
*/ | ||
MGLLightAnchorViewport, | ||
}; | ||
|
||
/** | ||
|
@@ -20,7 +29,7 @@ typedef NS_ENUM(NSUInteger, MGLLightAnchor) { | |
*/ | ||
typedef struct MGLSphericalPosition { | ||
/** Distance from the center of the base of an object to its light. */ | ||
CLLocationDistance radial; | ||
CGFloat radial; | ||
/** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds | ||
to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, | ||
and degrees proceed clockwise). */ | ||
|
@@ -54,72 +63,131 @@ MGL_EXPORT | |
@interface MGLLight : NSObject | ||
|
||
/** | ||
`anchor` Whether extruded geometries are lit relative to the map or viewport. | ||
Whether extruded geometries are lit relative to the map or viewport. | ||
|
||
The default value of this property is an `MGLStyleValue` object containing an | ||
`NSValue` object containing `MGLAnchorViewport`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should say |
||
|
||
You can set this property to an instance of: | ||
|
||
* `MGLConstantStyleValue` | ||
* `MGLCameraStyleFunction` with an interpolation mode of | ||
`MGLInterpolationModeInterval` | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-anchor"><code>anchor</code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property (nonatomic) MGLStyleValue<NSValue *> *anchor; | ||
|
||
/** | ||
Values describing animated transitions to `anchor` property. | ||
*/ | ||
@property (nonatomic) MGLTransition anchorTransition; | ||
|
||
|
||
/** | ||
Position of the light source relative to lit (extruded) geometries. | ||
Position of the light source relative to lit (extruded) geometries, in [r | ||
radial coordinate, a azimuthal angle, p polar angle] where r indicates the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This documentation comment is a good candidate for a Cocoa override, because it discusses an array syntax that isn’t relevant to Objective-C or Swift. The ideal documentation for this property would refer to |
||
distance from the center of the base of an object to its light, a indicates the | ||
position of the light relative to 0° (0° when `light.anchor` is set to | ||
`MGLLight.anchorViewport` corresponds to the top of the viewport, or 0° when | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should say |
||
`light.anchor` is set to `MGLLight.anchorMap` corresponds to due north, and | ||
degrees proceed clockwise), and p indicates the height of the light (from 0°, | ||
directly above, to 180°, directly below). | ||
|
||
The default value of this property is an `MGLStyleValue` object containing the | ||
array `1.15`, `210`, `30`. | ||
|
||
You can set this property to an instance of: | ||
|
||
* `MGLConstantStyleValue` | ||
* `MGLCameraStyleFunction` with an interpolation mode of: | ||
* `MGLInterpolationModeExponential` | ||
* `MGLInterpolationModeInterval` | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-position"><code>position</code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property (nonatomic) MGLStyleValue<NSValue *> *position; | ||
|
||
/** | ||
Values describing animated transitions to `position` property. | ||
*/ | ||
@property (nonatomic) MGLTransition positionTransiton; | ||
The transition affecting any changes to this layer’s `position` property. | ||
|
||
This property corresponds to the `position-transition` property in the style JSON file format. | ||
*/ | ||
@property (nonatomic) MGLTransition positionTransition; | ||
|
||
#if TARGET_OS_IPHONE | ||
/** | ||
Color tint for lighting extruded geometries. | ||
|
||
The default value of this property is an `MGLStyleValue` object containing | ||
`UIColor.whiteColor`. | ||
|
||
You can set this property to an instance of: | ||
|
||
* `MGLConstantStyleValue` | ||
* `MGLCameraStyleFunction` with an interpolation mode of: | ||
* `MGLInterpolationModeExponential` | ||
* `MGLInterpolationModeInterval` | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-color"><code>color</code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property (nonatomic) MGLStyleValue<UIColor *> *color; | ||
#else | ||
|
||
/** | ||
Color tint for lighting extruded geometries. | ||
|
||
The default value of this property is an `MGLStyleValue` object containing | ||
`NSColor.whiteColor`. | ||
|
||
You can set this property to an instance of: | ||
|
||
* `MGLConstantStyleValue` | ||
* `MGLCameraStyleFunction` with an interpolation mode of: | ||
* `MGLInterpolationModeExponential` | ||
* `MGLInterpolationModeInterval` | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-color"><code>color</code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property (nonatomic) MGLStyleValue<NSColor *> *color; | ||
#endif | ||
|
||
/** | ||
Values describing animated transitions to `color` property. | ||
*/ | ||
@property (nonatomic) MGLTransition colorTransiton; | ||
The transition affecting any changes to this layer’s `color` property. | ||
|
||
This property corresponds to the `color-transition` property in the style JSON file format. | ||
*/ | ||
@property (nonatomic) MGLTransition colorTransition; | ||
|
||
/** | ||
Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast. | ||
Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as | ||
more extreme contrast. | ||
|
||
The default value of this property is an `MGLStyleValue` object containing an | ||
`NSNumber` object containing the float `0.5`. | ||
|
||
You can set this property to an instance of: | ||
|
||
* `MGLConstantStyleValue` | ||
* `MGLCameraStyleFunction` with an interpolation mode of: | ||
* `MGLInterpolationModeExponential` | ||
* `MGLInterpolationModeInterval` | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-intensity"><code>intensity</code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property(nonatomic) MGLStyleValue<NSNumber *> *intensity; | ||
@property (nonatomic) MGLStyleValue<NSNumber *> *intensity; | ||
|
||
/** | ||
Values describing animated transitions to `intensity` property. | ||
*/ | ||
The transition affecting any changes to this layer’s `intensity` property. | ||
|
||
This property corresponds to the `intensity-transition` property in the style JSON file format. | ||
*/ | ||
@property (nonatomic) MGLTransition intensityTransition; | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<% | ||
const properties = locals.properties; | ||
const type = locals.type; | ||
const doc = locals.doc; | ||
-%> | ||
// This file is generated. | ||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. | ||
|
||
#import <CoreLocation/CoreLocation.h> | ||
|
||
#import "MGLFoundation.h" | ||
#import "MGLStyleValue.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
<% for (const property of properties) { -%> | ||
<% if (property.type == "enum") { -%> | ||
/** | ||
<%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %> | ||
*/ | ||
typedef NS_ENUM(NSUInteger, MGLLight<%- camelize(property.name) %>) { | ||
<% for (const value in property.values) { -%> | ||
/** | ||
<%- propertyDoc(property.name, property.values[value], type, 'enum').wrap(80, 4+1) %> | ||
*/ | ||
MGLLightAnchor<%- camelize(value) %>, | ||
<% } -%> | ||
}; | ||
<% } -%> | ||
<% } -%> | ||
|
||
/** | ||
A structure containing information about the position of the light source | ||
relative to lit geometries. | ||
*/ | ||
typedef struct MGLSphericalPosition { | ||
/** Distance from the center of the base of an object to its light. */ | ||
CGFloat radial; | ||
/** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds | ||
to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, | ||
and degrees proceed clockwise). */ | ||
CLLocationDirection azimuthal; | ||
/** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */ | ||
CLLocationDirection polar; | ||
} MGLSphericalPosition; | ||
|
||
/** | ||
Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar. | ||
|
||
@param radial The radial coordinate. | ||
@param azimuthal The azimuthal angle. | ||
@param polar The polar angle. | ||
|
||
@return Returns a `MGLSphericalPosition` struct containing the position attributes. | ||
*/ | ||
NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { | ||
MGLSphericalPosition position; | ||
position.radial = radial; | ||
position.azimuthal = azimuthal; | ||
position.polar = polar; | ||
|
||
return position; | ||
} | ||
|
||
/** | ||
<%- doc %> | ||
*/ | ||
MGL_EXPORT | ||
@interface MGLLight : NSObject | ||
<% if (properties.length) { -%> | ||
|
||
<% for (const property of properties) { -%> | ||
/** | ||
<%- propertyDoc(property.name, property, type, 'light').wrap(80, 1) %> | ||
|
||
This property corresponds to the <a | ||
href="https://www.mapbox.com/mapbox-gl-js/style-spec/#light-<%- originalPropertyName(property) %>"><code><%- originalPropertyName(property) %></code></a> | ||
light property in the Mapbox Style Specification. | ||
*/ | ||
@property (nonatomic<% 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 | ||
|
||
NS_ASSUME_NONNULL_END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but note that there’s no need to put every piece of Darwin-specific documentation in this file. The important thing is to put overrides here – things that would otherwise automatically say something different if we removed the entry from this file.