This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLStyle key-value coding compliance #6097
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7670444
[ios, macos] Added debug descriptions for runtime styling classes
1ec5 f71dd14
[ios, macos] Reorganized MGLStyle
1ec5 850b70f
[core, ios, macos] Added layers and sources properties to MGLStyle
1ec5 9fac640
[ios, macos] Key-value compliance for MGLStyle
1ec5 03a2dbe
[macos] Avoid first responder action name conflict
1ec5 992726a
[macos] Added Layers sidebar
1ec5 f611355
[macos] Name custom style in toolbar
1ec5 83e134e
[macos] Added option to localize labels
1ec5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ static const NSInteger MGLStyleDefaultVersion = 9; | |
*/ | ||
@interface MGLStyle : NSObject | ||
|
||
#pragma mark Default Style URLs | ||
#pragma mark Accessing Common Styles | ||
|
||
/** | ||
Returns the URL to version 8 of the | ||
|
@@ -165,33 +165,61 @@ static const NSInteger MGLStyleDefaultVersion = 9; | |
*/ | ||
+ (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; | ||
|
||
#pragma mark Accessing Metadata About the Style | ||
|
||
/** | ||
The name of the style. | ||
|
||
You can customize the style’s name in Mapbox Studio. | ||
*/ | ||
@property (readonly, copy, nullable) NSString *name; | ||
|
||
#pragma mark Runtime Styling | ||
#pragma mark Managing Sources | ||
|
||
/** | ||
Returns a layer that conforms to `MGLStyleLayer` if any layer with the given | ||
identifier was found. | ||
|
||
@return An instance of a concrete subclass of `MGLStyleLayer` associated with | ||
the given identifier. | ||
A set containing the style’s sources. | ||
*/ | ||
- (nullable MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier; | ||
|
||
@property (nonatomic, strong) NS_MUTABLE_SET_OF(MGLSource *) *sources; | ||
|
||
/** | ||
Returns a source if any source with the given identifier was found. | ||
Returns a source with the given identifier in the current style. | ||
|
||
@return An instance of a concrete subclass of `MGLSource` associated with the | ||
given identifier. | ||
given identifier, or `nil` if the current style contains no such source. | ||
*/ | ||
- (nullable MGLSource *)sourceWithIdentifier:(NSString *)identifier; | ||
|
||
/** | ||
Adds a new source to the current style. | ||
|
||
@param source The source to add to the current style. | ||
*/ | ||
- (void)addSource:(MGLSource *)source; | ||
|
||
/** | ||
Removes a source from the current style. | ||
|
||
@param source The source to remove from the current style. | ||
*/ | ||
- (void)removeSource:(MGLSource *)source; | ||
|
||
#pragma mark Managing Style Layers | ||
|
||
/** | ||
The layers included in the style, arranged according to their front-to-back | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be somewhat heretical to arrange the |
||
ordering on the screen. | ||
*/ | ||
@property (nonatomic, strong) NS_MUTABLE_ARRAY_OF(MGLStyleLayer *) *layers; | ||
|
||
/** | ||
Returns a style layer with the given identifier in the current style. | ||
|
||
@return An instance of a concrete subclass of `MGLStyleLayer` associated with | ||
the given identifier, or `nil` if the current style contains no such style | ||
layer. | ||
*/ | ||
- (nullable MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier; | ||
|
||
/** | ||
Adds a new layer on top of existing layers. | ||
|
||
|
@@ -201,34 +229,40 @@ static const NSInteger MGLStyleDefaultVersion = 9; | |
- (void)addLayer:(MGLStyleLayer *)layer; | ||
|
||
/** | ||
Inserts a new layer below another layer. | ||
|
||
@param layer Layer to be inserted. | ||
@param belowLayer A layer that's already on the map view. | ||
Inserts a new layer into the style at the given index. | ||
|
||
@param layer The layer to insert. | ||
@param index The index at which to insert the layer. An index of 0 would send | ||
the layer to the back; an index equal to the number of objects in the | ||
`layers` property would bring the layer to the front. | ||
*/ | ||
- (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)otherLayer; | ||
- (void)insertLayer:(MGLStyleLayer *)layer atIndex:(NSUInteger)index; | ||
|
||
/** | ||
Removes a layer from the map view. | ||
Inserts a new layer below another layer. | ||
|
||
@param layer The layer object to remove from the map view. This object | ||
must conform to the `MGLStyleLayer` protocol. | ||
@param layer The layer to insert. | ||
@param sibling An existing layer in the style. | ||
*/ | ||
- (void)removeLayer:(MGLStyleLayer *)layer; | ||
- (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)sibling; | ||
|
||
/** | ||
Adds a new source to the map view. | ||
Inserts a new layer above another layer. | ||
|
||
@param source The source to add to the map view. | ||
@param layer The layer to insert. | ||
@param sibling An existing layer in the style. | ||
*/ | ||
- (void)addSource:(MGLSource *)source; | ||
- (void)insertLayer:(MGLStyleLayer *)layer aboveLayer:(MGLStyleLayer *)sibling; | ||
|
||
/** | ||
Removes a source from the map view. | ||
Removes a layer from the map view. | ||
|
||
@param source The source to remove. | ||
@param layer The layer object to remove from the map view. This object | ||
must conform to the `MGLStyleLayer` protocol. | ||
*/ | ||
- (void)removeSource:(MGLSource *)source; | ||
- (void)removeLayer:(MGLStyleLayer *)layer; | ||
|
||
#pragma mark Managing Style Classes | ||
|
||
/** | ||
Currently active style classes, represented as an array of string identifiers. | ||
|
@@ -258,12 +292,14 @@ static const NSInteger MGLStyleDefaultVersion = 9; | |
*/ | ||
- (void)removeStyleClass:(NSString *)styleClass; | ||
|
||
/** | ||
Adds or overrides an image used by the style’s layers. | ||
|
||
To use an image in a style layer, give it a unique name using this method, | ||
then set the `iconImage` property of an `MGLSymbolStyleLayer` object to that name. | ||
#pragma mark Managing a Style’s Images | ||
|
||
/** | ||
Adds or overrides an image used by the style’s layers. | ||
|
||
To use an image in a style layer, give it a unique name using this method, then | ||
set the `iconImage` property of an `MGLSymbolStyleLayer` object to that name. | ||
|
||
@param image The image for the name. | ||
@param name The name of the image to set to the style. | ||
*/ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not part of this PR, but this cast is undefined behavior. You need to write something like:
And be aware that this will return a null
unique_ptr
(and deallocate the input) if thedynamic_cast
fails, i.e. if the input is not the anticipated derived type. In this particular code, it looks like this could happen if the user was aliasing*StyleLayer
objects while at the same time removing a layer and adding another layer with the same identifier but a different layer type.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.
→ #7211