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

Per-attribute transition properties on MGLStyleLayer #8225

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[ios, macos] The impl for transition properties were changed to publi…
…c methods
  • Loading branch information
fabian-guerra committed Mar 10, 2017
commit 5a180981be036b726dab93720c7a50ca2cd5c97e
15 changes: 15 additions & 0 deletions platform/darwin/src/MGLBackgroundStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ MGL_EXPORT
@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *backgroundColor;
#endif

/**
`backgroundColor` transition attributes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transition affecting any changes to this layer’s backgroundColor property.

This property corresponds to the background-color-transition property in the style JSON file format.

(We can't quite say "in the Mapbox Style Specification", as we do elsewhere, because of mapbox/mapbox-gl-js#4081.)

*/
@property (nonatomic) MGLTransition backgroundColorTransition;

/**
The opacity at which the background will be drawn.

Expand All @@ -84,6 +89,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *backgroundOpacity;

/**
`backgroundOpacity` transition attributes.
*/
@property (nonatomic) MGLTransition backgroundOpacityTransition;

/**
Name of image in style images to use for drawing an image background. For
seamless patterns, image width and height must be a factor of two (2, 4, 8,
Expand All @@ -97,6 +107,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *backgroundPattern;

/**
`backgroundPattern` transition attributes.
*/
@property (nonatomic) MGLTransition backgroundPatternTransition;

@end

NS_ASSUME_NONNULL_END
78 changes: 27 additions & 51 deletions platform/darwin/src/MGLBackgroundStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,13 @@ - (void)removeFromMapView:(MGLMapView *)mapView

#pragma mark - Accessing the Paint Attributes

+ (NSArray *)transitionKeys
{
return @[
@"backgroundColor",
@"backgroundOpacity",
@"backgroundPattern",
];
}

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

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

- (void)mbx_setBackgroundColorTransition:(NSValue *)transitionValue {
MGLAssertStyleLayerIsValid();

MGLTransition transition;
[transitionValue getValue:&transition];

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundColorTransition(options);
}

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

Expand All @@ -121,35 +102,30 @@ - (void)mbx_setBackgroundColorTransition:(NSValue *)transitionValue {
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
}

- (NSValue *)mbx_getBackgroundColorTransition {
- (void)setBackgroundColorTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundColorTransition(options);
}

- (MGLTransition)backgroundColorTransition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundColorTransition();
MGLTransition transition;
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));

NSValue *transitionValue = [NSValue value:&transition withObjCType:@encode(MGLTransition)];
return transitionValue;
return transition;
}

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

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

- (void)mbx_setBackgroundOpacityTransition:(NSValue *)transitionValue {
MGLAssertStyleLayerIsValid();

MGLTransition transition;
[transitionValue getValue:&transition];

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundOpacityTransition(options);
}

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

Expand All @@ -160,35 +136,30 @@ - (void)mbx_setBackgroundOpacityTransition:(NSValue *)transitionValue {
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
}

- (NSValue *)mbx_getBackgroundOpacityTransition {
- (void)setBackgroundOpacityTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundOpacityTransition(options);
}

- (MGLTransition)backgroundOpacityTransition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundOpacityTransition();
MGLTransition transition;
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));

NSValue *transitionValue = [NSValue value:&transition withObjCType:@encode(MGLTransition)];
return transitionValue;
return transition;
}

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

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

- (void)mbx_setBackgroundPatternTransition:(NSValue *)transitionValue {
MGLAssertStyleLayerIsValid();

MGLTransition transition;
[transitionValue getValue:&transition];

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundPatternTransition(options);
}

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

Expand All @@ -199,17 +170,22 @@ - (void)mbx_setBackgroundPatternTransition:(NSValue *)transitionValue {
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
}

- (NSValue *)mbx_getBackgroundPatternTransition {
- (void)setBackgroundPatternTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
self.rawLayer->setBackgroundPatternTransition(options);
}

- (MGLTransition)backgroundPatternTransition {
MGLAssertStyleLayerIsValid();

mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundPatternTransition();
MGLTransition transition;
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));

NSValue *transitionValue = [NSValue value:&transition withObjCType:@encode(MGLTransition)];
return transitionValue;
return transition;
}


@end
42 changes: 42 additions & 0 deletions platform/darwin/src/MGLCircleStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleBlur;

/**
`circleBlur` transition attributes.
*/
@property (nonatomic) MGLTransition circleBlurTransition;

#if TARGET_OS_IPHONE
/**
The fill color of the circle.
Expand Down Expand Up @@ -159,6 +164,11 @@ MGL_EXPORT
@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *circleColor;
#endif

/**
`circleColor` transition attributes.
*/
@property (nonatomic) MGLTransition circleColorTransition;

/**
The opacity at which the circle will be drawn.

Expand All @@ -184,6 +194,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleOpacity;

/**
`circleOpacity` transition attributes.
*/
@property (nonatomic) MGLTransition circleOpacityTransition;

/**
Circle radius.

Expand Down Expand Up @@ -211,6 +226,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleRadius;

/**
`circleRadius` transition attributes.
*/
@property (nonatomic) MGLTransition circleRadiusTransition;

/**
Controls the scaling behavior of the circle when the map is pitched.

Expand All @@ -230,6 +250,7 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleScaleAlignment;


@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circlePitchScale __attribute__((unavailable("Use circleScaleAlignment instead.")));

#if TARGET_OS_IPHONE
Expand Down Expand Up @@ -284,6 +305,11 @@ MGL_EXPORT
@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *circleStrokeColor;
#endif

/**
`circleStrokeColor` transition attributes.
*/
@property (nonatomic) MGLTransition circleStrokeColorTransition;

/**
The opacity of the circle's stroke.

Expand All @@ -309,6 +335,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleStrokeOpacity;

/**
`circleStrokeOpacity` transition attributes.
*/
@property (nonatomic) MGLTransition circleStrokeOpacityTransition;

/**
The width of the circle's stroke. Strokes are placed outside of the
`circleRadius`.
Expand Down Expand Up @@ -337,6 +368,11 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *circleStrokeWidth;

/**
`circleStrokeWidth` transition attributes.
*/
@property (nonatomic) MGLTransition circleStrokeWidthTransition;

#if TARGET_OS_IPHONE
/**
The geometry's offset.
Expand Down Expand Up @@ -383,6 +419,11 @@ MGL_EXPORT
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslation;
#endif

/**
`circleTranslate` transition attributes.
*/
@property (nonatomic) MGLTransition circleTranslationTransition;

@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslate __attribute__((unavailable("Use circleTranslation instead.")));

/**
Expand All @@ -407,6 +448,7 @@ MGL_EXPORT
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslationAnchor;


@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *circleTranslateAnchor __attribute__((unavailable("Use circleTranslationAnchor instead.")));

@end
Expand Down
Loading