Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-type elements #34

Merged
merged 21 commits into from
Oct 22, 2024
Merged

Multi-type elements #34

merged 21 commits into from
Oct 22, 2024

Conversation

nicbarker
Copy link
Owner

@nicbarker nicbarker commented Oct 3, 2024

This PR streamlines the way elements are declared / opened in clay, and allows you to attach multiple configs / element types to each element.

carbon(88)

the PR also introduces optional IDs and layout config declaration, which together with multiple configs can significantly reduce boilerplate in layout declaration.

It also includes a significant rewrite of the text wrapping logic and cache, which has improved performance by 2-3x.

Migration Guide

This PR introduces significant breaking changes to public APIs. The general process of refactoring should be as follows:

  • Rather than needing to be declared as seperate elements, elements can now be "configured" with any combination of RECTANGLE, BORDER, SCROLL, etc. These configurations are declared inside the generic CLAY() element declaration. e.g. CLAY(CLAY_RECTANGLE(...), CLAY_BORDER(...)) { ...children }
  • CLAY_ID is now optional and can be left unspecified.
  • Rename all element macros, e.g. instances of CLAY_RECTANGLE(, CLAY_SCROLL(, CLAY_BORDER( to just CLAY(
  • Rename all element config macros, e.g. instances of CLAY_RECTANGLE_CONFIG(, CLAY_SCROLL_CONFIG(, CLAY_BORDER_CONFIG( to CLAY_RECTANGLE(, CLAY_SCROLL( etc.
  • All macros that take designated initializer syntax (i.e. struct members) now need to have their contents wrapped in { } e.g. CLAY_SCROLL(.vertical = true) becomes CLAY_SCROLL({ .vertical = true })
  • Any empty layout configs or references to &CLAY_LAYOUT_DEFAULT can be removed.
  • For changes to Odin bindings, observe the changes to bindings/odin/examples/clay-official-website/clay-official-website.odin in this commit

Full details of changelist will be enumerated in the 0.12 release.

@nicbarker nicbarker force-pushed the 012-multi-configs branch 2 times, most recently from 1cbe843 to fad1f53 Compare October 7, 2024 06:37
@nicbarker nicbarker merged commit 29133bc into main Oct 22, 2024
3 checks passed
@nicbarker nicbarker changed the title [Draft] Multi-type elements Multi-type elements Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant