Skip to content

v0.11

Compare
Choose a tag to compare
@nicbarker nicbarker released this 17 Sep 23:55
· 58 commits to main since this release

Clay 0.11

Changelog

  • New Feature: Visual Debug Tools. Similar to the inspector in Chrome or Firefox. Browse your layout hierarchy, inspect bounding boxes and config, and view any warnings output during layout. To activate the debug tools, call the new function Clay_SetDebugModeEnabled. See the README for more details.
Screenshot 2024-09-12 at 12 54 03 PM
  • New Feature: Text Wrap Modes. A new feature of TEXT_CONFIG, this allows you to choose between three modes:
  • CLAY_TEXT_WRAP_WORDS - Text will wrap on whitespace characters as container width shrinks.
  • CLAY_TEXT_WRAP_NEWLINES - Text will only wrap when encountering newline characters
  • CLAY_TEXT_WRAP_NONE - Text will never wrap even if its container is compressed beyond the text measured width.

I am considering a wrap mode which will wrap on individual characters in future but haven't decided on an implementation yet.

  • Improved performance of text layout when wrap is disabled or no wrapping needs to occur.
  • Fixed a bug that occurred when multiple nested floating containers were used.
  • Fixed a bug where the text measurement cache would not be used correctly.
  • Fixed a bug in the HTML renderer where text could be measured and cached before custom fonts had loaded.
  • Fixed a bug in the HTML renderer where alpha wasn't correctly respected.

Upgrade Guide

Unfortunately, this release contains some small breaking changes to the public API.

While I do my best to avoid breaking changes, Clay is still in alpha and the API is subject to change.

  • Element's uint32_t id has changed to a struct, Clay_ElementId. CLAY_ID and CLAY_IDI now return this struct, so layout definitions that use macros should not require migration. There are several cases where you might need to change the type of variables.
// Before
uint32_t id = CLAY_ID("Button");
// After
Clay_ElementId id = CLAY_ID("Button");

While functions that previously took uint32_t id as an argument have been updated, the parentId field of CLAY_FLOATING_CONFIG is still uint32_t. You can access the .id field of the Clay_ElementId struct in this case:

CLAY_FLOATING_CONTAINER(CLAY_ID("ScrollBar"), CLAY_LAYOUT(), CLAY_FLOATING_CONFIG(.parentId = CLAY_ID("OuterScrollContainer").id), {
  • Clay_BeginLayout and Clay_EndLayout now take no arguments, and there is a seperate function Clay_SetLayoutDimensions which is used to update the layout dimensions before the current frame. See the README for more details.
  • Clay_Initialize now expects Clay_Dimensions to set the initial layout dimensions. See the README for more details.
  • Clay_SetPointerPosition has been renamed to Clay_SetPointerState, and now expects a second argument isPointerDown representing whether or not the main mouse button / touch is currently held down.