Compare commits

..

1 Commits

Author SHA1 Message Date
Harrison Lambeth
8512295b19
Merge 15fbf81e84 into 12b3280dab 2025-01-10 19:14:02 -07:00
3 changed files with 7 additions and 12 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
cmake-build-debug/ cmake-build-debug/
cmake-build-release/ cmake-build-release/
build/
.DS_Store .DS_Store
.idea/ .idea/
node_modules/ node_modules/

18
clay.h
View File

@ -1391,7 +1391,7 @@ struct Clay_Context {
bool externalScrollHandlingEnabled; bool externalScrollHandlingEnabled;
uint32_t debugSelectedElementId; uint32_t debugSelectedElementId;
uint32_t generation; uint32_t generation;
uintptr_t arenaResetOffset; uint64_t arenaResetOffset;
Clay_Arena internalArena; Clay_Arena internalArena;
// Layout Elements / Render Commands // Layout Elements / Render Commands
Clay_LayoutElementArray layoutElements; Clay_LayoutElementArray layoutElements;
@ -2103,9 +2103,6 @@ void Clay__CompressChildrenAlongAxis(bool xAxis, float totalSizeToDistribute, Cl
float targetSize = 0; float targetSize = 0;
for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) { for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) {
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i)); Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
if (!xAxis && Clay__ElementHasConfig(childElement, CLAY__ELEMENT_CONFIG_TYPE_IMAGE)) {
continue;
}
float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height; float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height;
if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) { if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) {
Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i)); Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
@ -2475,9 +2472,9 @@ void Clay__CalculateFinalLayout() {
while (sortMax > 0) { // todo dumb bubble sort while (sortMax > 0) { // todo dumb bubble sort
for (int32_t i = 0; i < sortMax; ++i) { for (int32_t i = 0; i < sortMax; ++i) {
Clay__LayoutElementTreeRoot current = *Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i); Clay__LayoutElementTreeRoot current = *Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i);
Clay__LayoutElementTreeRoot next = *Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i + 1); Clay__LayoutElementTreeRoot *next = Clay__LayoutElementTreeRootArray_Get(&context->layoutElementTreeRoots, i + 1);
if (next.zIndex < current.zIndex) { if (next->zIndex < current.zIndex) {
Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i, next); Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i, *next);
Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i + 1, current); Clay__LayoutElementTreeRootArray_Set(&context->layoutElementTreeRoots, i + 1, current);
} }
} }
@ -3226,19 +3223,16 @@ void Clay__RenderDebugView() {
Clay_TextElementConfig *infoTitleConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE }); Clay_TextElementConfig *infoTitleConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
Clay_ElementId scrollId = Clay__HashString(CLAY_STRING("Clay__DebugViewOuterScrollPane"), 0, 0); Clay_ElementId scrollId = Clay__HashString(CLAY_STRING("Clay__DebugViewOuterScrollPane"), 0, 0);
float scrollYOffset = 0; float scrollYOffset = 0;
bool pointerInDebugView = context->pointerInfo.position.y < context->layoutDimensions.height - 300;
for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) { for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) {
Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i); Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
if (scrollContainerData->elementId == scrollId.id) { if (scrollContainerData->elementId == scrollId.id) {
if (!context->externalScrollHandlingEnabled) { if (!context->externalScrollHandlingEnabled) {
scrollYOffset = scrollContainerData->scrollPosition.y; scrollYOffset = scrollContainerData->scrollPosition.y;
} else {
pointerInDebugView = context->pointerInfo.position.y + scrollContainerData->scrollPosition.y < context->layoutDimensions.height - 300;
} }
break; break;
} }
} }
int32_t highlightedRow = pointerInDebugView int32_t highlightedRow = context->pointerInfo.position.y < context->layoutDimensions.height - 300
? (int32_t)((context->pointerInfo.position.y - scrollYOffset) / (float)CLAY__DEBUGVIEW_ROW_HEIGHT) - 1 ? (int32_t)((context->pointerInfo.position.y - scrollYOffset) / (float)CLAY__DEBUGVIEW_ROW_HEIGHT) - 1
: -1; : -1;
if (context->pointerInfo.position.x < context->layoutDimensions.width - (float)Clay__debugViewWidth) { if (context->pointerInfo.position.x < context->layoutDimensions.width - (float)Clay__debugViewWidth) {
@ -3616,7 +3610,7 @@ uint32_t Clay_MinMemorySize(void) {
.maxMeasureTextCacheWordCount = Clay__defaultMaxMeasureTextWordCacheCount, .maxMeasureTextCacheWordCount = Clay__defaultMaxMeasureTextWordCacheCount,
.internalArena = { .internalArena = {
.capacity = SIZE_MAX, .capacity = SIZE_MAX,
.memory = NULL, .memory = (char*)&fakeContext,
} }
}; };
Clay_Context* currentContext = Clay_GetCurrentContext(); Clay_Context* currentContext = Clay_GetCurrentContext();