| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| clay-odin.zip | 2025-06-06 | 595.0 kB | |
| clay.h | 2025-06-06 | 266.1 kB | |
| 0.14 - Aspect Ratio Elements, Better Clipping source code.tar.gz | 2025-06-06 | 3.6 MB | |
| 0.14 - Aspect Ratio Elements, Better Clipping source code.zip | 2025-06-06 | 3.6 MB | |
| README.md | 2025-06-06 | 15.5 kB | |
| Totals: 5 Items | 8.1 MB | 0 | |
New Features
Non-image aspect ratio scaling elements, image stretching
Previously, only image elements supported aspect ratio scaling. The new .aspectRatio element configuration option allows you to specify a fixed width / height aspect ratio for any element. This also allows you to create image elements with no specified aspect ratio, allowing for stretched / distorted images with a different aspect ratio to their source dimensions. Different images rendering modes similar to the CSS concepts of contain and cover, as well as 9-slice support are scheduled for 0.15.
:::C
// Old
CLAY({
.image = { .imageData = &myImage, .sourceDimensions = { 1024, 768 } }
});
// New
CLAY({
.aspectRatio = 1024.0 / 768.0,
.image = { .imageData = &myImage }
});
Improved .clip configuration option replaces .scroll
As part of our longer term effort to separate interaction handling from the core layout library, the .scroll configuration option has been replace with .clip. This new configuration options allows:
- Cllipping of elements without enabling scrolling, similar to CSS's overflow:hidden
- Immediate mode scroll handling, by providing scroll offset directly to .clip.childOffset.
To use Clay's internal scroll handling (i.e. emulate the old .scroll behaviour, you can use the new function, Clay_GetScrollOffset function.
:::C
// Old
CLAY({
.scroll = { .vertical = true } // scrolling was automatically handled internally
});
// New, using clay's built in scroll handling
CLAY({
.clip = {
.vertical = true,
.childOffset = Clay_GetScrollOffset() // This function is context dependent and will automatically track scrolling for this element across frames
}
});
// New, providing your own scroll handling
Clay_Vector2 scrollOffset = { 0, 120 };
CLAY({
.clip = {
.vertical = true,
.childOffset = scrollOffset // This will offset all children by the provided Vector2 this frame, so scrolling can be handled externally
}
});
// New, clipping overflow without enabling scrolling
CLAY({
.clip = { .vertical = true }
});
New Renderers
We now have a simple ANSI terminal renderer (thanks to @EmmanuelMess), a Playdate renderer (thanks to @mattahj), a Windows GDI renderer (thanks to @hexmaster111), and a Sokol renderer (thanks to @nkorth). All of them look great!
Terminal Renderer
https://github.com/user-attachments/assets/a1819a24-cb57-4792-81d8-7929f9cc1b80
Playdate Renderer
Windows GDI renderer
Small Changes
- Hashing of text contents for the text measurement cache is now the default behaviour, and has a reasonably performant SIMD implementation both for x64 and ARM. Using a frame arena or scratch storage for text element strings should now work much more reliably.
- Layout calculations for some GROW edge cases, as well as aspect ratio scaling, have been improved.
- A new function, Clay_GetPointerOverIds is now available, which will return a z-sorted list of IDs of elements that the cursor is currently over.
Migration Guide
-
Convert any
.scrollconfiguration usage into.clip, and add.childOffset = Clay_GetScrollOffset()to emulate existing behaviour:::diff CLAY({ - .scroll = { + .clip = { .vertical = true, + .childOffset = Clay_GetScrollOffset() } })
-
Split any
.imageconfiguration into.imageand.aspectRatio:::diff CLAY({ .image = { .imageData = &myImage, - .sourceDimensions = { 1024, 768 } }, + .aspectRatio = { 1024.0 / 768.0 } })
-
Remove any references to
.hashStringContentsinCLAY_TEXT_CONFIG, this is now the default behaviour and no longer needed.:::diff CLAY_TEXT(CLAY_STRING("hello"), CLAY_TEXT_CONFIG({ - .hashStringContents = true }));
Changelist
- [Renderers/SDL3] Use text engine to render text on the SDL3 renderer by @ernestoyaquello in https://github.com/nicbarker/clay/pull/256
- [Renderers/SDL3] Add image rendering and scissor support to SDL3 renderer by @steviegt6 in https://github.com/nicbarker/clay/pull/246
- [Renderers/SDL2] add rounded corner borders and fixed maximum radius issues. by @TimothyHoytBSME in https://github.com/nicbarker/clay/pull/258
- [Renderers/SDL3] Enable sdl3 alpha blending by @irfan-zahir in https://github.com/nicbarker/clay/pull/261
- [Renderers/SDL2] Make SDL_RenderCornerBorder static by @TimothyHoytBSME in https://github.com/nicbarker/clay/pull/263
- [Renderers/Raylib] Convert Image usage to Texture by @CrackedPixel in https://github.com/nicbarker/clay/pull/266
- [Examples/SDL2] opengl, antialiasing, vsync, alpha blending by @TimothyHoytBSME in https://github.com/nicbarker/clay/pull/264
- [Bindings/Odin] add missing bindings, fix binding, improve ergonomics of userdata, conform to stricter style flags by @laytan in https://github.com/nicbarker/clay/pull/270
- Make Clay_MinMemorySize accurate based on word cache count by @alecks in https://github.com/nicbarker/clay/pull/269
- Fix inverted condition for setting booleanWarnings.maxTextMeasureCacheExceeded by @mizmar in https://github.com/nicbarker/clay/pull/275
- [Documentation] Update
README.mdfor Odin bindings to reflect the latest API changes. by @benjamindblock in https://github.com/nicbarker/clay/pull/281 - [Compilers] Added DLL macro to support .dll building by @Orcolom in https://github.com/nicbarker/clay/pull/278
- [Macros] Add versions of the CLAY_ID macros that take Clay_String by @FintasticMan in https://github.com/nicbarker/clay/pull/285
- [Core] Improve & streamline grow / shrink handling by @nicbarker in https://github.com/nicbarker/clay/pull/296
- [Bindings/Odin] fix CreateArenaWithCapacityAndMemory capacity type by @laytan in https://github.com/nicbarker/clay/pull/306
- [Renderers/Raylib] Use RayLib Default font if user font failed to load or was not specified. by @hexmaster111 in https://github.com/nicbarker/clay/pull/305
- [Documentation] fix example in README by @RicoP in https://github.com/nicbarker/clay/pull/307
- [Documentation] Fix typo in "vertiically" by @bowbahdoe in https://github.com/nicbarker/clay/pull/315
- [Core] Add a userData pointer to Clay_TextElementConfig by @mikejsavage in https://github.com/nicbarker/clay/pull/274
- [Compilers] Fixed SIMD related compile error on some ARM compilers by @emoon in https://github.com/nicbarker/clay/pull/316
- [Core] Support passing declaration by pointer as well by @emoon in https://github.com/nicbarker/clay/pull/319
- [Documentation] Update README.md: it's gotten bigger by @joshuahhh in https://github.com/nicbarker/clay/pull/300
- [Renderers/SDL2] Enable live resizing of layout during window resize in SDL2 by @shakkar23 in https://github.com/nicbarker/clay/pull/320
- [Renderers\win32_gdi] Create initial WinGDI renderer by @hexmaster111 in https://github.com/nicbarker/clay/pull/322
- [Compilers] Fix integer truncation warnings with explicit casts by @Nelarius in https://github.com/nicbarker/clay/pull/317
- [Renderers/Raylib] Reuse memory in raylib renderer for temporary string allocations by @hexmaster111 in https://github.com/nicbarker/clay/pull/298
- [Renderers/SDL2] Fix rounded corner border index by @mizmar in https://github.com/nicbarker/clay/pull/295
- [Renderers/SDL2] Added explicit include of math.h in SDL2 renderer by @Emerald-Ruby in https://github.com/nicbarker/clay/pull/327
- [Bindings/Odin] expose _OpenElement and _CloseElement by @lzurbriggen in https://github.com/nicbarker/clay/pull/301
- [Core] Switch text content hashing to default behaviour by @nicbarker in https://github.com/nicbarker/clay/pull/335
- [Core] Guard against hashmap item null dereference by @igadmg in https://github.com/nicbarker/clay/pull/338
- [Bindings/Odin] Remove field hashStringContents in odin bindings by @ellie-but-backwards in https://github.com/nicbarker/clay/pull/350
- [Core] Fix CLAY__ELEMENT_DEFINITION_LATCH overflow in CLAY macro if 256 loops end at the same time by @PiggybankStudios in https://github.com/nicbarker/clay/pull/349
- [Cmake] Basic CMake support for easier import into CMake projects by @Qualadia in https://github.com/nicbarker/clay/pull/345
- [Renderers/WinGDI] Working on Win32 GDI renderer and example by @Philosoph228 in https://github.com/nicbarker/clay/pull/344
- [Renderers/Sokol] Sokol renderer & examples by @nkorth in https://github.com/nicbarker/clay/pull/373
- [Renderers/Raylib] Add explicit type cast for malloc by @boringlily in https://github.com/nicbarker/clay/pull/379
- [Renderers/Raylib] fix bottom left corner radius of border by @timlueg in https://github.com/nicbarker/clay/pull/378
- [Documentation] Fix Clay_String definition in README.md file. by @Oglo12 in https://github.com/nicbarker/clay/pull/374
- [Core] Fix a string hash bug with single characters by @nicbarker in https://github.com/nicbarker/clay/pull/384
- [Core] Replace .scroll config with .clip by @nicbarker in https://github.com/nicbarker/clay/pull/376
- [Bindings/Odin] Odin Raylib renderer rewrite by @rats159 in https://github.com/nicbarker/clay/pull/395
- [Bindings/Odin] Updated odin bindings with new clip config by @A1029384756 in https://github.com/nicbarker/clay/pull/397
- [Renderers/SDL3] Use
SDL_Textureinstead ofSDL_Surfacefor images by @linkdd in https://github.com/nicbarker/clay/pull/402 - [Debug] Update
Clay__RenderDebugLayoutSizingto handle more sizing types. by @tritao in https://github.com/nicbarker/clay/pull/392 - Fix README: use correct anchor to Clay_CustomElementConfig by @dgellow in https://github.com/nicbarker/clay/pull/403
- [Bindings/Odin] Add missing border macros to Odin bindings by @Kelimion in https://github.com/nicbarker/clay/pull/407
- [Core] Add
Clay_GetPointerOverIdsfunction to the public API. by @tritao in https://github.com/nicbarker/clay/pull/389 - [Core] Add Clay_FloatingClipToElement by @pdoane in https://github.com/nicbarker/clay/pull/413
- [Core] restore compatibility with C99 by @gmasil in https://github.com/nicbarker/clay/pull/412
- [Documentation] Add Go rewrites of clay to README by @soypat in https://github.com/nicbarker/clay/pull/411
- [Renderers/Cairo] Fix cairo renderer and example by @zordythezordan in https://github.com/nicbarker/clay/pull/416
- [Renderers/Playdate] Playdate console example by @mattahj in https://github.com/nicbarker/clay/pull/404
- [Renderers/Terminal] Add initial implementation of terminal renderer by @EmmanuelMess in https://github.com/nicbarker/clay/pull/91
- Add struct names to public structs by @Nelarius in https://github.com/nicbarker/clay/pull/336
- [CMake] Indent SDL2's CMakeLists.txt consistently by @weslord in https://github.com/nicbarker/clay/pull/424
- [Core] Fix sign comparison warning by @boreals-back-again in https://github.com/nicbarker/clay/pull/427
- [Core] Split aspect ratio scaling into its own config by @nicbarker in https://github.com/nicbarker/clay/pull/426
- [Core] Fix dimension calculation that would always result in 0 by @michael-tanner-coder in https://github.com/nicbarker/clay/pull/428
- [CMake] Set CMake FetchContent GIT_TAG for SDL_ttf by @weslord in https://github.com/nicbarker/clay/pull/423
- [Bindings/Odin] Update README to better match official website example. by @rats159 in https://github.com/nicbarker/clay/pull/422
- [Renderers/Raylib] Fix element float distortion by @rootBrz in https://github.com/nicbarker/clay/pull/430
New Contributors
- @ernestoyaquello made their first contribution in https://github.com/nicbarker/clay/pull/256
- @irfan-zahir made their first contribution in https://github.com/nicbarker/clay/pull/261
- @alecks made their first contribution in https://github.com/nicbarker/clay/pull/269
- @mizmar made their first contribution in https://github.com/nicbarker/clay/pull/275
- @benjamindblock made their first contribution in https://github.com/nicbarker/clay/pull/281
- @RicoP made their first contribution in https://github.com/nicbarker/clay/pull/307
- @bowbahdoe made their first contribution in https://github.com/nicbarker/clay/pull/315
- @joshuahhh made their first contribution in https://github.com/nicbarker/clay/pull/300
- @shakkar23 made their first contribution in https://github.com/nicbarker/clay/pull/320
- @Nelarius made their first contribution in https://github.com/nicbarker/clay/pull/317
- @Emerald-Ruby made their first contribution in https://github.com/nicbarker/clay/pull/327
- @lzurbriggen made their first contribution in https://github.com/nicbarker/clay/pull/301
- @igadmg made their first contribution in https://github.com/nicbarker/clay/pull/338
- @ellie-but-backwards made their first contribution in https://github.com/nicbarker/clay/pull/350
- @PiggybankStudios made their first contribution in https://github.com/nicbarker/clay/pull/349
- @Qualadia made their first contribution in https://github.com/nicbarker/clay/pull/345
- @Philosoph228 made their first contribution in https://github.com/nicbarker/clay/pull/344
- @nkorth made their first contribution in https://github.com/nicbarker/clay/pull/373
- @boringlily made their first contribution in https://github.com/nicbarker/clay/pull/379
- @timlueg made their first contribution in https://github.com/nicbarker/clay/pull/378
- @Oglo12 made their first contribution in https://github.com/nicbarker/clay/pull/374
- @rats159 made their first contribution in https://github.com/nicbarker/clay/pull/395
- @A1029384756 made their first contribution in https://github.com/nicbarker/clay/pull/397
- @linkdd made their first contribution in https://github.com/nicbarker/clay/pull/402
- @tritao made their first contribution in https://github.com/nicbarker/clay/pull/392
- @dgellow made their first contribution in https://github.com/nicbarker/clay/pull/403
- @Kelimion made their first contribution in https://github.com/nicbarker/clay/pull/407
- @pdoane made their first contribution in https://github.com/nicbarker/clay/pull/413
- @gmasil made their first contribution in https://github.com/nicbarker/clay/pull/412
- @soypat made their first contribution in https://github.com/nicbarker/clay/pull/411
- @zordythezordan made their first contribution in https://github.com/nicbarker/clay/pull/416
- @mattahj made their first contribution in https://github.com/nicbarker/clay/pull/404
- @EmmanuelMess made their first contribution in https://github.com/nicbarker/clay/pull/91
- @weslord made their first contribution in https://github.com/nicbarker/clay/pull/424
- @boreals-back-again made their first contribution in https://github.com/nicbarker/clay/pull/427
- @michael-tanner-coder made their first contribution in https://github.com/nicbarker/clay/pull/428
- @rootBrz made their first contribution in https://github.com/nicbarker/clay/pull/430
Full Changelog: https://github.com/nicbarker/clay/compare/v0.13...v0.14