diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-01-04 07:35:25 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-02 09:44:42 -0800 |
commit | 22b3834caa5fe3ae91cf957124a3f1ad1d165cee (patch) | |
tree | 95439ccd498c414acfec70dc41b94ab9591f18c8 /platform/darwin/src/MGLStyleValue.h | |
parent | f562ecdfc3a08f7b9b0c2be938f237852a82d374 (diff) | |
download | qtlocation-mapboxgl-22b3834caa5fe3ae91cf957124a3f1ad1d165cee.tar.gz |
[ios, macos] Add support for data-driven property functions
Diffstat (limited to 'platform/darwin/src/MGLStyleValue.h')
-rw-r--r-- | platform/darwin/src/MGLStyleValue.h | 144 |
1 files changed, 87 insertions, 57 deletions
diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h index 2f462b5a2e..c8ec08b6a0 100644 --- a/platform/darwin/src/MGLStyleValue.h +++ b/platform/darwin/src/MGLStyleValue.h @@ -2,9 +2,27 @@ #import <CoreGraphics/CoreGraphics.h> #import "MGLFoundation.h" +#import "MGLTypes.h" NS_ASSUME_NONNULL_BEGIN +// TODO: API docs +typedef NSString *MGLStyleFunctionOption NS_STRING_ENUM; + +// TODO: API docs +extern MGL_EXPORT const MGLStyleFunctionOption MGLStyleFunctionOptionInterpolationBase; + +// TODO: API docs +extern MGL_EXPORT const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue; + +// TODO: API docs +typedef NS_ENUM(NSUInteger, MGLInterpolationMode) { + MGLInterpolationModeExponential = 0, + MGLInterpolationModeInterval, + MGLInterpolationModeCategorical, + MGLInterpolationModeIdentity +}; + /** An `MGLStyleValue` object is a generic container for a style attribute value. The layout and paint attribute properties of `MGLStyleLayer` can be set to @@ -41,6 +59,8 @@ MGL_EXPORT */ + (instancetype)valueWithRawValue:(T)rawValue; +#pragma mark Function values + /** Creates and returns an `MGLStyleFunction` object representing a linear zoom level function with any number of stops. @@ -48,7 +68,7 @@ MGL_EXPORT @param stops A dictionary associating zoom levels with style values. @return An `MGLStyleFunction` object with the given stops. */ -+ (instancetype)valueWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops; ++ (instancetype)valueWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops __attribute__((deprecated("Use +[MGLStyleValue valueWithInterpolationMode:cameraStops:options:]"))); /** Creates and returns an `MGLStyleFunction` object representing a zoom level @@ -58,7 +78,16 @@ MGL_EXPORT @param stops A dictionary associating zoom levels with style values. @return An `MGLStyleFunction` object with the given interpolation base and stops. */ -+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops; ++ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops __attribute__((deprecated("Use +[MGLStyleValue valueWithInterpolationMode:cameraStops:options:]"))); + +// TODO: API docs ++ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode cameraStops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; + +// TODO: API docs ++ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode sourceStops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; + +// TODO: API docs ++ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode compositeStops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; @end @@ -106,75 +135,76 @@ MGL_EXPORT @end -/** - An `MGLStyleFunction` is a value function defining a style value that changes - as the zoom level changes. The layout and paint attribute properties of an - `MGLStyleLayer` object can be set to `MGLStyleFunction` objects. Use a zoom - level function to create the illusion of depth and control data density. - - The `MGLStyleFunction` class takes a generic parameter `T` that indicates the - Foundation class being wrapped by this class. - */ MGL_EXPORT -@interface MGLStyleFunction<T> : MGLStyleValue<T> +@interface MGLCameraStyleFunction<T> : MGLStyleValue<T> -#pragma mark Creating a Style Function +// TODO: API docs ++ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; -/** - Creates and returns an `MGLStyleFunction` object representing a linear zoom - level function with any number of stops. +// TODO: API docs +- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER; - @param stops A dictionary associating zoom levels with style values. - @return An `MGLStyleFunction` object with the given stops. - */ -+ (instancetype)functionWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops; +// TODO: API docs +@property (nonatomic) MGLInterpolationMode interpolationMode; -/** - Creates and returns an `MGLStyleFunction` object representing a zoom level - function with an exponential interpolation base and any number of stops. +// TODO: API docs +@property (nonatomic, copy) NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *stops; - @param interpolationBase The exponential base of the interpolation curve. - @param stops A dictionary associating zoom levels with style values. - @return An `MGLStyleFunction` object with the given interpolation base and stops. - */ -+ (instancetype)functionWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops; +// TODO: API docs +@property (nonatomic) CGFloat interpolationBase; -#pragma mark Initializing a Style Function +@end -/** - Returns an `MGLStyleFunction` object representing a zoom level function with an - exponential interpolation base and any number of stops. +@compatibility_alias MGLStyleFunction MGLCameraStyleFunction; - @param interpolationBase The exponential base of the interpolation curve. - @param stops A dictionary associating zoom levels with style values. - @return An `MGLStyleFunction` object with the given interpolation base and stops. - */ -- (instancetype)initWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops NS_DESIGNATED_INITIALIZER; +MGL_EXPORT +@interface MGLSourceStyleFunction<T> : MGLStyleValue<T> -#pragma mark Accessing the Parameters of a Function +// TODO: API docs ++ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; -/** - The exponential interpolation base of the function’s interpolation curve. +// TODO: API docs +- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER; - The exponential interpolation base controls the rate at which the function’s output values - increase. A value of 1 causes the function to increase linearly by zoom level. - A higher exponential interpolation base causes the function’s output values to vary - exponentially, increasing more rapidly towards the high end of the function’s - range. The default value of this property is 1, for a linear curve. - */ +// TODO: API docs +@property (nonatomic) MGLInterpolationMode interpolationMode; + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic, copy, nullable) NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *stops; + +// TODO: API docs +@property (nonatomic, nullable) MGLStyleValue<T> *defaultValue; + +// TODO: API docs @property (nonatomic) CGFloat interpolationBase; -/** - A dictionary associating zoom levels with style values. - - Each of the function’s stops is represented by one key-value pair in the - dictionary. Each key in the dictionary is an `NSNumber` object containing a - floating-point zoom level. Each value in the dictionary is an `MGLStyleValue` - object containing the value of the style attribute when the map is at the - associated zoom level. An `MGLStyleFunction` object may not be used recursively - as a stop value. - */ -@property (nonatomic, copy) NSDictionary<NSNumber *, MGLStyleValue<T> *> *stops; +@end + +MGL_EXPORT +@interface MGLCompositeStyleFunction<T> : MGLStyleValue<T> + +// TODO: API docs ++ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options; + +- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER; + +// TODO: API docs +@property (nonatomic) MGLInterpolationMode interpolationMode; + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic, copy) NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *stops; + +// TODO: API docs +@property (nonatomic, nullable) MGLStyleValue<T> *defaultValue; + +// TODO: API docs +@property (nonatomic) CGFloat interpolationBase; @end |