mirror of
https://github.com/nicbarker/clay.git
synced 2026-06-01 05:57:14 +00:00
Fix more missing cases of text element guards
This commit is contained in:
parent
e0df55cafa
commit
d9a8902cf3
1 changed files with 44 additions and 41 deletions
85
clay.h
85
clay.h
|
|
@ -2336,7 +2336,7 @@ void Clay__SizeContainersAlongAxis(bool xAxis, float deltaTime, Clay__int32_tArr
|
|||
Clay__int32_tArray_Add(&bfsBuffer, childElementIndex);
|
||||
}
|
||||
|
||||
if (aspectRatioElementsOut && childElement->config.aspectRatio.aspectRatio != 0) {
|
||||
if (!childElement->isTextElement && aspectRatioElementsOut && childElement->config.aspectRatio.aspectRatio != 0) {
|
||||
Clay__int32_tArray_Add(aspectRatioElementsOut, childElementIndex);
|
||||
}
|
||||
|
||||
|
|
@ -2459,7 +2459,8 @@ void Clay__SizeContainersAlongAxis(bool xAxis, float deltaTime, Clay__int32_tArr
|
|||
for (int childIndex = 0; childIndex < resizableContainerBuffer.length; childIndex++) {
|
||||
Clay_LayoutElement *child = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&resizableContainerBuffer, childIndex));
|
||||
float *childSize = xAxis ? &child->dimensions.width : &child->dimensions.height;
|
||||
float maxSize = xAxis ? child->config.layout.sizing.width.size.minMax.max : child->config.layout.sizing.height.size.minMax.max;
|
||||
Clay_SizingAxis childSizing = Clay__GetElementSizing(child, xAxis);
|
||||
float maxSize = childSizing.size.minMax.max;
|
||||
float previousWidth = *childSize;
|
||||
if (Clay__FloatEqual(*childSize, smallest)) {
|
||||
*childSize += widthToAdd;
|
||||
|
|
@ -2790,7 +2791,7 @@ void Clay__CalculateFinalLayout(float deltaTime, bool useStoredBoundingBoxes, bo
|
|||
while (dfsBuffer.length > 0) {
|
||||
Clay__LayoutElementTreeNode *currentElementTreeNode = Clay__LayoutElementTreeNodeArray_Get(&dfsBuffer, (int)dfsBuffer.length - 1);
|
||||
Clay_LayoutElement *currentElement = currentElementTreeNode->layoutElement;
|
||||
Clay_LayoutConfig *layoutConfig = ¤tElement->config.layout;
|
||||
Clay_LayoutConfig *layoutConfig = currentElement->isTextElement ? &CLAY_LAYOUT_DEFAULT : ¤tElement->config.layout;
|
||||
Clay_Vector2 scrollOffset = CLAY__DEFAULT_STRUCT;
|
||||
|
||||
// DFS is returning back upwards
|
||||
|
|
@ -2896,50 +2897,52 @@ void Clay__CalculateFinalLayout(float deltaTime, bool useStoredBoundingBoxes, bo
|
|||
// This will only be run a single time for each element in downwards DFS order
|
||||
context->treeNodeVisited.internalArray[dfsBuffer.length - 1] = true;
|
||||
Clay_BoundingBox currentElementBoundingBox = { currentElementTreeNode->position.x, currentElementTreeNode->position.y, currentElement->dimensions.width, currentElement->dimensions.height };
|
||||
bool found = false;
|
||||
if (useStoredBoundingBoxes && currentElement->config.transition.handler) {
|
||||
for (int j = 0; j < context->transitionDatas.length; ++j) {
|
||||
Clay__TransitionDataInternal* transitionData = Clay__TransitionDataInternalArray_Get(&context->transitionDatas, j);
|
||||
if (transitionData->elementId == currentElement->id) {
|
||||
found = true;
|
||||
if (transitionData->state != CLAY_TRANSITION_STATE_IDLE) {
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_X) != 0) currentElementBoundingBox.x = transitionData->currentState.boundingBox.x;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_Y) != 0) currentElementBoundingBox.y = transitionData->currentState.boundingBox.y;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_WIDTH) != 0) currentElementBoundingBox.width = transitionData->currentState.boundingBox.width;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_HEIGHT) != 0) currentElementBoundingBox.height = transitionData->currentState.boundingBox.height;
|
||||
Clay__ScrollContainerDataInternal *scrollContainerData = CLAY__NULL;
|
||||
if (!currentElement->isTextElement) {
|
||||
if (useStoredBoundingBoxes && currentElement->config.transition.handler) {
|
||||
bool found = false;
|
||||
for (int j = 0; j < context->transitionDatas.length; ++j) {
|
||||
Clay__TransitionDataInternal* transitionData = Clay__TransitionDataInternalArray_Get(&context->transitionDatas, j);
|
||||
if (transitionData->elementId == currentElement->id) {
|
||||
found = true;
|
||||
if (transitionData->state != CLAY_TRANSITION_STATE_IDLE) {
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_X) != 0) currentElementBoundingBox.x = transitionData->currentState.boundingBox.x;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_Y) != 0) currentElementBoundingBox.y = transitionData->currentState.boundingBox.y;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_WIDTH) != 0) currentElementBoundingBox.width = transitionData->currentState.boundingBox.width;
|
||||
if ((currentElement->config.transition.properties & CLAY_TRANSITION_PROPERTY_HEIGHT) != 0) currentElementBoundingBox.height = transitionData->currentState.boundingBox.height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// An exiting element that completed its transition this frame - skip tree
|
||||
if (!found && currentElement->config.transition.exit.setFinalState) {
|
||||
dfsBuffer.length--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// An exiting element that completed its transition this frame - skip tree
|
||||
if (!found && currentElement->config.transition.exit.setFinalState) {
|
||||
dfsBuffer.length--;
|
||||
continue;
|
||||
if (currentElement->config.floating.attachTo != CLAY_ATTACH_TO_NONE) {
|
||||
Clay_FloatingElementConfig *floatingElementConfig = ¤tElement->config.floating;
|
||||
Clay_Dimensions expand = floatingElementConfig->expand;
|
||||
currentElementBoundingBox.x -= expand.width;
|
||||
currentElementBoundingBox.width += expand.width * 2;
|
||||
currentElementBoundingBox.y -= expand.height;
|
||||
currentElementBoundingBox.height += expand.height * 2;
|
||||
}
|
||||
}
|
||||
if (currentElement->config.floating.attachTo != CLAY_ATTACH_TO_NONE) {
|
||||
Clay_FloatingElementConfig *floatingElementConfig = ¤tElement->config.floating;
|
||||
Clay_Dimensions expand = floatingElementConfig->expand;
|
||||
currentElementBoundingBox.x -= expand.width;
|
||||
currentElementBoundingBox.width += expand.width * 2;
|
||||
currentElementBoundingBox.y -= expand.height;
|
||||
currentElementBoundingBox.height += expand.height * 2;
|
||||
}
|
||||
|
||||
Clay__ScrollContainerDataInternal *scrollContainerData = CLAY__NULL;
|
||||
// Apply scroll offsets to container
|
||||
if (currentElement->config.clip.horizontal || currentElement->config.clip.vertical) {
|
||||
// This linear scan could theoretically be slow under very strange conditions, but I can't imagine a real UI with more than a few 10's of scroll containers
|
||||
for (int32_t i = 0; i < context->scrollContainerDatas.length; i++) {
|
||||
Clay__ScrollContainerDataInternal *mapping = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
|
||||
if (mapping->layoutElement == currentElement) {
|
||||
scrollContainerData = mapping;
|
||||
mapping->boundingBox = currentElementBoundingBox;
|
||||
scrollOffset = currentElement->config.clip.childOffset;
|
||||
if (context->externalScrollHandlingEnabled) {
|
||||
scrollOffset = CLAY__INIT(Clay_Vector2) CLAY__DEFAULT_STRUCT;
|
||||
// Apply scroll offsets to container
|
||||
if (currentElement->config.clip.horizontal || currentElement->config.clip.vertical) {
|
||||
// This linear scan could theoretically be slow under very strange conditions, but I can't imagine a real UI with more than a few 10's of scroll containers
|
||||
for (int32_t i = 0; i < context->scrollContainerDatas.length; i++) {
|
||||
Clay__ScrollContainerDataInternal *mapping = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
|
||||
if (mapping->layoutElement == currentElement) {
|
||||
scrollContainerData = mapping;
|
||||
mapping->boundingBox = currentElementBoundingBox;
|
||||
scrollOffset = currentElement->config.clip.childOffset;
|
||||
if (context->externalScrollHandlingEnabled) {
|
||||
scrollOffset = CLAY__INIT(Clay_Vector2) CLAY__DEFAULT_STRUCT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue