-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Convert NSColor/UIColor expressions to CSS color string values #8025
Conversation
@1ec5, thanks for your PR! By analyzing this pull request, we identified @incanus, @jfirebaugh and @boundsj to be potential reviewers. |
platform/darwin/src/MGLFeature.h
Outdated
`halfway`. | ||
|
||
The `MGLSymbolStyleLayer.textField` and `MGLSymbolStyleLayer.iconImageName` | ||
properties use attributes in a slightly different way. For example, to label |
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.
It might be more accurate to say that these properties "can use attributes in a slightly different way", or "can also use attributes in a second way" -- because once #7944 goes in, the source-function-based approach described in the previous paragraph would also apply to these.
…values When converting a constant NSExpression to an mbgl::Value, turn an NSColor or UIColor into an std::string containing a CSS color string. This allows developers to set an attribute of an MGLFeature to an NSColor or UIColor (rather than a CSS color string, which would be foreign), then use it in an MGLStyleFunction with identity interpolation.
03cdf6a
to
556afae
Compare
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.
LGTM -- one comment inline, but not gonna hold up the Approve for that, since I'm not familiar with the docs overall.
attribute to each of the source’s features, then set | ||
`MGLCircleStyleLayer.circleRadius` to an `MGLStyleValue` object with an | ||
interpolation mode of `MGLInterpolationModeIdentity` and an attribute name of | ||
`halfway`. |
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.
Ack, this didn't occur to me earlier, but would this be a good place to suggest referring to the DDS support tables to for those properties where ^ this approach is actually available?
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.
MGLCircleStyleLayer.circleRadius
will link automatically to the documentation for that property, which like all layout and paint properties will list the interpolation modes and function types that are supported. I would like to refer the developer to a guide on data-driven styling, once it’s written as part of #7924.
When converting a constant NSExpression to an
mbgl::Value
, turn an NSColor or UIColor into anstd::string
containing a CSS color string. This allows developers to set an attribute of an MGLFeature to an NSColor or UIColor (rather than a CSS color string, which would be foreign), then use it in an MGLStyleFunction with identity interpolation.Along the way, I added language to
MGLFeature.attributes
’ documentation to talk about the use of feature attributes in identity-interpolated style functions. I also simplified the NSExpression unit tests to more specifically test the category methods that convert constant NSExpressions tombgl::Value
s, without going through NSPredicate. Normally I’d be hesitant to rely so heavily on macros, which makes debugging more difficult, but the existing tests rely onfor
loops, which make test failures just as difficult to diagnose./cc @boundsj @jfirebaugh