Repository navigation
Add and remove layers dynamically - #4839
Conversation
There was a problem hiding this comment.
Any way we can move this to Impl?
|
Looks good! As for the generated files, it's probably useful to have them pre-generated to be able to look at them. We could still add the generation script to the build system, and check whether files were modified and fail if that is the case. |
976397a to
67ce67c
Compare
How about running the generation script as part of the build, but having the script output to the checkout, as it does now? |
|
For now I'm going to go with running the generator manually when you make a change. I looked at including it as part of the build step but outputting to the src directory (which I want to do) didn't fit in cleanly with our use of gyp. |
d298ab0 to
00c9500
Compare
|
The last commit here involves a lot of renaming and re-namespacing. Would be great to get a second opinion on my approach:
|
4ac3b87 to
0d8fb9a
Compare
PropertyValue<T> represents the three possible types of style property value: undefined, constant, or function.
This PR implements the first bit of the core runtime styling API: the ability to dynamically add and remove layers.
As appropriate for a C++ API, the layers API is strongly typed: there are subclasses for each layer type, with correctly-typed accessors for each style property. This results in a large API surface area. Fortunately, this is automated, by generating the API – and the regular portion of the implementation – from the style specification.
The layers API makes a distinction between public API and internal implementation using the
Implidiom seen elsewhere in the codebase. Here, it takes the form of two parallel class hierarchies:Layerand its subclasses form the public API.Layer::Impland its subclasses form the internal API.As well as forming the boundary between public and internal, these two class hierarchies form the boundary between generated code and handwritten code. Except for
CustomLayerandCustomLayer::Impl:Layersubclasses are entirely generated. (Layeritself is handwritten.)Layer::Impland its subclasses are entirely handwritten.There is still work to be done before this is ready to be exposed via SDK bindings:
mbgl::stylenamespace andmbgl/styledirectory. (Beneath that directory there can be alayerdirectory for organization.)map.getStyle().getLayer()as the API.Map::{add,remove}Layerwould also move toStyle.