Compare commits

...

4 Commits

Author SHA1 Message Date
Joshua Horowitz
41bc5cb1f7
Merge adc31f82e8 into 22e8cc318c 2025-03-07 23:30:20 -08:00
Nic Barker
22e8cc318c [Bindings/Odin] Update odin bindings for text config userdata pointer
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-08 11:08:04 +13:00
Michael Savage
8e6640f7a2
[Core] Add a userData pointer to Clay_TextElementConfig (#274) 2025-03-08 11:01:26 +13:00
Joshua Horowitz
adc31f82e8
Update README.md: it's gotten bigger 2025-03-03 21:38:25 -08:00
12 changed files with 8 additions and 3 deletions

View File

@ -4,7 +4,7 @@
### Major Features ### Major Features
- Microsecond layout performance - Microsecond layout performance
- Flex-box like layout model for complex, responsive layouts including text wrapping, scrolling containers and aspect ratio scaling - Flex-box like layout model for complex, responsive layouts including text wrapping, scrolling containers and aspect ratio scaling
- Single ~2k LOC **clay.h** file with **zero** dependencies (including no standard library) - Single ~4k LOC **clay.h** file with **zero** dependencies (including no standard library)
- Wasm support: compile with clang to a 15kb uncompressed **.wasm** file for use in the browser - Wasm support: compile with clang to a 15kb uncompressed **.wasm** file for use in the browser
- Static arena based memory use with no malloc / free, and low total memory overhead (e.g. ~3.5mb for 8192 layout elements). - Static arena based memory use with no malloc / free, and low total memory overhead (e.g. ~3.5mb for 8192 layout elements).
- React-like nested declarative syntax - React-like nested declarative syntax

View File

@ -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.

View File

@ -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 })

4
clay.h
View File

@ -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.
@ -2692,7 +2694,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,

View File

@ -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' },

View File

@ -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' },