WIP Add support for only rendering certain sub-trees. #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows filters to be written which not only exclude certain subtrees, but also which only include certain subtrees.
It has three parts:
ViewFilter
's matches method to return a three-value type instead of a boolean, where the third value means don't include this view, but include its children.ComposeLayoutInfo
a pointer to its parent.Open questions
viewFilterFor
still accept a boolean lambda instead of all 3 values, since the third value is likely not needed by most filters and it would allow more readable single-expression filters.View
hierarchy so that it included the complete subtrees. Would a better approach to make the filter stateful, so it could set an internal flag while visiting children that match? This would also be more efficient, since it wouldn't need to walk up the parent chain for every node. However it requires a slightly bigger change to the filter API.One way to solve the last point would be to pass an arbitrary value down the filter chain:
We could also then provide two versions of
viewFilterFor
, a simple one (no filter state, boolean return) and a complete one (same signature as the above method). One issue with this is that the returned filter state value would be ignored if the result isEXCLUDE
, so a sealed class might be better for the result than an enum at that point:Fixes #58.