Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Conversation

@rcancro
Copy link
Contributor

@rcancro rcancro commented Oct 19, 2015

Created a class called ASAsciiArtBoxCreator that, given a parent name and an array of string representations of the children, will create an ascii representation of the parent.

Objects that want to be rendered in ascii art should implement the ASLayoutableAsciiArtProtocol protocol. The two methods are:

- (NSString *)asciiArtString;
- (NSString *)asciiArtName;

I have updated ASDisplayNode and ASLayoutSpec so that they conform to this new protocol. If you are working on a layout, you can put a breakpoint at the end of - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize and type po [layoutSpec asciiArtString] to see a visual representation of your layout.

For example, this is what the layout for KittenNode looks like:

(lldb) po [insetSpec asciiArtString]
-------------ASInsetLayoutSpec------------
|  ----------ASStackLayoutSpec---------  |
|  |  ASNetworkImageNode  ASTextNode  |  |
|  ------------------------------------  |
------------------------------------------

Here is an example of a more complicated example:

---------------------ASStackLayoutSpec-----------------------
|               -----ASStackLayoutSpec------                | 
|               |  --ASInsetLayoutSpec--   |                | 
|               |  |     ASTextNode    |   |                | 
|               |  ---------------------   |                | 
|               |  --ASInsetLayoutSpec--   |                | 
|  ASImageNode  |  |     ASTextNode    |   |  ASButtonNode  | 
|               |  ---------------------   |                | 
|               |  --ASInsetLayoutSpec--|  |                | 
|               |  |    ASStackNode     |  |                | 
|               |  ----------------------  |                | 
|               ----------------------------                | 
------------------------------------------------------------- 

@nguyenhuy
Copy link
Contributor

This is gold 👍 👍 👍

@SRandazzo
Copy link
Contributor

omg. 👍

@wmcbain
Copy link

wmcbain commented Oct 19, 2015

😍WOW 😍

@Adlai-Holler
Copy link
Contributor

yesjacknicholson

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure I understand — this only prints out one box with the node's name in it? Or does it somehow print the hierarchy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should just print the node's name. If someone wanted to make ascii art of the node hierarchy they'd pass in self.subnodes as the children.

@appleguy
Copy link
Contributor

This is just so cool. Thanks @rcancro for one of the most delightful patches ASDK has ever seen :).

If someone wants to write a few tests for this, it will keep our code coverage number up. It should be easy to add one or two in an existing test suite, just printing the node tree or spec tree of some existing hierarchy in the tests.

appleguy added a commit that referenced this pull request Oct 26, 2015
Ascii art visual debugging for ASLayoutSpecs
@appleguy appleguy merged commit 7a97c5c into facebookarchive:master Oct 26, 2015
aimalygin pushed a commit to aimalygin/AsyncDisplayKit that referenced this pull request Feb 19, 2018
…rs preload state (facebookarchive#751)

- After facebookarchive#706, a layout pass is forced on an ASM-enabled node that enters preload state to make sure that its subnodes can start preloading as well. However, when the node is visible, a (coalesced, thus more efficient) layout pass will be triggered by CA soon anyways, so rely on it instead.
aimalygin pushed a commit to aimalygin/AsyncDisplayKit that referenced this pull request Feb 19, 2018
…nters preload state (facebookarchive#779)

This reverts commit 2e98588 (facebookarchive#751).

The reason we can't wait for the coming CA's layout pass is that cell node visibility events occur before the pass, at which time the cell's subnodes don't have correct frames for impression tracking.

The root cause of this problem is that, right now, cell node visible states are set by ASRangeController well before the layout pass of the hosting collection/table view. That means we're "jumping the gun". The more I think about this, the more I agree with @Adlai-Holler that we need to treat visible state differently. That is, a node should only be visible (and thus get visibility events) after it's fully loaded, it's view/layer attached to the hierarchy and laid out by a CA transaction. In other words, at the end of the CA layout pass. Such change needs time and effort to be thoroughly reviewed and tested. Until then, let's roll with this fix.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants