aboutsummaryrefslogtreecommitdiff
path: root/third-party/clay
diff options
context:
space:
mode:
authorspl3g <spleefer6@yandex.ru>2025-10-10 22:17:32 +0300
committerspl3g <spleefer6@yandex.ru>2025-10-10 22:17:32 +0300
commit9a86280a6378615c70f8463e649ab0b025c2018a (patch)
tree508d99ed1c056cde162d73d390766ccf3fa01bb3 /third-party/clay
parent6e79fee0171f41a06389cfed19e050785fd33b93 (diff)
Fix clay pointer state update bug
Diffstat (limited to 'third-party/clay')
-rw-r--r--third-party/clay/clay.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/third-party/clay/clay.h b/third-party/clay/clay.h
index 7adf9ea..58a6093 100644
--- a/third-party/clay/clay.h
+++ b/third-party/clay/clay.h
@@ -3964,8 +3964,24 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
if (context->booleanWarnings.maxElementsExceeded) {
return;
}
+
context->pointerInfo.position = position;
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;
for (int32_t rootIndex = context->layoutElementTreeRoots.length - 1; rootIndex >= 0; --rootIndex) {
dfsBuffer.length = 0;
@@ -4013,20 +4029,6 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
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")