mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-19 12:48:05 +00:00
Im not sure if this is too bullish of an approch to the issue, but i was unable to get at the internal data from another c file
This commit is contained in:
parent
6a9b723dcc
commit
ccd9edfc9e
102
clay.h
102
clay.h
@ -438,6 +438,40 @@ typedef struct
|
|||||||
Clay_PointerDataInteractionState state;
|
Clay_PointerDataInteractionState state;
|
||||||
} Clay_PointerData;
|
} Clay_PointerData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct Clay_LayoutElement Clay_LayoutElement;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Clay_LayoutElement *layoutElement;
|
||||||
|
Clay_BoundingBox boundingBox;
|
||||||
|
Clay_Dimensions contentSize;
|
||||||
|
Clay_Vector2 scrollOrigin;
|
||||||
|
Clay_Vector2 pointerOrigin;
|
||||||
|
Clay_Vector2 scrollMomentum;
|
||||||
|
Clay_Vector2 scrollPosition;
|
||||||
|
Clay_Vector2 previousDelta;
|
||||||
|
float momentumTime;
|
||||||
|
uint32_t elementId;
|
||||||
|
bool openThisFrame;
|
||||||
|
bool pointerScrollActive;
|
||||||
|
} Clay__ScrollContainerDataInternal;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct Clay__ScrollContainerDataInternalArray
|
||||||
|
{
|
||||||
|
uint32_t capacity;
|
||||||
|
uint32_t length;
|
||||||
|
Clay__ScrollContainerDataInternal *internalArray;
|
||||||
|
} Clay__ScrollContainerDataInternalArray;
|
||||||
|
|
||||||
|
|
||||||
|
Clay__ScrollContainerDataInternal *Clay__ScrollContainerDataInternalArray_Get(Clay__ScrollContainerDataInternalArray *array, int index);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function Forward Declarations ---------------------------------
|
// Function Forward Declarations ---------------------------------
|
||||||
// Public API functions ---
|
// Public API functions ---
|
||||||
uint32_t Clay_MinMemorySize();
|
uint32_t Clay_MinMemorySize();
|
||||||
@ -551,13 +585,13 @@ typedef struct
|
|||||||
} Clay__WarningArray;
|
} Clay__WarningArray;
|
||||||
|
|
||||||
Clay__WarningArray Clay__WarningArray_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
Clay__WarningArray Clay__WarningArray_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||||
size_t totalSizeBytes = capacity * sizeof(Clay_String);
|
uint64_t totalSizeBytes = capacity * sizeof(Clay_String);
|
||||||
Clay__WarningArray array = CLAY__INIT(Clay__WarningArray){.capacity = capacity, .length = 0};
|
Clay__WarningArray array = CLAY__INIT(Clay__WarningArray){.capacity = capacity, .length = 0};
|
||||||
uintptr_t nextAllocAddress = (uintptr_t)arena->nextAllocation + (uintptr_t)arena->memory;
|
uint64_t nextAllocAddress = (uint64_t)arena->nextAllocation + (uint64_t)arena->memory;
|
||||||
uintptr_t arenaOffsetAligned = nextAllocAddress + (CLAY__ALIGNMENT(Clay_String) - (nextAllocAddress % CLAY__ALIGNMENT(Clay_String)));
|
uint64_t arenaOffsetAligned = nextAllocAddress + (CLAY__ALIGNMENT(Clay_String) - (nextAllocAddress % CLAY__ALIGNMENT(Clay_String)));
|
||||||
arenaOffsetAligned -= (uintptr_t)arena->memory;
|
arenaOffsetAligned -= (uint64_t)arena->memory;
|
||||||
if (arenaOffsetAligned + totalSizeBytes <= arena->capacity) {
|
if (arenaOffsetAligned + totalSizeBytes <= arena->capacity) {
|
||||||
array.internalArray = (Clay__Warning*)((uintptr_t)arena->memory + (uintptr_t)arenaOffsetAligned);
|
array.internalArray = (Clay__Warning*)((uint64_t)arena->memory + (uint64_t)arenaOffsetAligned);
|
||||||
arena->nextAllocation = arenaOffsetAligned + totalSizeBytes;
|
arena->nextAllocation = arenaOffsetAligned + totalSizeBytes;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -586,13 +620,13 @@ Clay__Warning *Clay__WarningArray_Add(Clay__WarningArray *array, Clay__Warning i
|
|||||||
|
|
||||||
void* Clay__Array_Allocate_Arena(uint32_t capacity, uint32_t itemSize, uint32_t alignment, Clay_Arena *arena)
|
void* Clay__Array_Allocate_Arena(uint32_t capacity, uint32_t itemSize, uint32_t alignment, Clay_Arena *arena)
|
||||||
{
|
{
|
||||||
size_t totalSizeBytes = capacity * itemSize;
|
uint64_t totalSizeBytes = capacity * itemSize;
|
||||||
uintptr_t nextAllocAddress = (uintptr_t)arena->nextAllocation + (uintptr_t)arena->memory;
|
uint64_t nextAllocAddress = (uint64_t)arena->nextAllocation + (uint64_t)arena->memory;
|
||||||
uintptr_t arenaOffsetAligned = nextAllocAddress + (alignment - (nextAllocAddress % alignment));
|
uint64_t arenaOffsetAligned = nextAllocAddress + (alignment - (nextAllocAddress % alignment));
|
||||||
arenaOffsetAligned -= (uintptr_t)arena->memory;
|
arenaOffsetAligned -= (uint64_t)arena->memory;
|
||||||
if (arenaOffsetAligned + totalSizeBytes <= arena->capacity) {
|
if (arenaOffsetAligned + totalSizeBytes <= arena->capacity) {
|
||||||
arena->nextAllocation = arenaOffsetAligned + totalSizeBytes;
|
arena->nextAllocation = arenaOffsetAligned + totalSizeBytes;
|
||||||
return (void*)((uintptr_t)arena->memory + (uintptr_t)arenaOffsetAligned);
|
return (void*)((uint64_t)arena->memory + (uint64_t)arenaOffsetAligned);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Clay__warningsEnabled) {
|
if (Clay__warningsEnabled) {
|
||||||
@ -953,7 +987,7 @@ typedef struct
|
|||||||
uint16_t length;
|
uint16_t length;
|
||||||
} Clay__LayoutElementChildren;
|
} Clay__LayoutElementChildren;
|
||||||
|
|
||||||
typedef struct
|
typedef struct Clay_LayoutElement
|
||||||
{
|
{
|
||||||
#ifdef CLAY_DEBUG
|
#ifdef CLAY_DEBUG
|
||||||
Clay_String name;
|
Clay_String name;
|
||||||
@ -1043,38 +1077,20 @@ Clay_RenderCommand *Clay_RenderCommandArray_Add(Clay_RenderCommandArray *array,
|
|||||||
}
|
}
|
||||||
return &CLAY__RENDER_COMMAND_DEFAULT;
|
return &CLAY__RENDER_COMMAND_DEFAULT;
|
||||||
}
|
}
|
||||||
Clay_RenderCommand *Clay_RenderCommandArray_Get(Clay_RenderCommandArray *array, int32_t index) {
|
Clay_RenderCommand *Clay_RenderCommandArray_Get(Clay_RenderCommandArray *array, int index) {
|
||||||
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : &CLAY__RENDER_COMMAND_DEFAULT;
|
return Clay__Array_RangeCheck(index, array->length) ? &array->internalArray[index] : &CLAY__RENDER_COMMAND_DEFAULT;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
// __GENERATED__ template
|
// __GENERATED__ template
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Clay_LayoutElement *layoutElement;
|
|
||||||
Clay_BoundingBox boundingBox;
|
|
||||||
Clay_Dimensions contentSize;
|
|
||||||
Clay_Vector2 scrollOrigin;
|
|
||||||
Clay_Vector2 pointerOrigin;
|
|
||||||
Clay_Vector2 scrollMomentum;
|
|
||||||
Clay_Vector2 scrollPosition;
|
|
||||||
Clay_Vector2 previousDelta;
|
|
||||||
float momentumTime;
|
|
||||||
uint32_t elementId;
|
|
||||||
bool openThisFrame;
|
|
||||||
bool pointerScrollActive;
|
|
||||||
} Clay__ScrollContainerDataInternal;
|
|
||||||
|
|
||||||
Clay__ScrollContainerDataInternal CLAY__SCROLL_CONTAINER_DEFAULT = CLAY__INIT(Clay__ScrollContainerDataInternal) {};
|
Clay__ScrollContainerDataInternal CLAY__SCROLL_CONTAINER_DEFAULT = CLAY__INIT(Clay__ScrollContainerDataInternal) {};
|
||||||
|
|
||||||
// __GENERATED__ template array_define,array_allocate,array_add,array_get TYPE=Clay__ScrollContainerDataInternal NAME=Clay__ScrollContainerDataInternalArray DEFAULT_VALUE=&CLAY__SCROLL_CONTAINER_DEFAULT
|
// __GENERATED__ template array_define,array_allocate,array_add,array_get TYPE=Clay__ScrollContainerDataInternal NAME=Clay__ScrollContainerDataInternalArray DEFAULT_VALUE=&CLAY__SCROLL_CONTAINER_DEFAULT
|
||||||
#pragma region generated
|
#pragma region generated
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t capacity;
|
|
||||||
uint32_t length;
|
|
||||||
Clay__ScrollContainerDataInternal *internalArray;
|
|
||||||
} Clay__ScrollContainerDataInternalArray;
|
|
||||||
Clay__ScrollContainerDataInternalArray Clay__ScrollContainerDataInternalArray_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
Clay__ScrollContainerDataInternalArray Clay__ScrollContainerDataInternalArray_Allocate_Arena(uint32_t capacity, Clay_Arena *arena) {
|
||||||
return CLAY__INIT(Clay__ScrollContainerDataInternalArray){.capacity = capacity, .length = 0, .internalArray = (Clay__ScrollContainerDataInternal *)Clay__Array_Allocate_Arena(capacity, sizeof(Clay__ScrollContainerDataInternal), CLAY__ALIGNMENT(Clay__ScrollContainerDataInternal), arena)};
|
return CLAY__INIT(Clay__ScrollContainerDataInternalArray){.capacity = capacity, .length = 0, .internalArray = (Clay__ScrollContainerDataInternal *)Clay__Array_Allocate_Arena(capacity, sizeof(Clay__ScrollContainerDataInternal), CLAY__ALIGNMENT(Clay__ScrollContainerDataInternal), arena)};
|
||||||
}
|
}
|
||||||
@ -1546,7 +1562,7 @@ uint32_t Clay__RehashWithNumber(uint32_t id, uint32_t number) {
|
|||||||
|
|
||||||
uint32_t Clay__HashTextWithConfig(Clay_String *text, Clay_TextElementConfig *config) {
|
uint32_t Clay__HashTextWithConfig(Clay_String *text, Clay_TextElementConfig *config) {
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
uintptr_t pointerAsNumber = (uintptr_t)text->chars;
|
uint64_t pointerAsNumber = (uint64_t)text->chars;
|
||||||
|
|
||||||
hash += pointerAsNumber;
|
hash += pointerAsNumber;
|
||||||
hash += (hash << 10);
|
hash += (hash << 10);
|
||||||
@ -2881,14 +2897,14 @@ void Clay__AttachElementConfig(Clay_ElementConfigUnion config, Clay__ElementConf
|
|||||||
openLayoutElement->elementConfigs.length++;
|
openLayoutElement->elementConfigs.length++;
|
||||||
Clay__ElementConfigArray_Add(&Clay__elementConfigBuffer, CLAY__INIT(Clay_ElementConfig) { .type = type, .config = config });
|
Clay__ElementConfigArray_Add(&Clay__elementConfigBuffer, CLAY__INIT(Clay_ElementConfig) { .type = type, .config = config });
|
||||||
}
|
}
|
||||||
Clay_LayoutConfig * Clay__StoreLayoutConfig(Clay_LayoutConfig config) { return Clay__debugMaxElementsLatch ? &CLAY_LAYOUT_DEFAULT : Clay__LayoutConfigArray_Add(&Clay__layoutConfigs, config); }
|
inline Clay_LayoutConfig * Clay__StoreLayoutConfig(Clay_LayoutConfig config) { return Clay__debugMaxElementsLatch ? &CLAY_LAYOUT_DEFAULT : Clay__LayoutConfigArray_Add(&Clay__layoutConfigs, config); }
|
||||||
Clay_RectangleElementConfig * Clay__StoreRectangleElementConfig(Clay_RectangleElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__RECTANGLE_ELEMENT_CONFIG_DEFAULT : Clay__RectangleElementConfigArray_Add(&Clay__rectangleElementConfigs, config); }
|
inline Clay_RectangleElementConfig * Clay__StoreRectangleElementConfig(Clay_RectangleElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__RECTANGLE_ELEMENT_CONFIG_DEFAULT : Clay__RectangleElementConfigArray_Add(&Clay__rectangleElementConfigs, config); }
|
||||||
Clay_TextElementConfig * Clay__StoreTextElementConfig(Clay_TextElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__TEXT_ELEMENT_CONFIG_DEFAULT : Clay__TextElementConfigArray_Add(&Clay__textElementConfigs, config); }
|
inline Clay_TextElementConfig * Clay__StoreTextElementConfig(Clay_TextElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__TEXT_ELEMENT_CONFIG_DEFAULT : Clay__TextElementConfigArray_Add(&Clay__textElementConfigs, config); }
|
||||||
Clay_ImageElementConfig * Clay__StoreImageElementConfig(Clay_ImageElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__IMAGE_ELEMENT_CONFIG_DEFAULT : Clay__ImageElementConfigArray_Add(&Clay__imageElementConfigs, config); }
|
inline Clay_ImageElementConfig * Clay__StoreImageElementConfig(Clay_ImageElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__IMAGE_ELEMENT_CONFIG_DEFAULT : Clay__ImageElementConfigArray_Add(&Clay__imageElementConfigs, config); }
|
||||||
Clay_FloatingElementConfig * Clay__StoreFloatingElementConfig(Clay_FloatingElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__FLOATING_ELEMENT_CONFIG_DEFAULT : Clay__FloatingElementConfigArray_Add(&Clay__floatingElementConfigs, config); }
|
inline Clay_FloatingElementConfig * Clay__StoreFloatingElementConfig(Clay_FloatingElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__FLOATING_ELEMENT_CONFIG_DEFAULT : Clay__FloatingElementConfigArray_Add(&Clay__floatingElementConfigs, config); }
|
||||||
Clay_CustomElementConfig * Clay__StoreCustomElementConfig(Clay_CustomElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__CUSTOM_ELEMENT_CONFIG_DEFAULT : Clay__CustomElementConfigArray_Add(&Clay__customElementConfigs, config); }
|
inline Clay_CustomElementConfig * Clay__StoreCustomElementConfig(Clay_CustomElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__CUSTOM_ELEMENT_CONFIG_DEFAULT : Clay__CustomElementConfigArray_Add(&Clay__customElementConfigs, config); }
|
||||||
Clay_ScrollElementConfig * Clay__StoreScrollElementConfig(Clay_ScrollElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__SCROLL_ELEMENT_CONFIG_DEFAULT : Clay__ScrollElementConfigArray_Add(&Clay__scrollElementConfigs, config); }
|
inline Clay_ScrollElementConfig * Clay__StoreScrollElementConfig(Clay_ScrollElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__SCROLL_ELEMENT_CONFIG_DEFAULT : Clay__ScrollElementConfigArray_Add(&Clay__scrollElementConfigs, config); }
|
||||||
Clay_BorderElementConfig * Clay__StoreBorderElementConfig(Clay_BorderElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__BORDER_ELEMENT_CONFIG_DEFAULT : Clay__BorderElementConfigArray_Add(&Clay__borderElementConfigs, config); }
|
inline Clay_BorderElementConfig * Clay__StoreBorderElementConfig(Clay_BorderElementConfig config) { return Clay__debugMaxElementsLatch ? &CLAY__BORDER_ELEMENT_CONFIG_DEFAULT : Clay__BorderElementConfigArray_Add(&Clay__borderElementConfigs, config); }
|
||||||
|
|
||||||
#pragma region DebugTools
|
#pragma region DebugTools
|
||||||
Clay_Color CLAY__DEBUGVIEW_COLOR_1 = CLAY__INIT(Clay_Color) {58, 56, 52, 255};
|
Clay_Color CLAY__DEBUGVIEW_COLOR_1 = CLAY__INIT(Clay_Color) {58, 56, 52, 255};
|
||||||
@ -3211,7 +3227,7 @@ void Clay__RenderDebugView() {
|
|||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})}, .layoutDirection = CLAY_TOP_TO_BOTTOM }), CLAY_RECTANGLE({ .color = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 })) {
|
||||||
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0, 0);
|
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0, 0);
|
||||||
// Element list
|
// Element list
|
||||||
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})} }), CLAY_FLOATING({ .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH })) {
|
CLAY(Clay__AttachId(panelContentsId), CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})} }), CLAY_FLOATING({})) {
|
||||||
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
CLAY(CLAY_LAYOUT({ .sizing = {CLAY_SIZING_GROW({}), CLAY_SIZING_GROW({})}, .padding = {.x = CLAY__DEBUGVIEW_OUTER_PADDING }, .layoutDirection = CLAY_TOP_TO_BOTTOM })) {
|
||||||
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user