Swiftgram/AsyncDisplayKit/Layout/ASStaticLayoutNodeDimension.h
Huy Nguyen 99fe79339d Simplify ASDimension:
- ASRelativeSize and ASRelativeSizeRange are used only by ASStaticLayoutNode. They are declared in a standalone header.
- ASDimension contains a minimal set of new size types required to use the common layouts. Thus minimize the learning curve.
2015-06-25 11:36:02 +07:00

74 lines
2.5 KiB
Objective-C

/*
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <AsyncDisplayKit/ASDimension.h>
/**
Expresses a size with relative dimensions.
Used by ASStaticLayoutNode.
*/
typedef struct {
ASRelativeDimension width;
ASRelativeDimension height;
} ASRelativeSize;
/**
Expresses an inclusive range of relative sizes. Used to provide additional constraint to layout.
Used by ASStaticLayoutNode.
*/
typedef struct {
ASRelativeSize min;
ASRelativeSize max;
} ASRelativeSizeRange;
extern ASRelativeSizeRange const ASRelativeSizeRangeUnconstrained;
ASDISPLAYNODE_EXTERN_C_BEGIN
#pragma mark -
#pragma mark ASRelativeSize
extern ASRelativeSize ASRelativeSizeMake(ASRelativeDimension width, ASRelativeDimension height);
/** Convenience constructor to provide size in Points. */
extern ASRelativeSize ASRelativeSizeMakeWithCGSize(CGSize size);
/** Resolve this relative size relative to a parent size. */
extern CGSize ASRelativeSizeResolve(ASRelativeSize relativeSize, CGSize parentSize);
extern BOOL ASRelativeSizeEqualToRelativeSize(ASRelativeSize lhs, ASRelativeSize rhs);
extern NSString *NSStringFromASRelativeSize(ASRelativeSize size);
#pragma mark -
#pragma mark ASRelativeSizeRange
extern ASRelativeSizeRange ASRelativeSizeRangeMake(ASRelativeSize min, ASRelativeSize max);
#pragma mark Convenience constructors to provide an exact size (min == max).
extern ASRelativeSizeRange ASRelativeSizeRangeMakeWithExactRelativeSize(ASRelativeSize exact);
extern ASRelativeSizeRange ASRelativeSizeRangeMakeWithExactCGSize(CGSize exact);
extern ASRelativeSizeRange ASRelativeSizeRangeMakeWithExactRelativeDimensions(ASRelativeDimension exactWidth,
ASRelativeDimension exactHeight);
extern BOOL ASRelativeSizeRangeEqualToRelativeSizeRange(ASRelativeSizeRange lhs, ASRelativeSizeRange rhs);
/**
Provided a parent size, compute final dimensions for this RelativeSizeRange to arrive at a SizeRange.
*/
extern ASSizeRange ASRelativeSizeRangeResolve(ASRelativeSizeRange relativeSizeRange,
CGSize parentSize);
ASDISPLAYNODE_EXTERN_C_END