Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default tuning params #1158

Merged
merged 38 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
929d118
fix SIMULATE_WEB_RESPONSE not imported #449
wsdwsd0829 Jul 16, 2017
dd24d8f
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Sep 6, 2017
b8eaffa
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Oct 4, 2017
2918ea0
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Oct 11, 2017
9c42266
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Oct 12, 2017
329f35f
Fix to make rangeMode update in right time
wsdwsd0829 Feb 5, 2018
5f8b7ec
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Feb 7, 2018
d87bb11
merge master from upstream
wsdwsd0829 Feb 15, 2018
269c2ab
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Mar 10, 2018
24c1ce8
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Mar 12, 2018
233169e
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Mar 26, 2018
b19f90d
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Mar 28, 2018
b50cec4
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Apr 5, 2018
b75a5f3
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 May 3, 2018
64b46e0
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 May 16, 2018
5fabc1e
remove uncessary assert
wsdwsd0829 May 17, 2018
3d5b84b
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 May 21, 2018
098b978
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Jun 8, 2018
77eefd6
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Jun 13, 2018
0310ed7
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Jul 3, 2018
0b886de
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Jul 25, 2018
a63d438
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Aug 21, 2018
06e18a1
Fix collection cell editing bug for iOS 9 & 10
wsdwsd0829 Aug 22, 2018
918434d
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Aug 31, 2018
41d3680
Revert "Fix collection cell editing bug for iOS 9 & 10"
wsdwsd0829 Sep 10, 2018
34833a3
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Sep 19, 2018
8d82d21
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Sep 25, 2018
91d6c46
Only test when photo library is enabled.
wsdwsd0829 Sep 27, 2018
e397bfc
Add ChangeLog.
wsdwsd0829 Sep 27, 2018
2e09fc0
set default tuning parameters for collection/table node
wsdwsd0829 Oct 3, 2018
f02d47c
Merge branch 'master' of github.com:TextureGroup/Texture
wsdwsd0829 Oct 3, 2018
d2d5afd
Merge branch 'master' into set-default-tuning-params
wsdwsd0829 Oct 3, 2018
08a4e70
add change log
wsdwsd0829 Oct 3, 2018
7c4c529
Move to framework private.
wsdwsd0829 Oct 5, 2018
9575d92
Apply to tableNode
wsdwsd0829 Oct 5, 2018
7ed9ebe
trigger ci
wsdwsd0829 Oct 8, 2018
f878da2
fix directory
wsdwsd0829 Oct 8, 2018
31f3be6
fix file link
wsdwsd0829 Oct 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions AsyncDisplayKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (instancetype)init
self = [super init];
if (self) {
_rangeMode = ASLayoutRangeModeUnspecified;
_tuningParameters = std::vector<std::vector<ASRangeTuningParameters>> (ASLayoutRangeModeCount, std::vector<ASRangeTuningParameters> (ASLayoutRangeTypeCount, ASRangeTuningParametersZero));
_tuningParameters = [ASAbstractLayoutController defaultTuningParameters];
_allowsSelection = YES;
_allowsMultipleSelection = NO;
_inverted = NO;
Expand Down Expand Up @@ -220,11 +220,9 @@ - (void)didLoad
let tuningParametersVectorRangeModeSize = tuningparametersRangeModeVector.size();
for (NSInteger rangeType = 0; rangeType < tuningParametersVectorRangeModeSize; rangeType++) {
ASRangeTuningParameters tuningParameters = tuningparametersRangeModeVector[rangeType];
if (!ASRangeTuningParametersEqualToRangeTuningParameters(tuningParameters, ASRangeTuningParametersZero)) {
[_rangeController setTuningParameters:tuningParameters
forRangeMode:(ASLayoutRangeMode)rangeMode
rangeType:(ASLayoutRangeType)rangeType];
}
[_rangeController setTuningParameters:tuningParameters
forRangeMode:(ASLayoutRangeMode)rangeMode
rangeType:(ASLayoutRangeType)rangeType];
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/ASTableNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (instancetype)init
self = [super init];
if (self) {
_rangeMode = ASLayoutRangeModeUnspecified;
_tuningParameters = std::vector<std::vector<ASRangeTuningParameters>> (ASLayoutRangeModeCount, std::vector<ASRangeTuningParameters> (ASLayoutRangeTypeCount, ASRangeTuningParametersZero));
_tuningParameters = [ASAbstractLayoutController defaultTuningParameters];
_allowsSelection = YES;
_allowsSelectionDuringEditing = NO;
_allowsMultipleSelection = NO;
Expand Down
4 changes: 4 additions & 0 deletions Source/Details/ASAbstractLayoutController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import <AsyncDisplayKit/ASLayoutController.h>
#import <AsyncDisplayKit/ASBaseDefines.h>

#include <vector>

NS_ASSUME_NONNULL_BEGIN

AS_EXTERN ASDirectionalScreenfulBuffer ASDirectionalScreenfulBufferHorizontal(ASScrollDirection scrollDirection, ASRangeTuningParameters rangeTuningParameters);
Expand All @@ -20,6 +22,8 @@ AS_EXTERN CGRect CGRectExpandToRangeWithScrollableDirections(CGRect rect, ASRang

@interface ASAbstractLayoutController : NSObject <ASLayoutController>

+ (std::vector<std::vector<ASRangeTuningParameters>>)defaultTuningParameters;
Copy link
Member

@nguyenhuy nguyenhuy Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a public header, I'm a bit worried about exposing Obj-C++ here since it's going to cause a cascade effect on every header file that imports it and every impl file that imports any of these headers. We're already seeing the effect in this PR.

How about we expose a Obj-C method here that converts the Obj-C data structure into a vector? Then maybe expose this Obj-C++ version in a framework private header, in case we want to mitigate any perf concern regarding the conversion.

How about exposing this Obj-C++ method in a framework private header?


@end

@interface ASAbstractLayoutController (Unavailable)
Expand Down
45 changes: 25 additions & 20 deletions Source/Details/ASAbstractLayoutController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#import <AsyncDisplayKit/ASAssert.h>

#include <vector>

ASRangeTuningParameters const ASRangeTuningParametersZero = {};

BOOL ASRangeTuningParametersEqualToRangeTuningParameters(ASRangeTuningParameters lhs, ASRangeTuningParameters rhs)
Expand Down Expand Up @@ -89,53 +87,60 @@ @interface ASAbstractLayoutController () {

@implementation ASAbstractLayoutController

- (instancetype)init
+ (std::vector<std::vector<ASRangeTuningParameters>>)defaultTuningParameters
{
if (!(self = [super init])) {
return nil;
}
ASDisplayNodeAssert(self.class != [ASAbstractLayoutController class], @"Should never create instances of abstract class ASAbstractLayoutController.");

_tuningParameters = std::vector<std::vector<ASRangeTuningParameters>> (ASLayoutRangeModeCount, std::vector<ASRangeTuningParameters> (ASLayoutRangeTypeCount));

_tuningParameters[ASLayoutRangeModeFull][ASLayoutRangeTypeDisplay] = {
var tuningParameters = std::vector<std::vector<ASRangeTuningParameters>> (ASLayoutRangeModeCount, std::vector<ASRangeTuningParameters> (ASLayoutRangeTypeCount));

tuningParameters[ASLayoutRangeModeFull][ASLayoutRangeTypeDisplay] = {
.leadingBufferScreenfuls = 1.0,
.trailingBufferScreenfuls = 0.5
};
_tuningParameters[ASLayoutRangeModeFull][ASLayoutRangeTypePreload] = {

tuningParameters[ASLayoutRangeModeFull][ASLayoutRangeTypePreload] = {
.leadingBufferScreenfuls = 2.5,
.trailingBufferScreenfuls = 1.5
};
_tuningParameters[ASLayoutRangeModeMinimum][ASLayoutRangeTypeDisplay] = {

tuningParameters[ASLayoutRangeModeMinimum][ASLayoutRangeTypeDisplay] = {
.leadingBufferScreenfuls = 0.25,
.trailingBufferScreenfuls = 0.25
};
_tuningParameters[ASLayoutRangeModeMinimum][ASLayoutRangeTypePreload] = {
tuningParameters[ASLayoutRangeModeMinimum][ASLayoutRangeTypePreload] = {
.leadingBufferScreenfuls = 0.5,
.trailingBufferScreenfuls = 0.25
};

_tuningParameters[ASLayoutRangeModeVisibleOnly][ASLayoutRangeTypeDisplay] = {
tuningParameters[ASLayoutRangeModeVisibleOnly][ASLayoutRangeTypeDisplay] = {
.leadingBufferScreenfuls = 0,
.trailingBufferScreenfuls = 0
};
_tuningParameters[ASLayoutRangeModeVisibleOnly][ASLayoutRangeTypePreload] = {
tuningParameters[ASLayoutRangeModeVisibleOnly][ASLayoutRangeTypePreload] = {
.leadingBufferScreenfuls = 0,
.trailingBufferScreenfuls = 0
};

// The Low Memory range mode has special handling. Because a zero range still includes the visible area / bounds,
// in order to implement the behavior of releasing all graphics memory (backing stores), ASRangeController must check
// for this range mode and use an empty set for displayIndexPaths rather than querying the ASLayoutController for the indexPaths.
_tuningParameters[ASLayoutRangeModeLowMemory][ASLayoutRangeTypeDisplay] = {
tuningParameters[ASLayoutRangeModeLowMemory][ASLayoutRangeTypeDisplay] = {
.leadingBufferScreenfuls = 0,
.trailingBufferScreenfuls = 0
};
_tuningParameters[ASLayoutRangeModeLowMemory][ASLayoutRangeTypePreload] = {
tuningParameters[ASLayoutRangeModeLowMemory][ASLayoutRangeTypePreload] = {
.leadingBufferScreenfuls = 0,
.trailingBufferScreenfuls = 0
};
return tuningParameters;
}

- (instancetype)init
{
if (!(self = [super init])) {
return nil;
}
ASDisplayNodeAssert(self.class != [ASAbstractLayoutController class], @"Should never create instances of abstract class ASAbstractLayoutController.");

_tuningParameters = [[self class] defaultTuningParameters];

return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
};
typedef struct ASRangeGeometry ASRangeGeometry;


#pragma mark -
#pragma mark ASCollectionViewLayoutController

Expand Down