mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-05-16 16:01:00 +08:00
Workaround for ensuring creation of visualizerNode for ALL layoutspecs
This commit is contained in:
@@ -31,8 +31,10 @@
|
||||
#import "ASLayoutSpec.h"
|
||||
#import "ASCellNode.h"
|
||||
|
||||
#import "ASLayoutSpec+Debug.h" // FIXME: remove later
|
||||
#import "ASStaticLayoutSpec.h" // FIXME: remove later
|
||||
|
||||
|
||||
NSInteger const ASDefaultDrawingPriority = ASDefaultTransactionPriority;
|
||||
NSString * const ASRenderingEngineDidDisplayScheduledNodesNotification = @"ASRenderingEngineDidDisplayScheduledNodes";
|
||||
NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp = @"ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp";
|
||||
@@ -1791,12 +1793,15 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
||||
{
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
if (_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) {
|
||||
ASLayoutSpec *layoutSpec = [self layoutSpecThatFits:constrainedSize];
|
||||
|
||||
if (ASHierarchyStateIncludesVisualizeLayoutSpecs(_hierarchyState)) {
|
||||
[layoutSpec recursivelySetShouldVisualize:YES];
|
||||
// [layoutSpec recursivelySetShouldVisualize:YES];
|
||||
[ASLayoutSpec setShouldVisualizeLayoutSpecs2:YES];
|
||||
}
|
||||
|
||||
ASStaticLayoutSpec *staticSpec = [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[[self layoutSpecThatFits:constrainedSize]]];
|
||||
|
||||
ASLayoutSpec *layoutSpec = staticSpec;
|
||||
|
||||
layoutSpec.isMutable = NO;
|
||||
ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize];
|
||||
// Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct.
|
||||
@@ -1804,6 +1809,12 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
||||
layout.position = CGPointZero;
|
||||
layout = [ASLayout layoutWithLayoutableObject:self size:layout.size sublayouts:@[layout]];
|
||||
}
|
||||
|
||||
if (ASHierarchyStateIncludesVisualizeLayoutSpecs(_hierarchyState)) {
|
||||
[ASLayoutSpec setShouldVisualizeLayoutSpecs2:NO];
|
||||
}
|
||||
|
||||
|
||||
return [layout flattenedLayoutUsingPredicateBlock:^BOOL(ASLayout *evaluatedLayout) {
|
||||
if (self.usesImplicitHierarchyManagement) {
|
||||
return ASObjectIsEqual(layout, evaluatedLayout) == NO && [evaluatedLayout.layoutableObject isKindOfClass:[ASDisplayNode class]];
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
@interface ASLayoutSpec (Debugging2)
|
||||
|
||||
+ (BOOL)shouldVisualizeLayoutSpecs2;
|
||||
+ (void)setShouldVisualizeLayoutSpecs2:(BOOL)shouldVisualizeLayoutSpecs;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -13,7 +13,16 @@
|
||||
|
||||
@implementation ASLayoutSpec (Debugging2)
|
||||
|
||||
static BOOL __shouldVisualizeLayoutSpecs = NO;
|
||||
+ (BOOL)shouldVisualizeLayoutSpecs2
|
||||
{
|
||||
return __shouldVisualizeLayoutSpecs;
|
||||
}
|
||||
|
||||
+ (void)setShouldVisualizeLayoutSpecs2:(BOOL)shouldVisualizeLayoutSpecs
|
||||
{
|
||||
__shouldVisualizeLayoutSpecs = shouldVisualizeLayoutSpecs;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -36,8 +45,8 @@
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
ASInsetLayoutSpec *insetSpec = [[ASInsetLayoutSpec alloc] init];
|
||||
insetSpec.shouldVisualize = YES;
|
||||
self.layoutSpec.shouldVisualize = YES;
|
||||
insetSpec.neverShouldVisualize = YES;
|
||||
self.layoutSpec.neverShouldVisualize = YES;
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10);
|
||||
insetSpec.insets = insets;
|
||||
insetSpec.child = self.layoutSpec;
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef struct {
|
||||
CGSize min;
|
||||
CGSize max;
|
||||
int32_t transitionID;
|
||||
BOOL visualize;
|
||||
} ASSizeRange;
|
||||
|
||||
extern ASRelativeDimension const ASRelativeDimensionUnconstrained;
|
||||
|
||||
@@ -101,6 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// FIXME:
|
||||
@property (nonatomic, assign) BOOL shouldVisualize;
|
||||
@property (nonatomic, assign) BOOL neverShouldVisualize;
|
||||
- (void)recursivelySetShouldVisualize:(BOOL)visualize;
|
||||
|
||||
@end
|
||||
|
||||
@@ -58,7 +58,7 @@ static NSString * const kDefaultChildrenKey = @"kDefaultChildrenKey";
|
||||
|
||||
- (id<ASLayoutable>)finalLayoutable
|
||||
{
|
||||
return self;
|
||||
return ((!self.neverShouldVisualize && [ASLayoutSpec shouldVisualizeLayoutSpecs2] ) ? [[ASLayoutSpecVisualizerNode alloc] initWithLayoutSpec:self] : self);
|
||||
}
|
||||
|
||||
- (void)recursivelySetShouldVisualize:(BOOL)visualize
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
lpgr.minimumPressDuration = 0.0;
|
||||
lpgr.allowableMovement = CGFLOAT_MAX;
|
||||
[_resizeHandle.view addGestureRecognizer:lpgr];
|
||||
|
||||
[self shouldVisualizeLayoutSpecs:YES];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
_individualColorNode = [[ColorNode alloc] init];
|
||||
_individualColorNode.backgroundColor = [UIColor orangeColor];
|
||||
|
||||
[self shouldVisualizeLayoutSpecs:YES];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user