mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-17 15:58:05 +00:00
Compare commits
4 Commits
2a7169e120
...
b165b69200
Author | SHA1 | Date | |
---|---|---|---|
|
b165b69200 | ||
|
22e8cc318c | ||
|
8e6640f7a2 | ||
|
94a3d57236 |
@ -102,6 +102,7 @@ TextAlignment :: enum EnumBackingType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextElementConfig :: struct {
|
TextElementConfig :: struct {
|
||||||
|
userData: rawptr,
|
||||||
textColor: Color,
|
textColor: Color,
|
||||||
fontId: u16,
|
fontId: u16,
|
||||||
fontSize: u16,
|
fontSize: u16,
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -489,7 +489,7 @@ errorHandler :: proc "c" (errorData: clay.ErrorData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
minMemorySize: u32 = clay.MinMemorySize()
|
minMemorySize: c.size_t = cast(c.size_t)clay.MinMemorySize()
|
||||||
memory := make([^]u8, minMemorySize)
|
memory := make([^]u8, minMemorySize)
|
||||||
arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory)
|
arena: clay.Arena = clay.CreateArenaWithCapacityAndMemory(minMemorySize, memory)
|
||||||
clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler })
|
clay.Initialize(arena, {cast(f32)raylib.GetScreenWidth(), cast(f32)raylib.GetScreenHeight()}, { handler = errorHandler })
|
||||||
|
32
clay.h
32
clay.h
@ -357,6 +357,8 @@ typedef CLAY_PACKED_ENUM {
|
|||||||
|
|
||||||
// Controls various functionality related to text elements.
|
// Controls various functionality related to text elements.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
// A pointer that will be transparently passed through to the resulting render command.
|
||||||
|
void *userData;
|
||||||
// The RGBA color of the font to render, conventionally specified as 0-255.
|
// The RGBA color of the font to render, conventionally specified as 0-255.
|
||||||
Clay_Color textColor;
|
Clay_Color textColor;
|
||||||
// An integer transparently passed to Clay_MeasureText to identify the font to use.
|
// An integer transparently passed to Clay_MeasureText to identify the font to use.
|
||||||
@ -703,7 +705,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 {
|
||||||
@ -796,6 +799,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)
|
||||||
@ -2692,7 +2697,7 @@ void Clay__CalculateFinalLayout(void) {
|
|||||||
.letterSpacing = textElementConfig->letterSpacing,
|
.letterSpacing = textElementConfig->letterSpacing,
|
||||||
.lineHeight = textElementConfig->lineHeight,
|
.lineHeight = textElementConfig->lineHeight,
|
||||||
}},
|
}},
|
||||||
.userData = sharedConfig->userData,
|
.userData = textElementConfig->userData,
|
||||||
.id = Clay__HashNumber(lineIndex, currentElement->id).id,
|
.id = Clay__HashNumber(lineIndex, currentElement->id).id,
|
||||||
.zIndex = root->zIndex,
|
.zIndex = root->zIndex,
|
||||||
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,
|
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT,
|
||||||
@ -3657,8 +3662,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;
|
||||||
@ -3730,6 +3735,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")
|
||||||
|
@ -119,6 +119,7 @@
|
|||||||
{name: 'bottomRight', type: 'float'},
|
{name: 'bottomRight', type: 'float'},
|
||||||
]};
|
]};
|
||||||
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
||||||
|
{ name: 'userData', type: 'uint32_t' },
|
||||||
{ name: 'textColor', ...colorDefinition },
|
{ name: 'textColor', ...colorDefinition },
|
||||||
{ name: 'fontId', type: 'uint16_t' },
|
{ name: 'fontId', type: 'uint16_t' },
|
||||||
{ name: 'fontSize', type: 'uint16_t' },
|
{ name: 'fontSize', type: 'uint16_t' },
|
||||||
|
Binary file not shown.
@ -119,6 +119,7 @@
|
|||||||
{name: 'bottomRight', type: 'float'},
|
{name: 'bottomRight', type: 'float'},
|
||||||
]};
|
]};
|
||||||
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
let textConfigDefinition = { name: 'text', type: 'struct', members: [
|
||||||
|
{ name: 'userData', type: 'uint32_t' },
|
||||||
{ name: 'textColor', ...colorDefinition },
|
{ name: 'textColor', ...colorDefinition },
|
||||||
{ name: 'fontId', type: 'uint16_t' },
|
{ name: 'fontId', type: 'uint16_t' },
|
||||||
{ name: 'fontSize', type: 'uint16_t' },
|
{ name: 'fontSize', type: 'uint16_t' },
|
||||||
|
Loading…
Reference in New Issue
Block a user