mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-23 22:58:06 +00:00
Compare commits
8 Commits
93871f0b47
...
499d205725
Author | SHA1 | Date | |
---|---|---|---|
|
499d205725 | ||
|
982ade4cf9 | ||
|
d5af2c3dc0 | ||
|
2677bec854 | ||
|
05ac2810d8 | ||
|
1f8cab8d72 | ||
|
6186596b41 | ||
|
94a3d57236 |
37
clay.h
37
clay.h
@ -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.
|
||||
@ -705,7 +709,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_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_PointerDataInteractionState state;
|
||||
Clay_PointerDataInteractionState state : 4;
|
||||
Clay_PointerDataInteractionState right_state : 4;
|
||||
} Clay_PointerData;
|
||||
|
||||
typedef struct {
|
||||
@ -798,6 +803,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,
|
||||
// as well as for Clay_Hovered() and scroll element handling.
|
||||
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.
|
||||
// - 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)
|
||||
@ -1654,6 +1661,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 +1942,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,
|
||||
@ -3664,8 +3676,8 @@ void Clay_SetLayoutDimensions(Clay_Dimensions dimensions) {
|
||||
Clay_GetCurrentContext()->layoutDimensions = dimensions;
|
||||
}
|
||||
|
||||
CLAY_WASM_EXPORT("Clay_SetPointerState")
|
||||
void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
||||
CLAY_WASM_EXPORT("Clay_SetPointerStateEx")
|
||||
void Clay_SetPointerStateEx(Clay_Vector2 position, bool isPointerDown, bool isRightPointerDown) {
|
||||
Clay_Context* context = Clay_GetCurrentContext();
|
||||
if (context->booleanWarnings.maxElementsExceeded) {
|
||||
return;
|
||||
@ -3737,6 +3749,25 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
||||
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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user