mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-23 14:48:06 +00:00
Compare commits
5 Commits
f598f4dde8
...
62b402bcbb
Author | SHA1 | Date | |
---|---|---|---|
|
62b402bcbb | ||
|
08e4c5b198 | ||
|
b1c72a0647 | ||
|
aee4baee1c | ||
|
46c962d7f2 |
@ -111,7 +111,6 @@ TextElementConfig :: struct {
|
|||||||
lineHeight: u16,
|
lineHeight: u16,
|
||||||
wrapMode: TextWrapMode,
|
wrapMode: TextWrapMode,
|
||||||
textAlignment: TextAlignment,
|
textAlignment: TextAlignment,
|
||||||
hashStringContents: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageElementConfig :: struct {
|
ImageElementConfig :: struct {
|
||||||
|
36
clay.h
36
clay.h
@ -1670,6 +1670,7 @@ Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Cl
|
|||||||
item.nextIndex = hashItem->nextIndex;
|
item.nextIndex = hashItem->nextIndex;
|
||||||
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
||||||
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
||||||
|
hashItem->idAlias = idAlias;
|
||||||
hashItem->generation = context->generation + 1;
|
hashItem->generation = context->generation + 1;
|
||||||
hashItem->layoutElement = layoutElement;
|
hashItem->layoutElement = layoutElement;
|
||||||
hashItem->debugData->collision = false;
|
hashItem->debugData->collision = false;
|
||||||
@ -3793,6 +3794,21 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
}
|
}
|
||||||
context->pointerInfo.position = position;
|
context->pointerInfo.position = position;
|
||||||
context->pointerOverIds.length = 0;
|
context->pointerOverIds.length = 0;
|
||||||
|
|
||||||
|
if (isPointerDown) {
|
||||||
|
if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
|
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED;
|
||||||
|
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) {
|
||||||
|
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) {
|
||||||
|
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED;
|
||||||
|
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) {
|
||||||
|
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Clay__int32_tArray dfsBuffer = context->layoutElementChildrenBuffer;
|
Clay__int32_tArray dfsBuffer = context->layoutElementChildrenBuffer;
|
||||||
for (int32_t rootIndex = context->layoutElementTreeRoots.length - 1; rootIndex >= 0; --rootIndex) {
|
for (int32_t rootIndex = context->layoutElementTreeRoots.length - 1; rootIndex >= 0; --rootIndex) {
|
||||||
dfsBuffer.length = 0;
|
dfsBuffer.length = 0;
|
||||||
@ -3810,10 +3826,10 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
Clay_LayoutElementHashMapItem *mapItem = Clay__GetHashMapItem(currentElement->id); // TODO think of a way around this, maybe the fact that it's essentially a binary tree limits the cost, but the worst case is not great
|
Clay_LayoutElementHashMapItem *mapItem = Clay__GetHashMapItem(currentElement->id); // TODO think of a way around this, maybe the fact that it's essentially a binary tree limits the cost, but the worst case is not great
|
||||||
int32_t clipElementId = Clay__int32_tArray_GetValue(&context->layoutElementClipElementIds, (int32_t)(currentElement - context->layoutElements.internalArray));
|
int32_t clipElementId = Clay__int32_tArray_GetValue(&context->layoutElementClipElementIds, (int32_t)(currentElement - context->layoutElements.internalArray));
|
||||||
Clay_LayoutElementHashMapItem *clipItem = Clay__GetHashMapItem(clipElementId);
|
Clay_LayoutElementHashMapItem *clipItem = Clay__GetHashMapItem(clipElementId);
|
||||||
Clay_BoundingBox elementBox = mapItem->boundingBox;
|
|
||||||
elementBox.x -= root->pointerOffset.x;
|
|
||||||
elementBox.y -= root->pointerOffset.y;
|
|
||||||
if (mapItem) {
|
if (mapItem) {
|
||||||
|
Clay_BoundingBox elementBox = mapItem->boundingBox;
|
||||||
|
elementBox.x -= root->pointerOffset.x;
|
||||||
|
elementBox.y -= root->pointerOffset.y;
|
||||||
if ((Clay__PointIsInsideRect(position, elementBox)) && (clipElementId == 0 || (Clay__PointIsInsideRect(position, clipItem->boundingBox)))) {
|
if ((Clay__PointIsInsideRect(position, elementBox)) && (clipElementId == 0 || (Clay__PointIsInsideRect(position, clipItem->boundingBox)))) {
|
||||||
if (mapItem->onHoverFunction) {
|
if (mapItem->onHoverFunction) {
|
||||||
mapItem->onHoverFunction(mapItem->elementId, context->pointerInfo, mapItem->hoverFunctionUserData);
|
mapItem->onHoverFunction(mapItem->elementId, context->pointerInfo, mapItem->hoverFunctionUserData);
|
||||||
@ -3844,20 +3860,6 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPointerDown) {
|
|
||||||
if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
|
||||||
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED;
|
|
||||||
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) {
|
|
||||||
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) {
|
|
||||||
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED;
|
|
||||||
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) {
|
|
||||||
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY_WASM_EXPORT("Clay_Initialize")
|
CLAY_WASM_EXPORT("Clay_Initialize")
|
||||||
|
Loading…
Reference in New Issue
Block a user