Files
MapLibreParticleLab/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm
Minh Nguyễn 0a4f0e40ec [ios, macos] Offsets as vectors, padding as edge insets
An offset style attribute is now exposed publicly as an NSValue representing a CGVector instead of an NSArray of NSNumbers. A padding style attribute is now exposed publicly as an NSValue representing an NSEdgeInsets or UIEdgeInsets instead of an NSArray of NSNumbers. This change also fixes round-tripping of padding values due to a difference between the style specification and Foundation regarding the order of edges around a box. Used a designated initializer on NSEdgeInsets/UIEdgeInsets to ensure correct order when converting from C++ to Objective-C.

Fixes #5947, fixes #6065.
2016-08-19 15:45:14 -07:00

37 lines
768 B
Plaintext

#import "NSArray+MGLStyleAttributeAdditions.h"
#import "NSArray+MGLStyleAttributeAdditions_Private.h"
#import "MGLStyleAttributeValue_Private.h"
#include <array>
@interface NSArray(Private) <MGLStyleAttributeValue_Private>
@end
@implementation NSArray (MGLStyleAttributeAdditions)
- (mbgl::style::PropertyValue<std::vector<std::string> >)mbgl_stringArrayPropertyValue
{
std::vector<std::string>fonts;
for (NSString *font in self) {
fonts.emplace_back(font.UTF8String);
}
return {{fonts}};
}
- (mbgl::style::PropertyValue<std::vector<float> >)mbgl_numberArrayPropertyValue
{
std::vector<float>values;
for (NSNumber *n in self) {
values.emplace_back(n.floatValue);
}
return {{values}};
}
@end