mirror of
https://github.com/nicbarker/clay.git
synced 2025-11-07 13:26:17 +00:00
Compare commits
10 commits
bfa29c68fc
...
80563ce588
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80563ce588 | ||
|
|
7874cdb085 | ||
|
|
37675089e3 | ||
|
|
1cbc56cbf2 | ||
|
|
0d6969c8c3 | ||
|
|
958d684b3c | ||
|
|
f55513493b | ||
|
|
dabf8214a8 | ||
|
|
747643e84e | ||
|
|
5a0d301c60 |
275
README.md
275
README.md
|
|
@ -59,7 +59,7 @@ Clay_ElementDeclaration sidebarItemConfig = (Clay_ElementDeclaration) {
|
||||||
|
|
||||||
// Re-useable components are just normal functions
|
// Re-useable components are just normal functions
|
||||||
void SidebarItemComponent() {
|
void SidebarItemComponent() {
|
||||||
CLAY(sidebarItemConfig) {
|
CLAY(id, sidebarItemConfig) {
|
||||||
// children go here...
|
// children go here...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,14 +85,13 @@ int main() {
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
|
|
||||||
// An example of laying out a UI with a fixed width sidebar and flexible width main content
|
// An example of laying out a UI with a fixed width sidebar and flexible width main content
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer"), .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }, .backgroundColor = {250,250,255,255} }) {
|
CLAY(CLAY_ID("OuterContainer"), { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }, .backgroundColor = {250,250,255,255} }) {
|
||||||
CLAY({
|
CLAY(CLAY_ID("SideBar"), {
|
||||||
.id = CLAY_ID("SideBar"),
|
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 },
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 },
|
||||||
.backgroundColor = COLOR_LIGHT
|
.backgroundColor = COLOR_LIGHT
|
||||||
}) {
|
}) {
|
||||||
CLAY({ .id = CLAY_ID("ProfilePictureOuter"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = COLOR_RED }) {
|
CLAY(CLAY_ID("ProfilePictureOuter"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = COLOR_RED }) {
|
||||||
CLAY({ .id = CLAY_ID("ProfilePicture"), .layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = { .imageData = &profilePicture } }) {}
|
CLAY(CLAY_ID("ProfilePicture"), {.layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = { .imageData = &profilePicture } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay - UI Library"), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255, 255, 255, 255} }));
|
CLAY_TEXT(CLAY_STRING("Clay - UI Library"), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255, 255, 255, 255} }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +100,7 @@ int main() {
|
||||||
SidebarItemComponent();
|
SidebarItemComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({ .id = CLAY_ID("MainContent"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) {}
|
CLAY(CLAY_ID("MainContent"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,16 +193,16 @@ For help starting out or to discuss clay, considering joining [the discord serve
|
||||||
## High Level Documentation
|
## High Level Documentation
|
||||||
|
|
||||||
### Building UI Hierarchies
|
### Building UI Hierarchies
|
||||||
Clay UIs are built using the C macro `CLAY({ configuration })`. This macro creates a new empty element in the UI hierarchy, and supports modular customisation of layout, styling and functionality. The `CLAY()` macro can also be _nested_, similar to other declarative UI systems like HTML.
|
Clay UIs are built using the C macro `CLAY(id, { configuration })`. This macro creates a new empty element in the UI hierarchy, and supports modular customisation of layout, styling and functionality. The `CLAY()` macro can also be _nested_, similar to other declarative UI systems like HTML.
|
||||||
|
|
||||||
Child elements are added by opening a block: `{}` after calling the `CLAY()` macro (exactly like you would with an `if` statement or `for` loop), and declaring child components inside the braces.
|
Child elements are added by opening a block: `{}` after calling the `CLAY()` macro (exactly like you would with an `if` statement or `for` loop), and declaring child components inside the braces.
|
||||||
```C
|
```C
|
||||||
// Parent element with 8px of padding
|
// Parent element with 8px of padding
|
||||||
CLAY({ .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
CLAY(CLAY_ID("parent"), { .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
||||||
// Child element 1
|
// Child element 1
|
||||||
CLAY_TEXT(CLAY_STRING("Hello World"), CLAY_TEXT_CONFIG({ .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("Hello World"), CLAY_TEXT_CONFIG({ .fontSize = 16 }));
|
||||||
// Child element 2 with red background
|
// Child element 2 with red background
|
||||||
CLAY({ .backgroundColor = COLOR_RED }) {
|
CLAY((CLAY_ID("child"), { .backgroundColor = COLOR_RED }) {
|
||||||
// etc
|
// etc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,13 +213,13 @@ However, unlike HTML and other declarative DSLs, this macro is just C. As a resu
|
||||||
// Re-usable "components" are just functions that declare more UI
|
// Re-usable "components" are just functions that declare more UI
|
||||||
void ButtonComponent(Clay_String buttonText) {
|
void ButtonComponent(Clay_String buttonText) {
|
||||||
// Red box button with 8px of padding
|
// Red box button with 8px of padding
|
||||||
CLAY({ .layout = { .padding = CLAY_PADDING_ALL(8) }, .backgroundColor = COLOR_RED }) {
|
CLAY_AUTO_ID({ .layout = { .padding = CLAY_PADDING_ALL(8) }, .backgroundColor = COLOR_RED }) {
|
||||||
CLAY_TEXT(buttonText, textConfig);
|
CLAY_TEXT(buttonText, textConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent element
|
// Parent element
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("parent"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// Render a bunch of text elements
|
// Render a bunch of text elements
|
||||||
for (int i = 0; i < textArray.length; i++) {
|
for (int i = 0; i < textArray.length; i++) {
|
||||||
CLAY_TEXT(textArray.elements[i], textConfig);
|
CLAY_TEXT(textArray.elements[i], textConfig);
|
||||||
|
|
@ -240,7 +239,7 @@ CLAY({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
### Configuring Layout and Styling UI Elements
|
### Configuring Layout and Styling UI Elements
|
||||||
The layout and style of clay elements is configured with the [Clay_ElementDeclaration](#clay_elementdeclaration) struct passed to the `CLAY()` macro.
|
The layout and style of clay elements is configured with the [Clay_ElementDeclaration](#clay_elementdeclaration) struct passed to the `CLAY()` macro.
|
||||||
```C
|
```C
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 8, 8 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("box"), { .layout = { .padding = { 8, 8, 8, 8 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// Children are 8px inset into parent, and laid out top to bottom
|
// Children are 8px inset into parent, and laid out top to bottom
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -257,18 +256,21 @@ Clay_ElementDeclaration reuseableStyle = (Clay_ElementDeclaration) {
|
||||||
.cornerRadius = { 12, 12, 12, 12 }
|
.cornerRadius = { 12, 12, 12, 12 }
|
||||||
};
|
};
|
||||||
|
|
||||||
CLAY(reuseableStyle) {
|
CLAY(CLAY_ID("box"), reuseableStyle) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Element IDs
|
### Element IDs
|
||||||
|
|
||||||
Clay elements can optionally be tagged with a unique identifier using the `.id` field of an element declaration, and with the [CLAY_ID()](#clay_id) convenience macro.
|
The Clay macro by default accepts an ID as its first argument, which is usually provided by the [CLAY_ID()](#clay_id) convenience macro. Elements can also be created with auto generated IDs, by using the [CLAY_AUTO_ID()](#clay-auto-id) macro.
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// Will always produce the same ID from the same input string
|
// Will always produce the same ID from the same input string
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer") }) {}
|
CLAY(CLAY_ID("OuterContainer"), { ...configuration }) {}
|
||||||
|
|
||||||
|
// Generates a unique ID that may not be the same between two layout calls
|
||||||
|
CLAY_AUTO_ID({ ...configuration }) {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Element IDs have two main use cases. Firstly, tagging an element with an ID allows you to query information about the element later, such as its [mouseover state](#clay_pointerover) or dimensions.
|
Element IDs have two main use cases. Firstly, tagging an element with an ID allows you to query information about the element later, such as its [mouseover state](#clay_pointerover) or dimensions.
|
||||||
|
|
@ -279,11 +281,11 @@ To avoid having to construct dynamic strings at runtime to differentiate ids in
|
||||||
```C
|
```C
|
||||||
// This is the equivalent of calling CLAY_ID("Item0"), CLAY_ID("Item1") etc
|
// This is the equivalent of calling CLAY_ID("Item0"), CLAY_ID("Item1") etc
|
||||||
for (int index = 0; index < items.length; index++) {
|
for (int index = 0; index < items.length; index++) {
|
||||||
CLAY({ .id = CLAY_IDI("Item", index) }) {}
|
CLAY(CLAY_IDI("Item", index), { ..configuration }) {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This ID (or, if not provided, an auto generated ID) will be forwarded to the final `Clay_RenderCommandArray` for use in retained mode UIs. Using duplicate IDs may cause some functionality to misbehave (i.e. if you're trying to attach a floating container to a specific element with ID that is duplicated, it may not attach to the one you expect)
|
This ID will be forwarded to the final `Clay_RenderCommandArray` for use in retained mode UIs. Using duplicate IDs may cause some functionality to misbehave (i.e. if you're trying to attach a floating container to a specific element with ID that is duplicated, it may not attach to the one you expect)
|
||||||
|
|
||||||
### Mouse, Touch and Pointer Interactions
|
### Mouse, Touch and Pointer Interactions
|
||||||
|
|
||||||
|
|
@ -297,7 +299,7 @@ The function `bool Clay_Hovered()` can be called during element construction or
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// An orange button that turns blue when hovered
|
// An orange button that turns blue when hovered
|
||||||
CLAY({ .backgroundColor = Clay_Hovered() ? COLOR_BLUE : COLOR_ORANGE }) {
|
CLAY(CLAY_ID("Button"), { .backgroundColor = Clay_Hovered() ? COLOR_BLUE : COLOR_ORANGE }) {
|
||||||
bool buttonHovered = Clay_Hovered();
|
bool buttonHovered = Clay_Hovered();
|
||||||
CLAY_TEXT(buttonHovered ? CLAY_STRING("Hovered") : CLAY_STRING("Hover me!"), headerTextConfig);
|
CLAY_TEXT(buttonHovered ? CLAY_STRING("Hovered") : CLAY_STRING("Hover me!"), headerTextConfig);
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +320,7 @@ void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerI
|
||||||
ButtonData linkButton = (ButtonData) { .link = "https://github.com/nicbarker/clay" };
|
ButtonData linkButton = (ButtonData) { .link = "https://github.com/nicbarker/clay" };
|
||||||
|
|
||||||
// HandleButtonInteraction will be called for each frame the mouse / pointer / touch is inside the button boundaries
|
// HandleButtonInteraction will be called for each frame the mouse / pointer / touch is inside the button boundaries
|
||||||
CLAY({ .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
CLAY(CLAY_ID("Button"), { .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
||||||
Clay_OnHover(HandleButtonInteraction, &linkButton);
|
Clay_OnHover(HandleButtonInteraction, &linkButton);
|
||||||
CLAY_TEXT(CLAY_STRING("Button"), &headerTextConfig);
|
CLAY_TEXT(CLAY_STRING("Button"), &headerTextConfig);
|
||||||
}
|
}
|
||||||
|
|
@ -360,11 +362,11 @@ Clay_UpdateScrollContainers(
|
||||||
);
|
);
|
||||||
// ...
|
// ...
|
||||||
// Clay internally tracks the scroll containers offset, and Clay_GetScrollOffset returns the x,y offset of the currently open element
|
// Clay internally tracks the scroll containers offset, and Clay_GetScrollOffset returns the x,y offset of the currently open element
|
||||||
CLAY({ .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
CLAY(CLAY_ID("ScrollContainer"), { .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
||||||
// Scrolling contents
|
// Scrolling contents
|
||||||
}
|
}
|
||||||
// .childOffset can be provided directly if you would prefer to manage scrolling outside of clay
|
// .childOffset can be provided directly if you would prefer to manage scrolling outside of clay
|
||||||
CLAY({ .clip = { .vertical = true, .childOffset = myData.scrollContainer.offset } }) {
|
CLAY(CLAY_ID("ScrollContainer"), { .clip = { .vertical = true, .childOffset = myData.scrollContainer.offset } }) {
|
||||||
// Scrolling contents
|
// Scrolling contents
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -383,10 +385,10 @@ A classic example use case for floating elements is tooltips and modals.
|
||||||
```C
|
```C
|
||||||
// The two text elements will be laid out top to bottom, and the floating container
|
// The two text elements will be laid out top to bottom, and the floating container
|
||||||
// will be attached to "Outer"
|
// will be attached to "Outer"
|
||||||
CLAY({ .id = CLAY_ID("Outer"), .layout = { .layoutDirection = TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("Outer"), { .layout = { .layoutDirection = TOP_TO_BOTTOM } }) {
|
||||||
CLAY_TEXT(CLAY_ID("Button"), text, &headerTextConfig);
|
CLAY_TEXT(text, &headerTextConfig);
|
||||||
CLAY({ .id = CLAY_ID("Tooltip"), .floating = { .attachTo = CLAY_ATTACH_TO_PARENT } }) {}
|
CLAY(CLAY_ID("Tooltip"), { .floating = { .attachTo = CLAY_ATTACH_TO_PARENT } }) {}
|
||||||
CLAY_TEXT(CLAY_ID("Button"), text, &headerTextConfig);
|
CLAY_TEXT(text, &headerTextConfig);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -424,14 +426,11 @@ typedef struct {
|
||||||
// During init
|
// During init
|
||||||
Arena frameArena = (Arena) { .memory = malloc(1024) };
|
Arena frameArena = (Arena) { .memory = malloc(1024) };
|
||||||
|
|
||||||
// ...
|
// Custom elements only take a single pointer, so we need to store the data somewhere
|
||||||
CLAY(0) {
|
CustomElementData *modelData = (CustomElementData *)(frameArena.memory + frameArena.offset);
|
||||||
// Custom elements only take a single pointer, so we need to store the data somewhere
|
*modelData = (CustomElementData) { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel };
|
||||||
CustomElementData *modelData = (CustomElementData *)(frameArena.memory + frameArena.offset);
|
frameArena.offset += sizeof(CustomElementData);
|
||||||
*modelData = (CustomElementData) { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel };
|
CLAY(CLAY_ID("3DModelViewer"), { .custom = { .customData = modelData } }) {}
|
||||||
frameArena.offset += sizeof(CustomElementData);
|
|
||||||
CLAY({ .custom = { .customData = modelData } }) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Later during your rendering
|
// Later during your rendering
|
||||||
switch (renderCommand->commandType) {
|
switch (renderCommand->commandType) {
|
||||||
|
|
@ -682,7 +681,7 @@ See [Scrolling Elements](#scrolling-elements) for more details.
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// Create a horizontally scrolling container
|
// Create a horizontally scrolling container
|
||||||
CLAY({
|
CLAY(CLAY_ID("ScrollContainer"), {
|
||||||
.clip = { .horizontal = true, .childOffset = Clay_GetScrollOffset() }
|
.clip = { .horizontal = true, .childOffset = Clay_GetScrollOffset() }
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
@ -732,9 +731,9 @@ void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerD
|
||||||
ButtonData linkButton = (ButtonData) { .link = "https://github.com/nicbarker/clay" };
|
ButtonData linkButton = (ButtonData) { .link = "https://github.com/nicbarker/clay" };
|
||||||
|
|
||||||
// HandleButtonInteraction will be called for each frame the mouse / pointer / touch is inside the button boundaries
|
// HandleButtonInteraction will be called for each frame the mouse / pointer / touch is inside the button boundaries
|
||||||
CLAY({ .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
CLAY(CLAY_ID("Button"), { .layout = { .padding = CLAY_PADDING_ALL(8) } }) {
|
||||||
Clay_OnHover(HandleButtonInteraction, &buttonData);
|
Clay_OnHover(HandleButtonInteraction, &buttonData);
|
||||||
CLAY_TEXT(CLAY_STRING("Button"), &headerTextConfig);
|
CLAY_TEXT(CLAY_STRING("Click me!"), &headerTextConfig);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -788,13 +787,40 @@ Returns a [Clay_ElementId](#clay_elementid) for the provided id string, used for
|
||||||
**Examples**
|
**Examples**
|
||||||
```C
|
```C
|
||||||
// Define an element with 16px of x and y padding
|
// Define an element with 16px of x and y padding
|
||||||
CLAY({ .id = CLAY_ID("Outer"), .layout = { .padding = CLAY_PADDING_ALL(16) } }) {
|
CLAY(CLAY_ID("Outer"), { .layout = { .padding = CLAY_PADDING_ALL(16) } }) {
|
||||||
// A nested child element
|
// A nested child element
|
||||||
CLAY({ .id = CLAY_ID("SideBar"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
CLAY(CLAY_ID("SideBar"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
||||||
// Children laid out top to bottom with a 16 px gap between them
|
// Children laid out top to bottom with a 16 px gap between them
|
||||||
}
|
}
|
||||||
// A vertical scrolling container with a colored background
|
// A vertical scrolling container with a colored background
|
||||||
CLAY({
|
CLAY(CLAY_ID("ScrollContainer"), {
|
||||||
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 },
|
||||||
|
.backgroundColor = { 200, 200, 100, 255 },
|
||||||
|
.cornerRadius = CLAY_CORNER_RADIUS(10),
|
||||||
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }
|
||||||
|
}) {
|
||||||
|
// child elements
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CLAY_AUTO_ID()
|
||||||
|
|
||||||
|
A version of the core [CLAY()](#clay) element creation macro that generates an ID automatically instead of requiring it as the first argument.
|
||||||
|
|
||||||
|
Note that under the hood this ID is generated in the same way as [CLAY_ID_LOCAL()](#clay_id_local), which is based on the element's position in the hierarchy, and may chance between layout calls if elements are added / removed from the hierarchy before the element is defined. As a result, for transitions & retained mode backends to work correctly, IDs should be specified.
|
||||||
|
|
||||||
|
```C
|
||||||
|
// Note that CLAY_AUTO_ID only takes one argument: the configuration
|
||||||
|
CLAY_AUTO_ID({ .layout = { .padding = CLAY_PADDING_ALL(16) } }) {
|
||||||
|
// A nested child element
|
||||||
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
||||||
|
// Children laid out top to bottom with a 16 px gap between them
|
||||||
|
}
|
||||||
|
// A vertical scrolling container with a colored background
|
||||||
|
CLAY_AUTO_ID({
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 },
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 },
|
||||||
.backgroundColor = { 200, 200, 100, 255 },
|
.backgroundColor = { 200, 200, 100, 255 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(10),
|
.cornerRadius = CLAY_CORNER_RADIUS(10),
|
||||||
|
|
@ -931,8 +957,7 @@ To regenerate the same ID outside of layout declaration when using utility funct
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// Tag a button with the Id "Button"
|
// Tag a button with the Id "Button"
|
||||||
CLAY({
|
CLAY(CLAY_ID("Button"), {
|
||||||
.id = CLAY_ID("Button"),
|
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }
|
||||||
}) {
|
}) {
|
||||||
// ...children
|
// ...children
|
||||||
|
|
@ -1065,18 +1090,9 @@ typedef struct {
|
||||||
|
|
||||||
**Fields**
|
**Fields**
|
||||||
|
|
||||||
**`.id`** - `Clay_ElementID`
|
|
||||||
|
|
||||||
`CLAY({ .id = CLAY_ID("FileButton") })`
|
|
||||||
|
|
||||||
Uses [Clay_ElementId](#clay_elementid). Tags the element with an ID that can be later used to query data about the element, and gives it a human readable name in the debug tools.
|
|
||||||
IDs are typically generated using the [CLAY_ID](#clay_id), [CLAY_IDI](#clay_idi), [CLAY_ID_LOCAL](#clay_id_local) and [CLAY_IDI_LOCAL](#clay_idi_local) macros.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**`.layout`** - `Clay_LayoutConfig`
|
**`.layout`** - `Clay_LayoutConfig`
|
||||||
|
|
||||||
`CLAY({ .layout = { .padding = { 16, 16, 12, 12 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .padding = { 16, 16, 12, 12 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } })`
|
||||||
|
|
||||||
Uses [Clay_LayoutConfig](#clay_layoutconfig). Controls various settings related to _layout_, which can be thought of as "the size and position of this element and its children".
|
Uses [Clay_LayoutConfig](#clay_layoutconfig). Controls various settings related to _layout_, which can be thought of as "the size and position of this element and its children".
|
||||||
|
|
||||||
|
|
@ -1084,7 +1100,7 @@ Uses [Clay_LayoutConfig](#clay_layoutconfig). Controls various settings related
|
||||||
|
|
||||||
**`.backgroundColor`** - `Clay_Color`
|
**`.backgroundColor`** - `Clay_Color`
|
||||||
|
|
||||||
`CLAY({ .backgroundColor = {120, 120, 120, 255} } })`
|
`CLAY(CLAY_ID("Element"), { .backgroundColor = {120, 120, 120, 255} } })`
|
||||||
|
|
||||||
Uses [Clay_Color](#clay_color). Conventionally accepts `rgba` float values between 0 and 255, but interpretation is left up to the renderer and does not affect layout.
|
Uses [Clay_Color](#clay_color). Conventionally accepts `rgba` float values between 0 and 255, but interpretation is left up to the renderer and does not affect layout.
|
||||||
|
|
||||||
|
|
@ -1092,7 +1108,7 @@ Uses [Clay_Color](#clay_color). Conventionally accepts `rgba` float values betwe
|
||||||
|
|
||||||
**`.cornerRadius`** - `float`
|
**`.cornerRadius`** - `float`
|
||||||
|
|
||||||
`CLAY({ .cornerRadius = { .topLeft = 16, .topRight = 16, .bottomLeft = 16, .bottomRight = 16 } })`
|
`CLAY(CLAY_ID("Element"), { .cornerRadius = { .topLeft = 16, .topRight = 16, .bottomLeft = 16, .bottomRight = 16 } })`
|
||||||
|
|
||||||
Defines the radius in pixels for the arc of rectangle corners (`0` is square, `rectangle.width / 2` is circular).
|
Defines the radius in pixels for the arc of rectangle corners (`0` is square, `rectangle.width / 2` is circular).
|
||||||
|
|
||||||
|
|
@ -1102,7 +1118,7 @@ Note that the `CLAY_CORNER_RADIUS(radius)` function-like macro is available to p
|
||||||
|
|
||||||
**`.aspectRatio`** - `Clay_AspectRatioElementConfig`
|
**`.aspectRatio`** - `Clay_AspectRatioElementConfig`
|
||||||
|
|
||||||
`CLAY({ .aspectRatio = 1 })`
|
`CLAY(CLAY_ID("Element"), { .aspectRatio = 1 })`
|
||||||
|
|
||||||
Uses [Clay_AspectRatioElementConfig](#clay_aspectratioelementconfig). Configures the element as an aspect ratio scaling element. Especially useful for rendering images, but can also be used to enforce a fixed width / height ratio of other elements.
|
Uses [Clay_AspectRatioElementConfig](#clay_aspectratioelementconfig). Configures the element as an aspect ratio scaling element. Especially useful for rendering images, but can also be used to enforce a fixed width / height ratio of other elements.
|
||||||
|
|
||||||
|
|
@ -1110,7 +1126,7 @@ Uses [Clay_AspectRatioElementConfig](#clay_aspectratioelementconfig). Configures
|
||||||
|
|
||||||
**`.image`** - `Clay_ImageElementConfig`
|
**`.image`** - `Clay_ImageElementConfig`
|
||||||
|
|
||||||
`CLAY({ .image = { .imageData = &myImage } })`
|
`CLAY(CLAY_ID("Element"), { .image = { .imageData = &myImage } })`
|
||||||
|
|
||||||
Uses [Clay_ImageElementConfig](#clay_imageelementconfig). Configures the element as an image element. Causes a render command with type `IMAGE` to be emitted.
|
Uses [Clay_ImageElementConfig](#clay_imageelementconfig). Configures the element as an image element. Causes a render command with type `IMAGE` to be emitted.
|
||||||
|
|
||||||
|
|
@ -1118,7 +1134,7 @@ Uses [Clay_ImageElementConfig](#clay_imageelementconfig). Configures the element
|
||||||
|
|
||||||
**`.floating`** - `Clay_FloatingElementConfig`
|
**`.floating`** - `Clay_FloatingElementConfig`
|
||||||
|
|
||||||
`CLAY({ .floating = { .attachTo = CLAY_ATTACH_TO_PARENT } })`
|
`CLAY(CLAY_ID("Element"), { .floating = { .attachTo = CLAY_ATTACH_TO_PARENT } })`
|
||||||
|
|
||||||
Uses [Clay_FloatingElementConfig](#clay_floatingelementconfig). Configures the element as an floating element, which allows it to stack "in front" and "on top" of other elements without affecting sibling or parent size or position.
|
Uses [Clay_FloatingElementConfig](#clay_floatingelementconfig). Configures the element as an floating element, which allows it to stack "in front" and "on top" of other elements without affecting sibling or parent size or position.
|
||||||
|
|
||||||
|
|
@ -1126,7 +1142,7 @@ Uses [Clay_FloatingElementConfig](#clay_floatingelementconfig). Configures the e
|
||||||
|
|
||||||
**`.custom`** - `Clay_CustomElementConfig`
|
**`.custom`** - `Clay_CustomElementConfig`
|
||||||
|
|
||||||
`CLAY({ .custom = { .customData = &my3DModel } })`
|
`CLAY(CLAY_ID("Element"), { .custom = { .customData = &my3DModel } })`
|
||||||
|
|
||||||
Uses [Clay_CustomElementConfig](#clay_customelementconfig). Configures the element as a custom element, which allows you to pass custom data through to the renderer. Causes a render command with type `CUSTOM` to be emitted.
|
Uses [Clay_CustomElementConfig](#clay_customelementconfig). Configures the element as a custom element, which allows you to pass custom data through to the renderer. Causes a render command with type `CUSTOM` to be emitted.
|
||||||
|
|
||||||
|
|
@ -1134,7 +1150,7 @@ Uses [Clay_CustomElementConfig](#clay_customelementconfig). Configures the eleme
|
||||||
|
|
||||||
**`.clip`** - `Clay_ClipElementConfig`
|
**`.clip`** - `Clay_ClipElementConfig`
|
||||||
|
|
||||||
`CLAY({ .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() } })`
|
`CLAY(CLAY_ID("Element"), { .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() } })`
|
||||||
|
|
||||||
Uses [Clay_ClipElementConfig](#clay_scrollelementconfig). Configures the element as a clip element, which causes child elements to be clipped / masked if they overflow, and together with the functions listed in [Scrolling Elements](#scrolling-elements) enables scrolling of child contents.
|
Uses [Clay_ClipElementConfig](#clay_scrollelementconfig). Configures the element as a clip element, which causes child elements to be clipped / masked if they overflow, and together with the functions listed in [Scrolling Elements](#scrolling-elements) enables scrolling of child contents.
|
||||||
|
|
||||||
|
|
@ -1144,7 +1160,7 @@ Uses [Clay_ClipElementConfig](#clay_scrollelementconfig). Configures the element
|
||||||
|
|
||||||
**`.border`** - `Clay_BorderElementConfig`
|
**`.border`** - `Clay_BorderElementConfig`
|
||||||
|
|
||||||
`CLAY({ .border = { .width = { .left = 5 }, .color = COLOR_BLUE } })`
|
`CLAY(CLAY_ID("Element"), { .border = { .width = { .left = 5 }, .color = COLOR_BLUE } })`
|
||||||
|
|
||||||
Uses [Clay_BorderElementConfig](#clay_borderelementconfig). Configures the element as a border element, which instructs the renderer to draw coloured border lines along the perimeter of this element's bounding box. Causes a render command with type `BORDER` to be emitted.
|
Uses [Clay_BorderElementConfig](#clay_borderelementconfig). Configures the element as a border element, which instructs the renderer to draw coloured border lines along the perimeter of this element's bounding box. Causes a render command with type `BORDER` to be emitted.
|
||||||
|
|
||||||
|
|
@ -1152,7 +1168,7 @@ Uses [Clay_BorderElementConfig](#clay_borderelementconfig). Configures the eleme
|
||||||
|
|
||||||
**`.userData`** - `void *`
|
**`.userData`** - `void *`
|
||||||
|
|
||||||
`CLAY({ .userData = &extraData })`
|
`CLAY(CLAY_ID("Element"), { .userData = &extraData })`
|
||||||
|
|
||||||
Transparently passes a pointer through to the corresponding [Clay_RenderCommands](#clay_rendercommand)s generated by this element.
|
Transparently passes a pointer through to the corresponding [Clay_RenderCommands](#clay_rendercommand)s generated by this element.
|
||||||
|
|
||||||
|
|
@ -1164,13 +1180,13 @@ Transparently passes a pointer through to the corresponding [Clay_RenderCommands
|
||||||
// Declare a reusable rectangle config, with a purple color and 10px rounded corners
|
// Declare a reusable rectangle config, with a purple color and 10px rounded corners
|
||||||
Clay_RectangleElementConfig rectangleConfig = (Clay_RectangleElementConfig) { .color = { 200, 200, 100, 255 }, .cornerRadius = CLAY_CORNER_RADIUS(10) };
|
Clay_RectangleElementConfig rectangleConfig = (Clay_RectangleElementConfig) { .color = { 200, 200, 100, 255 }, .cornerRadius = CLAY_CORNER_RADIUS(10) };
|
||||||
// Declare a rectangle element using a reusable config
|
// Declare a rectangle element using a reusable config
|
||||||
CLAY(rectangleConfig)) {}
|
CLAY(CLAY_ID("Box"), rectangleConfig) {}
|
||||||
// Declare a retangle element using an inline config
|
// Declare a retangle element using an inline config
|
||||||
CLAY({ .color = { 200, 200, 100, 255 }, .cornerRadius = CLAY_CORNER_RADIUS(10) })) {
|
CLAY(CLAY_ID("BoxInline"), { .color = { 200, 200, 100, 255 }, .cornerRadius = CLAY_CORNER_RADIUS(10) })) {
|
||||||
// child elements
|
// child elements
|
||||||
}
|
}
|
||||||
// Declare a scrolling container with a colored background
|
// Declare a scrolling container with a colored background
|
||||||
CLAY({
|
CLAY(CLAY_ID("ScrollingContainer"), {
|
||||||
.backgroundColor = { 200, 200, 100, 255 },
|
.backgroundColor = { 200, 200, 100, 255 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(10)
|
.cornerRadius = CLAY_CORNER_RADIUS(10)
|
||||||
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }
|
||||||
|
|
@ -1210,7 +1226,7 @@ Clay_LayoutConfig {
|
||||||
|
|
||||||
**`.layoutDirection`** - `Clay_LayoutDirection`
|
**`.layoutDirection`** - `Clay_LayoutDirection`
|
||||||
|
|
||||||
`CLAY({ .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM } })`
|
||||||
|
|
||||||
Controls the axis / direction in which child elements are laid out. Available options are `CLAY_LEFT_TO_RIGHT` (default) and `CLAY_TOP_TO_BOTTOM`.
|
Controls the axis / direction in which child elements are laid out. Available options are `CLAY_LEFT_TO_RIGHT` (default) and `CLAY_TOP_TO_BOTTOM`.
|
||||||
|
|
||||||
|
|
@ -1222,7 +1238,7 @@ _Did you know that "left to right" and "top to bottom" both have 13 letters?_
|
||||||
|
|
||||||
**`.padding`** - `Clay_Padding`
|
**`.padding`** - `Clay_Padding`
|
||||||
|
|
||||||
`CLAY({ .layout = { .padding = { .left = 16, .right = 16, .top = 8, .bottom = 8 } } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .padding = { .left = 16, .right = 16, .top = 8, .bottom = 8 } } })`
|
||||||
|
|
||||||
Controls white-space "padding" around the **outside** of child elements.
|
Controls white-space "padding" around the **outside** of child elements.
|
||||||
|
|
||||||
|
|
@ -1232,7 +1248,7 @@ Controls white-space "padding" around the **outside** of child elements.
|
||||||
|
|
||||||
**`.childGap`** - `uint16_t`
|
**`.childGap`** - `uint16_t`
|
||||||
|
|
||||||
`CLAY({ .layout = { .childGap = 16 } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .childGap = 16 } })`
|
||||||
|
|
||||||
Controls the white-space **between** child elements as they are laid out. When `.layoutDirection` is `CLAY_LEFT_TO_RIGHT` (default), this will be horizontal space, whereas for `CLAY_TOP_TO_BOTTOM` it will be vertical space.
|
Controls the white-space **between** child elements as they are laid out. When `.layoutDirection` is `CLAY_LEFT_TO_RIGHT` (default), this will be horizontal space, whereas for `CLAY_TOP_TO_BOTTOM` it will be vertical space.
|
||||||
|
|
||||||
|
|
@ -1242,7 +1258,7 @@ Controls the white-space **between** child elements as they are laid out. When `
|
||||||
|
|
||||||
**`.childAlignment`** - `Clay_ChildAlignment`
|
**`.childAlignment`** - `Clay_ChildAlignment`
|
||||||
|
|
||||||
`CLAY({ .layout = { .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER } } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER } } })`
|
||||||
|
|
||||||
Controls the alignment of children relative to the height and width of the parent container. Available options are:
|
Controls the alignment of children relative to the height and width of the parent container. Available options are:
|
||||||
```C
|
```C
|
||||||
|
|
@ -1256,7 +1272,7 @@ Controls the alignment of children relative to the height and width of the paren
|
||||||
|
|
||||||
**`.sizing`** - `Clay_Sizing`
|
**`.sizing`** - `Clay_Sizing`
|
||||||
|
|
||||||
`CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_PERCENT(0.5) } } })`
|
`CLAY(CLAY_ID("Element"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_PERCENT(0.5) } } })`
|
||||||
|
|
||||||
Controls how final width and height of element are calculated. The same configurations are available for both the `.width` and `.height` axis. There are several options:
|
Controls how final width and height of element are calculated. The same configurations are available for both the `.width` and `.height` axis. There are several options:
|
||||||
|
|
||||||
|
|
@ -1276,7 +1292,7 @@ Controls how final width and height of element are calculated. The same configur
|
||||||
**Example Usage**
|
**Example Usage**
|
||||||
|
|
||||||
```C
|
```C
|
||||||
CLAY({ .id = CLAY_ID("Button"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16, .childGap = 16) } }) {
|
CLAY(CLAY_ID("Button"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16, .childGap = 16) } }) {
|
||||||
// Children will be laid out vertically with 16px of padding around and between
|
// Children will be laid out vertically with 16px of padding around and between
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -1286,7 +1302,7 @@ CLAY({ .id = CLAY_ID("Button"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTO
|
||||||
### Clay_ImageElementConfig
|
### Clay_ImageElementConfig
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .image = { ...image config } }) {}`
|
`CLAY(CLAY_ID("Element"), { .image = { ...image config } }) {}`
|
||||||
|
|
||||||
**Clay_ImageElementConfig** configures a clay element to render an image as its background.
|
**Clay_ImageElementConfig** configures a clay element to render an image as its background.
|
||||||
|
|
||||||
|
|
@ -1302,7 +1318,7 @@ Clay_ImageElementConfig {
|
||||||
|
|
||||||
**`.imageData`** - `void *`
|
**`.imageData`** - `void *`
|
||||||
|
|
||||||
`CLAY({ .image = { .imageData = &myImage } }) {}`
|
`CLAY(CLAY_ID("Image"), { .image = { .imageData = &myImage } }) {}`
|
||||||
|
|
||||||
`.imageData` is a generic void pointer that can be used to pass through image data to the renderer.
|
`.imageData` is a generic void pointer that can be used to pass through image data to the renderer.
|
||||||
|
|
||||||
|
|
@ -1310,7 +1326,7 @@ Clay_ImageElementConfig {
|
||||||
// Load an image somewhere in your code
|
// Load an image somewhere in your code
|
||||||
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
||||||
// Note that when rendering, .imageData will be void* type.
|
// Note that when rendering, .imageData will be void* type.
|
||||||
CLAY({ .image = { .imageData = &profilePicture } }) {}
|
CLAY(CLAY_ID("Image"), { .image = { .imageData = &profilePicture } }) {}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
@ -1321,9 +1337,9 @@ YourImage profilePicture = LoadYourImage("profilePicture.png");
|
||||||
// Declare a reusable image config
|
// Declare a reusable image config
|
||||||
Clay_ImageElementConfig imageConfig = (Clay_ImageElementConfig) { .imageData = &profilePicture };
|
Clay_ImageElementConfig imageConfig = (Clay_ImageElementConfig) { .imageData = &profilePicture };
|
||||||
// Declare an image element using a reusable config
|
// Declare an image element using a reusable config
|
||||||
CLAY({ .image = imageConfig }) {}
|
CLAY(CLAY_ID("Image"), { .image = imageConfig }) {}
|
||||||
// Declare an image element using an inline config
|
// Declare an image element using an inline config
|
||||||
CLAY({ .image = { .imageData = &profilePicture }, .aspectRatio = 16.0 / 9.0 }) {}
|
CLAY(CLAY_ID("ImageInline"), { .image = { .imageData = &profilePicture }, .aspectRatio = 16.0 / 9.0 }) {}
|
||||||
// Rendering example
|
// Rendering example
|
||||||
YourImage *imageToRender = renderCommand->elementConfig.imageElementConfig->imageData;
|
YourImage *imageToRender = renderCommand->elementConfig.imageElementConfig->imageData;
|
||||||
```
|
```
|
||||||
|
|
@ -1338,7 +1354,7 @@ Element is subject to [culling](#visibility-culling). Otherwise, a single `Clay_
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .aspectRatio = 16.0 / 9.0 }) {}`
|
`CLAY(CLAY_ID("Aspect"), { .aspectRatio = 16.0 / 9.0 }) {}`
|
||||||
|
|
||||||
**Clay_AspectRatioElementConfig** configures a clay element to enforce a fixed width / height ratio in its final dimensions. Mostly used for image elements, but can also be used for non image elements.
|
**Clay_AspectRatioElementConfig** configures a clay element to enforce a fixed width / height ratio in its final dimensions. Mostly used for image elements, but can also be used for non image elements.
|
||||||
|
|
||||||
|
|
@ -1354,11 +1370,11 @@ Clay_AspectRatioElementConfig {
|
||||||
|
|
||||||
**`.aspectRatio`** - `float`
|
**`.aspectRatio`** - `float`
|
||||||
|
|
||||||
`CLAY({ .aspectRatio = { .aspectRatio = 16.0 / 9.0 } }) {}`
|
`CLAY(CLAY_ID("Aspect"), { .aspectRatio = { .aspectRatio = 16.0 / 9.0 } }) {}`
|
||||||
|
|
||||||
or alternatively, as C will automatically pass the value to the first nested struct field:
|
or alternatively, as C will automatically pass the value to the first nested struct field:
|
||||||
|
|
||||||
`CLAY({ .aspectRatio = 16.0 / 9.0 }) {}`
|
`CLAY(CLAY_ID("Aspect"), { .aspectRatio = 16.0 / 9.0 }) {}`
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
|
|
@ -1366,7 +1382,7 @@ or alternatively, as C will automatically pass the value to the first nested str
|
||||||
// Load an image somewhere in your code
|
// Load an image somewhere in your code
|
||||||
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
||||||
// Declare an image element that will grow along the X axis while maintaining its original aspect ratio
|
// Declare an image element that will grow along the X axis while maintaining its original aspect ratio
|
||||||
CLAY({
|
CLAY(CLAY_ID("ProfilePicture"), {
|
||||||
.layout = { .width = CLAY_SIZING_GROW() },
|
.layout = { .width = CLAY_SIZING_GROW() },
|
||||||
.aspectRatio = profilePicture.width / profilePicture.height,
|
.aspectRatio = profilePicture.width / profilePicture.height,
|
||||||
.image = { .imageData = &profilePicture },
|
.image = { .imageData = &profilePicture },
|
||||||
|
|
@ -1378,7 +1394,7 @@ CLAY({
|
||||||
### Clay_ImageElementConfig
|
### Clay_ImageElementConfig
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .image = { ...image config } }) {}`
|
`CLAY(CLAY_ID("Image"), { .image = { ...image config } }) {}`
|
||||||
|
|
||||||
**Clay_ImageElementConfig** configures a clay element to render an image as its background.
|
**Clay_ImageElementConfig** configures a clay element to render an image as its background.
|
||||||
|
|
||||||
|
|
@ -1394,7 +1410,7 @@ Clay_ImageElementConfig {
|
||||||
|
|
||||||
**`.imageData`** - `void *`
|
**`.imageData`** - `void *`
|
||||||
|
|
||||||
`CLAY({ .image = { .imageData = &myImage } }) {}`
|
`CLAY(CLAY_ID("Image"), { .image = { .imageData = &myImage } }) {}`
|
||||||
|
|
||||||
`.imageData` is a generic void pointer that can be used to pass through image data to the renderer.
|
`.imageData` is a generic void pointer that can be used to pass through image data to the renderer.
|
||||||
|
|
||||||
|
|
@ -1402,7 +1418,7 @@ Clay_ImageElementConfig {
|
||||||
// Load an image somewhere in your code
|
// Load an image somewhere in your code
|
||||||
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
YourImage profilePicture = LoadYourImage("profilePicture.png");
|
||||||
// Note that when rendering, .imageData will be void* type.
|
// Note that when rendering, .imageData will be void* type.
|
||||||
CLAY({ .image = { .imageData = &profilePicture } }) {}
|
CLAY(CLAY_ID("Image"), { .image = { .imageData = &profilePicture } }) {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: for an image to maintain its original aspect ratio when using dynamic scaling, the [.aspectRatio](#clay_aspectratioelementconfig) config option must be used.
|
Note: for an image to maintain its original aspect ratio when using dynamic scaling, the [.aspectRatio](#clay_aspectratioelementconfig) config option must be used.
|
||||||
|
|
@ -1415,9 +1431,9 @@ YourImage profilePicture = LoadYourImage("profilePicture.png");
|
||||||
// Declare a reusable image config
|
// Declare a reusable image config
|
||||||
Clay_ImageElementConfig imageConfig = (Clay_ImageElementConfig) { .imageData = &profilePicture };
|
Clay_ImageElementConfig imageConfig = (Clay_ImageElementConfig) { .imageData = &profilePicture };
|
||||||
// Declare an image element using a reusable config
|
// Declare an image element using a reusable config
|
||||||
CLAY({ .image = imageConfig }) {}
|
CLAY(CLAY_ID("Image"), { .image = imageConfig }) {}
|
||||||
// Declare an image element using an inline config
|
// Declare an image element using an inline config
|
||||||
CLAY({ .image = { .imageData = &profilePicture }, .aspectRatio = 16.0 / 9.0 }) {}
|
CLAY(CLAY_ID("ImageInline"), { .image = { .imageData = &profilePicture }, .aspectRatio = 16.0 / 9.0 }) {}
|
||||||
// Rendering example
|
// Rendering example
|
||||||
YourImage *imageToRender = renderCommand->elementConfig.imageElementConfig->imageData;
|
YourImage *imageToRender = renderCommand->elementConfig.imageElementConfig->imageData;
|
||||||
```
|
```
|
||||||
|
|
@ -1432,7 +1448,7 @@ Element is subject to [culling](#visibility-culling). Otherwise, a single `Clay_
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .clip = { ...clip config } }) {}`
|
`CLAY(CLAY_ID("ScrollBox"), { .clip = { ...clip config } }) {}`
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
|
||||||
|
|
@ -1453,7 +1469,7 @@ Clay_ClipElementConfig {
|
||||||
|
|
||||||
**`.horizontal`** - `bool`
|
**`.horizontal`** - `bool`
|
||||||
|
|
||||||
`CLAY({ .clip = { .horizontal = true } })`
|
`CLAY(CLAY_ID("HorizontalScroll"), { .clip = { .horizontal = true } })`
|
||||||
|
|
||||||
Enables or disables horizontal clipping for this container element.
|
Enables or disables horizontal clipping for this container element.
|
||||||
|
|
||||||
|
|
@ -1461,7 +1477,7 @@ Enables or disables horizontal clipping for this container element.
|
||||||
|
|
||||||
**`.vertical`** - `bool`
|
**`.vertical`** - `bool`
|
||||||
|
|
||||||
`CLAY({ .clip = { .vertical = true } })`
|
`CLAY(LAY_ID("VerticalScroll"), { .clip = { .vertical = true } })`
|
||||||
|
|
||||||
Enables or disables vertical clipping for this container element.
|
Enables or disables vertical clipping for this container element.
|
||||||
|
|
||||||
|
|
@ -1476,9 +1492,9 @@ Enabling clip for an element will result in two additional render commands:
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```C
|
```C
|
||||||
CLAY({ .clip = { .vertical = true } }) {
|
CLAY(CLAY_ID("ScrollOuter"), { .clip = { .vertical = true } }) {
|
||||||
// Create child content with a fixed height of 5000
|
// Create child content with a fixed height of 5000
|
||||||
CLAY({ .id = CLAY_ID("ScrollInner"), .layout = { .sizing = { .height = CLAY_SIZING_FIXED(5000) } } }) {}
|
CLAY(CLAY_ID("ScrollInner"), { .layout = { .sizing = { .height = CLAY_SIZING_FIXED(5000) } } }) {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -1488,7 +1504,7 @@ CLAY({ .clip = { .vertical = true } }) {
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .border = { ...border config } }) {}`
|
`CLAY(CLAY_ID("Border"), { .border = { ...border config } }) {}`
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
|
||||||
|
|
@ -1516,7 +1532,7 @@ typedef struct Clay_BorderElementConfig
|
||||||
|
|
||||||
**`.color`** - `Clay_Color`
|
**`.color`** - `Clay_Color`
|
||||||
|
|
||||||
`CLAY({ .border = { .color = { 255, 0, 0, 255 } } })`
|
`CLAY(CLAY_ID("Border"), { .border = { .color = { 255, 0, 0, 255 } } })`
|
||||||
|
|
||||||
Uses [Clay_Color](#clay_color). Specifies the shared color for all borders configured by this element. Conventionally accepts `rgba` float values between 0 and 255, but interpretation is left up to the renderer and does not affect layout.
|
Uses [Clay_Color](#clay_color). Specifies the shared color for all borders configured by this element. Conventionally accepts `rgba` float values between 0 and 255, but interpretation is left up to the renderer and does not affect layout.
|
||||||
|
|
||||||
|
|
@ -1524,7 +1540,7 @@ Uses [Clay_Color](#clay_color). Specifies the shared color for all borders confi
|
||||||
|
|
||||||
**`.width`** - `Clay_BorderWidth`
|
**`.width`** - `Clay_BorderWidth`
|
||||||
|
|
||||||
`CLAY({ .border = { .width = { .left = 2, .right = 10 } } })`
|
`CLAY(CLAY_ID("Border"), { .border = { .width = { .left = 2, .right = 10 } } })`
|
||||||
|
|
||||||
Indicates to the renderer that a border of `.color` should be draw at the specified edges of the bounding box, **inset and overlapping the box contents by `.width`**.
|
Indicates to the renderer that a border of `.color` should be draw at the specified edges of the bounding box, **inset and overlapping the box contents by `.width`**.
|
||||||
|
|
||||||
|
|
@ -1534,7 +1550,7 @@ Note:
|
||||||
|
|
||||||
**`.width.betweenChildren`**
|
**`.width.betweenChildren`**
|
||||||
|
|
||||||
`CLAY({ .border = { .width = { .betweenChildren = 2 } }, .color = COLOR_RED })`
|
`CLAY(CLAY_ID("Border"), { .border = { .width = { .betweenChildren = 2 } }, .color = COLOR_RED })`
|
||||||
|
|
||||||
Configures the width and color of borders to be drawn between children. These borders will be vertical lines if the parent uses `.layoutDirection = CLAY_LEFT_TO_RIGHT` and horizontal lines if the parent uses `CLAY_TOP_TO_BOTTOM`. Unlike `.left, .top` etc, this option **will generate additional rectangle render commands representing the borders between children.** As a result, the renderer does not need to specifically implement rendering for these border elements.
|
Configures the width and color of borders to be drawn between children. These borders will be vertical lines if the parent uses `.layoutDirection = CLAY_LEFT_TO_RIGHT` and horizontal lines if the parent uses `CLAY_TOP_TO_BOTTOM`. Unlike `.left, .top` etc, this option **will generate additional rectangle render commands representing the borders between children.** As a result, the renderer does not need to specifically implement rendering for these border elements.
|
||||||
|
|
||||||
|
|
@ -1544,8 +1560,7 @@ Configures the width and color of borders to be drawn between children. These bo
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// 300x300 container with a 1px red border around all the edges
|
// 300x300 container with a 1px red border around all the edges
|
||||||
CLAY({
|
CLAY(CLAY_ID("OuterBorder"), {
|
||||||
.id = CLAY_ID("OuterBorder"),
|
|
||||||
.layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_FIXED(300) } },
|
.layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_FIXED(300) } },
|
||||||
.border = { .width = { 1, 1, 1, 1, 0 }, .color = COLOR_RED }
|
.border = { .width = { 1, 1, 1, 1, 0 }, .color = COLOR_RED }
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -1553,16 +1568,14 @@ CLAY({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container with a 3px yellow bottom border
|
// Container with a 3px yellow bottom border
|
||||||
CLAY({
|
CLAY(CLAY_ID("OuterBorder"), {
|
||||||
.id = CLAY_ID("OuterBorder"),
|
|
||||||
.border = { .width = { .bottom = 3 }, .color = COLOR_YELLOW }
|
.border = { .width = { .bottom = 3 }, .color = COLOR_YELLOW }
|
||||||
}) {
|
}) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container with a 5px curved border around the edges, and a 5px blue border between all children laid out top to bottom
|
// Container with a 5px curved border around the edges, and a 5px blue border between all children laid out top to bottom
|
||||||
CLAY({
|
CLAY(CLAY_ID("OuterBorder"), {
|
||||||
.id = CLAY_ID("OuterBorder"),
|
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
.border = { .width = { 5, 5, 5, 5, 5 }, .color = COLOR_BLUE }
|
.border = { .width = { 5, 5, 5, 5, 5 }, .color = COLOR_BLUE }
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -1585,7 +1598,7 @@ Rendering of borders and rounded corners is left up to the user. See the provide
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .floating = { ...floating config } }) {}`
|
`CLAY(CLAY_ID("Floating"), { .floating = { ...floating config } }) {}`
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
|
||||||
|
|
@ -1636,7 +1649,7 @@ Clay_FloatingElementConfig {
|
||||||
|
|
||||||
**`.offset`** - `Clay_Vector2`
|
**`.offset`** - `Clay_Vector2`
|
||||||
|
|
||||||
`CLAY({ .floating = { .offset = { -24, -24 } } })`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .offset = { -24, -24 } } })`
|
||||||
|
|
||||||
Used to apply a position offset to the floating container _after_ all other layout has been calculated.
|
Used to apply a position offset to the floating container _after_ all other layout has been calculated.
|
||||||
|
|
||||||
|
|
@ -1644,7 +1657,7 @@ Used to apply a position offset to the floating container _after_ all other layo
|
||||||
|
|
||||||
**`.expand`** - `Clay_Dimensions`
|
**`.expand`** - `Clay_Dimensions`
|
||||||
|
|
||||||
`CLAY({ .floating = { .expand = { 16, 16 } } })`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .expand = { 16, 16 } } })`
|
||||||
|
|
||||||
Used to expand the width and height of the floating container _before_ laying out child elements.
|
Used to expand the width and height of the floating container _before_ laying out child elements.
|
||||||
|
|
||||||
|
|
@ -1652,7 +1665,7 @@ Used to expand the width and height of the floating container _before_ laying ou
|
||||||
|
|
||||||
**`.zIndex`** - `float`
|
**`.zIndex`** - `float`
|
||||||
|
|
||||||
`CLAY({ .floating = { .zIndex = 1 } })`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .zIndex = 1 } })`
|
||||||
|
|
||||||
All floating elements (as well as their entire child hierarchies) will be sorted by `.zIndex` order before being converted to render commands. If render commands are drawn in order, elements with higher `.zIndex` values will be drawn on top.
|
All floating elements (as well as their entire child hierarchies) will be sorted by `.zIndex` order before being converted to render commands. If render commands are drawn in order, elements with higher `.zIndex` values will be drawn on top.
|
||||||
|
|
||||||
|
|
@ -1660,41 +1673,41 @@ All floating elements (as well as their entire child hierarchies) will be sorted
|
||||||
|
|
||||||
**`.parentId`** - `uint32_t`
|
**`.parentId`** - `uint32_t`
|
||||||
|
|
||||||
`CLAY({ .floating = { .parentId = Clay_GetElementId("HeaderButton").id } })`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .parentId = Clay_GetElementId("HeaderButton").id } })`
|
||||||
|
|
||||||
By default, floating containers will "attach" to the parent element that they are declared inside. However, there are cases where this limitation could cause significant performance or ergonomics problems. `.parentId` allows you to specify a `CLAY_ID().id` to attach the floating container to. The parent element with the matching id can be declared anywhere in the hierarchy, it doesn't need to be declared before or after the floating container in particular.
|
By default, floating containers will "attach" to the parent element that they are declared inside. However, there are cases where this limitation could cause significant performance or ergonomics problems. `.parentId` allows you to specify a `CLAY_ID().id` to attach the floating container to. The parent element with the matching id can be declared anywhere in the hierarchy, it doesn't need to be declared before or after the floating container in particular.
|
||||||
|
|
||||||
Consider the following case:
|
Consider the following case:
|
||||||
```C
|
```C
|
||||||
// Load an image somewhere in your code
|
// Load an image somewhere in your code
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 1) }) {
|
CLAY(CLAY_IDI("SidebarButton", 1), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
if (tooltip.attachedButtonIndex == 1) {
|
if (tooltip.attachedButtonIndex == 1) {
|
||||||
CLAY({ /* floating config... */ })
|
CLAY(CLAY_ID("OptionTooltip"), { /* floating config... */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 2) }) {
|
CLAY(CLAY_IDI("SidebarButton", 2), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
if (tooltip.attachedButtonIndex == 2) {
|
if (tooltip.attachedButtonIndex == 2) {
|
||||||
CLAY({ /* floating config... */ })
|
CLAY(CLAY_ID("OptionTooltip"), { /* floating config... */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 3) }) {
|
CLAY(CLAY_IDI("SidebarButton", 3), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
if (tooltip.attachedButtonIndex == 3) {
|
if (tooltip.attachedButtonIndex == 3) {
|
||||||
CLAY({ /* floating config... */ })
|
CLAY(CLAY_ID("OptionTooltip"), { /* floating config... */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 4) }) {
|
CLAY(CLAY_IDI("SidebarButton", 4), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
if (tooltip.attachedButtonIndex == 4) {
|
if (tooltip.attachedButtonIndex == 4) {
|
||||||
CLAY({ /* floating config... */ })
|
CLAY(CLAY_ID("OptionTooltip"), { /* floating config... */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 5) }) {
|
CLAY(CLAY_IDI("SidebarButton", 5), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
if (tooltip.attachedButtonIndex == 5) {
|
if (tooltip.attachedButtonIndex == 5) {
|
||||||
CLAY({ /* floating config... */ })
|
CLAY(CLAY_ID("OptionTooltip"), { /* floating config... */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -1703,24 +1716,24 @@ The definition of the above UI is significantly polluted by the need to conditio
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// Load an image somewhere in your code
|
// Load an image somewhere in your code
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 1) }) {
|
CLAY(CLAY_IDI("SidebarButton", 1), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 2) }) {
|
CLAY(CLAY_IDI("SidebarButton", 2), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 3) }) {
|
CLAY(CLAY_IDI("SidebarButton", 3), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 4) }) {
|
CLAY(CLAY_IDI("SidebarButton", 4), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("SidebarButton", 5) }) {
|
CLAY(CLAY_IDI("SidebarButton", 5), { }) {
|
||||||
// .. some button contents
|
// .. some button contents
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any other point in the hierarchy
|
// Any other point in the hierarchy
|
||||||
CLAY({ .id = CLAY_ID("OptionTooltip"), .floating = { .attachTo = CLAY_ATTACH_TO_ELEMENT_ID, .parentId = CLAY_IDI("SidebarButton", tooltip.attachedButtonIndex).id }) {
|
CLAY(CLAY_ID("OptionTooltip"), { .floating = { .attachTo = CLAY_ATTACH_TO_ELEMENT_ID, .parentId = CLAY_IDI("SidebarButton", tooltip.attachedButtonIndex).id }) {
|
||||||
// Tooltip contents...
|
// Tooltip contents...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -1729,7 +1742,7 @@ CLAY({ .id = CLAY_ID("OptionTooltip"), .floating = { .attachTo = CLAY_ATTACH_TO_
|
||||||
|
|
||||||
**`.attachment`** - `Clay_FloatingAttachPoints`
|
**`.attachment`** - `Clay_FloatingAttachPoints`
|
||||||
|
|
||||||
`CLAY({ .floating = { .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_TOP } } }) {}`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_TOP } } }) {}`
|
||||||
|
|
||||||
In terms of positioning the floating container, `.attachment` specifies
|
In terms of positioning the floating container, `.attachment` specifies
|
||||||
|
|
||||||
|
|
@ -1744,7 +1757,7 @@ For example:
|
||||||
|
|
||||||
"Attach the LEFT_CENTER of the floating container to the RIGHT_TOP of the parent"
|
"Attach the LEFT_CENTER of the floating container to the RIGHT_TOP of the parent"
|
||||||
|
|
||||||
`CLAY({ .floating = { .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_TOP } } });`
|
`CLAY(CLAY_ID("Floating"), { .floating = { .attachment = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_TOP } } });`
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
@ -1758,31 +1771,31 @@ Controls whether pointer events like hover and click should pass through to cont
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// Horizontal container with three option buttons
|
// Horizontal container with three option buttons
|
||||||
CLAY({ .id = CLAY_ID("OptionsList"), .layout = { childGap = 16 } }) {
|
CLAY(CLAY_ID("OptionsList"), { .layout = { childGap = 16 } }) {
|
||||||
CLAY({ .id = CLAY_IDI("Option", 1), .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
CLAY(CLAY_IDI("Option", 1), { .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Option 1"), CLAY_TEXT_CONFIG());
|
CLAY_TEXT(CLAY_STRING("Option 1"), CLAY_TEXT_CONFIG());
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("Option", 2), .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
CLAY(CLAY_IDI("Option", 2), { .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Option 2"), CLAY_TEXT_CONFIG());
|
CLAY_TEXT(CLAY_STRING("Option 2"), CLAY_TEXT_CONFIG());
|
||||||
// Floating tooltip will attach above the "Option 2" container and not affect widths or positions of other elements
|
// Floating tooltip will attach above the "Option 2" container and not affect widths or positions of other elements
|
||||||
CLAY({ .id = CLAY_ID("OptionTooltip"), .floating = { .zIndex = 1, .attachment = { .element = CLAY_ATTACH_POINT_CENTER_BOTTOM, .parent = CLAY_ATTACH_POINT_CENTER_TOP } } }) {
|
CLAY(CLAY_ID("OptionTooltip"), { .floating = { .zIndex = 1, .attachment = { .element = CLAY_ATTACH_POINT_CENTER_BOTTOM, .parent = CLAY_ATTACH_POINT_CENTER_TOP } } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Most popular!"), CLAY_TEXT_CONFIG());
|
CLAY_TEXT(CLAY_STRING("Most popular!"), CLAY_TEXT_CONFIG());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("Option", 3), .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
CLAY(CLAY_IDI("Option", 3), { .layout = { padding = CLAY_PADDING_ALL(16)), .backgroundColor = COLOR_BLUE } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Option 3"), CLAY_TEXT_CONFIG());
|
CLAY_TEXT(CLAY_STRING("Option 3"), CLAY_TEXT_CONFIG());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floating containers can also be declared elsewhere in a layout, to avoid branching or polluting other UI
|
// Floating containers can also be declared elsewhere in a layout, to avoid branching or polluting other UI
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
CLAY({ .id = CLAY_IDI("Option", i + 1) }) {
|
CLAY(CLAY_IDI("Option", i + 1), { }) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Note the use of "parentId".
|
// Note the use of "parentId".
|
||||||
// Floating tooltip will attach above the "Option 2" container and not affect widths or positions of other elements
|
// Floating tooltip will attach above the "Option 2" container and not affect widths or positions of other elements
|
||||||
CLAY({ .id = CLAY_ID("OptionTooltip"), .floating = { .parentId = CLAY_IDI("Option", 2).id, .zIndex = 1, .attachment = { .element = CLAY_ATTACH_POINT_CENTER_BOTTOM, .parent = CLAY_ATTACH_POINT_TOP_CENTER } } }) {
|
CLAY(CLAY_ID("OptionTooltip"), { .floating = { .parentId = CLAY_IDI("Option", 2).id, .zIndex = 1, .attachment = { .element = CLAY_ATTACH_POINT_CENTER_BOTTOM, .parent = CLAY_ATTACH_POINT_TOP_CENTER } } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Most popular!"), CLAY_TEXT_CONFIG());
|
CLAY_TEXT(CLAY_STRING("Most popular!"), CLAY_TEXT_CONFIG());
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -1799,7 +1812,7 @@ When using `.parentId`, the floating container can be declared anywhere after `B
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
`CLAY({ .custom = { .customData = &something } }) {}`
|
`CLAY(CLAY_ID("Custom"), { .custom = { .customData = &something } }) {}`
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
|
||||||
|
|
@ -1858,7 +1871,7 @@ CLAY(0) {
|
||||||
CustomElementData *modelData = (CustomElementData *)(frameArena.memory + frameArena.offset);
|
CustomElementData *modelData = (CustomElementData *)(frameArena.memory + frameArena.offset);
|
||||||
*modelData = (CustomElementData) { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel };
|
*modelData = (CustomElementData) { .type = CUSTOM_ELEMENT_TYPE_MODEL, .model = myModel };
|
||||||
frameArena.offset += sizeof(CustomElementData);
|
frameArena.offset += sizeof(CustomElementData);
|
||||||
CLAY({ .custom = { .customData = modelData } }) {}
|
CLAY(CLAY_ID("3DModelViewer"), { .custom = { .customData = modelData } }) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Later during your rendering
|
// Later during your rendering
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
cp ../../clay.h clay.c;
|
cp ../../clay.h clay.c;
|
||||||
# Intel Mac
|
# Intel Mac
|
||||||
clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-apple-darwin clay.c -fPIC -O3 && ar r clay-odin/macos/clay.a clay.o;
|
rm -f clay-odin/macos/clay.a && clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-apple-darwin clay.c -fPIC -O3 && ar r clay-odin/macos/clay.a clay.o;
|
||||||
# ARM Mac
|
# ARM Mac
|
||||||
clang -c -DCLAY_IMPLEMENTATION -g -o clay.o -static clay.c -fPIC -O3 && ar r clay-odin/macos-arm64/clay.a clay.o;
|
rm -f clay-odin/macos-arm64/clay.a && clang -c -DCLAY_IMPLEMENTATION -g -o clay.o -static clay.c -fPIC -O3 && ar r clay-odin/macos-arm64/clay.a clay.o;
|
||||||
# x64 Windows
|
# x64 Windows
|
||||||
clang -c -DCLAY_IMPLEMENTATION -o clay-odin/windows/clay.lib -ffreestanding -target x86_64-pc-windows-msvc -fuse-ld=llvm-lib -static -O3 clay.c;
|
rm -f clay-odin/windows/clay.lib && clang -c -DCLAY_IMPLEMENTATION -o clay-odin/windows/clay.lib -ffreestanding -target x86_64-pc-windows-msvc -fuse-ld=llvm-lib -static -O3 clay.c;
|
||||||
# Linux
|
# Linux
|
||||||
clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-unknown-linux-gnu clay.c -fPIC -O3 && ar r clay-odin/linux/clay.a clay.o;
|
rm -f clay-odin/linux/clay.a && clang -c -DCLAY_IMPLEMENTATION -o clay.o -ffreestanding -static -target x86_64-unknown-linux-gnu clay.c -fPIC -O3 && ar r clay-odin/linux/clay.a clay.o;
|
||||||
# WASM
|
# WASM
|
||||||
clang -c -DCLAY_IMPLEMENTATION -o clay-odin/wasm/clay.o -target wasm32 -nostdlib -static -O3 clay.c;
|
rm -f clay-odin/wasm/clay.o && clang -c -DCLAY_IMPLEMENTATION -o clay-odin/wasm/clay.o -target wasm32 -nostdlib -static -O3 clay.c;
|
||||||
rm clay.o;
|
rm clay.o;
|
||||||
rm clay.c;
|
rm clay.c;
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,6 @@ ClayArray :: struct($type: typeid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementDeclaration :: struct {
|
ElementDeclaration :: struct {
|
||||||
id: ElementId,
|
|
||||||
layout: LayoutConfig,
|
layout: LayoutConfig,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
cornerRadius: CornerRadius,
|
cornerRadius: CornerRadius,
|
||||||
|
|
@ -378,6 +377,7 @@ Context :: struct {} // opaque structure, only use as a pointer
|
||||||
@(link_prefix = "Clay_", default_calling_convention = "c")
|
@(link_prefix = "Clay_", default_calling_convention = "c")
|
||||||
foreign Clay {
|
foreign Clay {
|
||||||
_OpenElement :: proc() ---
|
_OpenElement :: proc() ---
|
||||||
|
_OpenElementWithId :: proc(id: ElementId) ---
|
||||||
_CloseElement :: proc() ---
|
_CloseElement :: proc() ---
|
||||||
MinMemorySize :: proc() -> u32 ---
|
MinMemorySize :: proc() -> u32 ---
|
||||||
CreateArenaWithCapacityAndMemory :: proc(capacity: c.size_t, offset: [^]u8) -> Arena ---
|
CreateArenaWithCapacityAndMemory :: proc(capacity: c.size_t, offset: [^]u8) -> Arena ---
|
||||||
|
|
@ -426,11 +426,19 @@ ConfigureOpenElement :: proc(config: ElementDeclaration) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
@(deferred_none = _CloseElement)
|
@(deferred_none = _CloseElement)
|
||||||
UI :: proc() -> proc (config: ElementDeclaration) -> bool {
|
UI_WithId :: proc(id: ElementId) -> proc (config: ElementDeclaration) -> bool {
|
||||||
|
_OpenElementWithId(id)
|
||||||
|
return ConfigureOpenElement
|
||||||
|
}
|
||||||
|
|
||||||
|
@(deferred_none = _CloseElement)
|
||||||
|
UI_AutoId :: proc() -> proc (config: ElementDeclaration) -> bool {
|
||||||
_OpenElement()
|
_OpenElement()
|
||||||
return ConfigureOpenElement
|
return ConfigureOpenElement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI :: proc{UI_WithId, UI_AutoId};
|
||||||
|
|
||||||
Text :: proc($text: string, config: ^TextElementConfig) {
|
Text :: proc($text: string, config: ^TextElementConfig) {
|
||||||
wrapped := MakeString(text)
|
wrapped := MakeString(text)
|
||||||
wrapped.isStaticallyAllocated = true
|
wrapped.isStaticallyAllocated = true
|
||||||
|
|
@ -482,7 +490,7 @@ MakeString :: proc(label: string) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
ID :: proc(label: string, index: u32 = 0) -> ElementId {
|
ID :: proc(label: string, index: u32 = 0) -> ElementId {
|
||||||
return _HashString(MakeString(label), 0)
|
return _HashString(MakeString(label), index)
|
||||||
}
|
}
|
||||||
|
|
||||||
ID_LOCAL :: proc(label: string, index: u32 = 0) -> ElementId {
|
ID_LOCAL :: proc(label: string, index: u32 = 0) -> ElementId {
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -63,14 +63,12 @@ border2pxRed := clay.BorderElementConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
LandingPageBlob :: proc(index: u32, fontSize: u16, fontId: u16, color: clay.Color, $text: string, image: ^raylib.Texture2D) {
|
LandingPageBlob :: proc(index: u32, fontSize: u16, fontId: u16, color: clay.Color, $text: string, image: ^raylib.Texture2D) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("HeroBlob", index))({
|
||||||
id = clay.ID("HeroBlob", index),
|
|
||||||
layout = { sizing = { width = clay.SizingGrow({ max = 480 }) }, padding = clay.PaddingAll(16), childGap = 16, childAlignment = clay.ChildAlignment{ y = .Center } },
|
layout = { sizing = { width = clay.SizingGrow({ max = 480 }) }, padding = clay.PaddingAll(16), childGap = 16, childAlignment = clay.ChildAlignment{ y = .Center } },
|
||||||
border = border2pxRed,
|
border = border2pxRed,
|
||||||
cornerRadius = clay.CornerRadiusAll(10)
|
cornerRadius = clay.CornerRadiusAll(10)
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("CheckImage", index))({
|
||||||
id = clay.ID("CheckImage", index),
|
|
||||||
layout = { sizing = { width = clay.SizingFixed(32) } },
|
layout = { sizing = { width = clay.SizingFixed(32) } },
|
||||||
aspectRatio = { 1.0 },
|
aspectRatio = { 1.0 },
|
||||||
image = { imageData = image },
|
image = { imageData = image },
|
||||||
|
|
@ -80,16 +78,14 @@ LandingPageBlob :: proc(index: u32, fontSize: u16, fontId: u16, color: clay.Colo
|
||||||
}
|
}
|
||||||
|
|
||||||
LandingPageDesktop :: proc() {
|
LandingPageDesktop :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("LandingPage1Desktop"))({
|
||||||
id = clay.ID("LandingPage1Desktop"),
|
|
||||||
layout = { sizing = { width = clay.SizingGrow(), height = clay.SizingFit({ min = cast(f32)windowHeight - 70 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
layout = { sizing = { width = clay.SizingGrow(), height = clay.SizingFit({ min = cast(f32)windowHeight - 70 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("LandingPage1"))({
|
||||||
id = clay.ID("LandingPage1"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
||||||
border = { COLOR_RED, { left = 2, right = 2 } },
|
border = { COLOR_RED, { left = 2, right = 2 } },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({ id = clay.ID("LeftText"), layout = { sizing = { width = clay.SizingPercent(0.55) }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
if clay.UI(clay.ID("LeftText"))({ layout = { sizing = { width = clay.SizingPercent(0.55) }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
||||||
clay.Text(
|
clay.Text(
|
||||||
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
|
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
|
||||||
clay.TextConfig({fontSize = 56, fontId = FONT_ID_TITLE_56, textColor = COLOR_RED}),
|
clay.TextConfig({fontSize = 56, fontId = FONT_ID_TITLE_56, textColor = COLOR_RED}),
|
||||||
|
|
@ -100,8 +96,7 @@ LandingPageDesktop :: proc() {
|
||||||
clay.TextConfig({fontSize = 36, fontId = FONT_ID_TITLE_36, textColor = COLOR_ORANGE}),
|
clay.TextConfig({fontSize = 36, fontId = FONT_ID_TITLE_36, textColor = COLOR_ORANGE}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("HeroImageOuter"))({
|
||||||
id = clay.ID("HeroImageOuter"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingPercent(0.45) }, childAlignment = { x = .Center }, childGap = 16 },
|
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingPercent(0.45) }, childAlignment = { x = .Center }, childGap = 16 },
|
||||||
}) {
|
}) {
|
||||||
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_5, "High performance", &checkImage5)
|
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_5, "High performance", &checkImage5)
|
||||||
|
|
@ -115,8 +110,7 @@ LandingPageDesktop :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LandingPageMobile :: proc() {
|
LandingPageMobile :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("LandingPage1Mobile"))({
|
||||||
id = clay.ID("LandingPage1Mobile"),
|
|
||||||
layout = {
|
layout = {
|
||||||
layoutDirection = .TopToBottom,
|
layoutDirection = .TopToBottom,
|
||||||
sizing = { width = clay.SizingGrow(), height = clay.SizingFit({ min = cast(f32)windowHeight - 70 }) },
|
sizing = { width = clay.SizingGrow(), height = clay.SizingFit({ min = cast(f32)windowHeight - 70 }) },
|
||||||
|
|
@ -125,7 +119,7 @@ LandingPageMobile :: proc() {
|
||||||
childGap = 32,
|
childGap = 32,
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({ id = clay.ID("LeftText"), layout = { sizing = { width = clay.SizingGrow() }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
if clay.UI(clay.ID("LeftText"))({ layout = { sizing = { width = clay.SizingGrow() }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
||||||
clay.Text(
|
clay.Text(
|
||||||
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
|
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
|
||||||
clay.TextConfig({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_RED}),
|
clay.TextConfig({fontSize = 48, fontId = FONT_ID_TITLE_48, textColor = COLOR_RED}),
|
||||||
|
|
@ -136,8 +130,7 @@ LandingPageMobile :: proc() {
|
||||||
clay.TextConfig({fontSize = 32, fontId = FONT_ID_TITLE_32, textColor = COLOR_ORANGE}),
|
clay.TextConfig({fontSize = 32, fontId = FONT_ID_TITLE_32, textColor = COLOR_ORANGE}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("HeroImageOuter"))({
|
||||||
id = clay.ID("HeroImageOuter"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingGrow() }, childAlignment = { x = .Center }, childGap = 16 },
|
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingGrow() }, childAlignment = { x = .Center }, childGap = 16 },
|
||||||
}) {
|
}) {
|
||||||
LandingPageBlob(1, 24, FONT_ID_BODY_24, COLOR_BLOB_BORDER_5, "High performance", &checkImage5)
|
LandingPageBlob(1, 24, FONT_ID_BODY_24, COLOR_BLOB_BORDER_5, "High performance", &checkImage5)
|
||||||
|
|
@ -151,18 +144,16 @@ LandingPageMobile :: proc() {
|
||||||
|
|
||||||
FeatureBlocks :: proc(widthSizing: clay.SizingAxis, outerPadding: u16) {
|
FeatureBlocks :: proc(widthSizing: clay.SizingAxis, outerPadding: u16) {
|
||||||
textConfig := clay.TextConfig({fontSize = 24, fontId = FONT_ID_BODY_24, textColor = COLOR_RED})
|
textConfig := clay.TextConfig({fontSize = 24, fontId = FONT_ID_BODY_24, textColor = COLOR_RED})
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("HFileBoxOuter"))({
|
||||||
id = clay.ID("HFileBoxOuter"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { width = widthSizing }, childAlignment = { y = .Center }, padding = { outerPadding, outerPadding, 32, 32 }, childGap = 8 },
|
layout = { layoutDirection = .TopToBottom, sizing = { width = widthSizing }, childAlignment = { y = .Center }, padding = { outerPadding, outerPadding, 32, 32 }, childGap = 8 },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({ id = clay.ID("HFileIncludeOuter"), layout = { padding = { 8, 8, 4, 4 } }, backgroundColor = COLOR_RED, cornerRadius = clay.CornerRadiusAll(8) }) {
|
if clay.UI(clay.ID("HFileIncludeOuter"))({ layout = { padding = { 8, 8, 4, 4 } }, backgroundColor = COLOR_RED, cornerRadius = clay.CornerRadiusAll(8) }) {
|
||||||
clay.Text("#include clay.h", clay.TextConfig({fontSize = 24, fontId = FONT_ID_BODY_24, textColor = COLOR_LIGHT}))
|
clay.Text("#include clay.h", clay.TextConfig({fontSize = 24, fontId = FONT_ID_BODY_24, textColor = COLOR_LIGHT}))
|
||||||
}
|
}
|
||||||
clay.Text("~2000 lines of C99.", textConfig)
|
clay.Text("~2000 lines of C99.", textConfig)
|
||||||
clay.Text("Zero dependencies, including no C standard library.", textConfig)
|
clay.Text("Zero dependencies, including no C standard library.", textConfig)
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("BringYourOwnRendererOuter"))({
|
||||||
id = clay.ID("BringYourOwnRendererOuter"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { width = widthSizing }, childAlignment = { y = .Center }, padding = { outerPadding, outerPadding, 32, 32 }, childGap = 8 },
|
layout = { layoutDirection = .TopToBottom, sizing = { width = widthSizing }, childAlignment = { y = .Center }, padding = { outerPadding, outerPadding, 32, 32 }, childGap = 8 },
|
||||||
}) {
|
}) {
|
||||||
clay.Text("Renderer agnostic.", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = COLOR_ORANGE}))
|
clay.Text("Renderer agnostic.", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = COLOR_ORANGE}))
|
||||||
|
|
@ -172,9 +163,8 @@ FeatureBlocks :: proc(widthSizing: clay.SizingAxis, outerPadding: u16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FeatureBlocksDesktop :: proc() {
|
FeatureBlocksDesktop :: proc() {
|
||||||
if clay.UI()({ id = clay.ID("FeatureBlocksOuter"), layout = { sizing = { width = clay.SizingGrow({}) } } }) {
|
if clay.UI(clay.ID("FeatureBlocksOuter"))({ layout = { sizing = { width = clay.SizingGrow({}) } } }) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("FeatureBlocksInner"))({
|
||||||
id = clay.ID("FeatureBlocksInner"),
|
|
||||||
layout = { sizing = { width = clay.SizingGrow() }, childAlignment = { y = .Center } },
|
layout = { sizing = { width = clay.SizingGrow() }, childAlignment = { y = .Center } },
|
||||||
border = { width = { betweenChildren = 2}, color = COLOR_RED },
|
border = { width = { betweenChildren = 2}, color = COLOR_RED },
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -184,8 +174,7 @@ FeatureBlocksDesktop :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FeatureBlocksMobile :: proc() {
|
FeatureBlocksMobile :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("FeatureBlocksInner"))({
|
||||||
id = clay.ID("FeatureBlocksInner"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingGrow() } },
|
layout = { layoutDirection = .TopToBottom, sizing = { width = clay.SizingGrow() } },
|
||||||
border = { width = { betweenChildren = 2}, color = COLOR_RED },
|
border = { width = { betweenChildren = 2}, color = COLOR_RED },
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -194,9 +183,9 @@ FeatureBlocksMobile :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeSyntaxPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
DeclarativeSyntaxPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
||||||
if clay.UI()({ id = clay.ID("SyntaxPageLeftText"), layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
if clay.UI(clay.ID("SyntaxPageLeftText"))({ layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
||||||
clay.Text("Declarative Syntax", clay.TextConfig(titleTextConfig))
|
clay.Text("Declarative Syntax", clay.TextConfig(titleTextConfig))
|
||||||
if clay.UI()({ id = clay.ID("SyntaxSpacer"), layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } } }) {}
|
if clay.UI(clay.ID("SyntaxSpacer"))({ layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } } }) {}
|
||||||
clay.Text(
|
clay.Text(
|
||||||
"Flexible and readable declarative syntax with nested UI element hierarchies.",
|
"Flexible and readable declarative syntax with nested UI element hierarchies.",
|
||||||
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_28, textColor = COLOR_RED}),
|
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_28, textColor = COLOR_RED}),
|
||||||
|
|
@ -210,9 +199,8 @@ DeclarativeSyntaxPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizi
|
||||||
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_28, textColor = COLOR_RED}),
|
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_28, textColor = COLOR_RED}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if clay.UI()({ id = clay.ID("SyntaxPageRightImage"), layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center } } }) {
|
if clay.UI(clay.ID("SyntaxPageRightImage"))({ layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center } } }) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("SyntaxPageRightImageInner"))({
|
||||||
id = clay.ID("SyntaxPageRightImageInner"),
|
|
||||||
layout = { sizing = { width = clay.SizingGrow({ max = 568 }) } },
|
layout = { sizing = { width = clay.SizingGrow({ max = 568 }) } },
|
||||||
aspectRatio = { 1136.0 / 1194.0 },
|
aspectRatio = { 1136.0 / 1194.0 },
|
||||||
image = { imageData = &syntaxImage },
|
image = { imageData = &syntaxImage },
|
||||||
|
|
@ -221,12 +209,10 @@ DeclarativeSyntaxPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizi
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeSyntaxPageDesktop :: proc() {
|
DeclarativeSyntaxPageDesktop :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("SyntaxPageDesktop"))({
|
||||||
id = clay.ID("SyntaxPageDesktop"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("SyntaxPage"))({
|
||||||
id = clay.ID("SyntaxPage"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
||||||
border = border2pxRed,
|
border = border2pxRed,
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -236,8 +222,7 @@ DeclarativeSyntaxPageDesktop :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclarativeSyntaxPageMobile :: proc() {
|
DeclarativeSyntaxPageMobile :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("SyntaxPageMobile"))({
|
||||||
id = clay.ID("SyntaxPageMobile"),
|
|
||||||
layout = {
|
layout = {
|
||||||
layoutDirection = .TopToBottom,
|
layoutDirection = .TopToBottom,
|
||||||
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
||||||
|
|
@ -257,7 +242,7 @@ ColorLerp :: proc(a: clay.Color, b: clay.Color, amount: f32) -> clay.Color {
|
||||||
LOREM_IPSUM_TEXT :: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
LOREM_IPSUM_TEXT :: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
||||||
|
|
||||||
HighPerformancePage :: proc(lerpValue: f32, titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
HighPerformancePage :: proc(lerpValue: f32, titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
||||||
if clay.UI()({ id = clay.ID("PerformanceLeftText"), layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
if clay.UI(clay.ID("PerformanceLeftText"))({ layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
||||||
clay.Text("High Performance", clay.TextConfig(titleTextConfig))
|
clay.Text("High Performance", clay.TextConfig(titleTextConfig))
|
||||||
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } }}) {}
|
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } }}) {}
|
||||||
clay.Text(
|
clay.Text(
|
||||||
|
|
@ -273,21 +258,18 @@ HighPerformancePage :: proc(lerpValue: f32, titleTextConfig: clay.TextElementCon
|
||||||
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_36, textColor = COLOR_LIGHT}),
|
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_36, textColor = COLOR_LIGHT}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if clay.UI()({ id = clay.ID("PerformanceRightImageOuter"), layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center } } }) {
|
if clay.UI(clay.ID("PerformanceRightImageOuter"))({ layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center } } }) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("PerformanceRightBorder"))({
|
||||||
id = clay.ID("PerformanceRightBorder"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(400) } },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(400) } },
|
||||||
border = { COLOR_LIGHT, {2, 2, 2, 2, 2} },
|
border = { COLOR_LIGHT, {2, 2, 2, 2, 2} },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("AnimationDemoContainerLeft"))({
|
||||||
id = clay.ID("AnimationDemoContainerLeft"),
|
|
||||||
layout = { sizing = { clay.SizingPercent(0.35 + 0.3 * lerpValue), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(16) },
|
layout = { sizing = { clay.SizingPercent(0.35 + 0.3 * lerpValue), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(16) },
|
||||||
backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue),
|
backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue),
|
||||||
}) {
|
}) {
|
||||||
clay.Text(LOREM_IPSUM_TEXT, clay.TextConfig({fontSize = 16, fontId = FONT_ID_BODY_16, textColor = COLOR_LIGHT}))
|
clay.Text(LOREM_IPSUM_TEXT, clay.TextConfig({fontSize = 16, fontId = FONT_ID_BODY_16, textColor = COLOR_LIGHT}))
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("AnimationDemoContainerRight"))({
|
||||||
id = clay.ID("AnimationDemoContainerRight"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(16) },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(16) },
|
||||||
backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue),
|
backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue),
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -298,8 +280,7 @@ HighPerformancePage :: proc(lerpValue: f32, titleTextConfig: clay.TextElementCon
|
||||||
}
|
}
|
||||||
|
|
||||||
HighPerformancePageDesktop :: proc(lerpValue: f32) {
|
HighPerformancePageDesktop :: proc(lerpValue: f32) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("PerformanceDesktop"))({
|
||||||
id = clay.ID("PerformanceDesktop"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { 82, 82, 32, 32 }, childGap = 64 },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { 82, 82, 32, 32 }, childGap = 64 },
|
||||||
backgroundColor = COLOR_RED,
|
backgroundColor = COLOR_RED,
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -308,8 +289,7 @@ HighPerformancePageDesktop :: proc(lerpValue: f32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HighPerformancePageMobile :: proc(lerpValue: f32) {
|
HighPerformancePageMobile :: proc(lerpValue: f32) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("PerformanceMobile"))({
|
||||||
id = clay.ID("PerformanceMobile"),
|
|
||||||
layout = {
|
layout = {
|
||||||
layoutDirection = .TopToBottom,
|
layoutDirection = .TopToBottom,
|
||||||
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
||||||
|
|
@ -335,8 +315,7 @@ RendererButtonActive :: proc(index: i32, $text: string) {
|
||||||
|
|
||||||
RendererButtonInactive :: proc(index: u32, $text: string) {
|
RendererButtonInactive :: proc(index: u32, $text: string) {
|
||||||
if clay.UI()({ border = border2pxRed }) {
|
if clay.UI()({ border = border2pxRed }) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("RendererButtonInactiveInner", index))({
|
||||||
id = clay.ID("RendererButtonInactiveInner", index),
|
|
||||||
layout = { sizing = { width = clay.SizingFixed(300) }, padding = clay.PaddingAll(16) },
|
layout = { sizing = { width = clay.SizingFixed(300) }, padding = clay.PaddingAll(16) },
|
||||||
backgroundColor = COLOR_LIGHT,
|
backgroundColor = COLOR_LIGHT,
|
||||||
cornerRadius = clay.CornerRadiusAll(10)
|
cornerRadius = clay.CornerRadiusAll(10)
|
||||||
|
|
@ -347,7 +326,7 @@ RendererButtonInactive :: proc(index: u32, $text: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
RendererPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.SizingAxis) {
|
||||||
if clay.UI()({ id = clay.ID("RendererLeftText"), layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
if clay.UI(clay.ID("RendererLeftText"))({ layout = { sizing = { width = widthSizing }, layoutDirection = .TopToBottom, childGap = 8 } }) {
|
||||||
clay.Text("Renderer & Platform Agnostic", clay.TextConfig(titleTextConfig))
|
clay.Text("Renderer & Platform Agnostic", clay.TextConfig(titleTextConfig))
|
||||||
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } } }) {}
|
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow({ max = 16 }) } } }) {}
|
||||||
clay.Text(
|
clay.Text(
|
||||||
|
|
@ -363,8 +342,7 @@ RendererPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.
|
||||||
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_36, textColor = COLOR_RED}),
|
clay.TextConfig({fontSize = 28, fontId = FONT_ID_BODY_36, textColor = COLOR_RED}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("RendererRightText"))({
|
||||||
id = clay.ID("RendererRightText"),
|
|
||||||
layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center }, layoutDirection = .TopToBottom, childGap = 16 },
|
layout = { sizing = { width = widthSizing }, childAlignment = { x = .Center }, layoutDirection = .TopToBottom, childGap = 16 },
|
||||||
}) {
|
}) {
|
||||||
clay.Text("Try changing renderer!", clay.TextConfig({fontSize = 36, fontId = FONT_ID_BODY_36, textColor = COLOR_ORANGE}))
|
clay.Text("Try changing renderer!", clay.TextConfig({fontSize = 36, fontId = FONT_ID_BODY_36, textColor = COLOR_ORANGE}))
|
||||||
|
|
@ -374,12 +352,10 @@ RendererPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizing: clay.
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererPageDesktop :: proc() {
|
RendererPageDesktop :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("RendererPageDesktop"))({
|
||||||
id = clay.ID("RendererPageDesktop"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) }, childAlignment = { y = .Center }, padding = { left = 50, right = 50 } },
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("RendererPage"))({
|
||||||
id = clay.ID("RendererPage"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, childAlignment = { y = .Center }, padding = clay.PaddingAll(32), childGap = 32 },
|
||||||
border = { COLOR_RED, { left = 2, right = 2 } },
|
border = { COLOR_RED, { left = 2, right = 2 } },
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -389,8 +365,7 @@ RendererPageDesktop :: proc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererPageMobile :: proc() {
|
RendererPageMobile :: proc() {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("RendererMobile"))({
|
||||||
id = clay.ID("RendererMobile"),
|
|
||||||
layout = {
|
layout = {
|
||||||
layoutDirection = .TopToBottom,
|
layoutDirection = .TopToBottom,
|
||||||
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
sizing = { clay.SizingGrow(), clay.SizingFit({ min = cast(f32)windowHeight - 50 }) },
|
||||||
|
|
@ -416,28 +391,25 @@ animationLerpValue: f32 = -1.0
|
||||||
createLayout :: proc(lerpValue: f32) -> clay.ClayArray(clay.RenderCommand) {
|
createLayout :: proc(lerpValue: f32) -> clay.ClayArray(clay.RenderCommand) {
|
||||||
mobileScreen := windowWidth < 750
|
mobileScreen := windowWidth < 750
|
||||||
clay.BeginLayout()
|
clay.BeginLayout()
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("OuterContainer"))({
|
||||||
id = clay.ID("OuterContainer"),
|
|
||||||
layout = { layoutDirection = .TopToBottom, sizing = { clay.SizingGrow(), clay.SizingGrow() } },
|
layout = { layoutDirection = .TopToBottom, sizing = { clay.SizingGrow(), clay.SizingGrow() } },
|
||||||
backgroundColor = COLOR_LIGHT,
|
backgroundColor = COLOR_LIGHT,
|
||||||
}) {
|
}) {
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("Header"))({
|
||||||
id = clay.ID("Header"),
|
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(50) }, childAlignment = { y = .Center }, childGap = 24, padding = { left = 32, right = 32 } },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(50) }, childAlignment = { y = .Center }, childGap = 24, padding = { left = 32, right = 32 } },
|
||||||
}) {
|
}) {
|
||||||
clay.Text("Clay", &headerTextConfig)
|
clay.Text("Clay", &headerTextConfig)
|
||||||
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow() } } }) {}
|
if clay.UI()({ layout = { sizing = { width = clay.SizingGrow() } } }) {}
|
||||||
|
|
||||||
if (!mobileScreen) {
|
if (!mobileScreen) {
|
||||||
if clay.UI()({ id = clay.ID("LinkExamplesOuter"), backgroundColor = {0, 0, 0, 0} }) {
|
if clay.UI(clay.ID("LinkExamplesOuter"))({ backgroundColor = {0, 0, 0, 0} }) {
|
||||||
clay.Text("Examples", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
clay.Text("Examples", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
||||||
}
|
}
|
||||||
if clay.UI()({ id = clay.ID("LinkDocsOuter"), backgroundColor = {0, 0, 0, 0} }) {
|
if clay.UI(clay.ID("LinkDocsOuter"))({ backgroundColor = {0, 0, 0, 0} }) {
|
||||||
clay.Text("Docs", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
clay.Text("Docs", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("LinkGithubOuter"))({
|
||||||
id = clay.ID("LinkGithubOuter"),
|
|
||||||
layout = { padding = { 16, 16, 6, 6 } },
|
layout = { padding = { 16, 16, 6, 6 } },
|
||||||
border = border2pxRed,
|
border = border2pxRed,
|
||||||
backgroundColor = clay.Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
backgroundColor = clay.Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
||||||
|
|
@ -446,13 +418,12 @@ createLayout :: proc(lerpValue: f32) -> clay.ClayArray(clay.RenderCommand) {
|
||||||
clay.Text("Github", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
clay.Text("Github", clay.TextConfig({fontId = FONT_ID_BODY_24, fontSize = 24, textColor = {61, 26, 5, 255}}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if clay.UI()({ id = clay.ID("TopBorder1"), layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_5 } ) {}
|
if clay.UI(clay.ID("TopBorder1"))({ layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_5 } ) {}
|
||||||
if clay.UI()({ id = clay.ID("TopBorder2"), layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_4 } ) {}
|
if clay.UI(clay.ID("TopBorder2"))({ layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_4 } ) {}
|
||||||
if clay.UI()({ id = clay.ID("TopBorder3"), layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_3 } ) {}
|
if clay.UI(clay.ID("TopBorder3"))({ layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_3 } ) {}
|
||||||
if clay.UI()({ id = clay.ID("TopBorder4"), layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_2 } ) {}
|
if clay.UI(clay.ID("TopBorder4"))({ layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_2 } ) {}
|
||||||
if clay.UI()({ id = clay.ID("TopBorder5"), layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_1 } ) {}
|
if clay.UI(clay.ID("TopBorder5"))({ layout = { sizing = { clay.SizingGrow(), clay.SizingFixed(4) } }, backgroundColor = COLOR_TOP_BORDER_1 } ) {}
|
||||||
if clay.UI()({
|
if clay.UI(clay.ID("ScrollContainerBackgroundRectangle"))({
|
||||||
id = clay.ID("ScrollContainerBackgroundRectangle"),
|
|
||||||
clip = { vertical = true, childOffset = clay.GetScrollOffset() },
|
clip = { vertical = true, childOffset = clay.GetScrollOffset() },
|
||||||
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, layoutDirection = clay.LayoutDirection.TopToBottom },
|
layout = { sizing = { clay.SizingGrow(), clay.SizingGrow() }, layoutDirection = clay.LayoutDirection.TopToBottom },
|
||||||
backgroundColor = COLOR_LIGHT,
|
backgroundColor = COLOR_LIGHT,
|
||||||
|
|
|
||||||
230
clay.h
230
clay.h
|
|
@ -85,7 +85,7 @@
|
||||||
// Note: If a compile error led you here, you might be trying to use CLAY_ID_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SID_LOCAL instead.
|
// Note: If a compile error led you here, you might be trying to use CLAY_ID_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SID_LOCAL instead.
|
||||||
#define CLAY_ID_LOCAL(label) CLAY_SID_LOCAL(CLAY_STRING(label))
|
#define CLAY_ID_LOCAL(label) CLAY_SID_LOCAL(CLAY_STRING(label))
|
||||||
|
|
||||||
#define CLAY_SID_LOCAL(label, index) Clay__HashString(label, Clay__GetParentElementId())
|
#define CLAY_SID_LOCAL(label) Clay__HashString(label, Clay__GetParentElementId())
|
||||||
|
|
||||||
// Note: If a compile error led you here, you might be trying to use CLAY_IDI_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SIDI_LOCAL instead.
|
// Note: If a compile error led you here, you might be trying to use CLAY_IDI_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SIDI_LOCAL instead.
|
||||||
#define CLAY_IDI_LOCAL(label, index) CLAY_SIDI_LOCAL(CLAY_STRING(label), index)
|
#define CLAY_IDI_LOCAL(label, index) CLAY_SIDI_LOCAL(CLAY_STRING(label), index)
|
||||||
|
|
@ -121,25 +121,32 @@ static inline void Clay__SuppressUnusedLatchDefinitionVariableWarning(void) { (v
|
||||||
|
|
||||||
Into calls like this:
|
Into calls like this:
|
||||||
|
|
||||||
Clay_OpenElement();
|
Clay__OpenElement();
|
||||||
Clay_ConfigureOpenElement((Clay_ElementDeclaration) {
|
Clay__ConfigureOpenElement((Clay_ElementDeclaration) {
|
||||||
.id = CLAY_ID("Container"),
|
.id = CLAY_ID("Container"),
|
||||||
.backgroundColor = { 255, 200, 200, 255 }
|
.backgroundColor = { 255, 200, 200, 255 }
|
||||||
});
|
});
|
||||||
...children declared here
|
...children declared here
|
||||||
Clay_CloseElement();
|
Clay__CloseElement();
|
||||||
|
|
||||||
The for loop will only ever run a single iteration, putting Clay__CloseElement() in the increment of the loop
|
The for loop will only ever run a single iteration, putting Clay__CloseElement() in the increment of the loop
|
||||||
means that it will run after the body - where the children are declared. It just exists to make sure you don't forget
|
means that it will run after the body - where the children are declared. It just exists to make sure you don't forget
|
||||||
to call Clay_CloseElement().
|
to call Clay_CloseElement().
|
||||||
*/
|
*/
|
||||||
#define CLAY(...) \
|
#define CLAY_AUTO_ID(...) \
|
||||||
for ( \
|
for ( \
|
||||||
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), Clay__ConfigureOpenElement(CLAY__CONFIG_WRAPPER(Clay_ElementDeclaration, __VA_ARGS__)), 0); \
|
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElement(), Clay__ConfigureOpenElement(CLAY__CONFIG_WRAPPER(Clay_ElementDeclaration, __VA_ARGS__)), 0); \
|
||||||
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
|
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
|
||||||
CLAY__ELEMENT_DEFINITION_LATCH=1, Clay__CloseElement() \
|
CLAY__ELEMENT_DEFINITION_LATCH=1, Clay__CloseElement() \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#define CLAY(id, ...) \
|
||||||
|
for ( \
|
||||||
|
CLAY__ELEMENT_DEFINITION_LATCH = (Clay__OpenElementWithId(id), Clay__ConfigureOpenElement(CLAY__CONFIG_WRAPPER(Clay_ElementDeclaration, __VA_ARGS__)), 0); \
|
||||||
|
CLAY__ELEMENT_DEFINITION_LATCH < 1; \
|
||||||
|
CLAY__ELEMENT_DEFINITION_LATCH=1, Clay__CloseElement() \
|
||||||
|
)
|
||||||
|
|
||||||
// These macros exist to allow the CLAY() macro to be called both with an inline struct definition, such as
|
// These macros exist to allow the CLAY() macro to be called both with an inline struct definition, such as
|
||||||
// CLAY({ .id = something... });
|
// CLAY({ .id = something... });
|
||||||
// As well as by passing a predefined declaration struct
|
// As well as by passing a predefined declaration struct
|
||||||
|
|
@ -740,9 +747,6 @@ typedef struct Clay_PointerData {
|
||||||
} Clay_PointerData;
|
} Clay_PointerData;
|
||||||
|
|
||||||
typedef struct Clay_ElementDeclaration {
|
typedef struct Clay_ElementDeclaration {
|
||||||
// Primarily created via the CLAY_ID(), CLAY_IDI(), CLAY_ID_LOCAL() and CLAY_IDI_LOCAL() macros.
|
|
||||||
// Represents a hashed string ID used for identifying and finding specific clay UI elements, required by functions such as Clay_PointerOver() and Clay_GetElementData().
|
|
||||||
Clay_ElementId id;
|
|
||||||
// Controls various settings that affect the size and position of an element, as well as the sizes and positions of any child elements.
|
// Controls various settings that affect the size and position of an element, as well as the sizes and positions of any child elements.
|
||||||
Clay_LayoutConfig layout;
|
Clay_LayoutConfig layout;
|
||||||
// Controls the background color of the resulting element.
|
// Controls the background color of the resulting element.
|
||||||
|
|
@ -789,6 +793,8 @@ typedef CLAY_PACKED_ENUM {
|
||||||
CLAY_ERROR_TYPE_PERCENTAGE_OVER_1,
|
CLAY_ERROR_TYPE_PERCENTAGE_OVER_1,
|
||||||
// Clay encountered an internal error. It would be wonderful if you could report this so we can fix it!
|
// Clay encountered an internal error. It would be wonderful if you could report this so we can fix it!
|
||||||
CLAY_ERROR_TYPE_INTERNAL_ERROR,
|
CLAY_ERROR_TYPE_INTERNAL_ERROR,
|
||||||
|
// Clay__OpenElement was called more times than Clay__CloseElement, so there were still remaining open elements when the layout ended.
|
||||||
|
CLAY_ERROR_TYPE_UNBALANCED_OPEN_CLOSE,
|
||||||
} Clay_ErrorType;
|
} Clay_ErrorType;
|
||||||
|
|
||||||
// Data to identify the error that clay has encountered.
|
// Data to identify the error that clay has encountered.
|
||||||
|
|
@ -916,6 +922,7 @@ CLAY_DLL_EXPORT void Clay_ResetMeasureTextCache(void);
|
||||||
// Internal API functions required by macros ----------------------
|
// Internal API functions required by macros ----------------------
|
||||||
|
|
||||||
CLAY_DLL_EXPORT void Clay__OpenElement(void);
|
CLAY_DLL_EXPORT void Clay__OpenElement(void);
|
||||||
|
CLAY_DLL_EXPORT void Clay__OpenElementWithId(Clay_ElementId elementId);
|
||||||
CLAY_DLL_EXPORT void Clay__ConfigureOpenElement(const Clay_ElementDeclaration config);
|
CLAY_DLL_EXPORT void Clay__ConfigureOpenElement(const Clay_ElementDeclaration config);
|
||||||
CLAY_DLL_EXPORT void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *config);
|
CLAY_DLL_EXPORT void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *config);
|
||||||
CLAY_DLL_EXPORT void Clay__CloseElement(void);
|
CLAY_DLL_EXPORT void Clay__CloseElement(void);
|
||||||
|
|
@ -1175,7 +1182,6 @@ typedef struct { // todo get this struct into a single cache line
|
||||||
intptr_t hoverFunctionUserData;
|
intptr_t hoverFunctionUserData;
|
||||||
int32_t nextIndex;
|
int32_t nextIndex;
|
||||||
uint32_t generation;
|
uint32_t generation;
|
||||||
uint32_t idAlias;
|
|
||||||
Clay__DebugElementData *debugData;
|
Clay__DebugElementData *debugData;
|
||||||
} Clay_LayoutElementHashMapItem;
|
} Clay_LayoutElementHashMapItem;
|
||||||
|
|
||||||
|
|
@ -1659,7 +1665,7 @@ Clay__MeasureTextCacheItem *Clay__MeasureTextCached(Clay_String *text, Clay_Text
|
||||||
char current = text->chars[end];
|
char current = text->chars[end];
|
||||||
if (current == ' ' || current == '\n') {
|
if (current == ' ' || current == '\n') {
|
||||||
int32_t length = end - start;
|
int32_t length = end - start;
|
||||||
Clay_Dimensions dimensions = {};
|
Clay_Dimensions dimensions = CLAY__DEFAULT_STRUCT;
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
dimensions = Clay__MeasureText(CLAY__INIT(Clay_StringSlice) {.length = length, .chars = &text->chars[start], .baseChars = text->chars}, config, context->measureTextUserData);
|
dimensions = Clay__MeasureText(CLAY__INIT(Clay_StringSlice) {.length = length, .chars = &text->chars[start], .baseChars = text->chars}, config, context->measureTextUserData);
|
||||||
}
|
}
|
||||||
|
|
@ -1709,12 +1715,12 @@ bool Clay__PointIsInsideRect(Clay_Vector2 point, Clay_BoundingBox rect) {
|
||||||
return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Clay_LayoutElement* layoutElement, uint32_t idAlias) {
|
Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Clay_LayoutElement* layoutElement) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
if (context->layoutElementsHashMapInternal.length == context->layoutElementsHashMapInternal.capacity - 1) {
|
if (context->layoutElementsHashMapInternal.length == context->layoutElementsHashMapInternal.capacity - 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Clay_LayoutElementHashMapItem item = { .elementId = elementId, .layoutElement = layoutElement, .nextIndex = -1, .generation = context->generation + 1, .idAlias = idAlias };
|
Clay_LayoutElementHashMapItem item = { .elementId = elementId, .layoutElement = layoutElement, .nextIndex = -1, .generation = context->generation + 1 };
|
||||||
uint32_t hashBucket = elementId.id % context->layoutElementsHashMap.capacity;
|
uint32_t hashBucket = elementId.id % context->layoutElementsHashMap.capacity;
|
||||||
int32_t hashItemPrevious = -1;
|
int32_t hashItemPrevious = -1;
|
||||||
int32_t hashItemIndex = context->layoutElementsHashMap.internalArray[hashBucket];
|
int32_t hashItemIndex = context->layoutElementsHashMap.internalArray[hashBucket];
|
||||||
|
|
@ -1724,7 +1730,6 @@ Clay_LayoutElementHashMapItem* Clay__AddHashMapItem(Clay_ElementId elementId, Cl
|
||||||
item.nextIndex = hashItem->nextIndex;
|
item.nextIndex = hashItem->nextIndex;
|
||||||
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
if (hashItem->generation <= context->generation) { // First collision - assume this is the "same" element
|
||||||
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
hashItem->elementId = elementId; // Make sure to copy this across. If the stringId reference has changed, we should update the hash item to use the new one.
|
||||||
hashItem->idAlias = idAlias;
|
|
||||||
hashItem->generation = context->generation + 1;
|
hashItem->generation = context->generation + 1;
|
||||||
hashItem->layoutElement = layoutElement;
|
hashItem->layoutElement = layoutElement;
|
||||||
hashItem->debugData->collision = false;
|
hashItem->debugData->collision = false;
|
||||||
|
|
@ -1773,7 +1778,7 @@ Clay_ElementId Clay__GenerateIdForAnonymousElement(Clay_LayoutElement *openLayou
|
||||||
Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2));
|
Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2));
|
||||||
Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
|
Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
|
||||||
openLayoutElement->id = elementId.id;
|
openLayoutElement->id = elementId.id;
|
||||||
Clay__AddHashMapItem(elementId, openLayoutElement, 0);
|
Clay__AddHashMapItem(elementId, openLayoutElement);
|
||||||
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
|
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
|
||||||
return elementId;
|
return elementId;
|
||||||
}
|
}
|
||||||
|
|
@ -1812,6 +1817,10 @@ void Clay__CloseElement(void) {
|
||||||
}
|
}
|
||||||
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
|
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
|
||||||
Clay_LayoutConfig *layoutConfig = openLayoutElement->layoutConfig;
|
Clay_LayoutConfig *layoutConfig = openLayoutElement->layoutConfig;
|
||||||
|
if (!layoutConfig) {
|
||||||
|
openLayoutElement->layoutConfig = &Clay_LayoutConfig_DEFAULT;
|
||||||
|
layoutConfig = &Clay_LayoutConfig_DEFAULT;
|
||||||
|
}
|
||||||
bool elementHasClipHorizontal = false;
|
bool elementHasClipHorizontal = false;
|
||||||
bool elementHasClipVertical = false;
|
bool elementHasClipVertical = false;
|
||||||
for (int32_t i = 0; i < openLayoutElement->elementConfigs.length; i++) {
|
for (int32_t i = 0; i < openLayoutElement->elementConfigs.length; i++) {
|
||||||
|
|
@ -1988,8 +1997,28 @@ void Clay__OpenElement(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Clay_LayoutElement layoutElement = CLAY__DEFAULT_STRUCT;
|
Clay_LayoutElement layoutElement = CLAY__DEFAULT_STRUCT;
|
||||||
Clay_LayoutElementArray_Add(&context->layoutElements, layoutElement);
|
Clay_LayoutElement* openLayoutElement = Clay_LayoutElementArray_Add(&context->layoutElements, layoutElement);
|
||||||
Clay__int32_tArray_Add(&context->openLayoutElementStack, context->layoutElements.length - 1);
|
Clay__int32_tArray_Add(&context->openLayoutElementStack, context->layoutElements.length - 1);
|
||||||
|
Clay__GenerateIdForAnonymousElement(openLayoutElement);
|
||||||
|
if (context->openClipElementStack.length > 0) {
|
||||||
|
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, context->layoutElements.length - 1, Clay__int32_tArray_GetValue(&context->openClipElementStack, (int)context->openClipElementStack.length - 1));
|
||||||
|
} else {
|
||||||
|
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, context->layoutElements.length - 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clay__OpenElementWithId(Clay_ElementId elementId) {
|
||||||
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
|
if (context->layoutElements.length == context->layoutElements.capacity - 1 || context->booleanWarnings.maxElementsExceeded) {
|
||||||
|
context->booleanWarnings.maxElementsExceeded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Clay_LayoutElement layoutElement = CLAY__DEFAULT_STRUCT;
|
||||||
|
layoutElement.id = elementId.id;
|
||||||
|
Clay_LayoutElement * openLayoutElement = Clay_LayoutElementArray_Add(&context->layoutElements, layoutElement);
|
||||||
|
Clay__int32_tArray_Add(&context->openLayoutElementStack, context->layoutElements.length - 1);
|
||||||
|
Clay__AddHashMapItem(elementId, openLayoutElement);
|
||||||
|
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
|
||||||
if (context->openClipElementStack.length > 0) {
|
if (context->openClipElementStack.length > 0) {
|
||||||
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, context->layoutElements.length - 1, Clay__int32_tArray_GetValue(&context->openClipElementStack, (int)context->openClipElementStack.length - 1));
|
Clay__int32_tArray_Set(&context->layoutElementClipElementIds, context->layoutElements.length - 1, Clay__int32_tArray_GetValue(&context->openClipElementStack, (int)context->openClipElementStack.length - 1));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2017,7 +2046,7 @@ void Clay__OpenTextElement(Clay_String text, Clay_TextElementConfig *textConfig)
|
||||||
Clay__MeasureTextCacheItem *textMeasured = Clay__MeasureTextCached(&text, textConfig);
|
Clay__MeasureTextCacheItem *textMeasured = Clay__MeasureTextCached(&text, textConfig);
|
||||||
Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
|
Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
|
||||||
textElement->id = elementId.id;
|
textElement->id = elementId.id;
|
||||||
Clay__AddHashMapItem(elementId, textElement, 0);
|
Clay__AddHashMapItem(elementId, textElement);
|
||||||
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
|
Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
|
||||||
Clay_Dimensions textDimensions = { .width = textMeasured->unwrappedDimensions.width, .height = textConfig->lineHeight > 0 ? (float)textConfig->lineHeight : textMeasured->unwrappedDimensions.height };
|
Clay_Dimensions textDimensions = { .width = textMeasured->unwrappedDimensions.width, .height = textConfig->lineHeight > 0 ? (float)textConfig->lineHeight : textMeasured->unwrappedDimensions.height };
|
||||||
textElement->dimensions = textDimensions;
|
textElement->dimensions = textDimensions;
|
||||||
|
|
@ -2031,19 +2060,6 @@ void Clay__OpenTextElement(Clay_String text, Clay_TextElementConfig *textConfig)
|
||||||
parentElement->childrenOrTextContent.children.length++;
|
parentElement->childrenOrTextContent.children.length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_ElementId Clay__AttachId(Clay_ElementId elementId) {
|
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
|
||||||
if (context->booleanWarnings.maxElementsExceeded) {
|
|
||||||
return Clay_ElementId_DEFAULT;
|
|
||||||
}
|
|
||||||
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
|
|
||||||
uint32_t idAlias = openLayoutElement->id;
|
|
||||||
openLayoutElement->id = elementId.id;
|
|
||||||
Clay__AddHashMapItem(elementId, openLayoutElement, idAlias);
|
|
||||||
Clay__StringArray_Set(&context->layoutElementIdStrings, context->layoutElements.length - 1, elementId.stringId);
|
|
||||||
return elementId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
|
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
|
||||||
|
|
@ -2055,8 +2071,6 @@ void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
||||||
.userData = context->errorHandler.userData });
|
.userData = context->errorHandler.userData });
|
||||||
}
|
}
|
||||||
|
|
||||||
Clay_ElementId openLayoutElementId = declaration->id;
|
|
||||||
|
|
||||||
openLayoutElement->elementConfigs.internalArray = &context->elementConfigs.internalArray[context->elementConfigs.length];
|
openLayoutElement->elementConfigs.internalArray = &context->elementConfigs.internalArray[context->elementConfigs.length];
|
||||||
Clay_SharedElementConfig *sharedConfig = NULL;
|
Clay_SharedElementConfig *sharedConfig = NULL;
|
||||||
if (declaration->backgroundColor.a > 0) {
|
if (declaration->backgroundColor.a > 0) {
|
||||||
|
|
@ -2111,9 +2125,6 @@ void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
||||||
} else if (declaration->floating.attachTo == CLAY_ATTACH_TO_ROOT) {
|
} else if (declaration->floating.attachTo == CLAY_ATTACH_TO_ROOT) {
|
||||||
floatingConfig.parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0).id;
|
floatingConfig.parentId = Clay__HashString(CLAY_STRING("Clay__RootContainer"), 0).id;
|
||||||
}
|
}
|
||||||
if (!openLayoutElementId.id) {
|
|
||||||
openLayoutElementId = Clay__HashStringWithOffset(CLAY_STRING("Clay__FloatingContainer"), context->layoutElementTreeRoots.length, 0);
|
|
||||||
}
|
|
||||||
if (declaration->floating.clipTo == CLAY_CLIP_TO_NONE) {
|
if (declaration->floating.clipTo == CLAY_CLIP_TO_NONE) {
|
||||||
clipElementId = 0;
|
clipElementId = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2133,12 +2144,6 @@ void Clay__ConfigureOpenElementPtr(const Clay_ElementDeclaration *declaration) {
|
||||||
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(declaration->custom) }, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM);
|
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(declaration->custom) }, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openLayoutElementId.id != 0) {
|
|
||||||
Clay__AttachId(openLayoutElementId);
|
|
||||||
} else if (openLayoutElement->id == 0) {
|
|
||||||
openLayoutElementId = Clay__GenerateIdForAnonymousElement(openLayoutElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (declaration->clip.horizontal | declaration->clip.vertical) {
|
if (declaration->clip.horizontal | declaration->clip.vertical) {
|
||||||
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .clipElementConfig = Clay__StoreClipElementConfig(declaration->clip) }, CLAY__ELEMENT_CONFIG_TYPE_CLIP);
|
Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .clipElementConfig = Clay__StoreClipElementConfig(declaration->clip) }, CLAY__ELEMENT_CONFIG_TYPE_CLIP);
|
||||||
Clay__int32_tArray_Add(&context->openClipElementStack, (int)openLayoutElement->id);
|
Clay__int32_tArray_Add(&context->openClipElementStack, (int)openLayoutElement->id);
|
||||||
|
|
@ -2787,12 +2792,6 @@ void Clay__CalculateFinalLayout(void) {
|
||||||
Clay_LayoutElementHashMapItem *hashMapItem = Clay__GetHashMapItem(currentElement->id);
|
Clay_LayoutElementHashMapItem *hashMapItem = Clay__GetHashMapItem(currentElement->id);
|
||||||
if (hashMapItem) {
|
if (hashMapItem) {
|
||||||
hashMapItem->boundingBox = currentElementBoundingBox;
|
hashMapItem->boundingBox = currentElementBoundingBox;
|
||||||
if (hashMapItem->idAlias) {
|
|
||||||
Clay_LayoutElementHashMapItem *hashMapItemAlias = Clay__GetHashMapItem(hashMapItem->idAlias);
|
|
||||||
if (hashMapItemAlias) {
|
|
||||||
hashMapItemAlias->boundingBox = currentElementBoundingBox;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sortedConfigIndexes[20];
|
int32_t sortedConfigIndexes[20];
|
||||||
|
|
@ -3190,8 +3189,8 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
Clay__int32_tArray_Add(&dfsBuffer, (int32_t)root->layoutElementIndex);
|
Clay__int32_tArray_Add(&dfsBuffer, (int32_t)root->layoutElementIndex);
|
||||||
context->treeNodeVisited.internalArray[0] = false;
|
context->treeNodeVisited.internalArray[0] = false;
|
||||||
if (rootIndex > 0) {
|
if (rootIndex > 0) {
|
||||||
CLAY({ .id = CLAY_IDI("Clay__DebugView_EmptyRowOuter", rootIndex), .layout = { .sizing = {.width = CLAY_SIZING_GROW(0)}, .padding = {CLAY__DEBUGVIEW_INDENT_WIDTH / 2, 0, 0, 0} } }) {
|
CLAY(CLAY_IDI("Clay__DebugView_EmptyRowOuter", rootIndex), { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0)}, .padding = {CLAY__DEBUGVIEW_INDENT_WIDTH / 2, 0, 0, 0} } }) {
|
||||||
CLAY({ .id = CLAY_IDI("Clay__DebugView_EmptyRow", rootIndex), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED((float)CLAY__DEBUGVIEW_ROW_HEIGHT) }}, .border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .top = 1 } } }) {}
|
CLAY(CLAY_IDI("Clay__DebugView_EmptyRow", rootIndex), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED((float)CLAY__DEBUGVIEW_ROW_HEIGHT) }}, .border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .top = 1 } } }) {}
|
||||||
}
|
}
|
||||||
layoutData.rowCount++;
|
layoutData.rowCount++;
|
||||||
}
|
}
|
||||||
|
|
@ -3221,11 +3220,10 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
if (context->debugSelectedElementId == currentElement->id) {
|
if (context->debugSelectedElementId == currentElement->id) {
|
||||||
layoutData.selectedElementRowIndex = layoutData.rowCount;
|
layoutData.selectedElementRowIndex = layoutData.rowCount;
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_IDI("Clay__DebugView_ElementOuter", currentElement->id), .layout = Clay__DebugView_ScrollViewItemLayoutConfig }) {
|
CLAY(CLAY_IDI("Clay__DebugView_ElementOuter", currentElement->id), { .layout = Clay__DebugView_ScrollViewItemLayoutConfig }) {
|
||||||
// Collapse icon / button
|
// Collapse icon / button
|
||||||
if (!(Clay__ElementHasConfig(currentElement, CLAY__ELEMENT_CONFIG_TYPE_TEXT) || currentElement->childrenOrTextContent.children.length == 0)) {
|
if (!(Clay__ElementHasConfig(currentElement, CLAY__ELEMENT_CONFIG_TYPE_TEXT) || currentElement->childrenOrTextContent.children.length == 0)) {
|
||||||
CLAY({
|
CLAY(CLAY_IDI("Clay__DebugView_CollapseElement", currentElement->id), {
|
||||||
.id = CLAY_IDI("Clay__DebugView_CollapseElement", currentElement->id),
|
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED(16), CLAY_SIZING_FIXED(16)}, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} },
|
.layout = { .sizing = {CLAY_SIZING_FIXED(16), CLAY_SIZING_FIXED(16)}, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = {1, 1, 1, 1, 0} },
|
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = {1, 1, 1, 1, 0} },
|
||||||
|
|
@ -3233,19 +3231,19 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
CLAY_TEXT((currentElementData && currentElementData->debugData->collapsed) ? CLAY_STRING("+") : CLAY_STRING("-"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT((currentElementData && currentElementData->debugData->collapsed) ? CLAY_STRING("+") : CLAY_STRING("-"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
} else { // Square dot for empty containers
|
} else { // Square dot for empty containers
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_FIXED(16), CLAY_SIZING_FIXED(16)}, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER } } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_FIXED(16), CLAY_SIZING_FIXED(16)}, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER } } }) {
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_FIXED(8), CLAY_SIZING_FIXED(8)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3, .cornerRadius = CLAY_CORNER_RADIUS(2) }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_FIXED(8), CLAY_SIZING_FIXED(8)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3, .cornerRadius = CLAY_CORNER_RADIUS(2) }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Collisions and offscreen info
|
// Collisions and offscreen info
|
||||||
if (currentElementData) {
|
if (currentElementData) {
|
||||||
if (currentElementData->debugData->collision) {
|
if (currentElementData->debugData->collision) {
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 }}, .border = { .color = {177, 147, 8, 255}, .width = {1, 1, 1, 1, 0} } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 }}, .border = { .color = {177, 147, 8, 255}, .width = {1, 1, 1, 1, 0} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Duplicate ID"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("Duplicate ID"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offscreen) {
|
if (offscreen) {
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 } }, .border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { 1, 1, 1, 1, 0} } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 } }, .border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { 1, 1, 1, 1, 0} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Offscreen"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("Offscreen"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3262,12 +3260,12 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
Clay_Color backgroundColor = elementConfig->config.sharedElementConfig->backgroundColor;
|
Clay_Color backgroundColor = elementConfig->config.sharedElementConfig->backgroundColor;
|
||||||
Clay_CornerRadius radius = elementConfig->config.sharedElementConfig->cornerRadius;
|
Clay_CornerRadius radius = elementConfig->config.sharedElementConfig->cornerRadius;
|
||||||
if (backgroundColor.a > 0) {
|
if (backgroundColor.a > 0) {
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = labelColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = labelColor, .width = { 1, 1, 1, 1, 0} } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = labelColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = labelColor, .width = { 1, 1, 1, 1, 0} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Color"), CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("Color"), CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (radius.bottomLeft > 0) {
|
if (radius.bottomLeft > 0) {
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = labelColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = labelColor, .width = { 1, 1, 1, 1, 0 } } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = labelColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = labelColor, .width = { 1, 1, 1, 1, 0 } } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Radius"), CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("Radius"), CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3276,7 +3274,7 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
Clay__DebugElementConfigTypeLabelConfig config = Clay__DebugGetElementConfigTypeLabel(elementConfig->type);
|
Clay__DebugElementConfigTypeLabelConfig config = Clay__DebugGetElementConfigTypeLabel(elementConfig->type);
|
||||||
Clay_Color backgroundColor = config.color;
|
Clay_Color backgroundColor = config.color;
|
||||||
backgroundColor.a = 90;
|
backgroundColor.a = 90;
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = backgroundColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = config.color, .width = { 1, 1, 1, 1, 0 } } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = backgroundColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = config.color, .width = { 1, 1, 1, 1, 0 } } }) {
|
||||||
CLAY_TEXT(config.label, CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT(config.label, CLAY_TEXT_CONFIG({ .textColor = offscreen ? CLAY__DEBUGVIEW_COLOR_3 : CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3287,8 +3285,8 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
layoutData.rowCount++;
|
layoutData.rowCount++;
|
||||||
Clay__TextElementData *textElementData = currentElement->childrenOrTextContent.textElementData;
|
Clay__TextElementData *textElementData = currentElement->childrenOrTextContent.textElementData;
|
||||||
Clay_TextElementConfig *rawTextConfig = offscreen ? CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }) : &Clay__DebugView_TextNameConfig;
|
Clay_TextElementConfig *rawTextConfig = offscreen ? CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16 }) : &Clay__DebugView_TextNameConfig;
|
||||||
CLAY({ .layout = { .sizing = { .height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { .height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } } }) {
|
||||||
CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_INDENT_WIDTH + 16) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {.width = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_INDENT_WIDTH + 16) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("\""), rawTextConfig);
|
CLAY_TEXT(CLAY_STRING("\""), rawTextConfig);
|
||||||
CLAY_TEXT(textElementData->text.length > 40 ? (CLAY__INIT(Clay_String) { .length = 40, .chars = textElementData->text.chars }) : textElementData->text, rawTextConfig);
|
CLAY_TEXT(textElementData->text.length > 40 ? (CLAY__INIT(Clay_String) { .length = 40, .chars = textElementData->text.chars }) : textElementData->text, rawTextConfig);
|
||||||
if (textElementData->text.length > 40) {
|
if (textElementData->text.length > 40) {
|
||||||
|
|
@ -3328,8 +3326,8 @@ Clay__RenderDebugLayoutData Clay__RenderDebugLayoutElementsList(int32_t initialR
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlightedElementId) {
|
if (highlightedElementId) {
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugView_ElementHighlight"), .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .floating = { .parentId = highlightedElementId, .zIndex = 32767, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH, .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID } }) {
|
CLAY(CLAY_ID("Clay__DebugView_ElementHighlight"), { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .floating = { .parentId = highlightedElementId, .zIndex = 32767, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH, .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID } }) {
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugView_ElementHighlightRectangle"), .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .backgroundColor = Clay__debugViewHighlightColor }) {}
|
CLAY(CLAY_ID("Clay__DebugView_ElementHighlightRectangle"), { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .backgroundColor = Clay__debugViewHighlightColor }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return layoutData;
|
return layoutData;
|
||||||
|
|
@ -3370,17 +3368,17 @@ void Clay__RenderDebugViewElementConfigHeader(Clay_String elementId, Clay__Eleme
|
||||||
Clay__DebugElementConfigTypeLabelConfig config = Clay__DebugGetElementConfigTypeLabel(type);
|
Clay__DebugElementConfigTypeLabelConfig config = Clay__DebugGetElementConfigTypeLabel(type);
|
||||||
Clay_Color backgroundColor = config.color;
|
Clay_Color backgroundColor = config.color;
|
||||||
backgroundColor.a = 90;
|
backgroundColor.a = 90;
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(CLAY__DEBUGVIEW_OUTER_PADDING), .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(CLAY__DEBUGVIEW_OUTER_PADDING), .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } } }) {
|
||||||
CLAY({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = backgroundColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = config.color, .width = { 1, 1, 1, 1, 0 } } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = { 8, 8, 2, 2 } }, .backgroundColor = backgroundColor, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = config.color, .width = { 1, 1, 1, 1, 0 } } }) {
|
||||||
CLAY_TEXT(config.label, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT(config.label, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
||||||
CLAY_TEXT(elementId, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE }));
|
CLAY_TEXT(elementId, CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_3, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clay__RenderDebugViewColor(Clay_Color color, Clay_TextElementConfig *textConfig) {
|
void Clay__RenderDebugViewColor(Clay_Color color, Clay_TextElementConfig *textConfig) {
|
||||||
CLAY({ .layout = { .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
CLAY_AUTO_ID({ .layout = { .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ r: "), textConfig);
|
CLAY_TEXT(CLAY_STRING("{ r: "), textConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(color.r), textConfig);
|
CLAY_TEXT(Clay__IntToString(color.r), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", g: "), textConfig);
|
CLAY_TEXT(CLAY_STRING(", g: "), textConfig);
|
||||||
|
|
@ -3390,13 +3388,13 @@ void Clay__RenderDebugViewColor(Clay_Color color, Clay_TextElementConfig *textCo
|
||||||
CLAY_TEXT(CLAY_STRING(", a: "), textConfig);
|
CLAY_TEXT(CLAY_STRING(", a: "), textConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(color.a), textConfig);
|
CLAY_TEXT(Clay__IntToString(color.a), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(" }"), textConfig);
|
CLAY_TEXT(CLAY_STRING(" }"), textConfig);
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_FIXED(10) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_FIXED(10) } } }) {}
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 8), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 8)} }, .backgroundColor = color, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = CLAY__DEBUGVIEW_COLOR_4, .width = { 1, 1, 1, 1, 0 } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 8), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 8)} }, .backgroundColor = color, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = { .color = CLAY__DEBUGVIEW_COLOR_4, .width = { 1, 1, 1, 1, 0 } } }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clay__RenderDebugViewCornerRadius(Clay_CornerRadius cornerRadius, Clay_TextElementConfig *textConfig) {
|
void Clay__RenderDebugViewCornerRadius(Clay_CornerRadius cornerRadius, Clay_TextElementConfig *textConfig) {
|
||||||
CLAY({ .layout = { .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
CLAY_AUTO_ID({ .layout = { .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ topLeft: "), textConfig);
|
CLAY_TEXT(CLAY_STRING("{ topLeft: "), textConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(cornerRadius.topLeft), textConfig);
|
CLAY_TEXT(Clay__IntToString(cornerRadius.topLeft), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", topRight: "), textConfig);
|
CLAY_TEXT(CLAY_STRING(", topRight: "), textConfig);
|
||||||
|
|
@ -3455,16 +3453,16 @@ void Clay__RenderDebugView(void) {
|
||||||
highlightedRow = -1;
|
highlightedRow = -1;
|
||||||
}
|
}
|
||||||
Clay__RenderDebugLayoutData layoutData = CLAY__DEFAULT_STRUCT;
|
Clay__RenderDebugLayoutData layoutData = CLAY__DEFAULT_STRUCT;
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugView"),
|
CLAY(CLAY_ID("Clay__DebugView"), {
|
||||||
.layout = { .sizing = { CLAY_SIZING_FIXED((float)Clay__debugViewWidth) , CLAY_SIZING_FIXED(context->layoutDimensions.height) }, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .sizing = { CLAY_SIZING_FIXED((float)Clay__debugViewWidth) , CLAY_SIZING_FIXED(context->layoutDimensions.height) }, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
.floating = { .zIndex = 32765, .attachPoints = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_CENTER }, .attachTo = CLAY_ATTACH_TO_ROOT, .clipTo = CLAY_CLIP_TO_ATTACHED_PARENT },
|
.floating = { .zIndex = 32765, .attachPoints = { .element = CLAY_ATTACH_POINT_LEFT_CENTER, .parent = CLAY_ATTACH_POINT_RIGHT_CENTER }, .attachTo = CLAY_ATTACH_TO_ROOT, .clipTo = CLAY_CLIP_TO_ATTACHED_PARENT },
|
||||||
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .bottom = 1 } }
|
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .bottom = 1 } }
|
||||||
}) {
|
}) {
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_2 }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_2 }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Clay Debug Tools"), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("Clay Debug Tools"), infoTextConfig);
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
||||||
// Close button
|
// Close button
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10)}, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} },
|
.layout = { .sizing = {CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT - 10)}, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER} },
|
||||||
.backgroundColor = {217,91,67,80},
|
.backgroundColor = {217,91,67,80},
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
|
|
@ -3474,18 +3472,18 @@ void Clay__RenderDebugView(void) {
|
||||||
CLAY_TEXT(CLAY_STRING("x"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
CLAY_TEXT(CLAY_STRING("x"), CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(1)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3 } ) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(1)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3 } ) {}
|
||||||
CLAY({ .id = scrollId, .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .clip = { .horizontal = true, .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
CLAY(scrollId, { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .clip = { .horizontal = true, .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = ((initialElementsLength + initialRootsLength) & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1 }) {
|
||||||
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0);
|
Clay_ElementId panelContentsId = Clay__HashString(CLAY_STRING("Clay__DebugViewPaneOuter"), 0);
|
||||||
// Element list
|
// Element list
|
||||||
CLAY({ .id = panelContentsId, .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .floating = { .zIndex = 32766, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH, .attachTo = CLAY_ATTACH_TO_PARENT, .clipTo = CLAY_CLIP_TO_ATTACHED_PARENT } }) {
|
CLAY(panelContentsId, { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)} }, .floating = { .zIndex = 32766, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH, .attachTo = CLAY_ATTACH_TO_PARENT, .clipTo = CLAY_CLIP_TO_ATTACHED_PARENT } }) {
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = { CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = { CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
layoutData = Clay__RenderDebugLayoutElementsList((int32_t)initialRootsLength, highlightedRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float contentWidth = Clay__GetHashMapItem(panelContentsId.id)->layoutElement->dimensions.width;
|
float contentWidth = Clay__GetHashMapItem(panelContentsId.id)->layoutElement->dimensions.width;
|
||||||
CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_FIXED(contentWidth) }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {.width = CLAY_SIZING_FIXED(contentWidth) }, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {}
|
||||||
for (int32_t i = 0; i < layoutData.rowCount; i++) {
|
for (int32_t i = 0; i < layoutData.rowCount; i++) {
|
||||||
Clay_Color rowColor = (i & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1;
|
Clay_Color rowColor = (i & 1) == 0 ? CLAY__DEBUGVIEW_COLOR_2 : CLAY__DEBUGVIEW_COLOR_1;
|
||||||
if (i == layoutData.selectedElementRowIndex) {
|
if (i == layoutData.selectedElementRowIndex) {
|
||||||
|
|
@ -3496,22 +3494,22 @@ void Clay__RenderDebugView(void) {
|
||||||
rowColor.g *= 1.25f;
|
rowColor.g *= 1.25f;
|
||||||
rowColor.b *= 1.25f;
|
rowColor.b *= 1.25f;
|
||||||
}
|
}
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = rowColor } ) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = rowColor } ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3 }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_3 }) {}
|
||||||
if (context->debugSelectedElementId != 0) {
|
if (context->debugSelectedElementId != 0) {
|
||||||
Clay_LayoutElementHashMapItem *selectedItem = Clay__GetHashMapItem(context->debugSelectedElementId);
|
Clay_LayoutElementHashMapItem *selectedItem = Clay__GetHashMapItem(context->debugSelectedElementId);
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
.backgroundColor = CLAY__DEBUGVIEW_COLOR_2 ,
|
.backgroundColor = CLAY__DEBUGVIEW_COLOR_2 ,
|
||||||
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
||||||
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .betweenChildren = 1 } }
|
.border = { .color = CLAY__DEBUGVIEW_COLOR_3, .width = { .betweenChildren = 1 } }
|
||||||
}) {
|
}) {
|
||||||
CLAY({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT + 8)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Layout Config"), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("Layout Config"), infoTextConfig);
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
||||||
if (selectedItem->elementId.stringId.length != 0) {
|
if (selectedItem->elementId.stringId.length != 0) {
|
||||||
CLAY_TEXT(selectedItem->elementId.stringId, infoTitleConfig);
|
CLAY_TEXT(selectedItem->elementId.stringId, infoTitleConfig);
|
||||||
if (selectedItem->elementId.offset != 0) {
|
if (selectedItem->elementId.offset != 0) {
|
||||||
|
|
@ -3523,10 +3521,10 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
Clay_Padding attributeConfigPadding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 8, 8};
|
Clay_Padding attributeConfigPadding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 8, 8};
|
||||||
// Clay_LayoutConfig debug info
|
// Clay_LayoutConfig debug info
|
||||||
CLAY({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// .boundingBox
|
// .boundingBox
|
||||||
CLAY_TEXT(CLAY_STRING("Bounding Box"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Bounding Box"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(selectedItem->boundingBox.x), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(selectedItem->boundingBox.x), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", y: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING(", y: "), infoTextConfig);
|
||||||
|
|
@ -3543,17 +3541,17 @@ void Clay__RenderDebugView(void) {
|
||||||
CLAY_TEXT(layoutConfig->layoutDirection == CLAY_TOP_TO_BOTTOM ? CLAY_STRING("TOP_TO_BOTTOM") : CLAY_STRING("LEFT_TO_RIGHT"), infoTextConfig);
|
CLAY_TEXT(layoutConfig->layoutDirection == CLAY_TOP_TO_BOTTOM ? CLAY_STRING("TOP_TO_BOTTOM") : CLAY_STRING("LEFT_TO_RIGHT"), infoTextConfig);
|
||||||
// .sizing
|
// .sizing
|
||||||
CLAY_TEXT(CLAY_STRING("Sizing"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Sizing"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("width: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("width: "), infoTextConfig);
|
||||||
Clay__RenderDebugLayoutSizing(layoutConfig->sizing.width, infoTextConfig);
|
Clay__RenderDebugLayoutSizing(layoutConfig->sizing.width, infoTextConfig);
|
||||||
}
|
}
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("height: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("height: "), infoTextConfig);
|
||||||
Clay__RenderDebugLayoutSizing(layoutConfig->sizing.height, infoTextConfig);
|
Clay__RenderDebugLayoutSizing(layoutConfig->sizing.height, infoTextConfig);
|
||||||
}
|
}
|
||||||
// .padding
|
// .padding
|
||||||
CLAY_TEXT(CLAY_STRING("Padding"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Padding"), infoTitleConfig);
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewElementInfoPadding") }) {
|
CLAY(CLAY_ID("Clay__DebugViewElementInfoPadding"), { }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(layoutConfig->padding.left), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(layoutConfig->padding.left), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", right: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING(", right: "), infoTextConfig);
|
||||||
|
|
@ -3569,7 +3567,7 @@ void Clay__RenderDebugView(void) {
|
||||||
CLAY_TEXT(Clay__IntToString(layoutConfig->childGap), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(layoutConfig->childGap), infoTextConfig);
|
||||||
// .childAlignment
|
// .childAlignment
|
||||||
CLAY_TEXT(CLAY_STRING("Child Alignment"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Child Alignment"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
||||||
Clay_String alignX = CLAY_STRING("LEFT");
|
Clay_String alignX = CLAY_STRING("LEFT");
|
||||||
if (layoutConfig->childAlignment.x == CLAY_ALIGN_X_CENTER) {
|
if (layoutConfig->childAlignment.x == CLAY_ALIGN_X_CENTER) {
|
||||||
|
|
@ -3595,7 +3593,7 @@ void Clay__RenderDebugView(void) {
|
||||||
switch (elementConfig->type) {
|
switch (elementConfig->type) {
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_SHARED: {
|
case CLAY__ELEMENT_CONFIG_TYPE_SHARED: {
|
||||||
Clay_SharedElementConfig *sharedConfig = elementConfig->config.sharedElementConfig;
|
Clay_SharedElementConfig *sharedConfig = elementConfig->config.sharedElementConfig;
|
||||||
CLAY({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
CLAY_AUTO_ID({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
||||||
// .backgroundColor
|
// .backgroundColor
|
||||||
CLAY_TEXT(CLAY_STRING("Background Color"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Background Color"), infoTitleConfig);
|
||||||
Clay__RenderDebugViewColor(sharedConfig->backgroundColor, infoTextConfig);
|
Clay__RenderDebugViewColor(sharedConfig->backgroundColor, infoTextConfig);
|
||||||
|
|
@ -3607,7 +3605,7 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_TEXT: {
|
case CLAY__ELEMENT_CONFIG_TYPE_TEXT: {
|
||||||
Clay_TextElementConfig *textConfig = elementConfig->config.textElementConfig;
|
Clay_TextElementConfig *textConfig = elementConfig->config.textElementConfig;
|
||||||
CLAY({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// .fontSize
|
// .fontSize
|
||||||
CLAY_TEXT(CLAY_STRING("Font Size"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Font Size"), infoTitleConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(textConfig->fontSize), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(textConfig->fontSize), infoTextConfig);
|
||||||
|
|
@ -3646,10 +3644,10 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_ASPECT: {
|
case CLAY__ELEMENT_CONFIG_TYPE_ASPECT: {
|
||||||
Clay_AspectRatioElementConfig *aspectRatioConfig = elementConfig->config.aspectRatioElementConfig;
|
Clay_AspectRatioElementConfig *aspectRatioConfig = elementConfig->config.aspectRatioElementConfig;
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewElementInfoAspectRatioBody"), .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("Clay__DebugViewElementInfoAspectRatioBody"), { .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Aspect Ratio"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Aspect Ratio"), infoTitleConfig);
|
||||||
// Aspect Ratio
|
// Aspect Ratio
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewElementInfoAspectRatio") }) {
|
CLAY(CLAY_ID("Clay__DebugViewElementInfoAspectRatio"), { }) {
|
||||||
CLAY_TEXT(Clay__IntToString(aspectRatioConfig->aspectRatio), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(aspectRatioConfig->aspectRatio), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING("."), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("."), infoTextConfig);
|
||||||
float frac = aspectRatioConfig->aspectRatio - (int)(aspectRatioConfig->aspectRatio);
|
float frac = aspectRatioConfig->aspectRatio - (int)(aspectRatioConfig->aspectRatio);
|
||||||
|
|
@ -3668,16 +3666,16 @@ void Clay__RenderDebugView(void) {
|
||||||
if (Clay__ElementHasConfig(selectedItem->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_ASPECT)) {
|
if (Clay__ElementHasConfig(selectedItem->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_ASPECT)) {
|
||||||
aspectConfig = *Clay__FindElementConfigWithType(selectedItem->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_ASPECT).aspectRatioElementConfig;
|
aspectConfig = *Clay__FindElementConfigWithType(selectedItem->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_ASPECT).aspectRatioElementConfig;
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewElementInfoImageBody"), .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("Clay__DebugViewElementInfoImageBody"), { .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// Image Preview
|
// Image Preview
|
||||||
CLAY_TEXT(CLAY_STRING("Preview"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Preview"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(64, 128), .height = CLAY_SIZING_GROW(64, 128) }}, .aspectRatio = aspectConfig, .image = *imageConfig }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(64, 128), .height = CLAY_SIZING_GROW(64, 128) }}, .aspectRatio = aspectConfig, .image = *imageConfig }) {}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_CLIP: {
|
case CLAY__ELEMENT_CONFIG_TYPE_CLIP: {
|
||||||
Clay_ClipElementConfig *clipConfig = elementConfig->config.clipElementConfig;
|
Clay_ClipElementConfig *clipConfig = elementConfig->config.clipElementConfig;
|
||||||
CLAY({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// .vertical
|
// .vertical
|
||||||
CLAY_TEXT(CLAY_STRING("Vertical"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Vertical"), infoTitleConfig);
|
||||||
CLAY_TEXT(clipConfig->vertical ? CLAY_STRING("true") : CLAY_STRING("false") , infoTextConfig);
|
CLAY_TEXT(clipConfig->vertical ? CLAY_STRING("true") : CLAY_STRING("false") , infoTextConfig);
|
||||||
|
|
@ -3689,10 +3687,10 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_FLOATING: {
|
case CLAY__ELEMENT_CONFIG_TYPE_FLOATING: {
|
||||||
Clay_FloatingElementConfig *floatingConfig = elementConfig->config.floatingElementConfig;
|
Clay_FloatingElementConfig *floatingConfig = elementConfig->config.floatingElementConfig;
|
||||||
CLAY({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY_AUTO_ID({ .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
// .offset
|
// .offset
|
||||||
CLAY_TEXT(CLAY_STRING("Offset"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Offset"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ x: "), infoTextConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(floatingConfig->offset.x), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(floatingConfig->offset.x), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", y: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING(", y: "), infoTextConfig);
|
||||||
|
|
@ -3701,7 +3699,7 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
// .expand
|
// .expand
|
||||||
CLAY_TEXT(CLAY_STRING("Expand"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Expand"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ width: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ width: "), infoTextConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(floatingConfig->expand.width), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(floatingConfig->expand.width), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", height: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING(", height: "), infoTextConfig);
|
||||||
|
|
@ -3717,7 +3715,7 @@ void Clay__RenderDebugView(void) {
|
||||||
CLAY_TEXT(hashItem->elementId.stringId, infoTextConfig);
|
CLAY_TEXT(hashItem->elementId.stringId, infoTextConfig);
|
||||||
// .attachPoints
|
// .attachPoints
|
||||||
CLAY_TEXT(CLAY_STRING("Attach Points"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Attach Points"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ element: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ element: "), infoTextConfig);
|
||||||
Clay_String attachPointElement = CLAY_STRING("LEFT_TOP");
|
Clay_String attachPointElement = CLAY_STRING("LEFT_TOP");
|
||||||
if (floatingConfig->attachPoints.element == CLAY_ATTACH_POINT_LEFT_CENTER) {
|
if (floatingConfig->attachPoints.element == CLAY_ATTACH_POINT_LEFT_CENTER) {
|
||||||
|
|
@ -3790,9 +3788,9 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
case CLAY__ELEMENT_CONFIG_TYPE_BORDER: {
|
case CLAY__ELEMENT_CONFIG_TYPE_BORDER: {
|
||||||
Clay_BorderElementConfig *borderConfig = elementConfig->config.borderElementConfig;
|
Clay_BorderElementConfig *borderConfig = elementConfig->config.borderElementConfig;
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewElementInfoBorderBody"), .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
CLAY(CLAY_ID("Clay__DebugViewElementInfoBorderBody"), { .layout = { .padding = attributeConfigPadding, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Border Widths"), infoTitleConfig);
|
CLAY_TEXT(CLAY_STRING("Border Widths"), infoTitleConfig);
|
||||||
CLAY({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .layoutDirection = CLAY_LEFT_TO_RIGHT } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING("{ left: "), infoTextConfig);
|
||||||
CLAY_TEXT(Clay__IntToString(borderConfig->width.left), infoTextConfig);
|
CLAY_TEXT(Clay__IntToString(borderConfig->width.left), infoTextConfig);
|
||||||
CLAY_TEXT(CLAY_STRING(", right: "), infoTextConfig);
|
CLAY_TEXT(CLAY_STRING(", right: "), infoTextConfig);
|
||||||
|
|
@ -3815,16 +3813,16 @@ void Clay__RenderDebugView(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewWarningsScrollPane"), .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .childGap = 6, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_2, .clip = { .horizontal = true, .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
CLAY(CLAY_ID("Clay__DebugViewWarningsScrollPane"), { .layout = { .sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(300)}, .childGap = 6, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = CLAY__DEBUGVIEW_COLOR_2, .clip = { .horizontal = true, .vertical = true, .childOffset = Clay_GetScrollOffset() } }) {
|
||||||
Clay_TextElementConfig *warningConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
|
Clay_TextElementConfig *warningConfig = CLAY_TEXT_CONFIG({ .textColor = CLAY__DEBUGVIEW_COLOR_4, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE });
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewWarningItemHeader"), .layout = { .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
CLAY(CLAY_ID("Clay__DebugViewWarningItemHeader"), { .layout = { .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Warnings"), warningConfig);
|
CLAY_TEXT(CLAY_STRING("Warnings"), warningConfig);
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("Clay__DebugViewWarningsTopBorder"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }, .backgroundColor = {200, 200, 200, 255} }) {}
|
CLAY(CLAY_ID("Clay__DebugViewWarningsTopBorder"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(1)} }, .backgroundColor = {200, 200, 200, 255} }) {}
|
||||||
int32_t previousWarningsLength = context->warnings.length;
|
int32_t previousWarningsLength = context->warnings.length;
|
||||||
for (int32_t i = 0; i < previousWarningsLength; i++) {
|
for (int32_t i = 0; i < previousWarningsLength; i++) {
|
||||||
Clay__Warning warning = context->warnings.internalArray[i];
|
Clay__Warning warning = context->warnings.internalArray[i];
|
||||||
CLAY({ .id = CLAY_IDI("Clay__DebugViewWarningItem", i), .layout = { .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
CLAY(CLAY_IDI("Clay__DebugViewWarningItem", i), { .layout = { .sizing = {.height = CLAY_SIZING_FIXED(CLAY__DEBUGVIEW_ROW_HEIGHT)}, .padding = {CLAY__DEBUGVIEW_OUTER_PADDING, CLAY__DEBUGVIEW_OUTER_PADDING, 0, 0 }, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} } }) {
|
||||||
CLAY_TEXT(warning.baseMessage, warningConfig);
|
CLAY_TEXT(warning.baseMessage, warningConfig);
|
||||||
if (warning.dynamicMessage.length > 0) {
|
if (warning.dynamicMessage.length > 0) {
|
||||||
CLAY_TEXT(warning.dynamicMessage, warningConfig);
|
CLAY_TEXT(warning.dynamicMessage, warningConfig);
|
||||||
|
|
@ -3995,10 +3993,6 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
|
||||||
}
|
}
|
||||||
Clay_ElementIdArray_Add(&context->pointerOverIds, mapItem->elementId);
|
Clay_ElementIdArray_Add(&context->pointerOverIds, mapItem->elementId);
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if (mapItem->idAlias != 0) {
|
|
||||||
Clay_ElementIdArray_Add(&context->pointerOverIds, CLAY__INIT(Clay_ElementId) { .id = mapItem->idAlias });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Clay__ElementHasConfig(currentElement, CLAY__ELEMENT_CONFIG_TYPE_TEXT)) {
|
if (Clay__ElementHasConfig(currentElement, CLAY__ELEMENT_CONFIG_TYPE_TEXT)) {
|
||||||
dfsBuffer.length--;
|
dfsBuffer.length--;
|
||||||
|
|
@ -4222,10 +4216,9 @@ void Clay_BeginLayout(void) {
|
||||||
rootDimensions.width -= (float)Clay__debugViewWidth;
|
rootDimensions.width -= (float)Clay__debugViewWidth;
|
||||||
}
|
}
|
||||||
context->booleanWarnings = CLAY__INIT(Clay_BooleanWarnings) CLAY__DEFAULT_STRUCT;
|
context->booleanWarnings = CLAY__INIT(Clay_BooleanWarnings) CLAY__DEFAULT_STRUCT;
|
||||||
Clay__OpenElement();
|
Clay__OpenElementWithId(CLAY_ID("Clay__RootContainer"));
|
||||||
Clay__ConfigureOpenElement(CLAY__INIT(Clay_ElementDeclaration) {
|
Clay__ConfigureOpenElement(CLAY__INIT(Clay_ElementDeclaration) {
|
||||||
.id = CLAY_ID("Clay__RootContainer"),
|
.layout = { .sizing = {CLAY_SIZING_FIXED((rootDimensions.width)), CLAY_SIZING_FIXED(rootDimensions.height)} }
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED((rootDimensions.width)), CLAY_SIZING_FIXED(rootDimensions.height)} }
|
|
||||||
});
|
});
|
||||||
Clay__int32_tArray_Add(&context->openLayoutElementStack, 0);
|
Clay__int32_tArray_Add(&context->openLayoutElementStack, 0);
|
||||||
Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) { .layoutElementIndex = 0 });
|
Clay__LayoutElementTreeRootArray_Add(&context->layoutElementTreeRoots, CLAY__INIT(Clay__LayoutElementTreeRoot) { .layoutElementIndex = 0 });
|
||||||
|
|
@ -4253,9 +4246,14 @@ Clay_RenderCommandArray Clay_EndLayout(void) {
|
||||||
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },
|
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },
|
||||||
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT
|
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
Clay__CalculateFinalLayout();
|
|
||||||
}
|
}
|
||||||
|
if (context->openLayoutElementStack.length > 1) {
|
||||||
|
context->errorHandler.errorHandlerFunction(CLAY__INIT(Clay_ErrorData) {
|
||||||
|
.errorType = CLAY_ERROR_TYPE_UNBALANCED_OPEN_CLOSE,
|
||||||
|
.errorText = CLAY_STRING("There were still open layout elements when EndLayout was called. This results from an unequal number of calls to Clay__OpenElement and Clay__CloseElement."),
|
||||||
|
.userData = context->errorHandler.userData });
|
||||||
|
}
|
||||||
|
Clay__CalculateFinalLayout();
|
||||||
return context->renderCommands;
|
return context->renderCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ Clay_RenderCommandArray ClayImageSample_CreateLayout() {
|
||||||
.height = CLAY_SIZING_GROW(0)
|
.height = CLAY_SIZING_GROW(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer"),
|
CLAY(CLAY_ID("OuterContainer"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = layoutExpand,
|
.sizing = layoutExpand,
|
||||||
|
|
@ -61,8 +61,7 @@ Clay_RenderCommandArray ClayImageSample_CreateLayout() {
|
||||||
.childGap = 16
|
.childGap = 16
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY(CLAY_ID("SampleImage"), {
|
||||||
.id = CLAY_ID("SampleImage"),
|
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = layoutExpand
|
.sizing = layoutExpand
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ void Layout() {
|
||||||
static Clay_Color BACKGROUND = { 0xF4, 0xEB, 0xE6, 255 };
|
static Clay_Color BACKGROUND = { 0xF4, 0xEB, 0xE6, 255 };
|
||||||
static Clay_Color ACCENT = { 0xFA, 0xE0, 0xD4, 255 };
|
static Clay_Color ACCENT = { 0xFA, 0xE0, 0xD4, 255 };
|
||||||
|
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
.layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
.backgroundColor = BACKGROUND
|
.backgroundColor = BACKGROUND
|
||||||
}) {
|
}) {
|
||||||
CLAY({ .id = CLAY_ID("PageMargins"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
CLAY(CLAY_ID("PageMargins"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) },
|
||||||
.padding = { 70, 70, 50, 50 }, // Some nice looking page margins
|
.padding = { 70, 70, 50, 50 }, // Some nice looking page margins
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.childGap = 10}
|
.childGap = 10}
|
||||||
|
|
@ -54,9 +54,9 @@ void Layout() {
|
||||||
CLAY_TEXT(CLAY_STRING("Features Overview"), CLAY_TEXT_CONFIG({ .fontId = FONT_CALLISTOGA, .textColor = PRIMARY, .fontSize = 24 }));
|
CLAY_TEXT(CLAY_STRING("Features Overview"), CLAY_TEXT_CONFIG({ .fontId = FONT_CALLISTOGA, .textColor = PRIMARY, .fontSize = 24 }));
|
||||||
|
|
||||||
// Feature Box
|
// Feature Box
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }, .childGap = 10 }}) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }, .childGap = 10 }}) {
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }}, .backgroundColor = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(12) }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(0) }}, .backgroundColor = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(12) }) {
|
||||||
CLAY({ .layout = {.padding = CLAY_PADDING_ALL(20), .childGap = 4, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
CLAY_AUTO_ID({ .layout = {.padding = CLAY_PADDING_ALL(20), .childGap = 4, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
||||||
CLAY_TEXT(CLAY_STRING("- High performance"),
|
CLAY_TEXT(CLAY_STRING("- High performance"),
|
||||||
CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND }));
|
CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND }));
|
||||||
CLAY_TEXT(CLAY_STRING("- Declarative syntax"),
|
CLAY_TEXT(CLAY_STRING("- Declarative syntax"),
|
||||||
|
|
@ -69,7 +69,7 @@ void Layout() {
|
||||||
CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND }));
|
CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
||||||
.padding = CLAY_PADDING_ALL(10),
|
.padding = CLAY_PADDING_ALL(10),
|
||||||
|
|
@ -81,23 +81,23 @@ void Layout() {
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
||||||
}) {
|
}) {
|
||||||
// Profile picture
|
// Profile picture
|
||||||
CLAY({ .layout = {
|
CLAY_AUTO_ID({ .layout = {
|
||||||
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
.sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)},
|
||||||
.padding = { 30, 30, 0, 0 },
|
.padding = { 30, 30, 0, 0 },
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }},
|
.childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }},
|
||||||
.border = { .color = PRIMARY, .width = 2, 2, 2, 2 }, .cornerRadius = 10
|
.border = { .color = PRIMARY, .width = 2, 2, 2, 2 }, .cornerRadius = 10
|
||||||
}) {
|
}) {
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_FIXED(32), CLAY_SIZING_FIXED(32) } }, .image = { .imageData = "resources/check.png" }});
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_FIXED(32), CLAY_SIZING_FIXED(32) } }, .image = { .imageData = "resources/check.png" }});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(16) } }});
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(16) } }});
|
||||||
|
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childGap = 10, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childGap = 10, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) {
|
||||||
CLAY_TEXT(CLAY_STRING("Cairo"), CLAY_TEXT_CONFIG({ .fontId = FONT_CALLISTOGA, .fontSize = 24, .textColor = PRIMARY }));
|
CLAY_TEXT(CLAY_STRING("Cairo"), CLAY_TEXT_CONFIG({ .fontId = FONT_CALLISTOGA, .fontSize = 24, .textColor = PRIMARY }));
|
||||||
CLAY({ .layout = { .padding = CLAY_PADDING_ALL(10) }, .backgroundColor = ACCENT, .cornerRadius = 10 }) {
|
CLAY_AUTO_ID({ .layout = { .padding = CLAY_PADDING_ALL(10) }, .backgroundColor = ACCENT, .cornerRadius = 10 }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Officiis quia quia qui inventore ratione voluptas et. Quidem sunt unde similique. Qui est et exercitationem cumque harum illum. Numquam placeat aliquid quo voluptatem. "
|
CLAY_TEXT(CLAY_STRING("Officiis quia quia qui inventore ratione voluptas et. Quidem sunt unde similique. Qui est et exercitationem cumque harum illum. Numquam placeat aliquid quo voluptatem. "
|
||||||
"Deleniti saepe nihil exercitationem nemo illo. Consequatur beatae repellat provident similique. Provident qui exercitationem deserunt sapiente. Quam qui dolor corporis odit. "
|
"Deleniti saepe nihil exercitationem nemo illo. Consequatur beatae repellat provident similique. Provident qui exercitationem deserunt sapiente. Quam qui dolor corporis odit. "
|
||||||
"Assumenda corrupti sunt culpa pariatur. Vero sit ut minima. In est consequatur minus et cum sint illum aperiam. Qui ipsa quas nisi omnis aut quia nobis. "
|
"Assumenda corrupti sunt culpa pariatur. Vero sit ut minima. In est consequatur minus et cum sint illum aperiam. Qui ipsa quas nisi omnis aut quia nobis. "
|
||||||
|
|
|
||||||
|
|
@ -65,21 +65,21 @@ Clay_String* FrameAllocateString(Clay_String string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandingPageBlob(int index, int fontSize, Clay_Color color, Clay_String text, Clay_String imageURL) {
|
void LandingPageBlob(int index, int fontSize, Clay_Color color, Clay_String text, Clay_String imageURL) {
|
||||||
CLAY({ .id = CLAY_IDI("HeroBlob", index), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 480) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .border = { .color = color, .width = { 2, 2, 2, 2 }}, .cornerRadius = CLAY_CORNER_RADIUS(10) }) {
|
CLAY(CLAY_IDI("HeroBlob", index), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 480) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .border = { .color = color, .width = { 2, 2, 2, 2 }}, .cornerRadius = CLAY_CORNER_RADIUS(10) }) {
|
||||||
CLAY({ .id = CLAY_IDI("CheckImage", index), .layout = { .sizing = { CLAY_SIZING_FIXED(32) } }, .aspectRatio = { 1 }, .image = { .imageData = FrameAllocateString(imageURL) } }) {}
|
CLAY(CLAY_IDI("CheckImage", index), { .layout = { .sizing = { CLAY_SIZING_FIXED(32) } }, .aspectRatio = { 1 }, .image = { .imageData = FrameAllocateString(imageURL) } }) {}
|
||||||
CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = fontSize, .fontId = FONT_ID_BODY_24, .textColor = color }));
|
CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = fontSize, .fontId = FONT_ID_BODY_24, .textColor = color }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandingPageDesktop() {
|
void LandingPageDesktop() {
|
||||||
CLAY({ .id = CLAY_ID("LandingPage1Desktop"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
CLAY(CLAY_ID("LandingPage1Desktop"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
||||||
CLAY({ .id = CLAY_ID("LandingPage1"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED } }) {
|
CLAY(CLAY_ID("LandingPage1"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED } }) {
|
||||||
CLAY({ .id = CLAY_ID("LeftText"), .layout = { .sizing = { .width = CLAY_SIZING_PERCENT(0.55f) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("LeftText"), { .layout = { .sizing = { .width = CLAY_SIZING_PERCENT(0.55f) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 56, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 56, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("LandingPageSpacer"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
CLAY(CLAY_ID("LandingPageSpacer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("HeroImageOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_PERCENT(0.45f) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 } }) {
|
CLAY(CLAY_ID("HeroImageOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_PERCENT(0.45f) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 } }) {
|
||||||
LandingPageBlob(1, 32, COLOR_BLOB_BORDER_5, CLAY_STRING("High performance"), CLAY_STRING("/clay/images/check_5.png"));
|
LandingPageBlob(1, 32, COLOR_BLOB_BORDER_5, CLAY_STRING("High performance"), CLAY_STRING("/clay/images/check_5.png"));
|
||||||
LandingPageBlob(2, 32, COLOR_BLOB_BORDER_4, CLAY_STRING("Flexbox-style responsive layout"), CLAY_STRING("/clay/images/check_4.png"));
|
LandingPageBlob(2, 32, COLOR_BLOB_BORDER_4, CLAY_STRING("Flexbox-style responsive layout"), CLAY_STRING("/clay/images/check_4.png"));
|
||||||
LandingPageBlob(3, 32, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png"));
|
LandingPageBlob(3, 32, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png"));
|
||||||
|
|
@ -91,13 +91,13 @@ void LandingPageDesktop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandingPageMobile() {
|
void LandingPageMobile() {
|
||||||
CLAY({ .id = CLAY_ID("LandingPage1Mobile"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 16, 32, 32 }, .childGap = 32 } }) {
|
CLAY(CLAY_ID("LandingPage1Mobile"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = windowHeight - 70) }, .childAlignment = {CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 16, 32, 32 }, .childGap = 32 } }) {
|
||||||
CLAY({ .id = CLAY_ID("LeftText"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("LeftText"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance."), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("LandingPageSpacer"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
CLAY(CLAY_ID("LandingPageSpacer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Clay is laying out this webpage right now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("HeroImageOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 } }) {
|
CLAY(CLAY_ID("HeroImageOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { CLAY_ALIGN_X_CENTER }, .childGap = 16 } }) {
|
||||||
LandingPageBlob(1, 28, COLOR_BLOB_BORDER_5, CLAY_STRING("High performance"), CLAY_STRING("/clay/images/check_5.png"));
|
LandingPageBlob(1, 28, COLOR_BLOB_BORDER_5, CLAY_STRING("High performance"), CLAY_STRING("/clay/images/check_5.png"));
|
||||||
LandingPageBlob(2, 28, COLOR_BLOB_BORDER_4, CLAY_STRING("Flexbox-style responsive layout"), CLAY_STRING("/clay/images/check_4.png"));
|
LandingPageBlob(2, 28, COLOR_BLOB_BORDER_4, CLAY_STRING("Flexbox-style responsive layout"), CLAY_STRING("/clay/images/check_4.png"));
|
||||||
LandingPageBlob(3, 28, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png"));
|
LandingPageBlob(3, 28, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png"));
|
||||||
|
|
@ -108,17 +108,17 @@ void LandingPageMobile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureBlocksDesktop() {
|
void FeatureBlocksDesktop() {
|
||||||
CLAY({ .id = CLAY_ID("FeatureBlocksOuter"), .layout = { .sizing = { CLAY_SIZING_GROW(0) } } }) {
|
CLAY(CLAY_ID("FeatureBlocksOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) } } }) {
|
||||||
CLAY({ .id = CLAY_ID("FeatureBlocksInner"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED } }) {
|
CLAY(CLAY_ID("FeatureBlocksInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED } }) {
|
||||||
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
||||||
CLAY({ .id = CLAY_ID("HFileBoxOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_PERCENT(0.5f) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {50, 50, 32, 32}, .childGap = 8 } }) {
|
CLAY(CLAY_ID("HFileBoxOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_PERCENT(0.5f) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {50, 50, 32, 32}, .childGap = 8 } }) {
|
||||||
CLAY({ .id = CLAY_ID("HFileIncludeOuter"), .layout = { .padding = {8, 4} }, .backgroundColor = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
CLAY(CLAY_ID("HFileIncludeOuter"), { .layout = { .padding = {8, 4} }, .backgroundColor = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
||||||
CLAY_TEXT(CLAY_STRING("#include clay.h"), CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("#include clay.h"), CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig);
|
CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig);
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("BringYourOwnRendererOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_PERCENT(0.5f) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {50, 50, 32, 32}, .childGap = 8 } }) {
|
CLAY(CLAY_ID("BringYourOwnRendererOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_PERCENT(0.5f) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {50, 50, 32, 32}, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = COLOR_ORANGE }));
|
||||||
CLAY_TEXT(CLAY_STRING("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML."), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING("Flexible output for easy compositing in your custom engine or environment."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Flexible output for easy compositing in your custom engine or environment."), textConfig);
|
||||||
|
|
@ -128,16 +128,16 @@ void FeatureBlocksDesktop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureBlocksMobile() {
|
void FeatureBlocksMobile() {
|
||||||
CLAY({ .id = CLAY_ID("FeatureBlocksInner"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) } }, .border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED } }) {
|
CLAY(CLAY_ID("FeatureBlocksInner"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) } }, .border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED } }) {
|
||||||
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_RED });
|
||||||
CLAY({ .id = CLAY_ID("HFileBoxOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 8 } }) {
|
CLAY(CLAY_ID("HFileBoxOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 8 } }) {
|
||||||
CLAY({ .id = CLAY_ID("HFileIncludeOuter"), .layout = { .padding = {8, 4} }, .backgroundColor = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
CLAY(CLAY_ID("HFileIncludeOuter"), { .layout = { .padding = {8, 4} }, .backgroundColor = COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
||||||
CLAY_TEXT(CLAY_STRING("#include clay.h"), CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("#include clay.h"), CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_BODY_24, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig);
|
CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig);
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("BringYourOwnRendererOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 8 } }) {
|
CLAY(CLAY_ID("BringYourOwnRendererOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = COLOR_ORANGE }));
|
||||||
CLAY_TEXT(CLAY_STRING("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML."), textConfig);
|
||||||
CLAY_TEXT(CLAY_STRING("Flexible output for easy compositing in your custom engine or environment."), textConfig);
|
CLAY_TEXT(CLAY_STRING("Flexible output for easy compositing in your custom engine or environment."), textConfig);
|
||||||
|
|
@ -146,33 +146,33 @@ void FeatureBlocksMobile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeSyntaxPageDesktop() {
|
void DeclarativeSyntaxPageDesktop() {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageDesktop"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
CLAY(CLAY_ID("SyntaxPageDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPage"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED }}) {
|
CLAY(CLAY_ID("SyntaxPage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED }}) {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageLeftText"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("SyntaxPageLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("SyntaxSpacer"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) } } }) {}
|
CLAY(CLAY_ID("SyntaxSpacer"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageRightImage"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) {
|
CLAY(CLAY_ID("SyntaxPageRightImage"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageRightImageInner"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 568) } }, .aspectRatio = { 1136.0 / 1194.0 }, .image = { .imageData = FrameAllocateString(CLAY_STRING("/clay/images/declarative.png")) } }) {}
|
CLAY(CLAY_ID("SyntaxPageRightImageInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 568) } }, .aspectRatio = { 1136.0 / 1194.0 }, .image = { .imageData = FrameAllocateString(CLAY_STRING("/clay/images/declarative.png")) } }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeSyntaxPageMobile() {
|
void DeclarativeSyntaxPageMobile() {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageDesktop"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 16 } }) {
|
CLAY(CLAY_ID("SyntaxPageDesktop"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 16 } }) {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageLeftText"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("SyntaxPageLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("SyntaxSpacer"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) } } }) {}
|
CLAY(CLAY_ID("SyntaxSpacer"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageRightImage"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) {
|
CLAY(CLAY_ID("SyntaxPageRightImage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) {
|
||||||
CLAY({ .id = CLAY_ID("SyntaxPageRightImageInner"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 568) } }, .aspectRatio = { 1136.0 / 1194.0 }, .image = { .imageData = FrameAllocateString(CLAY_STRING("/clay/images/declarative.png")) } }) {}
|
CLAY(CLAY_ID("SyntaxPageRightImageInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 568) } }, .aspectRatio = { 1136.0 / 1194.0 }, .image = { .imageData = FrameAllocateString(CLAY_STRING("/clay/images/declarative.png")) } }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -189,20 +189,20 @@ Clay_Color ColorLerp(Clay_Color a, Clay_Color b, float amount) {
|
||||||
Clay_String LOREM_IPSUM_TEXT = CLAY_STRING("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
Clay_String LOREM_IPSUM_TEXT = CLAY_STRING("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
||||||
|
|
||||||
void HighPerformancePageDesktop(float lerpValue) {
|
void HighPerformancePageDesktop(float lerpValue) {
|
||||||
CLAY({ .id = CLAY_ID("PerformanceOuter"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {82, 82, 32, 32}, .childGap = 64 }, .backgroundColor = COLOR_RED }) {
|
CLAY(CLAY_ID("PerformanceOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = {82, 82, 32, 32}, .childGap = 64 }, .backgroundColor = COLOR_RED }) {
|
||||||
CLAY({ .id = CLAY_ID("PerformanceLeftText"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("PerformanceLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
CLAY({ .id = CLAY_ID("PerformanceSpacer"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
CLAY(CLAY_ID("PerformanceSpacer"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("PerformanceRightImageOuter"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
CLAY(CLAY_ID("PerformanceRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = {2, 2, 2, 2}, .color = COLOR_LIGHT } }) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = {2, 2, 2, 2}, .color = COLOR_LIGHT } }) {
|
||||||
CLAY({ .id = CLAY_ID("AnimationDemoContainerLeft"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.3f + 0.4f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32) }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) {
|
CLAY(CLAY_ID("AnimationDemoContainerLeft"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.3f + 0.4f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32) }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) {
|
||||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("AnimationDemoContainerRight"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32) }, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) {
|
CLAY(CLAY_ID("AnimationDemoContainerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(32) }, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) {
|
||||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,20 +211,20 @@ void HighPerformancePageDesktop(float lerpValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighPerformancePageMobile(float lerpValue) {
|
void HighPerformancePageMobile(float lerpValue) {
|
||||||
CLAY({ .id = CLAY_ID("PerformanceOuter"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 32 }, .backgroundColor = COLOR_RED }) {
|
CLAY(CLAY_ID("PerformanceOuter"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .padding = {16, 16, 32, 32}, .childGap = 32 }, .backgroundColor = COLOR_RED }) {
|
||||||
CLAY({ .id = CLAY_ID("PerformanceLeftText"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("PerformanceLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
CLAY({ .id = CLAY_ID("PerformanceSpacer"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
CLAY(CLAY_ID("PerformanceSpacer"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("PerformanceRightImageOuter"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
CLAY(CLAY_ID("PerformanceRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
||||||
CLAY({ .id = CLAY_ID(""), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = { 2, 2, 2, 2 }, .color = COLOR_LIGHT }}) {
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = { 2, 2, 2, 2 }, .color = COLOR_LIGHT }}) {
|
||||||
CLAY({ .id = CLAY_ID("AnimationDemoContainerLeft"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.35f + 0.3f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(16) }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) {
|
CLAY(CLAY_ID("AnimationDemoContainerLeft"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.35f + 0.3f * lerpValue), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(16) }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) {
|
||||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("AnimationDemoContainerRight"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(16) }, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) {
|
CLAY(CLAY_ID("AnimationDemoContainerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .padding = CLAY_PADDING_ALL(16) }, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) {
|
||||||
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .fontSize = 24, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +241,7 @@ void HandleRendererButtonInteraction(Clay_ElementId elementId, Clay_PointerData
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererButtonActive(Clay_String text) {
|
void RendererButtonActive(Clay_String text) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED(300) }, .padding = CLAY_PADDING_ALL(16) },
|
.layout = { .sizing = {CLAY_SIZING_FIXED(300) }, .padding = CLAY_PADDING_ALL(16) },
|
||||||
.backgroundColor = Clay_Hovered() ? COLOR_RED_HOVER : COLOR_RED,
|
.backgroundColor = Clay_Hovered() ? COLOR_RED_HOVER : COLOR_RED,
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(10),
|
.cornerRadius = CLAY_CORNER_RADIUS(10),
|
||||||
|
|
@ -252,7 +252,7 @@ void RendererButtonActive(Clay_String text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererButtonInactive(Clay_String text, size_t rendererIndex) {
|
void RendererButtonInactive(Clay_String text, size_t rendererIndex) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED(300)}, .padding = CLAY_PADDING_ALL(16) },
|
.layout = { .sizing = {CLAY_SIZING_FIXED(300)}, .padding = CLAY_PADDING_ALL(16) },
|
||||||
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
||||||
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
||||||
|
|
@ -265,18 +265,18 @@ void RendererButtonInactive(Clay_String text, size_t rendererIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererPageDesktop() {
|
void RendererPageDesktop() {
|
||||||
CLAY({ .id = CLAY_ID("RendererPageDesktop"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
CLAY(CLAY_ID("RendererPageDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 50, 50 } } }) {
|
||||||
CLAY({ .id = CLAY_ID("RendererPage"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED } }) {
|
CLAY(CLAY_ID("RendererPage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 }, .border = { .width = { .left = 2, .right = 2 }, .color = COLOR_RED } }) {
|
||||||
CLAY({ .id = CLAY_ID("RendererLeftText"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("RendererLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("RendererSpacerLeft"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
CLAY(CLAY_ID("RendererSpacerLeft"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("RendererRightText"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childAlignment = {CLAY_ALIGN_X_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
CLAY(CLAY_ID("RendererRightText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childAlignment = {CLAY_ALIGN_X_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
||||||
CLAY({ .id = CLAY_ID("RendererSpacerRight"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) } } }) {}
|
CLAY(CLAY_ID("RendererSpacerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) } } }) {}
|
||||||
if (ACTIVE_RENDERER_INDEX == 0) {
|
if (ACTIVE_RENDERER_INDEX == 0) {
|
||||||
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
||||||
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
||||||
|
|
@ -290,17 +290,17 @@ void RendererPageDesktop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererPageMobile() {
|
void RendererPageMobile() {
|
||||||
CLAY({ .id = CLAY_ID("RendererMobile"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 16, 32, 32}, .childGap = 32 }, .backgroundColor = COLOR_LIGHT }) {
|
CLAY(CLAY_ID("RendererMobile"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .padding = { 16, 16, 32, 32}, .childGap = 32 }, .backgroundColor = COLOR_LIGHT }) {
|
||||||
CLAY({ .id = CLAY_ID("RendererLeftText"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("RendererLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({ .fontSize = 48, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_RED }));
|
||||||
CLAY({ .id = CLAY_ID("RendererSpacerLeft"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
CLAY(CLAY_ID("RendererSpacerLeft"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("Write your own renderer in a few hundred lines of code, or use the provided examples for Raylib, WebGL canvas and more."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("RendererRightText"), .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
CLAY(CLAY_ID("RendererRightText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 16 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .fontSize = 36, .fontId = FONT_ID_BODY_36, .textColor = COLOR_ORANGE }));
|
||||||
CLAY({ .id = CLAY_ID("RendererSpacerRight"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) }} }) {}
|
CLAY(CLAY_ID("RendererSpacerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) }} }) {}
|
||||||
if (ACTIVE_RENDERER_INDEX == 0) {
|
if (ACTIVE_RENDERER_INDEX == 0) {
|
||||||
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
RendererButtonActive(CLAY_STRING("HTML Renderer"));
|
||||||
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
RendererButtonInactive(CLAY_STRING("Canvas Renderer"), 1);
|
||||||
|
|
@ -313,17 +313,17 @@ void RendererPageMobile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPageDesktop() {
|
void DebuggerPageDesktop() {
|
||||||
CLAY({ .id = CLAY_ID("DebuggerDesktop"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 82, 82, 32, 32 }, .childGap = 64 }, .backgroundColor = COLOR_RED }) {
|
CLAY(CLAY_ID("DebuggerDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = windowHeight - 50) }, .childAlignment = {0, CLAY_ALIGN_Y_CENTER}, .padding = { 82, 82, 32, 32 }, .childGap = 64 }, .backgroundColor = COLOR_RED }) {
|
||||||
CLAY({ .id = CLAY_ID("DebuggerLeftText"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
CLAY(CLAY_ID("DebuggerLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 8 } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Integrated Debug Tools"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Integrated Debug Tools"), CLAY_TEXT_CONFIG({ .fontSize = 52, .fontId = FONT_ID_TITLE_56, .textColor = COLOR_LIGHT }));
|
||||||
CLAY({ .id = CLAY_ID("DebuggerSpacer"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
CLAY(CLAY_ID("DebuggerSpacer"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 16) }} }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Clay includes built in \"Chrome Inspector\"-style debug tooling."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("Clay includes built in \"Chrome Inspector\"-style debug tooling."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY_TEXT(CLAY_STRING("View your layout hierarchy and config in real time."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
CLAY_TEXT(CLAY_STRING("View your layout hierarchy and config in real time."), CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT }));
|
||||||
CLAY({ .id = CLAY_ID("DebuggerPageSpacer"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
CLAY(CLAY_ID("DebuggerPageSpacer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(32) } } }) {}
|
||||||
CLAY_TEXT(CLAY_STRING("Press the \"d\" key to try it out now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
CLAY_TEXT(CLAY_STRING("Press the \"d\" key to try it out now!"), CLAY_TEXT_CONFIG({ .fontSize = 32, .fontId = FONT_ID_TITLE_36, .textColor = COLOR_ORANGE }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("DebuggerRightImageOuter"), .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
CLAY(CLAY_ID("DebuggerRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) {
|
||||||
CLAY({ .id = CLAY_ID("DebuggerPageRightImageInner"), .layout = { .sizing = { CLAY_SIZING_GROW(.max = 558) } }, .aspectRatio = { 1620.0 / 1474.0 }, .image = {.imageData = FrameAllocateString(CLAY_STRING("/clay/images/debugger.png")) } }) {}
|
CLAY(CLAY_ID("DebuggerPageRightImageInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 558) } }, .aspectRatio = { 1620.0 / 1474.0 }, .image = {.imageData = FrameAllocateString(CLAY_STRING("/clay/images/debugger.png")) } }) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -340,26 +340,26 @@ float animationLerpValue = -1.0f;
|
||||||
|
|
||||||
Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer"), .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) {
|
CLAY(CLAY_ID("OuterContainer"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) {
|
||||||
CLAY({ .id = CLAY_ID("Header"), .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(50) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = { 32, 32 } } }) {
|
CLAY(CLAY_ID("Header"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(50) }, .childAlignment = { 0, CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = { 32, 32 } } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Clay"), &headerTextConfig);
|
CLAY_TEXT(CLAY_STRING("Clay"), &headerTextConfig);
|
||||||
CLAY({ .id = CLAY_ID("Spacer"), .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
CLAY(CLAY_ID("Spacer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {}
|
||||||
if (!mobileScreen) {
|
if (!mobileScreen) {
|
||||||
CLAY({ .id = CLAY_ID("LinkExamplesOuter"), .layout = { .padding = {8, 8} } }) {
|
CLAY(CLAY_ID("LinkExamplesOuter"), { .layout = { .padding = {8, 8} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Examples"), CLAY_TEXT_CONFIG({
|
CLAY_TEXT(CLAY_STRING("Examples"), CLAY_TEXT_CONFIG({
|
||||||
.userData = FrameAllocateCustomData((CustomHTMLData) {
|
.userData = FrameAllocateCustomData((CustomHTMLData) {
|
||||||
.link = CLAY_STRING("https://github.com/nicbarker/clay/tree/main/examples")
|
.link = CLAY_STRING("https://github.com/nicbarker/clay/tree/main/examples")
|
||||||
}),
|
}),
|
||||||
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
||||||
}
|
}
|
||||||
CLAY({ .id = CLAY_ID("LinkDocsOuter"), .layout = { .padding = {8, 8} } }) {
|
CLAY(CLAY_ID("LinkDocsOuter"), { .layout = { .padding = {8, 8} } }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Docs"), CLAY_TEXT_CONFIG({
|
CLAY_TEXT(CLAY_STRING("Docs"), CLAY_TEXT_CONFIG({
|
||||||
.userData = FrameAllocateCustomData((CustomHTMLData) { .link = CLAY_STRING("https://github.com/nicbarker/clay/blob/main/README.md") }),
|
.userData = FrameAllocateCustomData((CustomHTMLData) { .link = CLAY_STRING("https://github.com/nicbarker/clay/blob/main/README.md") }),
|
||||||
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} })
|
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .padding = {16, 16, 6, 6} },
|
.layout = { .padding = {16, 16, 6, 6} },
|
||||||
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
||||||
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
||||||
|
|
@ -370,7 +370,7 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||||
.userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true }),
|
.userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true }),
|
||||||
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
.fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} }));
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .padding = {16, 16, 6, 6} },
|
.layout = { .padding = {16, 16, 6, 6} },
|
||||||
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
.backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT,
|
||||||
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
.border = { .width = {2, 2, 2, 2}, .color = COLOR_RED },
|
||||||
|
|
@ -383,12 +383,12 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Clay_LayoutConfig topBorderConfig = (Clay_LayoutConfig) { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(4) }};
|
Clay_LayoutConfig topBorderConfig = (Clay_LayoutConfig) { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(4) }};
|
||||||
CLAY({ .id = CLAY_ID("TopBorder1"), .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_5 }) {}
|
CLAY(CLAY_ID("TopBorder1"), { .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_5 }) {}
|
||||||
CLAY({ .id = CLAY_ID("TopBorder2"), .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_4 }) {}
|
CLAY(CLAY_ID("TopBorder2"), { .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_4 }) {}
|
||||||
CLAY({ .id = CLAY_ID("TopBorder3"), .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_3 }) {}
|
CLAY(CLAY_ID("TopBorder3"), { .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_3 }) {}
|
||||||
CLAY({ .id = CLAY_ID("TopBorder4"), .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_2 }) {}
|
CLAY(CLAY_ID("TopBorder4"), { .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_2 }) {}
|
||||||
CLAY({ .id = CLAY_ID("TopBorder5"), .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_1 }) {}
|
CLAY(CLAY_ID("TopBorder5"), { .layout = topBorderConfig, .backgroundColor = COLOR_TOP_BORDER_1 }) {}
|
||||||
CLAY({ .id = CLAY_ID("OuterScrollContainer"),
|
CLAY(CLAY_ID("OuterScrollContainer"), {
|
||||||
.layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
||||||
.border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED }
|
.border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED }
|
||||||
|
|
@ -419,8 +419,7 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) {
|
||||||
scrollbarColor = (Clay_Color){225, 138, 50, 160};
|
scrollbarColor = (Clay_Color){225, 138, 50, 160};
|
||||||
}
|
}
|
||||||
float scrollHeight = scrollData.scrollContainerDimensions.height - 12;
|
float scrollHeight = scrollData.scrollContainerDimensions.height - 12;
|
||||||
CLAY({
|
CLAY(CLAY_ID("ScrollBar"), {
|
||||||
.id = CLAY_ID("ScrollBar"),
|
|
||||||
.floating = { .offset = { .x = -6, .y = -(scrollData.scrollPosition->y / scrollData.contentDimensions.height) * scrollHeight + 6}, .zIndex = 1, .parentId = Clay_GetElementId(CLAY_STRING("OuterScrollContainer")).id, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP }, .attachTo = CLAY_ATTACH_TO_PARENT },
|
.floating = { .offset = { .x = -6, .y = -(scrollData.scrollPosition->y / scrollData.contentDimensions.height) * scrollHeight + 6}, .zIndex = 1, .parentId = Clay_GetElementId(CLAY_STRING("OuterScrollContainer")).id, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP }, .attachTo = CLAY_ATTACH_TO_PARENT },
|
||||||
.layout = { .sizing = {CLAY_SIZING_FIXED(10), CLAY_SIZING_FIXED((scrollHeight / scrollData.contentDimensions.height) * scrollHeight)} },
|
.layout = { .sizing = {CLAY_SIZING_FIXED(10), CLAY_SIZING_FIXED((scrollHeight / scrollData.contentDimensions.height) * scrollHeight)} },
|
||||||
.backgroundColor = scrollbarColor,
|
.backgroundColor = scrollbarColor,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ int main(void) {
|
||||||
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char *)malloc(totalMemorySize));
|
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char *)malloc(totalMemorySize));
|
||||||
Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}, Clay_ErrorHandler { HandleClayErrors });
|
Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}, Clay_ErrorHandler { HandleClayErrors });
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY({ .layout = layoutElement, .backgroundColor = {255,255,255,0} }) {
|
CLAY_AUTO_ID({ .layout = layoutElement, .backgroundColor = {255,255,255,0} }) {
|
||||||
CLAY_TEXT(CLAY_STRING(""), CLAY_TEXT_CONFIG({ .fontId = 0 }));
|
CLAY_TEXT(CLAY_STRING(""), CLAY_TEXT_CONFIG({ .fontId = 0 }));
|
||||||
}
|
}
|
||||||
Clay_EndLayout();
|
Clay_EndLayout();
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ Clay_Color COLOR_WHITE = { 255, 255, 255, 255 };
|
||||||
Clay_Color COLOR_BLACK = { 0, 0, 0, 255 };
|
Clay_Color COLOR_BLACK = { 0, 0, 0, 255 };
|
||||||
|
|
||||||
void RenderHeaderButton(Clay_String text) {
|
void RenderHeaderButton(Clay_String text) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .padding = { 8, 8, 4, 4 } },
|
.layout = { .padding = { 8, 8, 4, 4 } },
|
||||||
.backgroundColor = COLOR_BLACK,
|
.backgroundColor = COLOR_BLACK,
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
||||||
|
|
@ -212,8 +212,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build UI here
|
// Build UI here
|
||||||
CLAY({
|
CLAY(CLAY_ID("OuterContainer"), {
|
||||||
.id = CLAY_ID("OuterContainer"),
|
|
||||||
.backgroundColor = COLOR_WHITE,
|
.backgroundColor = COLOR_WHITE,
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
|
|
@ -223,8 +222,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
// Child elements go inside braces
|
// Child elements go inside braces
|
||||||
CLAY({
|
CLAY(CLAY_ID("HeaderBar"), {
|
||||||
.id = CLAY_ID("HeaderBar"),
|
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.height = CLAY_SIZING_FIXED(30),
|
.height = CLAY_SIZING_FIXED(30),
|
||||||
|
|
@ -235,8 +233,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
// Header buttons go here
|
// Header buttons go here
|
||||||
CLAY({
|
CLAY(CLAY_ID("FileButton"), {
|
||||||
.id = CLAY_ID("FileButton"),
|
|
||||||
.layout = {
|
.layout = {
|
||||||
.padding = { 8, 8, 4, 4 }
|
.padding = { 8, 8, 4, 4 }
|
||||||
},
|
},
|
||||||
|
|
@ -252,18 +249,16 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
RenderHeaderButton(CLAY_STRING("Edit"));
|
RenderHeaderButton(CLAY_STRING("Edit"));
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0) } } }) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0) } } }) {}
|
||||||
RenderHeaderButton(CLAY_STRING("Upload"));
|
RenderHeaderButton(CLAY_STRING("Upload"));
|
||||||
RenderHeaderButton(CLAY_STRING("Media"));
|
RenderHeaderButton(CLAY_STRING("Media"));
|
||||||
RenderHeaderButton(CLAY_STRING("Support"));
|
RenderHeaderButton(CLAY_STRING("Support"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({
|
CLAY(CLAY_ID("LowerContent"), {
|
||||||
.id = CLAY_ID("LowerContent"),
|
|
||||||
.layout = { .sizing = layoutExpand, .childGap = 8 },
|
.layout = { .sizing = layoutExpand, .childGap = 8 },
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY(CLAY_ID("Sidebar"), {
|
||||||
.id = CLAY_ID("Sidebar"),
|
|
||||||
.border = contentBorders,
|
.border = contentBorders,
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
.layout = {
|
.layout = {
|
||||||
|
|
@ -284,7 +279,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
};
|
};
|
||||||
|
|
||||||
if (i == selectedDocumentIndex) {
|
if (i == selectedDocumentIndex) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = sidebarButtonLayout,
|
.layout = sidebarButtonLayout,
|
||||||
.backgroundColor = COLOR_BLACK,
|
.backgroundColor = COLOR_BLACK,
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
||||||
|
|
@ -298,7 +293,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = sidebarButtonLayout,
|
.layout = sidebarButtonLayout,
|
||||||
.backgroundColor = (Clay_Color){ 0, 0, 0, Clay_Hovered() ? 120 : 0 },
|
.backgroundColor = (Clay_Color){ 0, 0, 0, Clay_Hovered() ? 120 : 0 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
|
|
@ -316,8 +311,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({
|
CLAY(CLAY_ID("MainContent"), {
|
||||||
.id = CLAY_ID("MainContent"),
|
|
||||||
.border = contentBorders,
|
.border = contentBorders,
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
||||||
|
|
@ -329,7 +323,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
Document selectedDocument = documents.documents[selectedDocumentIndex];
|
Document selectedDocument = documents.documents[selectedDocumentIndex];
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
.childGap = 4,
|
.childGap = 4,
|
||||||
|
|
@ -340,7 +334,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI
|
||||||
selectedDocument.title,
|
selectedDocument.title,
|
||||||
CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY, .textColor = COLOR_BLACK })
|
CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY, .textColor = COLOR_BLACK })
|
||||||
);
|
);
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_FIXED(32),
|
.width = CLAY_SIZING_FIXED(32),
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -3,7 +3,7 @@
|
||||||
// NOTE: This file only exists to make sure that clay works when included in multiple translation units.
|
// NOTE: This file only exists to make sure that clay works when included in multiple translation units.
|
||||||
|
|
||||||
void SatisfyCompiler(void) {
|
void SatisfyCompiler(void) {
|
||||||
CLAY({ .id = CLAY_ID("SatisfyCompiler") }) {
|
CLAY(CLAY_ID("SatisfyCompiler"), { }) {
|
||||||
CLAY_TEXT(CLAY_STRING("Test"), CLAY_TEXT_CONFIG({ .fontId = 0, .fontSize = 24 }));
|
CLAY_TEXT(CLAY_STRING("Test"), CLAY_TEXT_CONFIG({ .fontId = 0, .fontSize = 24 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const int FONT_ID_BODY_16 = 0;
|
||||||
Clay_Color COLOR_WHITE = { 255, 255, 255, 255};
|
Clay_Color COLOR_WHITE = { 255, 255, 255, 255};
|
||||||
|
|
||||||
void RenderHeaderButton(Clay_String text) {
|
void RenderHeaderButton(Clay_String text) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .padding = { 16, 16, 8, 8 }},
|
.layout = { .padding = { 16, 16, 8, 8 }},
|
||||||
.backgroundColor = { 140, 140, 140, 255 },
|
.backgroundColor = { 140, 140, 140, 255 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(5)
|
.cornerRadius = CLAY_CORNER_RADIUS(5)
|
||||||
|
|
@ -19,7 +19,7 @@ void RenderHeaderButton(Clay_String text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderDropdownMenuItem(Clay_String text) {
|
void RenderDropdownMenuItem(Clay_String text) {
|
||||||
CLAY({.layout = { .padding = CLAY_PADDING_ALL(16)}}) {
|
CLAY_AUTO_ID({.layout = { .padding = CLAY_PADDING_ALL(16)}}) {
|
||||||
CLAY_TEXT(text, CLAY_TEXT_CONFIG({
|
CLAY_TEXT(text, CLAY_TEXT_CONFIG({
|
||||||
.fontId = FONT_ID_BODY_16,
|
.fontId = FONT_ID_BODY_16,
|
||||||
.fontSize = 16,
|
.fontSize = 16,
|
||||||
|
|
@ -102,7 +102,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
Clay_Color contentBackgroundColor = { 90, 90, 90, 255 };
|
Clay_Color contentBackgroundColor = { 90, 90, 90, 255 };
|
||||||
|
|
||||||
// Build UI here
|
// Build UI here
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer"),
|
CLAY(CLAY_ID("OuterContainer"), {
|
||||||
.backgroundColor = {43, 41, 51, 255 },
|
.backgroundColor = {43, 41, 51, 255 },
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
|
|
@ -112,7 +112,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
// Child elements go inside braces
|
// Child elements go inside braces
|
||||||
CLAY({ .id = CLAY_ID("HeaderBar"),
|
CLAY(CLAY_ID("HeaderBar"), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.height = CLAY_SIZING_FIXED(60),
|
.height = CLAY_SIZING_FIXED(60),
|
||||||
|
|
@ -128,7 +128,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
||||||
}) {
|
}) {
|
||||||
// Header buttons go here
|
// Header buttons go here
|
||||||
CLAY({ .id = CLAY_ID("FileButton"),
|
CLAY(CLAY_ID("FileButton"), {
|
||||||
.layout = { .padding = { 16, 16, 8, 8 }},
|
.layout = { .padding = { 16, 16, 8, 8 }},
|
||||||
.backgroundColor = {140, 140, 140, 255 },
|
.backgroundColor = {140, 140, 140, 255 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(5)
|
.cornerRadius = CLAY_CORNER_RADIUS(5)
|
||||||
|
|
@ -145,7 +145,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
Clay_PointerOver(Clay_GetElementId(CLAY_STRING("FileMenu")));
|
Clay_PointerOver(Clay_GetElementId(CLAY_STRING("FileMenu")));
|
||||||
|
|
||||||
if (fileMenuVisible) { // Below has been changed slightly to fix the small bug where the menu would dismiss when mousing over the top gap
|
if (fileMenuVisible) { // Below has been changed slightly to fix the small bug where the menu would dismiss when mousing over the top gap
|
||||||
CLAY({ .id = CLAY_ID("FileMenu"),
|
CLAY(CLAY_ID("FileMenu"), {
|
||||||
.floating = {
|
.floating = {
|
||||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||||
.attachPoints = {
|
.attachPoints = {
|
||||||
|
|
@ -156,7 +156,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
.padding = {0, 0, 8, 8 }
|
.padding = {0, 0, 8, 8 }
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = {
|
.sizing = {
|
||||||
|
|
@ -175,18 +175,16 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RenderHeaderButton(CLAY_STRING("Edit"));
|
RenderHeaderButton(CLAY_STRING("Edit"));
|
||||||
CLAY({ .layout = { .sizing = { CLAY_SIZING_GROW(0) }}}) {}
|
CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0) }}}) {}
|
||||||
RenderHeaderButton(CLAY_STRING("Upload"));
|
RenderHeaderButton(CLAY_STRING("Upload"));
|
||||||
RenderHeaderButton(CLAY_STRING("Media"));
|
RenderHeaderButton(CLAY_STRING("Media"));
|
||||||
RenderHeaderButton(CLAY_STRING("Support"));
|
RenderHeaderButton(CLAY_STRING("Support"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({
|
CLAY(CLAY_ID("LowerContent"), {
|
||||||
.id = CLAY_ID("LowerContent"),
|
|
||||||
.layout = { .sizing = layoutExpand, .childGap = 16 }
|
.layout = { .sizing = layoutExpand, .childGap = 16 }
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY(CLAY_ID("Sidebar"), {
|
||||||
.id = CLAY_ID("Sidebar"),
|
|
||||||
.backgroundColor = contentBackgroundColor,
|
.backgroundColor = contentBackgroundColor,
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
|
|
@ -206,7 +204,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (i == data->selectedDocumentIndex) {
|
if (i == data->selectedDocumentIndex) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = sidebarButtonLayout,
|
.layout = sidebarButtonLayout,
|
||||||
.backgroundColor = {120, 120, 120, 255 },
|
.backgroundColor = {120, 120, 120, 255 },
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
.cornerRadius = CLAY_CORNER_RADIUS(8)
|
||||||
|
|
@ -221,7 +219,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
SidebarClickData *clickData = (SidebarClickData *)(data->frameArena.memory + data->frameArena.offset);
|
SidebarClickData *clickData = (SidebarClickData *)(data->frameArena.memory + data->frameArena.offset);
|
||||||
*clickData = (SidebarClickData) { .requestedDocumentIndex = i, .selectedDocumentIndex = &data->selectedDocumentIndex };
|
*clickData = (SidebarClickData) { .requestedDocumentIndex = i, .selectedDocumentIndex = &data->selectedDocumentIndex };
|
||||||
data->frameArena.offset += sizeof(SidebarClickData);
|
data->frameArena.offset += sizeof(SidebarClickData);
|
||||||
CLAY({ .layout = sidebarButtonLayout, .backgroundColor = (Clay_Color) { 120, 120, 120, Clay_Hovered() ? 120 : 0 }, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
CLAY_AUTO_ID({ .layout = sidebarButtonLayout, .backgroundColor = (Clay_Color) { 120, 120, 120, Clay_Hovered() ? 120 : 0 }, .cornerRadius = CLAY_CORNER_RADIUS(8) }) {
|
||||||
Clay_OnHover(HandleSidebarInteraction, (intptr_t)clickData);
|
Clay_OnHover(HandleSidebarInteraction, (intptr_t)clickData);
|
||||||
CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({
|
CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({
|
||||||
.fontId = FONT_ID_BODY_16,
|
.fontId = FONT_ID_BODY_16,
|
||||||
|
|
@ -233,7 +231,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({ .id = CLAY_ID("MainContent"),
|
CLAY(CLAY_ID("MainContent"), {
|
||||||
.backgroundColor = contentBackgroundColor,
|
.backgroundColor = contentBackgroundColor,
|
||||||
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
.clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() },
|
||||||
.layout = {
|
.layout = {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ Clay_RenderCommandArray CornerRadiusTest(){
|
||||||
.width = CLAY_SIZING_GROW(0),
|
.width = CLAY_SIZING_GROW(0),
|
||||||
.height = CLAY_SIZING_GROW(0)
|
.height = CLAY_SIZING_GROW(0)
|
||||||
};
|
};
|
||||||
CLAY({ .id = CLAY_ID("OuterContainer"),
|
CLAY(CLAY_ID("OuterContainer"), {
|
||||||
.backgroundColor = {43, 41, 51, 255},
|
.backgroundColor = {43, 41, 51, 255},
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
|
|
@ -43,7 +43,7 @@ Clay_RenderCommandArray CornerRadiusTest(){
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
for(int i = 0; i < 6; ++i){
|
for(int i = 0; i < 6; ++i){
|
||||||
CLAY({ .id = CLAY_IDI("Row", i),
|
CLAY(CLAY_IDI("Row", i), {
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
.sizing = layoutExpand,
|
.sizing = layoutExpand,
|
||||||
|
|
@ -52,7 +52,7 @@ Clay_RenderCommandArray CornerRadiusTest(){
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
for(int j = 0; j < 6; ++j){
|
for(int j = 0; j < 6; ++j){
|
||||||
CLAY({ .id = CLAY_IDI("Tile", i*6+j),
|
CLAY(CLAY_IDI("Tile", i*6+j), {
|
||||||
.backgroundColor = {120, 140, 255, 128},
|
.backgroundColor = {120, 140, 255, 128},
|
||||||
.cornerRadius = {(i%3)*15, (j%3)*15, (i/2)*15, (j/2)*15},
|
.cornerRadius = {(i%3)*15, (j%3)*15, (i/2)*15, (j/2)*15},
|
||||||
.border = {
|
.border = {
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
};
|
};
|
||||||
Clay_TextElementConfig *textconfig =
|
Clay_TextElementConfig *textconfig =
|
||||||
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } });
|
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } });
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = {
|
.width = {
|
||||||
|
|
@ -82,7 +82,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(keytext, textconfig);
|
CLAY_TEXT(keytext, textconfig);
|
||||||
CLAY({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { }
|
CLAY_AUTO_ID({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { }
|
||||||
CLAY_TEXT(valtext, textconfig);
|
CLAY_TEXT(valtext, textconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
|
|
||||||
void component_termbox_settings(void)
|
void component_termbox_settings(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.floating = {
|
.floating = {
|
||||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||||
.zIndex = 1,
|
.zIndex = 1,
|
||||||
|
|
@ -98,7 +98,7 @@ void component_termbox_settings(void)
|
||||||
.offset = { 0, 0 }
|
.offset = { 0, 0 }
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -229,7 +229,7 @@ void component_termbox_settings(void)
|
||||||
transparency = "false";
|
transparency = "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
}) {
|
}) {
|
||||||
component_text_pair("Color mode", color_mode);
|
component_text_pair("Color mode", color_mode);
|
||||||
|
|
@ -244,7 +244,7 @@ void component_termbox_settings(void)
|
||||||
|
|
||||||
void component_color_palette(void)
|
void component_color_palette(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.childGap = 16,
|
.childGap = 16,
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -261,7 +261,7 @@ void component_color_palette(void)
|
||||||
.backgroundColor = { 0x7f, 0x7f, 0x7f, 0xff }
|
.backgroundColor = { 0x7f, 0x7f, 0x7f, 0xff }
|
||||||
}) {
|
}) {
|
||||||
for (int type = 0; type < 2; ++type) {
|
for (int type = 0; type < 2; ++type) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout ={
|
.layout ={
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
|
|
@ -269,21 +269,21 @@ void component_color_palette(void)
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
for (float ri = 0; ri < 4; ri += 1) {
|
for (float ri = 0; ri < 4; ri += 1) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout ={
|
.layout ={
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.childGap = Clay_Termbox_Cell_Width()
|
.childGap = Clay_Termbox_Cell_Width()
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
for (float r = ri * 0x44; r < (ri + 1) * 0x44; r += 0x22) {
|
for (float r = ri * 0x44; r < (ri + 1) * 0x44; r += 0x22) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout ={
|
.layout ={
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
for (float g = 0; g < 0xff; g += 0x22) {
|
for (float g = 0; g < 0xff; g += 0x22) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout ={
|
.layout ={
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
},
|
},
|
||||||
|
|
@ -298,12 +298,12 @@ void component_color_palette(void)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (0 == type) {
|
if (0 == type) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = layout,
|
.layout = layout,
|
||||||
.backgroundColor = color
|
.backgroundColor = color
|
||||||
}) {}
|
}) {}
|
||||||
} else if (1 == type) {
|
} else if (1 == type) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = layout,
|
.layout = layout,
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(CLAY_STRING("#"), CLAY_TEXT_CONFIG({ .textColor = color }));
|
CLAY_TEXT(CLAY_STRING("#"), CLAY_TEXT_CONFIG({ .textColor = color }));
|
||||||
|
|
@ -323,7 +323,7 @@ void component_color_palette(void)
|
||||||
|
|
||||||
void component_unicode_text(void)
|
void component_unicode_text(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -377,7 +377,7 @@ void component_unicode_text(void)
|
||||||
|
|
||||||
void component_keybinds(void)
|
void component_keybinds(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -409,7 +409,7 @@ void component_keybinds(void)
|
||||||
|
|
||||||
void component_image(clay_tb_image *image, int width)
|
void component_image(clay_tb_image *image, int width)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = (0 == width) ? CLAY_SIZING_GROW() : CLAY_SIZING_FIXED(width),
|
.width = (0 == width) ? CLAY_SIZING_GROW() : CLAY_SIZING_FIXED(width),
|
||||||
|
|
@ -424,7 +424,7 @@ void component_image(clay_tb_image *image, int width)
|
||||||
|
|
||||||
void component_mouse_data(void)
|
void component_mouse_data(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -446,7 +446,7 @@ void component_mouse_data(void)
|
||||||
v = (255 < v) ? 255 : v;
|
v = (255 < v) ? 255 : v;
|
||||||
Clay_Color color = (Clay_Color) { v, v, v, 0xff };
|
Clay_Color color = (Clay_Color) { v, v, v, 0xff };
|
||||||
|
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = layout,
|
.layout = layout,
|
||||||
.backgroundColor = color
|
.backgroundColor = color
|
||||||
}) {}
|
}) {}
|
||||||
|
|
@ -457,7 +457,7 @@ void component_mouse_data(void)
|
||||||
color = (Clay_Color) { v, v, v, 0xff };
|
color = (Clay_Color) { v, v, v, 0xff };
|
||||||
|
|
||||||
|
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = layout,
|
.layout = layout,
|
||||||
.backgroundColor = color
|
.backgroundColor = color
|
||||||
}) {}
|
}) {}
|
||||||
|
|
@ -467,7 +467,7 @@ void component_mouse_data(void)
|
||||||
|
|
||||||
void component_bordered_text(void)
|
void component_bordered_text(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.sizing = {
|
.sizing = {
|
||||||
|
|
@ -478,25 +478,25 @@ void component_bordered_text(void)
|
||||||
},
|
},
|
||||||
.backgroundColor = { 0x24, 0x55, 0x34, 0xff },
|
.backgroundColor = { 0x24, 0x55, 0x34, 0xff },
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0xaa, 0x00, 0x00, 0xff } },
|
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0xaa, 0x00, 0x00, 0xff } },
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(
|
CLAY_TEXT(
|
||||||
CLAY_STRING("Test"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
CLAY_STRING("Test"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0xaa, 0x00, 0xff } },
|
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0xaa, 0x00, 0xff } },
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(CLAY_STRING("of the border width"),
|
CLAY_TEXT(CLAY_STRING("of the border width"),
|
||||||
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } },
|
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } },
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(CLAY_STRING("and overlap for multiple lines\nof text"),
|
CLAY_TEXT(CLAY_STRING("and overlap for multiple lines\nof text"),
|
||||||
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } }));
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } },
|
.border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } },
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(CLAY_STRING("this text\nis long enough\nto display all\n borders\naround it"),
|
CLAY_TEXT(CLAY_STRING("this text\nis long enough\nto display all\n borders\naround it"),
|
||||||
|
|
@ -508,7 +508,7 @@ void component_bordered_text(void)
|
||||||
Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image2)
|
Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image2)
|
||||||
{
|
{
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -522,7 +522,7 @@ Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image
|
||||||
},
|
},
|
||||||
.backgroundColor = { 0x24, 0x24, 0x24, 0xff }
|
.backgroundColor = { 0x24, 0x24, 0x24, 0xff }
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.childAlignment = {
|
.childAlignment = {
|
||||||
.x = CLAY_ALIGN_X_RIGHT,
|
.x = CLAY_ALIGN_X_RIGHT,
|
||||||
|
|
@ -534,7 +534,7 @@ Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image
|
||||||
component_keybinds();
|
component_keybinds();
|
||||||
component_unicode_text();
|
component_unicode_text();
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
.childGap = 32,
|
.childGap = 32,
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
};
|
};
|
||||||
Clay_TextElementConfig *textconfig =
|
Clay_TextElementConfig *textconfig =
|
||||||
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } });
|
CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } });
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = {
|
.width = {
|
||||||
|
|
@ -125,7 +125,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
CLAY_TEXT(keytext, textconfig);
|
CLAY_TEXT(keytext, textconfig);
|
||||||
CLAY({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { }
|
CLAY_AUTO_ID({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { }
|
||||||
CLAY_TEXT(valtext, textconfig);
|
CLAY_TEXT(valtext, textconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ void component_text_pair(const char *key, const char *value)
|
||||||
|
|
||||||
void component_termbox_settings(void)
|
void component_termbox_settings(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -264,7 +264,7 @@ void component_termbox_settings(void)
|
||||||
transparency = "false";
|
transparency = "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
.layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM },
|
||||||
}) {
|
}) {
|
||||||
component_text_pair("Color mode", color_mode);
|
component_text_pair("Color mode", color_mode);
|
||||||
|
|
@ -278,7 +278,7 @@ void component_termbox_settings(void)
|
||||||
|
|
||||||
void component_keybinds(void)
|
void component_keybinds(void)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = CLAY_SIZING_FIT(),
|
.sizing = CLAY_SIZING_FIT(),
|
||||||
.padding = {
|
.padding = {
|
||||||
|
|
@ -311,7 +311,7 @@ void component_keybinds(void)
|
||||||
|
|
||||||
void component_image(img_group *img_pair)
|
void component_image(img_group *img_pair)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -326,7 +326,7 @@ void component_image(img_group *img_pair)
|
||||||
},
|
},
|
||||||
.backgroundColor = { 0x24, 0x24, 0x24, 0xff }
|
.backgroundColor = { 0x24, 0x24, 0x24, 0xff }
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -343,7 +343,7 @@ void component_image(img_group *img_pair)
|
||||||
|
|
||||||
void component_image_small(img_group **img_pairs, int count, int selected_index)
|
void component_image_small(img_group **img_pairs, int count, int selected_index)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_PERCENT(0.25),
|
.width = CLAY_SIZING_PERCENT(0.25),
|
||||||
|
|
@ -356,7 +356,7 @@ void component_image_small(img_group **img_pairs, int count, int selected_index)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_PERCENT(0.7),
|
.width = CLAY_SIZING_PERCENT(0.7),
|
||||||
|
|
@ -367,7 +367,7 @@ void component_image_small(img_group **img_pairs, int count, int selected_index)
|
||||||
},
|
},
|
||||||
.aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height }
|
.aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height }
|
||||||
}) { }
|
}) { }
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -384,7 +384,7 @@ void component_image_small(img_group **img_pairs, int count, int selected_index)
|
||||||
|
|
||||||
void component_thumbnails(img_group **img_pairs, int count, int selected_index)
|
void component_thumbnails(img_group **img_pairs, int count, int selected_index)
|
||||||
{
|
{
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_PERCENT(0.1),
|
.width = CLAY_SIZING_PERCENT(0.1),
|
||||||
|
|
@ -407,7 +407,7 @@ void component_thumbnails(img_group **img_pairs, int count, int selected_index)
|
||||||
.width = CLAY_BORDER_OUTSIDE(0),
|
.width = CLAY_BORDER_OUTSIDE(0),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
@ -428,7 +428,7 @@ const int thumbnail_count = 5;
|
||||||
Clay_RenderCommandArray CreateLayout(struct img_group **imgs)
|
Clay_RenderCommandArray CreateLayout(struct img_group **imgs)
|
||||||
{
|
{
|
||||||
Clay_BeginLayout();
|
Clay_BeginLayout();
|
||||||
CLAY({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {
|
.sizing = {
|
||||||
.width = CLAY_SIZING_GROW(),
|
.width = CLAY_SIZING_GROW(),
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,15 @@
|
||||||
Unfortunately Clay does not currently provide feedback on whether a mouse
|
Unfortunately Clay does not currently provide feedback on whether a mouse
|
||||||
click was handled or not.
|
click was handled or not.
|
||||||
|
|
||||||
|
--- if you want to use images with clay, you should pass a pointer to a
|
||||||
|
sclay_image to the CLAY macro, like this:
|
||||||
|
CLAY({
|
||||||
|
...
|
||||||
|
.image = { .imageData = &(sclay_image){ .view = view, .sampler = 0 } },
|
||||||
|
})
|
||||||
|
Using 0 as a sampler uses the sokol default sampler with linear interpolation.
|
||||||
|
The image should be created using sg_make_image from sokol_gfx.
|
||||||
|
|
||||||
--- finally, on application shutdown, call
|
--- finally, on application shutdown, call
|
||||||
|
|
||||||
sclay_shutdown()
|
sclay_shutdown()
|
||||||
|
|
@ -101,6 +110,15 @@
|
||||||
|
|
||||||
typedef int sclay_font_t;
|
typedef int sclay_font_t;
|
||||||
|
|
||||||
|
typedef struct sclay_image {
|
||||||
|
sg_view view;
|
||||||
|
sg_sampler sampler;
|
||||||
|
struct {
|
||||||
|
float u0, v0, u1, v1;
|
||||||
|
} uv;
|
||||||
|
} sclay_image;
|
||||||
|
|
||||||
|
|
||||||
void sclay_setup();
|
void sclay_setup();
|
||||||
void sclay_shutdown();
|
void sclay_shutdown();
|
||||||
|
|
||||||
|
|
@ -247,6 +265,15 @@ static void _draw_rect(float x, float y, float w, float h){
|
||||||
sgl_v2f(x+w, y+h);
|
sgl_v2f(x+w, y+h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _draw_rect_textured(float x, float y, float w, float h, float u0, float v0, float u1, float v1){
|
||||||
|
sgl_v2f_t2f(x, y, u0, v0);
|
||||||
|
sgl_v2f_t2f(x, y, u0, v0);
|
||||||
|
sgl_v2f_t2f(x+w, y, u1, v0);
|
||||||
|
sgl_v2f_t2f(x, y+h, u0, v1);
|
||||||
|
sgl_v2f_t2f(x+w, y+h, u1, v1);
|
||||||
|
sgl_v2f_t2f(x+w, y+h, u1, v1);
|
||||||
|
}
|
||||||
|
|
||||||
static float _SIN[16] = {
|
static float _SIN[16] = {
|
||||||
0.000000f, 0.104528f, 0.207912f, 0.309017f,
|
0.000000f, 0.104528f, 0.207912f, 0.309017f,
|
||||||
0.406737f, 0.500000f, 0.587785f, 0.669131f,
|
0.406737f, 0.500000f, 0.587785f, 0.669131f,
|
||||||
|
|
@ -266,6 +293,23 @@ static void _draw_corner(float x, float y, float rx, float ry){
|
||||||
sgl_v2f(x+(rx*_SIN[0]), y+(ry*_SIN[15]));
|
sgl_v2f(x+(rx*_SIN[0]), y+(ry*_SIN[15]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _draw_corner_textured(float x, float y, float rx, float ry, float bx, float by, float bw, float bh, float u0, float v0, float u1, float v1) {
|
||||||
|
x -= rx;
|
||||||
|
y -= ry;
|
||||||
|
#define MAP_U(x) (u0+(((x)-bx)/bw)*(u1-u0))
|
||||||
|
#define MAP_V(y) (v0+(((y)-by)/bh)*(v1-v0))
|
||||||
|
sgl_v2f_t2f(x, y, MAP_U(x), MAP_V(y));
|
||||||
|
for(int i = 0; i < 16; ++i){
|
||||||
|
sgl_v2f_t2f(x, y, MAP_U(x), MAP_V(y));
|
||||||
|
float px = x+(rx*_SIN[15-i]);
|
||||||
|
float py = y+(ry*_SIN[i]);
|
||||||
|
sgl_v2f_t2f(px, py, MAP_U(px), MAP_V(py));
|
||||||
|
}
|
||||||
|
sgl_v2f_t2f(x+(rx*_SIN[0]), y+(ry*_SIN[15]), MAP_U(x+(rx*_SIN[0])), MAP_V(y+(ry*_SIN[15])));
|
||||||
|
#undef MAP_U
|
||||||
|
#undef MAP_V
|
||||||
|
}
|
||||||
|
|
||||||
/* rx,ry = radius ix,iy = inner radius */
|
/* rx,ry = radius ix,iy = inner radius */
|
||||||
static void _draw_corner_border(float x, float y, float rx, float ry, float ix, float iy){
|
static void _draw_corner_border(float x, float y, float rx, float ry, float ix, float iy){
|
||||||
x -= rx;
|
x -= rx;
|
||||||
|
|
@ -390,7 +434,108 @@ void sclay_render(Clay_RenderCommandArray renderCommands, sclay_font_t *fonts) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CLAY_RENDER_COMMAND_TYPE_IMAGE: {
|
case CLAY_RENDER_COMMAND_TYPE_IMAGE: {
|
||||||
//TODO
|
Clay_ImageRenderData *config = &renderCommand->renderData.image;
|
||||||
|
sclay_image* img = (sclay_image*)config->imageData;
|
||||||
|
// by default, u1 and v1 are 1. if we pass 0.
|
||||||
|
// note, we are modifying a copy !
|
||||||
|
float u0 = img->uv.u0;
|
||||||
|
float v0 = img->uv.v0;
|
||||||
|
float u1 = img->uv.u1;
|
||||||
|
float v1 = img->uv.v1;
|
||||||
|
if (u1 == 0.f) {
|
||||||
|
u1 = 1.f;
|
||||||
|
}
|
||||||
|
if (v1 == 0.f) {
|
||||||
|
v1 = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int untinted = config->backgroundColor.r == 0 && config->backgroundColor.g == 0 && config->backgroundColor.b == 0 && config->backgroundColor.a == 0;
|
||||||
|
float cr = untinted ? 1.f : (config->backgroundColor.r / 255.0f);
|
||||||
|
float gr = untinted ? 1.f : (config->backgroundColor.g / 255.0f);
|
||||||
|
float br = untinted ? 1.f : (config->backgroundColor.b / 255.0f);
|
||||||
|
float ar = untinted ? 1.f : (config->backgroundColor.a / 255.0f);
|
||||||
|
|
||||||
|
sgl_c4f(cr, gr, br, ar);
|
||||||
|
|
||||||
|
Clay_CornerRadius r = config->cornerRadius;
|
||||||
|
|
||||||
|
sgl_enable_texture();
|
||||||
|
sgl_texture(img->view, img->sampler);
|
||||||
|
|
||||||
|
sgl_begin_triangle_strip();
|
||||||
|
if(r.topLeft > 0 || r.topRight > 0){
|
||||||
|
_draw_corner_textured(bbox.x, bbox.y, -r.topLeft, -r.topLeft, bbox.x, bbox.y, bbox.width, bbox.height, u0, v0, u1, v1);
|
||||||
|
_draw_corner_textured(bbox.x+bbox.width, bbox.y, r.topRight, -r.topRight, bbox.x, bbox.y, bbox.width, bbox.height, u0, v0, u1, v1);
|
||||||
|
_draw_rect_textured(bbox.x+r.topLeft, bbox.y,
|
||||||
|
bbox.width-r.topLeft-r.topRight, CLAY__MAX(r.topLeft, r.topRight),
|
||||||
|
u0 + (r.topLeft/bbox.width)*(u1-u0), v0, u1 - (r.topRight/bbox.width)*(u1-u0), v0 + (CLAY__MAX(r.topLeft, r.topRight)/bbox.height)*(v1-v0));
|
||||||
|
}
|
||||||
|
if(r.bottomLeft > 0 || r.bottomRight > 0){
|
||||||
|
_draw_corner_textured(bbox.x, bbox.y+bbox.height, -r.bottomLeft, r.bottomLeft, bbox.x, bbox.y, bbox.width, bbox.height, u0, v0, u1, v1);
|
||||||
|
_draw_corner_textured(bbox.x+bbox.width, bbox.y+bbox.height, r.bottomRight, r.bottomRight, bbox.x, bbox.y, bbox.width, bbox.height, u0, v0, u1, v1);
|
||||||
|
_draw_rect_textured(bbox.x+r.bottomLeft,
|
||||||
|
bbox.y+bbox.height-CLAY__MAX(r.bottomLeft, r.bottomRight),
|
||||||
|
bbox.width-r.bottomLeft-r.bottomRight, CLAY__MAX(r.bottomLeft, r.bottomRight),
|
||||||
|
u0 + (r.bottomLeft/bbox.width)*(u1-u0), v1 - (CLAY__MAX(r.bottomLeft, r.bottomRight)/bbox.height)*(v1-v0), u1 - (r.bottomRight/bbox.width)*(u1-u0), v1);
|
||||||
|
}
|
||||||
|
if(r.topLeft < r.bottomLeft){
|
||||||
|
if(r.topLeft < r.topRight){
|
||||||
|
_draw_rect_textured(bbox.x, bbox.y+r.topLeft, r.topLeft, bbox.height-r.topLeft-r.bottomLeft,
|
||||||
|
u0, v0 + (r.topLeft/bbox.height)*(v1-v0), u0 + (r.topLeft/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
_draw_rect_textured(bbox.x+r.topLeft, bbox.y+r.topRight,
|
||||||
|
r.bottomLeft-r.topLeft, bbox.height-r.topRight-r.bottomLeft,
|
||||||
|
u0 + (r.topLeft/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u0 + (r.topLeft/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
} else {
|
||||||
|
_draw_rect_textured(bbox.x, bbox.y+r.topLeft, r.bottomLeft, bbox.height-r.topLeft-r.bottomLeft,
|
||||||
|
u0, v0 + (r.topLeft/bbox.height)*(v1-v0), u0 + (r.bottomLeft/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(r.bottomLeft < r.bottomRight){
|
||||||
|
_draw_rect_textured(bbox.x, bbox.y+r.topLeft, r.bottomLeft, bbox.height-r.topLeft-r.bottomLeft,
|
||||||
|
u0, v0 + (r.topLeft/bbox.height)*(v1-v0), u0 + (r.bottomLeft/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
_draw_rect_textured(bbox.x+r.bottomLeft, bbox.y+r.topLeft,
|
||||||
|
r.topLeft-r.bottomLeft, bbox.height-r.topLeft-r.bottomRight,
|
||||||
|
u0 + (r.bottomLeft/bbox.width)*(u1-u0), v0 + (r.topLeft/bbox.height)*(v1-v0), u0 + (r.topLeft/bbox.width)*(u1-u0), v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
} else {
|
||||||
|
_draw_rect_textured(bbox.x, bbox.y+r.topLeft, r.topLeft, bbox.height-r.topLeft-r.bottomLeft,
|
||||||
|
u0, v0 + (r.topLeft/bbox.height)*(v1-v0), u0 + (r.topLeft/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(r.topRight < r.bottomRight){
|
||||||
|
if(r.topRight < r.topLeft){
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.bottomRight, bbox.y+r.topLeft,
|
||||||
|
r.bottomRight-r.topRight, bbox.height-r.topLeft-r.bottomRight,
|
||||||
|
u1 - (r.bottomRight/bbox.width)*(u1-u0), v0 + (r.topLeft/bbox.height)*(v1-v0), u1 - (r.topRight/bbox.width)*(u1-u0), v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.topRight, bbox.y+r.topRight,
|
||||||
|
r.topRight, bbox.height-r.topRight-r.bottomRight,
|
||||||
|
u1 - (r.topRight/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u1, v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
} else {
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.bottomRight, bbox.y+r.topRight,
|
||||||
|
r.bottomRight, bbox.height-r.topRight-r.bottomRight,
|
||||||
|
u1 - (r.bottomRight/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u1, v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(r.bottomRight < r.bottomLeft){
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.topRight, bbox.y+r.topRight,
|
||||||
|
r.topRight-r.bottomRight, bbox.height-r.topRight-r.bottomLeft,
|
||||||
|
u1 - (r.topRight/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u1 - (r.bottomRight/bbox.width)*(u1-u0), v1 - (r.bottomLeft/bbox.height)*(v1-v0));
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.bottomRight, bbox.y+r.topRight,
|
||||||
|
r.bottomRight, bbox.height-r.topRight-r.bottomRight,
|
||||||
|
u1 - (r.bottomRight/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u1, v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
} else {
|
||||||
|
_draw_rect_textured(bbox.x+bbox.width-r.topRight, bbox.y+r.topRight,
|
||||||
|
r.topRight, bbox.height-r.topRight-r.bottomRight,
|
||||||
|
u1 - (r.topRight/bbox.width)*(u1-u0), v0 + (r.topRight/bbox.height)*(v1-v0), u1, v1 - (r.bottomRight/bbox.height)*(v1-v0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_draw_rect_textured(bbox.x+CLAY__MAX(r.topLeft, r.bottomLeft),
|
||||||
|
bbox.y+CLAY__MAX(r.topLeft, r.topRight),
|
||||||
|
bbox.width-CLAY__MAX(r.topLeft, r.bottomLeft)-CLAY__MAX(r.topRight, r.bottomRight),
|
||||||
|
bbox.height-CLAY__MAX(r.topLeft, r.topRight)-CLAY__MAX(r.bottomLeft, r.bottomRight),
|
||||||
|
u0+CLAY__MAX(r.topLeft,r.bottomLeft)/bbox.width*(u1-u0), v0+CLAY__MAX(r.topLeft,r.topRight)/bbox.height*(v1-v0),
|
||||||
|
u1-CLAY__MAX(r.topRight,r.bottomRight)/bbox.width*(u1-u0), v1-CLAY__MAX(r.bottomLeft,r.bottomRight)/bbox.height*(v1-v0));
|
||||||
|
sgl_end();
|
||||||
|
sgl_disable_texture();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CLAY_RENDER_COMMAND_TYPE_BORDER: {
|
case CLAY_RENDER_COMMAND_TYPE_BORDER: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue