Compare commits

...

8 Commits

Author SHA1 Message Date
Nick
1a3c8c69cb
Merge 46c962d7f2 into 982ade4cf9 2025-03-18 17:31:58 +02:00
Nic Barker
982ade4cf9 [Compilers] Add a dummy function to suppress unused variable warning in GCC
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
2025-03-18 11:21:23 +13:00
Nic Barker
d5af2c3dc0
[Renderers/SDL2] Added explicit include of math.h in SDL2 renderer 2025-03-18 11:13:46 +13:00
Nic Barker
2677bec854 [Housekeeping] Revert previous commit to allow proper PR attribution 2025-03-18 11:12:21 +13:00
Nic Barker
05ac2810d8 [Renderers/SDL2] Added explicit include of math.h in SDL2 renderer 2025-03-18 11:10:53 +13:00
Nic Barker
1f8cab8d72 [Core] Fix a bug where floating elements could be clipped incorrectly 2025-03-18 11:05:06 +13:00
Emerald-Ruby
6186596b41
math.h include missing cause lots of warning logs 2025-03-15 21:51:36 +00:00
Nicholas Molloy
46c962d7f2 Update the pointer state before the onHover function is called 2025-03-03 14:18:36 +13:00
2 changed files with 25 additions and 14 deletions

38
clay.h
View File

@ -102,6 +102,10 @@
static uint8_t CLAY__ELEMENT_DEFINITION_LATCH;
// GCC marks the above CLAY__ELEMENT_DEFINITION_LATCH as an unused variable for files that include clay.h but don't declare any layout
// This is to suppress that warning
static inline void Clay__SuppressUnusedLatchDefinitionVariableWarning(void) { (void) CLAY__ELEMENT_DEFINITION_LATCH; }
// Publicly visible layout element macros -----------------------------------------------------
/* This macro looks scary on the surface, but is actually quite simple.
@ -1654,6 +1658,8 @@ void Clay__CloseElement(void) {
elementHasScrollVertical = config->config.scrollElementConfig->vertical;
context->openClipElementStack.length--;
break;
} else if (config->type == CLAY__ELEMENT_CONFIG_TYPE_FLOATING) {
context->openClipElementStack.length--;
}
}
@ -1933,6 +1939,9 @@ void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
if (!openLayoutElementId.id) {
openLayoutElementId = Clay__HashString(CLAY_STRING("Clay__FloatingContainer"), context->layoutElementTreeRoots.length, 0);
}
int32_t currentElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1);
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, currentElementIndex, clipElementId);
Clay__int32_tArray_Add(&context->openClipElementStack, clipElementId);
Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) {
.layoutElementIndex = Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1),
.parentId = floatingConfig.parentId,
@ -3672,6 +3681,21 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
}
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;
@ -3723,20 +3747,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")

View File

@ -3,6 +3,7 @@
#include <SDL_ttf.h>
#include <SDL_image.h>
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159