forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASRelativeLayoutSpec.h
More file actions
90 lines (79 loc) · 4.16 KB
/
Copy pathASRelativeLayoutSpec.h
File metadata and controls
90 lines (79 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// ASRelativeLayoutSpec.h
// AsyncDisplayKit
//
// Created by Samuel Stow on 12/31/15.
//
// 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/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, assign) ASRelativeLayoutSpecPosition horizontalPosition;
@property (nonatomic, assign) ASRelativeLayoutSpecPosition verticalPosition;
@property (nonatomic, assign) 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 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