Swiftgram/Source/Layout/ASRelativeLayoutSpec.h
appleguy 465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9717d871dd16c4b07539f2f8208fc2b.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00

88 lines
4.0 KiB
Objective-C

//
// ASRelativeLayoutSpec.h
// Texture
//
// Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
// Changes after 4/13/2017 are: Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import <AsyncDisplayKit/ASLayoutSpec.h>
/**
* How the child is positioned within the spec.
*
* The default option will position the child at point 0.
* Swift: use [] for the default behavior.
*/
typedef NS_ENUM(NSUInteger, ASRelativeLayoutSpecPosition) {
/** The child is positioned at point 0 */
ASRelativeLayoutSpecPositionNone = 0,
/** The child is positioned at point 0 relatively to the layout axis (ie left / top most) */
ASRelativeLayoutSpecPositionStart = 1,
/** The child is centered along the specified axis */
ASRelativeLayoutSpecPositionCenter = 2,
/** The child is positioned at the maximum point of the layout axis (ie right / bottom most) */
ASRelativeLayoutSpecPositionEnd = 3,
};
/**
* How much space the spec will take up.
*
* The default option will allow the spec to take up the maximum size possible.
* Swift: use [] for the default behavior.
*/
typedef NS_OPTIONS(NSUInteger, ASRelativeLayoutSpecSizingOption) {
/** The spec will take up the maximum size possible */
ASRelativeLayoutSpecSizingOptionDefault,
/** The spec will take up the minimum size possible along the X axis */
ASRelativeLayoutSpecSizingOptionMinimumWidth = 1 << 0,
/** The spec will take up the minimum size possible along the Y axis */
ASRelativeLayoutSpecSizingOptionMinimumHeight = 1 << 1,
/** Convenience option to take up the minimum size along both the X and Y axis */
ASRelativeLayoutSpecSizingOptionMinimumSize = ASRelativeLayoutSpecSizingOptionMinimumWidth | ASRelativeLayoutSpecSizingOptionMinimumHeight,
};
NS_ASSUME_NONNULL_BEGIN
/** Lays out a single layoutElement child and positions it within the layout bounds according to vertical and horizontal positional specifiers.
* Can position the child at any of the 4 corners, or the middle of any of the 4 edges, as well as the center - similar to "9-part" image areas.
*/
@interface ASRelativeLayoutSpec : ASLayoutSpec
// You may create a spec with alloc / init, then set any non-default properties; or use a convenience initialize that accepts all properties.
@property (nonatomic) ASRelativeLayoutSpecPosition horizontalPosition;
@property (nonatomic) ASRelativeLayoutSpecPosition verticalPosition;
@property (nonatomic) ASRelativeLayoutSpecSizingOption sizingOption;
/*!
* @discussion convenience constructor for a ASRelativeLayoutSpec
* @param horizontalPosition how to position the item on the horizontal (x) axis
* @param verticalPosition how to position the item on the vertical (y) axis
* @param sizingOption how much size to take up
* @param child the child to layout
* @return a configured ASRelativeLayoutSpec
*/
+ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption
child:(id<ASLayoutElement>)child NS_RETURNS_RETAINED AS_WARN_UNUSED_RESULT;
/*!
* @discussion convenience initializer for a ASRelativeLayoutSpec
* @param horizontalPosition how to position the item on the horizontal (x) axis
* @param verticalPosition how to position the item on the vertical (y) axis
* @param sizingOption how much size to take up
* @param child the child to layout
* @return a configured ASRelativeLayoutSpec
*/
- (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption
child:(id<ASLayoutElement>)child;
@end
NS_ASSUME_NONNULL_END