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

Commit

Permalink
[ios, macos] Applied expression changes via codegen
Browse files Browse the repository at this point in the history
Ran make darwin-style-code and removed heatmap-specific changes.
  • Loading branch information
1ec5 committed Dec 19, 2017
1 parent a0f2bcb commit 1ae15d5
Show file tree
Hide file tree
Showing 23 changed files with 4,063 additions and 4,140 deletions.
75 changes: 33 additions & 42 deletions platform/darwin/src/MGLBackgroundStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.

#import "MGLFoundation.h"
#import "MGLStyleValue.h"
#import "MGLStyleLayer.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -38,45 +37,28 @@ which it is added.

#pragma mark - Accessing the Paint Attributes

#if TARGET_OS_IPHONE
/**
The color with which the background will be drawn.
The default value of this property is an `MGLStyleValue` object containing
The default value of this property is an expression that evaluates to
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `backgroundPattern` is set to
`nil`. Otherwise, it is ignored.
You can set this property to an instance of:
You can set this property to an expression containing any of the following:
* `MGLConstantStyleValue`
* `MGLCameraStyleFunction` with an interpolation mode of:
* `MGLInterpolationModeExponential`
* `MGLInterpolationModeInterval`
*/
@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *backgroundColor;
#else
/**
The color with which the background will be drawn.
* Constant values
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
* Interpolation and step functions applied to the `$zoomLevel` variable
The default value of this property is an `MGLStyleValue` object containing
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
value.
This property is only applied to the style if `backgroundPattern` is set to
`nil`. Otherwise, it is ignored.
You can set this property to an instance of:
* `MGLConstantStyleValue`
* `MGLCameraStyleFunction` with an interpolation mode of:
* `MGLInterpolationModeExponential`
* `MGLInterpolationModeInterval`
This property does not support applying interpolation or step functions to
feature attributes.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *backgroundColor;
#endif
@property (nonatomic, null_resettable) NSExpression *backgroundColor;

/**
The transition affecting any changes to this layer’s `backgroundColor` property.
Expand All @@ -88,18 +70,21 @@ which it is added.
/**
The opacity at which the background will be drawn.
The default value of this property is an `MGLStyleValue` object containing an
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
it to the default value.
The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
You can set this property to an instance of:
You can set this property to an expression containing any of the following:
* `MGLConstantStyleValue`
* `MGLCameraStyleFunction` with an interpolation mode of:
* `MGLInterpolationModeExponential`
* `MGLInterpolationModeInterval`
* Constant values
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
* Interpolation and step functions applied to the `$zoomLevel` variable
This property does not support applying interpolation or step functions to
feature attributes.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *backgroundOpacity;
@property (nonatomic, null_resettable) NSExpression *backgroundOpacity;

/**
The transition affecting any changes to this layer’s `backgroundOpacity` property.
Expand All @@ -113,13 +98,19 @@ which it is added.
seamless patterns, image width and height must be a factor of two (2, 4, 8,
..., 512).
You can set this property to an instance of:
You can set this property to an expression containing any of the following:
* Constant values
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
* Step functions applied to the `$zoomLevel` variable
* `MGLConstantStyleValue`
* `MGLCameraStyleFunction` with an interpolation mode of
`MGLInterpolationModeInterval`
This property does not support applying interpolation functions to the
`$zoomLevel` variable or applying interpolation or step functions to feature
attributes.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *backgroundPattern;
@property (nonatomic, null_resettable) NSExpression *backgroundPattern;

/**
The transition affecting any changes to this layer’s `backgroundPattern` property.
Expand Down
24 changes: 12 additions & 12 deletions platform/darwin/src/MGLBackgroundStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ - (instancetype)initWithIdentifier:(NSString *)identifier

#pragma mark - Accessing the Paint Attributes

- (void)setBackgroundColor:(MGLStyleValue<MGLColor *> *)backgroundColor {
- (void)setBackgroundColor:(NSExpression *)backgroundColor {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(backgroundColor);
self.rawLayer->setBackgroundColor(mbglValue);
}

- (MGLStyleValue<MGLColor *> *)backgroundColor {
- (NSExpression *)backgroundColor {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getBackgroundColor();
if (propertyValue.isUndefined()) {
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultBackgroundColor());
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(self.rawLayer->getDefaultBackgroundColor());
}
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
}

- (void)setBackgroundColorTransition:(MGLTransition )transition {
Expand All @@ -67,21 +67,21 @@ - (MGLTransition)backgroundColorTransition {
return transition;
}

- (void)setBackgroundOpacity:(MGLStyleValue<NSNumber *> *)backgroundOpacity {
- (void)setBackgroundOpacity:(NSExpression *)backgroundOpacity {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(backgroundOpacity);
self.rawLayer->setBackgroundOpacity(mbglValue);
}

- (MGLStyleValue<NSNumber *> *)backgroundOpacity {
- (NSExpression *)backgroundOpacity {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getBackgroundOpacity();
if (propertyValue.isUndefined()) {
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultBackgroundOpacity());
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(self.rawLayer->getDefaultBackgroundOpacity());
}
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
}

- (void)setBackgroundOpacityTransition:(MGLTransition )transition {
Expand All @@ -102,21 +102,21 @@ - (MGLTransition)backgroundOpacityTransition {
return transition;
}

- (void)setBackgroundPattern:(MGLStyleValue<NSString *> *)backgroundPattern {
- (void)setBackgroundPattern:(NSExpression *)backgroundPattern {
MGLAssertStyleLayerIsValid();

auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(backgroundPattern);
self.rawLayer->setBackgroundPattern(mbglValue);
}

- (MGLStyleValue<NSString *> *)backgroundPattern {
- (NSExpression *)backgroundPattern {
MGLAssertStyleLayerIsValid();

auto propertyValue = self.rawLayer->getBackgroundPattern();
if (propertyValue.isUndefined()) {
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultBackgroundPattern());
return MGLStyleValueTransformer<std::string, NSString *>().toExpression(self.rawLayer->getDefaultBackgroundPattern());
}
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
return MGLStyleValueTransformer<std::string, NSString *>().toExpression(propertyValue);
}

- (void)setBackgroundPatternTransition:(MGLTransition )transition {
Expand Down
Loading

0 comments on commit 1ae15d5

Please sign in to comment.