Files
MapLibreParticleLab/platform/darwin/test/MGLRuntimeStylingHelper.m
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

66 lines
1.1 KiB
Objective-C

#import "MGLRuntimeStylingHelper.h"
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import <UIKit/UIKit.h>
#define MGLEdgeInsets UIEdgeInsets
#else
#import <Cocoa/Cocoa.h>
#define MGLEdgeInsets NSEdgeInsets
#endif
@implementation MGLRuntimeStylingHelper
+ (NSValue *)testPadding
{
MGLEdgeInsets insets = {
.top = 1,
.left = 1,
.bottom = 1,
.right = 1,
};
return [NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)];
}
+ (NSValue *)testOffset
{
CGVector vector = CGVectorMake(1, 1);
return [NSValue value:&vector withObjCType:@encode(CGVector)];
}
+ (NSArray *)testFont
{
return @[@"Open Sans Regular", @"Arial Unicode MS Regular"];
}
+ (NSArray *)testDashArray
{
return @[@1, @2];
}
+ (NSNumber *)testNumber
{
return @1;
}
+ (NSNumber *)testBool
{
return @YES;
}
+ (NSString *)testString
{
return @"test";
}
+ (MGLColor *)testColor
{
return [MGLColor redColor];
}
+ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type
{
return [NSValue value:&value withObjCType:type];
}
@end