ASLayout Class Reference

Inherits from NSObject
Declared in ASLayout.h

Overview

A node in the layout tree that represents the size and position of the object that created it (ASLayoutable).

  layoutableObject

The underlying object described by this layout

@property (nonatomic, weak, readonly) id<ASLayoutable> layoutableObject

Declared In

ASLayout.h

  type

The type of ASLayoutable that created this layout

@property (nonatomic, readonly) ASLayoutableType type

Declared In

ASLayout.h

  size

Size of the current layout

@property (nonatomic, readonly) CGSize size

Declared In

ASLayout.h

  position

Position in parent. Default to CGPointNull.

@property (nonatomic, readwrite) CGPoint position

Discussion

When being used as a sublayout, this property must not equal CGPointNull.

Declared In

ASLayout.h

  constrainedSizeRange

The size range that was use to determine the size of the layout.

@property (nonatomic, readonly) ASSizeRange constrainedSizeRange

Declared In

ASLayout.h

  sublayouts

Array of ASLayouts. Each must have a valid non-null position.

@property (nonatomic, readonly) NSArray<ASLayout*> *sublayouts

Declared In

ASLayout.h

  dirty

Mark the layout dirty for future regeneration.

@property (nonatomic, getter=isDirty) BOOL dirty

Declared In

ASLayout.h

  frame

Returns a valid frame for the current layout computed with the size and position.

@property (nonatomic, readonly) CGRect frame

Discussion

Clamps the layout’s origin or position to 0 if any of the calculated values are infinite.

Declared In

ASLayout.h

– initWithLayoutableObject:constrainedSizeRange:size:position:sublayouts:

Designated initializer

- (instancetype)initWithLayoutableObject:(id<ASLayoutable>)layoutableObject constrainedSizeRange:(ASSizeRange)sizeRange size:(CGSize)size position:(CGPoint)position sublayouts:(NSArray *)sublayouts

Declared In

ASLayout.h

+ layoutWithLayoutableObject:constrainedSizeRange:size:position:sublayouts:

Convenience class initializer for layout construction.

+ (instancetype)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject constrainedSizeRange:(ASSizeRange)sizeRange size:(CGSize)size position:(CGPoint)position sublayouts:(nullable NSArray<ASLayout*> *)sublayouts

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

position

The position of this layout within its parent (if available).

sublayouts

Sublayouts belong to the new layout.

Declared In

ASLayout.h

+ layoutWithLayoutableObject:constrainedSizeRange:size:sublayouts:

Convenience initializer that has CGPointNull position. Best used by ASDisplayNode subclasses that are manually creating a layout for -calculateLayoutThatFits:, or for ASLayoutSpec subclasses that are referencing the “self” level in the layout tree, or for creating a sublayout of which the position is yet to be determined.

+ (instancetype)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject constrainedSizeRange:(ASSizeRange)sizeRange size:(CGSize)size sublayouts:(nullable NSArray<ASLayout*> *)sublayouts

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

sublayouts

Sublayouts belong to the new layout.

Declared In

ASLayout.h

+ layoutWithLayoutableObject:constrainedSizeRange:size:

Convenience that has CGPointNull position and no sublayouts. Best used for creating a layout that has no sublayouts, and is either a root one or a sublayout of which the position is yet to be determined.

+ (instancetype)layoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject constrainedSizeRange:(ASSizeRange)sizeRange size:(CGSize)size

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

Declared In

ASLayout.h

+ flattenedLayoutWithLayoutableObject:constrainedSizeRange:size:sublayouts:

Convenience initializer that is flattened and has CGPointNull position.

+ (instancetype)flattenedLayoutWithLayoutableObject:(id<ASLayoutable>)layoutableObject constrainedSizeRange:(ASSizeRange)sizeRange size:(CGSize)size sublayouts:(nullable NSArray<ASLayout*> *)sublayouts

Parameters

layoutableObject

The backing ASLayoutable object.

size

The size of this layout.

sublayouts

Sublayouts belong to the new layout.

Declared In

ASLayout.h

+ layoutWithLayout:position:

Convenience initializer that creates a layout based on the values of the given layout, with a new position

+ (instancetype)layoutWithLayout:(ASLayout *)layout position:(CGPoint)position

Parameters

layout

The layout to use to create the new layout

position

The position of the new layout

Declared In

ASLayout.h

– filteredNodeLayoutTree

Traverses the existing layout tree and generates a new tree that represents only ASDisplayNode layouts

- (ASLayout *)filteredNodeLayoutTree

Declared In

ASLayout.h