Repository navigation
Layer ownership refactor - #6904
Conversation
|
@fabian-guerra, thanks for your PR! By analyzing the history of the files in this pull request, we identified @boundsj, @1ec5 and @incanus to be potential reviewers. |
There was a problem hiding this comment.
I didn't meant to merge this storyboard.
3970310 to
4903b19
Compare
…GLForegroundStyleLayer subclasses
| @property (nonatomic, null_resettable) MGLStyleValue<NSString *> *fillPattern; | ||
|
|
||
|
|
||
| - (void)addToMapView:(MGLMapView *)mapView; |
There was a problem hiding this comment.
This method needs to be private. We want developers to continue to call -[MGLStyle addLayer:] or -[MGLStyle insertLayer:belowLayer:] as appropriate. To avoid having to create a separate private header for each layer subclass, declare it in the private header for MGLStyle.
There was a problem hiding this comment.
Er, I meant the private header for MGLStyleLayer, MGLStyleLayer_Private.h.
| // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. | ||
|
|
||
| #import "MGLSource.h" | ||
| #import "MGLMapView_Private.h" |
There was a problem hiding this comment.
These changes will eventually need to happen in all the style layer subclasses. We have a script (mentioned above) that automatically generates these headers. So when you're ready, update the templates that the script uses (the .ejs files in this directory) and run make style-code-darwin. Don't do that until you've updated the templates with your changes, though!
There was a problem hiding this comment.
I have updated the script to import MGLMapView_Private.h
…dated to import MGLMapView_Private header
boundsj
left a comment
There was a problem hiding this comment.
@fabian-guerra I think this is looking good! Adding a few suggestions here but nothing major.
| { | ||
| if (self = [super initWithIdentifier:identifier source:source]) { | ||
| _layer = new mbgl::style::<%- camelize(type) %>Layer(identifier.UTF8String, source.identifier.UTF8String); | ||
| [self commonInit:identifier source:source]; |
There was a problem hiding this comment.
Not a big deal but the commonInit pattern is typically used when there is some shared logic that needs to be called by several different initializers and/or something that happens in init also happens latter on. In this case it might be clearer to just do the work in initWithIdentifier:source: itself.
| @interface MGLStyleLayer (Private) | ||
|
|
||
| @property (nonatomic, readwrite, copy) NSString *identifier; | ||
| @property (nonatomic) mbgl::style::Layer *layer; |
There was a problem hiding this comment.
For future reference, I think we should add documentation for this property like we did in MGLSource_Private.h for the rawSource property. When coming back to this code (or looking at it for the first time) it is not immediately obvious that this is a raw pointer that is useable even after layer ownership is transferred in addToMapView:. Also, for consistency, it might be worth considering renaming this to rawLayer (or naming [MGLSource rawSource] to [MGLSource source] (again)).
…add StyleLayers to map

Fixes #6254
cc @boundsj @1ec5