mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-22 06:08:03 +00:00
Compare commits
9 Commits
d000ea1fd8
...
7da283045d
Author | SHA1 | Date | |
---|---|---|---|
|
7da283045d | ||
|
b33ba4ff62 | ||
|
f88f0517f7 | ||
|
5391a259f3 | ||
|
fe2d44a888 | ||
|
af3d63ad0f | ||
|
0eb162e3a3 | ||
|
d1fd147b09 | ||
|
13b588d8c1 |
21
README.md
21
README.md
@ -169,6 +169,7 @@ For help starting out or to discuss clay, considering joining [the discord serve
|
|||||||
- [Clay_SetCurrentContext](#clay_setcurrentcontext)
|
- [Clay_SetCurrentContext](#clay_setcurrentcontext)
|
||||||
- [Clay_SetLayoutDimensions](#clay_setlayoutdimensions)
|
- [Clay_SetLayoutDimensions](#clay_setlayoutdimensions)
|
||||||
- [Clay_SetPointerState](#clay_setpointerstate)
|
- [Clay_SetPointerState](#clay_setpointerstate)
|
||||||
|
- [Clay_GetPointerState](#clay_getpointerstate)
|
||||||
- [Clay_UpdateScrollContainers](#clay_updatescrollcontainers)
|
- [Clay_UpdateScrollContainers](#clay_updatescrollcontainers)
|
||||||
- [Clay_BeginLayout](#clay_beginlayout)
|
- [Clay_BeginLayout](#clay_beginlayout)
|
||||||
- [Clay_EndLayout](#clay_endlayout)
|
- [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
|
### Clay_UpdateScrollContainers
|
||||||
|
|
||||||
`void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)`
|
`void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)`
|
||||||
@ -1787,7 +1796,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 +1806,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._
|
||||||
|
|
||||||
|
11
clay.h
11
clay.h
@ -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,
|
// 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);
|
||||||
|
// 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.
|
// 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);
|
||||||
@ -3859,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_WASM_EXPORT("Clay_Initialize")
|
||||||
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
|
Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) {
|
||||||
Clay_Context *context = Clay__Context_Allocate_Arena(&arena);
|
Clay_Context *context = Clay__Context_Allocate_Arena(&arena);
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
@ -157,7 +157,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands, Font* fonts)
|
|||||||
if(strlen > temp_render_buffer_len) {
|
if(strlen > temp_render_buffer_len) {
|
||||||
// Grow the temp buffer if we need a larger string
|
// Grow the temp buffer if we need a larger string
|
||||||
if(temp_render_buffer) free(temp_render_buffer);
|
if(temp_render_buffer) free(temp_render_buffer);
|
||||||
temp_render_buffer = malloc(strlen);
|
temp_render_buffer = (char *) malloc(strlen);
|
||||||
temp_render_buffer_len = strlen;
|
temp_render_buffer_len = strlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands, Font* fonts)
|
|||||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomLeft > 0) {
|
if (config->cornerRadius.bottomLeft > 0) {
|
||||||
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.top), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.bottom), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
}
|
}
|
||||||
if (config->cornerRadius.bottomRight > 0) {
|
if (config->cornerRadius.bottomRight > 0) {
|
||||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||||
|
Loading…
Reference in New Issue
Block a user