mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-17 15:58:05 +00:00
Compare commits
8 Commits
10cbf8a0fd
...
f47d25409e
Author | SHA1 | Date | |
---|---|---|---|
|
f47d25409e | ||
|
22e8cc318c | ||
|
8e6640f7a2 | ||
|
4f8957d5d2 | ||
|
af3d63ad0f | ||
|
0eb162e3a3 | ||
|
d1fd147b09 | ||
|
13b588d8c1 |
@ -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)`
|
||||||
|
@ -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 })
|
||||||
|
15
clay.h
15
clay.h
@ -266,7 +266,7 @@ typedef CLAY_PACKED_ENUM {
|
|||||||
CLAY_ALIGN_Y_TOP,
|
CLAY_ALIGN_Y_TOP,
|
||||||
// Aligns child elements to the bottom of this element, offset by padding.width.bottom
|
// Aligns child elements to the bottom of this element, offset by padding.width.bottom
|
||||||
CLAY_ALIGN_Y_BOTTOM,
|
CLAY_ALIGN_Y_BOTTOM,
|
||||||
// Aligns child elements vertiically to the center of this element
|
// Aligns child elements vertically to the center of this element
|
||||||
CLAY_ALIGN_Y_CENTER,
|
CLAY_ALIGN_Y_CENTER,
|
||||||
} Clay_LayoutAlignmentY;
|
} Clay_LayoutAlignmentY;
|
||||||
|
|
||||||
@ -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.
|
||||||
@ -796,6 +798,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)
|
||||||
@ -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,
|
||||||
@ -3732,6 +3737,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);
|
||||||
|
@ -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