mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-14 02:08:04 +00:00
Add tree depth to render commands
This commit is contained in:
parent
1204ac400b
commit
f8bdf01b45
9
clay.h
9
clay.h
@ -666,6 +666,7 @@ typedef struct {
|
||||
// Note: the render command array is already sorted in ascending order, and will produce correct results if drawn in naive order.
|
||||
// This field is intended for use in batching renderers for improved performance.
|
||||
int16_t zIndex;
|
||||
int16_t treeDepth;
|
||||
// Specifies how to handle rendering of this command.
|
||||
// CLAY_RENDER_COMMAND_TYPE_RECTANGLE - The renderer should draw a solid color rectangle.
|
||||
// CLAY_RENDER_COMMAND_TYPE_BORDER - The renderer should draw a colored border inset into the bounding box.
|
||||
@ -1168,6 +1169,7 @@ typedef struct {
|
||||
Clay_LayoutElement *layoutElement;
|
||||
Clay_Vector2 position;
|
||||
Clay_Vector2 nextChildOffset;
|
||||
uint16_t treeDepth;
|
||||
} Clay__LayoutElementTreeNode;
|
||||
|
||||
CLAY__ARRAY_DEFINE(Clay__LayoutElementTreeNode, Clay__LayoutElementTreeNodeArray)
|
||||
@ -2752,6 +2754,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
.boundingBox = currentElementBoundingBox,
|
||||
.userData = sharedConfig->userData,
|
||||
.id = currentElement->id,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
};
|
||||
|
||||
bool offscreen = Clay__ElementIsOffscreen(¤tElementBoundingBox);
|
||||
@ -2824,6 +2827,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
.userData = textElementConfig->userData,
|
||||
.id = Clay__HashNumber(lineIndex, currentElement->id).id,
|
||||
.zIndex = root->zIndex,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,
|
||||
});
|
||||
yPosition += finalLineHeight;
|
||||
@ -2868,6 +2872,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
.userData = sharedConfig->userData,
|
||||
.id = currentElement->id,
|
||||
.zIndex = root->zIndex,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
|
||||
});
|
||||
}
|
||||
@ -2946,6 +2951,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
}},
|
||||
.userData = sharedConfig->userData,
|
||||
.id = Clay__HashNumber(currentElement->id, currentElement->childrenOrTextContent.children.length).id,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
.commandType = CLAY_RENDER_COMMAND_TYPE_BORDER,
|
||||
};
|
||||
Clay__AddRenderCommand(renderCommand);
|
||||
@ -2963,6 +2969,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
} },
|
||||
.userData = sharedConfig->userData,
|
||||
.id = Clay__HashNumber(currentElement->id, currentElement->childrenOrTextContent.children.length + 1 + i).id,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
|
||||
});
|
||||
}
|
||||
@ -2979,6 +2986,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
} },
|
||||
.userData = sharedConfig->userData,
|
||||
.id = Clay__HashNumber(currentElement->id, currentElement->childrenOrTextContent.children.length + 1 + i).id,
|
||||
.treeDepth = currentElementTreeNode->treeDepth,
|
||||
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
|
||||
});
|
||||
}
|
||||
@ -3035,6 +3043,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||
.layoutElement = childElement,
|
||||
.position = { childPosition.x, childPosition.y },
|
||||
.nextChildOffset = { .x = (float)childElement->layoutConfig->padding.left, .y = (float)childElement->layoutConfig->padding.top },
|
||||
.treeDepth = currentElementTreeNode->treeDepth + 1
|
||||
};
|
||||
context->treeNodeVisited.internalArray[newNodeIndex] = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user