Compare commits

...

8 Commits

Author SHA1 Message Date
Joram Vandemoortele
479a30f146
Merge af3d63ad0f into 1204ac400b 2025-03-28 19:12:05 +07:00
Nic Barker
1204ac400b [Compilers] Fix implicit typecast in simd hash function
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-28 11:52:20 +13:00
Nic Barker
6a7ce77024 [Core] Fix implicit simd typecast on arm architectures 2025-03-28 11:47:57 +13:00
Piggybank Studios
7c9506bc31
[Core] Fix CLAY__ELEMENT_DEFINITION_LATCH overflow in CLAY macro if 256 loops end at the same time
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-27 10:14:17 +13:00
Orcolom
af3d63ad0f added dll_export macro 2025-02-26 21:13:36 +01:00
Orcolom
0eb162e3a3 Merge branch 'main' into feature/get-pointer
# Conflicts:
#	clay.h
2025-02-26 21:12:35 +01:00
Orcolom
d1fd147b09 added getpointerstate to readme 2025-02-19 22:01:25 +01:00
Orcolom
13b588d8c1 added a pointer get method 2025-02-19 21:54:08 +01:00
2 changed files with 22 additions and 4 deletions

View File

@ -169,6 +169,7 @@ For help starting out or to discuss clay, considering joining [the discord serve
- [Clay_SetCurrentContext](#clay_setcurrentcontext)
- [Clay_SetLayoutDimensions](#clay_setlayoutdimensions)
- [Clay_SetPointerState](#clay_setpointerstate)
- [Clay_GetPointerState](#clay_getpointerstate)
- [Clay_UpdateScrollContainers](#clay_updatescrollcontainers)
- [Clay_BeginLayout](#clay_beginlayout)
- [Clay_EndLayout](#clay_endlayout)
@ -646,6 +647,14 @@ Sets the internal pointer position and state (i.e. current mouse / touch positio
---
### Clay_GetPointerState
`Clay_PointerData Clay_GetPointerState()`
Get the internal pointer position and state (i.e. current mouse / touch position). returns clay internal click start and stop state.
---
### Clay_UpdateScrollContainers
`void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)`

17
clay.h
View File

@ -136,7 +136,7 @@ static inline void Clay__SuppressUnusedLatchDefinitionVariableWarning(void) { (v
for ( \
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), Clay__ConfigureOpenElement(CLAY__CONFIG_WRAPPER(Clay_ElementDeclaration, __VA_ARGS__)), 0); \
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
++CLAY__ELEMENT_DEFINITION_LATCH, Clay__CloseElement() \
CLAY__ELEMENT_DEFINITION_LATCH=1, Clay__CloseElement() \
)
// These macros exist to allow the CLAY() macro to be called both with an inline struct definition, such as
@ -801,6 +801,9 @@ CLAY_DLL_EXPORT Clay_Arena Clay_CreateArenaWithCapacityAndMemory(size_t capacity
// Sets the state of the "pointer" (i.e. the mouse or touch) in Clay's internal data. Used for detecting and responding to mouse events in the debug view,
// as well as for Clay_Hovered() and scroll element handling.
CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown);
// Gets the state of the "pointer". This will return the position provided by `Clay_SetPointerState`
// and the frame pressed state.
CLAY_DLL_EXPORT Clay_PointerData Clay_GetPointerState();
// Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once.
// - arena can be created using Clay_CreateArenaWithCapacityAndMemory()
// - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout)
@ -1373,7 +1376,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
length -= 16;
}
else {
for (int i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
overflowBuffer[i] = data[i];
}
msg = _mm_loadu_si128((const __m128i*)overflowBuffer);
@ -1430,11 +1433,11 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
length -= 8;
}
else {
for (int i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
overflowBuffer[i] = data[i];
}
uint8x8_t lower = vld1_u8(overflowBuffer);
msg = vcombine_u8(lower, vdup_n_u8(0));
msg = vreinterpretq_u64_u8(vcombine_u8(lower, vdup_n_u8(0)));
length = 0;
}
v0 = veorq_u64(v0, msg);
@ -3861,6 +3864,12 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
}
}
CLAY_WASM_EXPORT("Clay_GetPointerState")
Clay_PointerData Clay_GetPointerState() {
Clay_Context* context = Clay_GetCurrentContext();
return context->pointerInfo;
}
CLAY_WASM_EXPORT("Clay_Initialize")
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
Clay_Context *context = Clay__Context_Allocate_Arena(&arena);