Swiftgram/AsyncDisplayKit/Layout/ASCenterLayoutNode.h
Huy Nguyen f8531f467d Add Layout nodes.
- The code is forked from LayoutComponents in ComponentKit.
- Public interfaces are modified to be strictly Objective-C. As a result, users are not forced to switch to Objective-C++, the linker can happily compile and Swift fans can continue using the mighty ASDK.
2015-06-25 11:32:30 +07:00

49 lines
2.1 KiB
Objective-C

/*
* Copyright (c) 2014-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 <AsyncDisplayKit/ASLayoutNode.h>
typedef NS_OPTIONS(NSUInteger, ASCenterLayoutNodeCenteringOptions) {
/** The child is positioned in {0,0} relatively to the layout bounds */
ASCenterLayoutNodeCenteringNone = 0,
/** The child is centered along the X axis */
ASCenterLayoutNodeCenteringX = 1 << 0,
/** The child is centered along the Y axis */
ASCenterLayoutNodeCenteringY = 1 << 1,
/** Convenience option to center both along the X and Y axis */
ASCenterLayoutNodeCenteringXY = ASCenterLayoutNodeCenteringX | ASCenterLayoutNodeCenteringY
};
typedef NS_OPTIONS(NSUInteger, ASCenterLayoutNodeSizingOptions) {
/** The node will take up the maximum size possible */
ASCenterLayoutNodeSizingOptionDefault,
/** The node will take up the minimum size possible along the X axis */
ASCenterLayoutNodeSizingOptionMinimumX = 1 << 0,
/** The node will take up the minimum size possible along the Y axis */
ASCenterLayoutNodeSizingOptionMinimumY = 1 << 1,
/** Convenience option to take up the minimum size along both the X and Y axis */
ASCenterLayoutNodeSizingOptionMinimumXY = ASCenterLayoutNodeSizingOptionMinimumX | ASCenterLayoutNodeSizingOptionMinimumY,
};
/** Lays out a single child layout node and position it so that it is centered into the layout bounds. */
@interface ASCenterLayoutNode : ASLayoutNode
/**
@param centeringOptions, see ASCenterLayoutNodeCenteringOptions.
@param child The child to center.
@param size The node size or {} for the default which is for the layout to take the maximum space available.
*/
+ (instancetype)newWithCenteringOptions:(ASCenterLayoutNodeCenteringOptions)centeringOptions
sizingOptions:(ASCenterLayoutNodeSizingOptions)sizingOptions
child:(ASLayoutNode *)child
size:(ASLayoutNodeSize)size;
@end