- ASLayoutable requires mutable properties that are used when attached to a stack layout.
- Thus, ASLayoutable objects (including ASDisplayNode) can be injected into stack layout directly.
- ASStackLayoutNodeChild no longer needed.
- Tests and Kitten sample updated.
- Both ASDisplayNode and ASLayoutNode conforms to this protocol.
- ASDisplayNode can be embeded directly into layout graph.
- Eliminate ASCompositeNode.
- Fix ASStaticSizeDisplayNode not recpect min constrained size.
- Updated tests.
- Introduce ASLayoutNode and its subclasses.
- ASDisplayNode measures its ASLayoutNode and cache the result (ASLayout). Calculated size and position of each subnode can be retrieved from the calculated layout.
- Custom nodes need to override -layoutNodeThatFits:(CGSize) instead of -calculateSizeThatFits:(CGSize).
- Custom nodes do not need to layout its subnodes (in -layout:) anymore. ASDisplayNode can handle the job most of the time, by walking through its layout tree.
- ASCompositeNode is used to embed (display) subnodes to a node's layout. That way, each subnode will also be measured while the parent node is measuring. And the parent node knows where its subnodes are within its layout.
Bring back this convenience API -- it disappeared somewhere along the
line while we were building Paper. This is totally trivial, but
conveniently won't break if you layer-back a leaf node.
Closes#278.
This adds new initializer methods to ASDisplayNode:
```objc
initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
```
Sometimes a view can't be constructed with `-[initWithViewClass:]` but you want to use it with ASDK, so these new methods provide a way to wrap an existing view in a node.
The API is meant to preserve ASDisplayNode's behavior, so you can still construct and set properties on the node on a background queue before its view is loaded; even though the view was created a priori, it is not considered to be loaded until `node.view` is accessed.
Using the API looks like this:
dispatch_async(backgroundQueue, ^{
ASDisplayNode *node = [ASDisplayNode alloc] initWithViewBlock:^{
// Guaranteed to run on the main queue
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button sizeToFit];
node.frame = button.frame;
return button;
}];
// Use `node` as you normally would...
node.backgroundColor = [UIColor redColor];
});
The main thing this bridging API doesn't do (can't do?) is layout. Methods like `-[ASDisplayNode calculateSizeThatFits:]` and `-[ASDisplayNode layout]` cannot delegate to `[UIView sizeThatFits:]` and `[UIView layoutSubviews]` since the UIView methods must run on the main thread. If ASDK were internally asynchronous and could dispatch its layout methods to different threads (sort of like how ASTableView computes its cells' layouts) then we could mark nodes with externally provided views/layers as having "main-queue affinity" and delegate its layout to UIKit.
Test cases are included and all existing tests pass.
ASDisplayNodes now have an overidable method -placeholderImage that lets you provide a custom UIImage to display while a node is displaying asyncronously. The default implementation of this method returns nil and thus does nothing. A provided example project also demonstrates using the placeholder API.
Postpone manual display until a future release when it can be called on any thread. Provide the current node manual display logic as a category on ASDisplayNode only available for ASRangeController. Deprecate -displayImmediately.
Add a `usleep(1.0 * USEC_PER_SEC)` delay to ASBasicImageDownloader and
slowly scroll through the Kittens sample project. Without this patch,
you'll see that images only start downloading after their purple
placeholders appear onscreen. With it, images can download and render
before you scroll them onscreen, thanks to the working range.
Rename the ASDisplayNode property to match its _ASDisplayLayer
counterpart -- `displaySuspended` is more succinct and is a more
plausible name for a Cocoa BOOL property.
This is a remnant from before `willAppear` and `didDisappear` were
renamed to better reflect their hierarchy-change status (being added to
the hierarchy != being visible). May be useful for turians.
* Reorganise and rename `_flags` for clarity and consistency.
* Remove ambiguity between `implementsDisplay` and `hasClassDisplay`.
* Delete useless `hasWillDisplayAsyncLayer` check -- make it a simple
subclass override point, as with `didDisplayAsyncLayer:`.
* Minor comment cleanup.
Added a sample project that will demonstrate how to manually display nodes. Removed the UIWindow hack that coupled display of nodes with Core Animation transactions.
ASImageNode and ASHighlightOverlayLayer were both using
[[UIScreen mainScreen] scale] directly. Bad. No cookie. Use
ASDisplayNodeScreenScale() instead.
(Also, regenerate Xcode project with Xcode 6 and current CocoaPods.)