Remove ASLayoutChild. ASLayout now has a position property defaults to (NAN, NAN).

This commit is contained in:
Huy Nguyen
2015-06-30 17:10:17 +07:00
parent e74823bbee
commit 4799a9d206
11 changed files with 79 additions and 54 deletions

View File

@@ -12,35 +12,45 @@
#import <AsyncDisplayKit/ASAssert.h>
#import <AsyncDisplayKit/ASLayoutable.h>
/** Represents the computed size of a layout node, as well as the computed sizes and positions of its children. */
extern CGPoint const CGPointNull;
extern BOOL CGPointIsNull(CGPoint point);
/** Represents a computed immutable layout tree. */
@interface ASLayout : NSObject
@property (nonatomic, readonly) id<ASLayoutable> layoutableObject;
@property (nonatomic, readonly) CGSize size;
/**
* Position parent (if any). Default to CGPointNull.
*
* @discussion Before being used as a child layout, this property must be set and no longer equal CGPointNull.
*
* @discussion Unlike all other properties, this property is read-write because often by initializaion time, it has yet been determined.
* To enforce immutability, this property can be set once and only once.
*
*/
@property (nonatomic, readwrite) CGPoint position;
/**
* Each item is of type ASLayoutChild.
* Array of ASLayout children. Each child must have a valid non-null position.
*/
@property (nonatomic, readonly) NSArray *children;
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject
size:(CGSize)size
position:(CGPoint)position
children:(NSArray *)children;
/**
* Convenience that does not have any children.
* Convenience that has CGPointNull position.
*/
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject
size:(CGSize)size
children:(NSArray *)children;
/**
* Convenience that has CGPointNull position and no children.
*/
+ (instancetype)newWithLayoutableObject:(id<ASLayoutable>)layoutableObject size:(CGSize)size;
@end
@interface ASLayoutChild : NSObject
@property (nonatomic, readonly) CGPoint position;
@property (nonatomic, readonly) ASLayout *layout;
/**
* Designated initializer
*/
+ (instancetype)newWithPosition:(CGPoint)position layout:(ASLayout *)layout;
@end