mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-22 06:08:03 +00:00
Compare commits
4 Commits
1f9b779dd1
...
14b51ef348
Author | SHA1 | Date | |
---|---|---|---|
|
14b51ef348 | ||
|
b33ba4ff62 | ||
|
f88f0517f7 | ||
|
94a3d57236 |
12
README.md
12
README.md
@ -1787,7 +1787,8 @@ Note: when using the debug tools, their internal colors are represented as 0-255
|
|||||||
|
|
||||||
```C
|
```C
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int length;
|
bool isStaticallyAllocated;
|
||||||
|
int32_t length;
|
||||||
const char *chars;
|
const char *chars;
|
||||||
} Clay_String;
|
} Clay_String;
|
||||||
```
|
```
|
||||||
@ -1796,7 +1797,14 @@ typedef struct {
|
|||||||
|
|
||||||
**Fields**
|
**Fields**
|
||||||
|
|
||||||
**`.length`** - `int`
|
**`.isStaticallyAllocated`** - `bool`
|
||||||
|
|
||||||
|
Whether or not the string is statically allocated, or in other words, whether
|
||||||
|
or not it lives for the entire lifetime of the program.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**`.length`** - `int32_t`
|
||||||
|
|
||||||
The number of characters in the string, _not including an optional null terminator._
|
The number of characters in the string, _not including an optional null terminator._
|
||||||
|
|
||||||
|
30
clay.h
30
clay.h
@ -708,7 +708,8 @@ typedef struct {
|
|||||||
// CLAY_POINTER_DATA_PRESSED - The left mouse button click or touch happened at some point in the past, and is still currently held down this frame.
|
// CLAY_POINTER_DATA_PRESSED - The left mouse button click or touch happened at some point in the past, and is still currently held down this frame.
|
||||||
// CLAY_POINTER_DATA_RELEASED_THIS_FRAME - The left mouse button click or touch was released this frame.
|
// CLAY_POINTER_DATA_RELEASED_THIS_FRAME - The left mouse button click or touch was released this frame.
|
||||||
// CLAY_POINTER_DATA_RELEASED - The left mouse button click or touch is not currently down / was released at some point in the past.
|
// CLAY_POINTER_DATA_RELEASED - The left mouse button click or touch is not currently down / was released at some point in the past.
|
||||||
Clay_PointerDataInteractionState state;
|
Clay_PointerDataInteractionState state : 4;
|
||||||
|
Clay_PointerDataInteractionState right_state : 4;
|
||||||
} Clay_PointerData;
|
} Clay_PointerData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -801,6 +802,8 @@ 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,
|
// 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.
|
// as well as for Clay_Hovered() and scroll element handling.
|
||||||
CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown);
|
CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown);
|
||||||
|
// Same as `Clay_SetPointerState` but includes right click info
|
||||||
|
CLAY_DLL_EXPORT void Clay_SetPointerStateEx(Clay_Vector2 position, bool pointerDown, bool rightPointerDown);
|
||||||
// Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once.
|
// 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()
|
// - 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)
|
// - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout)
|
||||||
@ -1392,6 +1395,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
|
|||||||
Clay__SIMDARXMix(&v2, &v3);
|
Clay__SIMDARXMix(&v2, &v3);
|
||||||
v0 = _mm_add_epi64(v0, v2);
|
v0 = _mm_add_epi64(v0, v2);
|
||||||
v1 = _mm_add_epi64(v1, v3);
|
v1 = _mm_add_epi64(v1, v3);
|
||||||
|
v0 = _mm_add_epi64(v0, v1);
|
||||||
|
|
||||||
uint64_t result[2];
|
uint64_t result[2];
|
||||||
_mm_storeu_si128((__m128i*)result, v0);
|
_mm_storeu_si128((__m128i*)result, v0);
|
||||||
@ -1445,6 +1449,7 @@ uint64_t Clay__HashData(const uint8_t* data, size_t length) {
|
|||||||
Clay__SIMDARXMix(&v2, &v3);
|
Clay__SIMDARXMix(&v2, &v3);
|
||||||
v0 = vaddq_u64(v0, v2);
|
v0 = vaddq_u64(v0, v2);
|
||||||
v1 = vaddq_u64(v1, v3);
|
v1 = vaddq_u64(v1, v3);
|
||||||
|
v0 = vaddq_u64(v0, v1);
|
||||||
|
|
||||||
uint64_t result[2];
|
uint64_t result[2];
|
||||||
vst1q_u64(result, v0);
|
vst1q_u64(result, v0);
|
||||||
@ -3784,8 +3789,8 @@ void Clay_SetLayoutDimensions(Clay_Dimensions dimensions) {
|
|||||||
Clay_GetCurrentContext()->layoutDimensions = dimensions;
|
Clay_GetCurrentContext()->layoutDimensions = dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY_WASM_EXPORT("Clay_SetPointerState")
|
CLAY_WASM_EXPORT("Clay_SetPointerStateEx")
|
||||||
void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
void Clay_SetPointerStateEx(Clay_Vector2 position, bool isPointerDown, bool isRightPointerDown) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
if (context->booleanWarnings.maxElementsExceeded) {
|
if (context->booleanWarnings.maxElementsExceeded) {
|
||||||
return;
|
return;
|
||||||
@ -3857,6 +3862,25 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
|||||||
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isRightPointerDown) {
|
||||||
|
if (context->pointerInfo.right_state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
|
||||||
|
context->pointerInfo.right_state = CLAY_POINTER_DATA_PRESSED;
|
||||||
|
} else if (context->pointerInfo.right_state != CLAY_POINTER_DATA_PRESSED) {
|
||||||
|
context->pointerInfo.right_state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (context->pointerInfo.right_state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) {
|
||||||
|
context->pointerInfo.right_state = CLAY_POINTER_DATA_RELEASED;
|
||||||
|
} else if (context->pointerInfo.right_state != CLAY_POINTER_DATA_RELEASED) {
|
||||||
|
context->pointerInfo.right_state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CLAY_WASM_EXPORT("Clay_SetPointerState")
|
||||||
|
void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown)
|
||||||
|
{
|
||||||
|
Clay_SetPointerStateEx(position, isPointerDown, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY_WASM_EXPORT("Clay_Initialize")
|
CLAY_WASM_EXPORT("Clay_Initialize")
|
||||||
|
@ -22,7 +22,7 @@ FetchContent_MakeAvailable(fontstash)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
sokol
|
sokol
|
||||||
GIT_REPOSITORY "https://github.com/floooh/sokol.git"
|
GIT_REPOSITORY "https://github.com/floooh/sokol.git"
|
||||||
GIT_TAG "da9de496f938b7575eff7f01ab774d77469bd390"
|
GIT_TAG "master"
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
GIT_SHALLOW TRUE
|
GIT_SHALLOW TRUE
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user