mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-18 20:28:01 +00:00
Fix missing context initialization
This commit is contained in:
parent
8efa855e8c
commit
209f30dd56
17
clay.h
17
clay.h
@ -3699,14 +3699,18 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
|
|
||||||
CLAY_WASM_EXPORT("Clay_Initialize")
|
CLAY_WASM_EXPORT("Clay_Initialize")
|
||||||
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
|
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
|
||||||
Clay_Context* context = Clay__Context_Allocate_Arena(&arena);
|
Clay_Context *context = Clay__Context_Allocate_Arena(&arena);
|
||||||
if (context == NULL) return NULL;
|
if (context == NULL) return NULL;
|
||||||
// DEFAULTS
|
// DEFAULTS
|
||||||
context->maxElementCount = Clay__defaultMaxElementCount;
|
Clay_Context *oldContext = Clay_GetCurrentContext();
|
||||||
context->maxMeasureTextCacheWordCount = context->maxElementCount * 2;
|
*context = CLAY__INIT(Clay_Context) {
|
||||||
context->errorHandler = CLAY__INIT(Clay_ErrorHandler) { Clay__ErrorHandlerFunctionDefault };
|
.maxElementCount = oldContext ? oldContext->maxElementCount : Clay__defaultMaxElementCount,
|
||||||
|
.maxMeasureTextCacheWordCount = oldContext ? oldContext->maxMeasureTextCacheWordCount : Clay__defaultMaxElementCount * 2,
|
||||||
|
.errorHandler = errorHandler.errorHandlerFunction ? errorHandler : CLAY__INIT(Clay_ErrorHandler) { Clay__ErrorHandlerFunctionDefault },
|
||||||
|
.internalArena = arena,
|
||||||
|
.layoutDimensions = layoutDimensions,
|
||||||
|
};
|
||||||
Clay_SetCurrentContext(context);
|
Clay_SetCurrentContext(context);
|
||||||
context->internalArena = arena;
|
|
||||||
Clay__InitializePersistentMemory(context);
|
Clay__InitializePersistentMemory(context);
|
||||||
Clay__InitializeEphemeralMemory(context);
|
Clay__InitializeEphemeralMemory(context);
|
||||||
for (int32_t i = 0; i < context->layoutElementsHashMap.capacity; ++i) {
|
for (int32_t i = 0; i < context->layoutElementsHashMap.capacity; ++i) {
|
||||||
@ -3717,9 +3721,6 @@ Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions
|
|||||||
}
|
}
|
||||||
context->measureTextHashMapInternal.length = 1; // Reserve the 0 value to mean "no next element"
|
context->measureTextHashMapInternal.length = 1; // Reserve the 0 value to mean "no next element"
|
||||||
context->layoutDimensions = layoutDimensions;
|
context->layoutDimensions = layoutDimensions;
|
||||||
if (errorHandler.errorHandlerFunction) {
|
|
||||||
context->errorHandler = errorHandler;
|
|
||||||
}
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user