Feature hidden nodes #302
40
yoga/Yoga.c
40
yoga/Yoga.c
@@ -98,6 +98,7 @@ typedef struct YGNode {
|
||||
YGNodeRef parent;
|
||||
YGNodeListRef children;
|
||||
bool isDirty;
|
||||
bool isVisible;
|
||||
|
||||
struct YGNode *nextChild;
|
||||
|
||||
@@ -190,6 +191,7 @@ static void YGNodeInit(const YGNodeRef node) {
|
||||
node->children = NULL;
|
||||
node->hasNewLayout = true;
|
||||
node->isDirty = false;
|
||||
node->isVisible = true;
|
||||
|
||||
node->style.flex = YGUndefined;
|
||||
node->style.flexGrow = YGUndefined;
|
||||
@@ -348,6 +350,22 @@ bool YGNodeIsDirty(const YGNodeRef node) {
|
||||
return node->isDirty;
|
||||
}
|
||||
|
||||
void YGNodeHide(const YGNodeRef node) {
|
||||
node->isVisible = false;
|
||||
node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */
|
||||
YGNodeMarkDirty(node);
|
||||
}
|
||||
|
||||
void YGNodeShow(const YGNodeRef node) {
|
||||
node->isVisible = true;
|
||||
node->isDirty = false; /* See https://github.com/facebook/css-layout/issues/241 */
|
||||
YGNodeMarkDirty(node);
|
||||
}
|
||||
|
||||
bool YGNodeIsVisible(const YGNodeRef node) {
|
||||
return node->isVisible;
|
||||
}
|
||||
|
||||
void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
||||
if (memcmp(&dstNode->style, &srcNode->style, sizeof(YGStyle)) != 0) {
|
||||
memcpy(&dstNode->style, &srcNode->style, sizeof(YGStyle));
|
||||
@@ -1531,6 +1549,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
|
||||
for (uint32_t i = 0; i < childCount; i++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, i);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (performLayout) {
|
||||
// Set the initial position (relative to the parent).
|
||||
@@ -1605,6 +1626,10 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
// Add items to the current line until it's full or we run out of items.
|
||||
for (uint32_t i = startOfLineIndex; i < childCount; i++, endOfLineIndex++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, i);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
child->lineIndex = lineCount;
|
||||
|
||||
if (child->style.positionType != YGPositionTypeAbsolute) {
|
||||
@@ -1939,6 +1964,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
|
||||
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, i);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->style.positionType == YGPositionTypeAbsolute &&
|
||||
YGNodeIsLeadingPosDefined(child, mainAxis)) {
|
||||
@@ -2011,6 +2039,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
if (performLayout) {
|
||||
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, i);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->style.positionType == YGPositionTypeAbsolute) {
|
||||
// If the child is absolutely positioned and has a
|
||||
@@ -2136,6 +2167,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
float lineHeight = 0;
|
||||
for (ii = startIndex; ii < childCount; ii++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, ii);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->style.positionType == YGPositionTypeRelative) {
|
||||
if (child->lineIndex != i) {
|
||||
@@ -2155,6 +2189,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
if (performLayout) {
|
||||
for (ii = startIndex; ii < endIndex; ii++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, ii);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->style.positionType == YGPositionTypeRelative) {
|
||||
switch (YGNodeAlignItem(node, child)) {
|
||||
@@ -2246,6 +2283,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||
for (uint32_t i = 0; i < childCount; i++) {
|
||||
const YGNodeRef child = YGNodeListGet(node->children, i);
|
||||
if (NULL != child && false == YGNodeIsVisible(child)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (needsMainTrailingPos) {
|
||||
YGNodeSetChildTrailingPosition(node, child, mainAxis);
|
||||
|
@@ -80,6 +80,10 @@ WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
|
||||
WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
|
||||
|
||||
WIN_EXPORT void YGNodeHide(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeShow(const YGNodeRef node);
|
||||
WIN_EXPORT bool YGNodeIsVisible(const YGNodeRef node);
|
||||
|
||||
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
|
||||
|
||||
WIN_EXPORT bool YGValueIsUndefined(const float value);
|
||||
|
Reference in New Issue
Block a user