Add YGNodeSetChildren(), YGNodeTraversePreOrder()
Summary: We had functions for inserting/removing a specific child, but not for simply replacing the child set with another list. `YGNodeSetChildren()` will unhook child nodes from the parent that don't appear in the new set. We set the disconnected child node layouts to `YGLayout()` b/c that's what the rest of the code does. `YGTraversePreOrder()` walks the tree and calls a labmda for each node. We could very easily add a post-order traversal and the ability to stop traversal if we ever want, but for now this is an MVP. Reviewed By: Woody17 Differential Revision: D7360203 fbshipit-source-id: 32df8e1213ead03bc0a026ec4bf453bc799bb9ce
This commit is contained in:
committed by
Facebook Github Bot
parent
c951ad7c7b
commit
187fc54596
13
yoga/Yoga.h
13
yoga/Yoga.h
@@ -84,6 +84,7 @@ WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node);
|
||||
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
|
||||
WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node);
|
||||
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeSetChildren(YGNodeRef const parent, const YGNodeRef children[], const uint32_t count);
|
||||
|
||||
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
const float availableWidth,
|
||||
@@ -298,3 +299,15 @@ WIN_EXPORT float YGRoundValueToPixelGrid(
|
||||
const bool forceFloor);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
// Calls f on each node in the tree including the given node argument.
|
||||
extern void YGTraversePreOrder(YGNodeRef const node, std::function<void(YGNodeRef node)>&& f);
|
||||
|
||||
extern void YGNodeSetChildren(YGNodeRef const parent, const std::vector<YGNodeRef> &children);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user