mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/AsyncDisplayKit git-subtree-mainline: d06f423e0ed3df1fed9bd10d79ee312a9179b632 git-subtree-split: 02bedc12816e251ad71777f9d2578329b6d2bef6
103 lines
2.8 KiB
Objective-C
103 lines
2.8 KiB
Objective-C
//
|
|
// ASDisplayNode+Yoga.h
|
|
// Texture
|
|
//
|
|
// Copyright (c) Pinterest, Inc. All rights reserved.
|
|
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
|
|
#import <AsyncDisplayKit/ASAvailability.h>
|
|
|
|
#if YOGA
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@class ASLayout;
|
|
|
|
AS_EXTERN void ASDisplayNodePerformBlockOnEveryYogaChild(ASDisplayNode * _Nullable node, void(^block)(ASDisplayNode *node));
|
|
|
|
@interface ASDisplayNode (Yoga)
|
|
|
|
@property (copy) NSArray *yogaChildren;
|
|
|
|
- (void)addYogaChild:(ASDisplayNode *)child;
|
|
- (void)removeYogaChild:(ASDisplayNode *)child;
|
|
- (void)insertYogaChild:(ASDisplayNode *)child atIndex:(NSUInteger)index;
|
|
|
|
- (void)semanticContentAttributeDidChange:(UISemanticContentAttribute)attribute;
|
|
|
|
@property BOOL yogaLayoutInProgress;
|
|
// TODO: Make this atomic (lock).
|
|
@property (nullable, nonatomic) ASLayout *yogaCalculatedLayout;
|
|
|
|
// Will walk up the Yoga tree and returns the root node
|
|
- (ASDisplayNode *)yogaRoot;
|
|
|
|
|
|
@end
|
|
|
|
@interface ASDisplayNode (YogaLocking)
|
|
/**
|
|
* @discussion Attempts(spinning) to lock all node up to root node when yoga is enabled.
|
|
* This will lock self when yoga is not enabled;
|
|
*/
|
|
- (ASLockSet)lockToRootIfNeededForLayout;
|
|
|
|
@end
|
|
|
|
|
|
// These methods are intended to be used internally to Texture, and should not be called directly.
|
|
@interface ASDisplayNode (YogaInternal)
|
|
|
|
/// For internal usage only
|
|
- (BOOL)shouldHaveYogaMeasureFunc;
|
|
/// For internal usage only
|
|
- (ASLayout *)calculateLayoutYoga:(ASSizeRange)constrainedSize;
|
|
/// For internal usage only
|
|
- (void)calculateLayoutFromYogaRoot:(ASSizeRange)rootConstrainedSize;
|
|
/// For internal usage only
|
|
- (void)invalidateCalculatedYogaLayout;
|
|
/**
|
|
* @discussion return true only when yoga enabled and the node is in yoga tree and the node is
|
|
* not leaf that implemented measure function.
|
|
*/
|
|
- (BOOL)locked_shouldLayoutFromYogaRoot;
|
|
|
|
@end
|
|
|
|
@interface ASDisplayNode (YogaDebugging)
|
|
|
|
- (NSString *)yogaTreeDescription;
|
|
|
|
@end
|
|
|
|
@interface ASLayoutElementStyle (Yoga)
|
|
|
|
- (YGNodeRef)yogaNodeCreateIfNeeded;
|
|
- (void)destroyYogaNode;
|
|
|
|
@property (readonly) YGNodeRef yogaNode;
|
|
|
|
@property ASStackLayoutDirection flexDirection;
|
|
@property YGDirection direction;
|
|
@property ASStackLayoutJustifyContent justifyContent;
|
|
@property ASStackLayoutAlignItems alignItems;
|
|
@property YGPositionType positionType;
|
|
@property ASEdgeInsets position;
|
|
@property ASEdgeInsets margin;
|
|
@property ASEdgeInsets padding;
|
|
@property ASEdgeInsets border;
|
|
@property CGFloat aspectRatio;
|
|
@property YGWrap flexWrap;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
// When Yoga is enabled, there are several points where we want to lock the tree to the root but otherwise (without Yoga)
|
|
// will want to simply lock self.
|
|
#define ASScopedLockSelfOrToRoot() ASScopedLockSet lockSet = [self lockToRootIfNeededForLayout]
|
|
#else
|
|
#define ASScopedLockSelfOrToRoot() ASLockScopeSelf()
|
|
#endif
|