Compare commits

..

No commits in common. "3030390038cf48f8a8c6df1570b6c87ce4101635" and "a5983dee96041762a45fe6015a3a6e9694d5d7e0" have entirely different histories.

7 changed files with 11 additions and 30 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

41
clay.h
View File

@ -21,11 +21,6 @@
#include <arm_neon.h> #include <arm_neon.h>
#endif #endif
#ifdef __JETBRAINS_IDE__
// Help jetbrains IDEs like CLion and Rider with intellisense & debugging
#define CLAY_IMPLEMENTATION
#endif
// ----------------------------------------- // -----------------------------------------
// HEADER DECLARATIONS --------------------- // HEADER DECLARATIONS ---------------------
// ----------------------------------------- // -----------------------------------------
@ -1279,14 +1274,13 @@ Clay_LayoutElementHashMapItem *Clay__GetHashMapItem(uint32_t id) {
return &Clay_LayoutElementHashMapItem_DEFAULT; return &Clay_LayoutElementHashMapItem_DEFAULT;
} }
Clay_ElementId Clay__GenerateIdForAnonymousElement(Clay_LayoutElement *openLayoutElement) { void Clay__GenerateIdForAnonymousElement(Clay_LayoutElement *openLayoutElement) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2)); Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2));
Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id); Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
openLayoutElement->id = elementId.id; openLayoutElement->id = elementId.id;
Clay__AddHashMapItem(elementId, openLayoutElement, 0); Clay__AddHashMapItem(elementId, openLayoutElement, 0);
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId); Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
return elementId;
} }
bool Clay__ElementHasConfig(Clay_LayoutElement *layoutElement, Clay__ElementConfigType type) { bool Clay__ElementHasConfig(Clay_LayoutElement *layoutElement, Clay__ElementConfigType type) {
@ -1521,8 +1515,11 @@ void Clay__ConfigureOpenElement(const Clay_ElementDeclaration declaration) {
.errorText = CLAY_STRING("An element was configured with CLAY_SIZING_PERCENT, but the provided percentage value was over 1.0. Clay expects a value between 0 and 1, i.e. 20% is 0.2."), .errorText = CLAY_STRING("An element was configured with CLAY_SIZING_PERCENT, but the provided percentage value was over 1.0. Clay expects a value between 0 and 1, i.e. 20% is 0.2."),
.userData = context->errorHandler.userData }); .userData = context->errorHandler.userData });
} }
if (declaration.id.id != 0) {
Clay_ElementId openLayoutElementId = declaration.id; Clay__AttachId(declaration.id);
} else if (openLayoutElement->id == 0) {
Clay__GenerateIdForAnonymousElement(openLayoutElement);
}
openLayoutElement->elementConfigs.internalArray = &context->elementConfigs.internalArray[context->elementConfigs.length]; openLayoutElement->elementConfigs.internalArray = &context->elementConfigs.internalArray[context->elementConfigs.length];
Clay_SharedElementConfig *sharedConfig = NULL; Clay_SharedElementConfig *sharedConfig = NULL;
@ -1575,9 +1572,6 @@ void Clay__ConfigureOpenElement(const Clay_ElementDeclaration declaration) {
} else if (declaration.floating.attachTo == CLAY_ATTACH_TO_ROOT) { } else if (declaration.floating.attachTo == CLAY_ATTACH_TO_ROOT) {
floatingConfig.parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0, 0).id; floatingConfig.parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0, 0).id;
} }
if (!openLayoutElementId.id) {
openLayoutElementId = Clay__HashString(CLAY_STRING("Clay__FloatingContainer"), context->layoutElementTreeRoots.length, 0);
}
Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) { Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) {
.layoutElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1), .layoutElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1),
.parentId = floatingConfig.parentId, .parentId = floatingConfig.parentId,
@ -1590,13 +1584,6 @@ void Clay__ConfigureOpenElement(const Clay_ElementDeclaration declaration) {
if (declaration.custom.customData) { if (declaration.custom.customData) {
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(declaration.custom) }, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM); Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(declaration.custom) }, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM);
} }
if (openLayoutElementId.id != 0) {
Clay__AttachId(openLayoutElementId);
} else if (openLayoutElement->id == 0) {
openLayoutElementId = Clay__GenerateIdForAnonymousElement(openLayoutElement);
}
if (declaration.scroll.horizontal | declaration.scroll.vertical) { if (declaration.scroll.horizontal | declaration.scroll.vertical) {
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(declaration.scroll) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL); Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(declaration.scroll) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL);
Clay__int32_tArray_Add(&context->openClipElementStack, (int)openLayoutElement->id); Clay__int32_tArray_Add(&context->openClipElementStack, (int)openLayoutElement->id);
@ -3120,11 +3107,11 @@ void Clay__RenderDebugView(void) {
CLAY({{0}}) { CLAY({{0}}) {
CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig); CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig);
CLAY_TEXT(Clay__IntToString(borderConfig->width.left), infoTextConfig); CLAY_TEXT(Clay__IntToString(borderConfig->width.left), infoTextConfig);
CLAY_TEXT(CLAY_STRING(", right: "), infoTextConfig); CLAY_TEXT(CLAY_STRING("{ right: "), infoTextConfig);
CLAY_TEXT(Clay__IntToString(borderConfig->width.right), infoTextConfig); CLAY_TEXT(Clay__IntToString(borderConfig->width.right), infoTextConfig);
CLAY_TEXT(CLAY_STRING(", top: "), infoTextConfig); CLAY_TEXT(CLAY_STRING("{ top: "), infoTextConfig);
CLAY_TEXT(Clay__IntToString(borderConfig->width.top), infoTextConfig); CLAY_TEXT(Clay__IntToString(borderConfig->width.top), infoTextConfig);
CLAY_TEXT(CLAY_STRING(", bottom: "), infoTextConfig); CLAY_TEXT(CLAY_STRING("{ bottom: "), infoTextConfig);
CLAY_TEXT(Clay__IntToString(borderConfig->width.bottom), infoTextConfig); CLAY_TEXT(Clay__IntToString(borderConfig->width.bottom), infoTextConfig);
CLAY_TEXT(CLAY_STRING(" }"), infoTextConfig); CLAY_TEXT(CLAY_STRING(" }"), infoTextConfig);
} }
@ -3534,19 +3521,13 @@ CLAY_WASM_EXPORT("Clay_EndLayout")
Clay_RenderCommandArray Clay_EndLayout(void) { Clay_RenderCommandArray Clay_EndLayout(void) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
Clay__CloseElement(); Clay__CloseElement();
bool elementsExceededBeforeDebugView = context->booleanWarnings.maxElementsExceeded; if (context->debugModeEnabled) {
if (context->debugModeEnabled && !elementsExceededBeforeDebugView) {
context->warningsEnabled = false; context->warningsEnabled = false;
Clay__RenderDebugView(); Clay__RenderDebugView();
context->warningsEnabled = true; context->warningsEnabled = true;
} }
if (context->booleanWarnings.maxElementsExceeded) { if (context->booleanWarnings.maxElementsExceeded) {
Clay_String message; Clay_String message = CLAY_STRING("Clay Error: Layout elements exceeded Clay__maxElementCount");
if (!elementsExceededBeforeDebugView) {
message = CLAY_STRING("Clay Error: Layout elements exceeded Clay__maxElementCount after adding the debug-view to the layout.");
} else {
message = CLAY_STRING("Clay Error: Layout elements exceeded Clay__maxElementCount");
}
Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand ) { Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand ) {
.boundingBox = { context->layoutDimensions.width / 2 - 59 * 4, context->layoutDimensions.height / 2, 0, 0 }, .boundingBox = { context->layoutDimensions.width / 2 - 59 * 4, context->layoutDimensions.height / 2, 0, 0 },
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } }, .renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },