diff --git a/examples/SDL3-simple-demo/main.c b/examples/SDL3-simple-demo/main.c index f9d227c..78bc123 100644 --- a/examples/SDL3-simple-demo/main.c +++ b/examples/SDL3-simple-demo/main.c @@ -55,10 +55,10 @@ Clay_RenderCommandArray ClayImageSample_CreateLayout() { CLAY(CLAY_ID("OuterContainer"), { .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = layoutExpand, .padding = CLAY_PADDING_ALL(16), - .childGap = 16 + .childGap = 16, + .layoutDirection = CLAY_TOP_TO_BOTTOM, } }) { CLAY(CLAY_ID("SampleImage"), { diff --git a/examples/cairo-pdf-rendering/main.c b/examples/cairo-pdf-rendering/main.c index 3c0946d..1b7218a 100644 --- a/examples/cairo-pdf-rendering/main.c +++ b/examples/cairo-pdf-rendering/main.c @@ -47,35 +47,35 @@ void Layout() { }) { CLAY(CLAY_ID("PageMargins"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = { 70, 70, 50, 50 }, // Some nice looking page margins - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .childGap = 10} + .childGap = 10, + .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { // Section Title - 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({ .textColor = PRIMARY, .fontId = FONT_CALLISTOGA, .fontSize = 24 })); // Feature Box CLAY_AUTO_ID({ .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) }}, .backgroundColor = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(12) }) { CLAY_AUTO_ID({ .layout = {.padding = CLAY_PADDING_ALL(20), .childGap = 4, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) { CLAY_TEXT(CLAY_STRING("- High performance"), - CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND })); + CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 14 })); CLAY_TEXT(CLAY_STRING("- Declarative syntax"), - CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND })); + CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 14 })); CLAY_TEXT(CLAY_STRING("- Flexbox-style responsive layout"), - CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND })); + CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 14 })); CLAY_TEXT(CLAY_STRING("- Single .h file for C/C++"), - CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND })); + CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 14 })); CLAY_TEXT(CLAY_STRING("- And now with cairo!"), - CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontSize = 14, .fontId = FONT_QUICKSAND })); + CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 14 })); } } CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)}, .padding = CLAY_PADDING_ALL(10), - .layoutDirection = CLAY_TOP_TO_BOTTOM, + .childGap = 4, .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }, - .childGap = 4 + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, .backgroundColor = ACCENT, .cornerRadius = CLAY_CORNER_RADIUS(8) @@ -84,9 +84,10 @@ void Layout() { CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_FIT(0), CLAY_SIZING_GROW(0)}, .padding = { 30, 30, 0, 0 }, - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }}, - .border = { .color = PRIMARY, .width = 2, 2, 2, 2 }, .cornerRadius = 10 + .childAlignment = { CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER }, + .layoutDirection = CLAY_TOP_TO_BOTTOM}, + .cornerRadius = {10}, + .border = { .color = PRIMARY, .width = {2, 2, 2, 2} } }) { CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_FIXED(32), CLAY_SIZING_FIXED(32) } }, .image = { .imageData = "resources/check.png" }}); } @@ -96,13 +97,13 @@ void Layout() { CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(16) } }}); 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_AUTO_ID({ .layout = { .padding = CLAY_PADDING_ALL(10) }, .backgroundColor = ACCENT, .cornerRadius = 10 }) { + CLAY_TEXT(CLAY_STRING("Cairo"), CLAY_TEXT_CONFIG({ .textColor = PRIMARY,.fontId = FONT_CALLISTOGA, .fontSize = 24 })); + 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. " "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. " "Corporis deserunt eum mollitia modi rerum voluptas. Expedita non ab esse. Sit voluptates eos voluptatem labore aspernatur quia eum. Modi cumque atque non. Sunt officiis corrupti neque ut inventore excepturi rem minima. Possimus sed soluta qui ea aut ipsum laborum fugit. " - "Voluptate eum consectetur non. Quo autem voluptate soluta atque dolorum maxime. Officiis inventore omnis eveniet beatae ipsa optio. Unde voluptatum ut autem quia sit sit et. Ut inventore qui quia totam consequatur. Sit ea consequatur omnis rerum nulla aspernatur deleniti."), CLAY_TEXT_CONFIG({ .fontId = FONT_QUICKSAND, .fontSize = 16, .textColor = PRIMARY, .lineHeight = 16 })); + "Voluptate eum consectetur non. Quo autem voluptate soluta atque dolorum maxime. Officiis inventore omnis eveniet beatae ipsa optio. Unde voluptatum ut autem quia sit sit et. Ut inventore qui quia totam consequatur. Sit ea consequatur omnis rerum nulla aspernatur deleniti."), CLAY_TEXT_CONFIG({ .textColor = PRIMARY, .fontId = FONT_QUICKSAND, .fontSize = 16, .lineHeight = 16 })); } } } @@ -138,9 +139,9 @@ int main(void) { Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize)); // We initialize Clay with the same size - Clay_Initialize(clayMemory, (Clay_Dimensions) { width, height }, (Clay_ErrorHandler) { HandleClayErrors }); + Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)width, (float)height }, (Clay_ErrorHandler) { HandleClayErrors }); - char** fonts = (char*[]) { + const char* fonts[2] = { "Callistoga", "Quicksand Semibold" }; @@ -168,4 +169,3 @@ int main(void) { cairo_destroy(cr); return 0; } - diff --git a/examples/clay-official-website/main.c b/examples/clay-official-website/main.c index 160c94c..061dbfe 100644 --- a/examples/clay-official-website/main.c +++ b/examples/clay-official-website/main.c @@ -34,8 +34,8 @@ const Clay_Color COLOR_BLOB_BORDER_5 = (Clay_Color) {240, 189, 100, 255}; #define RAYLIB_VECTOR2_TO_CLAY_VECTOR2(vector) (Clay_Vector2) { .x = (vector).x, .y = (vector).y } -Clay_TextElementConfig headerTextConfig = (Clay_TextElementConfig) { .fontId = 2, .fontSize = 24, .textColor = {61, 26, 5, 255} }; -Clay_TextElementConfig blobTextConfig = (Clay_TextElementConfig) { .fontId = 2, .fontSize = 30, .textColor = {244, 235, 230, 255} }; +Clay_TextElementConfig headerTextConfig = (Clay_TextElementConfig) { .textColor = {61, 26, 5, 255}, .fontId = 2, .fontSize = 24 }; +Clay_TextElementConfig blobTextConfig = (Clay_TextElementConfig) { .textColor = {244, 235, 230, 255}, .fontId = 2, .fontSize = 30 }; typedef struct { void* memory; @@ -51,35 +51,35 @@ typedef struct d { } CustomHTMLData; CustomHTMLData* FrameAllocateCustomData(CustomHTMLData data) { - CustomHTMLData *customData = (CustomHTMLData *)(frameArena.memory + frameArena.offset); + CustomHTMLData *customData = (CustomHTMLData *)((uintptr_t)frameArena.memory + frameArena.offset); *customData = data; frameArena.offset += sizeof(CustomHTMLData); return customData; } Clay_String* FrameAllocateString(Clay_String string) { - Clay_String *allocated = (Clay_String *)(frameArena.memory + frameArena.offset); + Clay_String *allocated = (Clay_String *)((uintptr_t)frameArena.memory + frameArena.offset); *allocated = string; frameArena.offset += sizeof(Clay_String); return allocated; } void LandingPageBlob(int index, int fontSize, Clay_Color color, Clay_String text, Clay_String imageURL) { - 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(CLAY_IDI("HeroBlob", index), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 480) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .cornerRadius = CLAY_CORNER_RADIUS(10) , .border = { .color = color, .width = { 2, 2, 2, 2 }}}) { 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({ .textColor = color, .fontId = FONT_ID_BODY_24, .fontSize = (uint16_t)fontSize })); } } void LandingPageDesktop() { - 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(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("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(CLAY_ID("LandingPage1Desktop"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = (float)windowHeight - 70) }, .padding = { 50, 50 } , .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}} }) { + CLAY(CLAY_ID("LandingPage1"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 , .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}}, .border = { .color = COLOR_RED, .width = { .left = 2, .right = 2 }} }) { + CLAY(CLAY_ID("LeftText"), { .layout = { .sizing = { .width = CLAY_SIZING_PERCENT(0.55f) }, .childGap = 8 , .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + 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({ .textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 56 })); 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({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_TITLE_36, .fontSize = 36 })); } - CLAY(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 = { .sizing = { .width = CLAY_SIZING_PERCENT(0.45f) }, .childGap = 16 , .childAlignment = { CLAY_ALIGN_X_CENTER }, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { 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(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() { - 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(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(CLAY_ID("LandingPage1Mobile"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(.min = (float)windowHeight - 70) }, .padding = { 16, 16, 32, 32 }, .childGap = 32, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY(CLAY_ID("LeftText"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { + 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({ .textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 48 })); 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({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_TITLE_36, .fontSize = 32 })); } - CLAY(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 = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .childGap = 16, .childAlignment = { CLAY_ALIGN_X_CENTER }, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { 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(3, 28, COLOR_BLOB_BORDER_3, CLAY_STRING("Declarative syntax"), CLAY_STRING("/clay/images/check_3.png")); @@ -109,17 +109,17 @@ void LandingPageMobile() { void FeatureBlocksDesktop() { CLAY(CLAY_ID("FeatureBlocksOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) } } }) { - 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(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("FeatureBlocksInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .border = {.color = COLOR_RED, .width = { .betweenChildren = 2 }} }) { + Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({.textColor = COLOR_RED, .fontId = FONT_ID_BODY_24, .fontSize = 24 }); + CLAY(CLAY_ID("HFileBoxOuter"), { .layout = {.sizing = { CLAY_SIZING_PERCENT(0.5f)}, .padding = {50, 50, 32, 32}, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { 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({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_24, .fontSize = 24 })); } CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig); CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig); } - 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(CLAY_ID("BringYourOwnRendererOuter"), { .layout = {.sizing = { CLAY_SIZING_PERCENT(0.5f) }, .padding = {50, 50, 32, 32}, .childGap = 8, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_BODY_24, .fontSize = 24 })); 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); } @@ -128,17 +128,17 @@ void FeatureBlocksDesktop() { } void FeatureBlocksMobile() { - 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(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("FeatureBlocksInner"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM}, .border = { .color = COLOR_RED, .width = { .betweenChildren = 2 }} }) { + Clay_TextElementConfig *textConfig = CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_24, .fontSize = 24}); + CLAY(CLAY_ID("HFileBoxOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW() }, .padding = {16, 16, 32, 32}, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { 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({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_24, .fontSize = 24 })); } CLAY_TEXT(CLAY_STRING("~2000 lines of C99."), textConfig); CLAY_TEXT(CLAY_STRING("Zero dependencies, including no C standard library."), textConfig); } - 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(CLAY_ID("BringYourOwnRendererOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .padding = {16, 16, 32, 32}, .childGap = 8 , .childAlignment = { .y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Renderer agnostic."), CLAY_TEXT_CONFIG({.textColor = COLOR_ORANGE, .fontId = FONT_ID_BODY_24, .fontSize = 24})); 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); } @@ -146,14 +146,14 @@ void FeatureBlocksMobile() { } void DeclarativeSyntaxPageDesktop() { - 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(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("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(CLAY_ID("SyntaxPageDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = { 50, 50 }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER} } }) { + CLAY(CLAY_ID("SyntaxPage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(32), .childGap = 32, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .border = { .color = COLOR_RED, .width = { .left = 2, .right = 2 }}}) { + CLAY(CLAY_ID("SyntaxPageLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 52 })); 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("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("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } CLAY(CLAY_ID("SyntaxPageRightImage"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) { 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")) } }) {} @@ -163,13 +163,13 @@ void DeclarativeSyntaxPageDesktop() { } void DeclarativeSyntaxPageMobile() { - 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(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(CLAY_ID("SyntaxPageDesktop"), { .layout = {.sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = {16, 16, 32, 32}, .childGap = 16, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { + CLAY(CLAY_ID("SyntaxPageLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { + CLAY_TEXT(CLAY_STRING("Declarative Syntax"), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 48 })); 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("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("Flexible and readable declarative syntax with nested UI element hierarchies."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28})); + CLAY_TEXT(CLAY_STRING("Mix elements with standard C code like loops, conditionals and functions."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Create your own library of re-usable components from UI primitives like text, images and rectangles."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } CLAY(CLAY_ID("SyntaxPageRightImage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {.x = CLAY_ALIGN_X_CENTER} } }) { 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,21 +189,21 @@ 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."); void HighPerformancePageDesktop(float lerpValue) { - 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(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(CLAY_ID("PerformanceOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = {82, 82, 32, 32}, .childGap = 64, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = COLOR_RED }) { + CLAY(CLAY_ID("PerformanceLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { + CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 52 })); 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("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("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({.textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } CLAY(CLAY_ID("PerformanceRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) { - CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = {2, 2, 2, 2}, .color = COLOR_LIGHT } }) { - 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_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .color = COLOR_LIGHT, .width = {2, 2, 2, 2} } }) { + CLAY(CLAY_ID("AnimationDemoContainerLeft"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.3f + 0.4f * lerpValue), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(32), .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) { + CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 24 })); } - 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(CLAY_ID("AnimationDemoContainerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(32), .childAlignment = {.y = CLAY_ALIGN_Y_CENTER}}, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) { + CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 24 })); } } } @@ -211,21 +211,21 @@ void HighPerformancePageDesktop(float lerpValue) { } void HighPerformancePageMobile(float lerpValue) { - 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(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(CLAY_ID("PerformanceOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = {16, 16, 32, 32}, .childGap = 32, .childAlignment = {CLAY_ALIGN_X_CENTER, CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = COLOR_RED }) { + CLAY(CLAY_ID("PerformanceLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { + CLAY_TEXT(CLAY_STRING("High Performance"), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 48 })); 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("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("Fast enough to recompute your entire UI every frame."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28})); + CLAY_TEXT(CLAY_STRING("Small memory footprint (3.5mb default) with static allocation & reuse. No malloc / free."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("Simplify animations and reactive UI design by avoiding the standard performance hacks."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } CLAY(CLAY_ID("PerformanceRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) { - CLAY_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .width = { 2, 2, 2, 2 }, .color = COLOR_LIGHT }}) { - 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_AUTO_ID({ .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(400) } }, .border = { .color = COLOR_LIGHT, .width = { 2, 2, 2, 2 }}}) { + CLAY(CLAY_ID("AnimationDemoContainerLeft"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.35f + 0.3f * lerpValue), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = ColorLerp(COLOR_RED, COLOR_ORANGE, lerpValue) }) { + CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 24 })); } - 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(CLAY_ID("AnimationDemoContainerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childAlignment = {.y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = ColorLerp(COLOR_ORANGE, COLOR_RED, lerpValue) }) { + CLAY_TEXT(LOREM_IPSUM_TEXT, CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56, .fontSize = 24 })); } } } @@ -245,37 +245,37 @@ void RendererButtonActive(Clay_String text) { .layout = { .sizing = {CLAY_SIZING_FIXED(300) }, .padding = CLAY_PADDING_ALL(16) }, .backgroundColor = Clay_Hovered() ? COLOR_RED_HOVER : COLOR_RED, .cornerRadius = CLAY_CORNER_RADIUS(10), - .userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true, .cursorPointer = true }) + .userData = FrameAllocateCustomData((CustomHTMLData) { .cursorPointer = true, .disablePointerEvents = true}) }) { - CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_LIGHT })); + CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } } void RendererButtonInactive(Clay_String text, size_t rendererIndex) { CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_FIXED(300)}, .padding = CLAY_PADDING_ALL(16) }, - .border = { .width = {2, 2, 2, 2}, .color = COLOR_RED }, .backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT, .cornerRadius = CLAY_CORNER_RADIUS(10), - .userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true, .cursorPointer = true }) + .border = { .color = COLOR_RED, .width = {2, 2, 2, 2} }, + .userData = FrameAllocateCustomData((CustomHTMLData) { .cursorPointer = true, .disablePointerEvents = true }), }) { Clay_OnHover(HandleRendererButtonInteraction, rendererIndex); - CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED })); + CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } } void RendererPageDesktop() { - 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(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("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(CLAY_ID("RendererPageDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = { 50, 50 }, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER} } }) { + CLAY(CLAY_ID("RendererPage"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(32), .childGap = 32 , .childAlignment = { .y = CLAY_ALIGN_Y_CENTER }}, .border = { .color = COLOR_RED, .width = { .left = 2, .right = 2 } } }) { + CLAY(CLAY_ID("RendererLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childGap = 8, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({.textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 52})); 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("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("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28})); + 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({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); } - 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(CLAY_ID("RendererRightText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childGap = 16, .childAlignment = {CLAY_ALIGN_X_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_BODY_36, .fontSize = 36 })); CLAY(CLAY_ID("RendererSpacerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) } } }) {} if (ACTIVE_RENDERER_INDEX == 0) { RendererButtonActive(CLAY_STRING("HTML Renderer")); @@ -290,16 +290,16 @@ void RendererPageDesktop() { } void RendererPageMobile() { - 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(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(CLAY_ID("RendererMobile"), { .layout = {.sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = { 16, 16, 32, 32}, .childGap = 32, .childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, .layoutDirection = CLAY_TOP_TO_BOTTOM}, .backgroundColor = COLOR_LIGHT }) { + CLAY(CLAY_ID("RendererLeftText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childGap = 8 , .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Renderer & Platform Agnostic"), CLAY_TEXT_CONFIG({.textColor = COLOR_RED, .fontId = FONT_ID_TITLE_56, .fontSize = 48 })); 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("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("Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE."), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + 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({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28})); + CLAY_TEXT(CLAY_STRING("There's even an HTML renderer - you're looking at it right now!"), CLAY_TEXT_CONFIG({ .textColor = COLOR_RED, .fontId = FONT_ID_BODY_36, .fontSize = 28})); } - 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(CLAY_ID("RendererRightText"), { .layout = { .sizing = { CLAY_SIZING_GROW(0) }, .childGap = 16 , .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Try changing renderer!"), CLAY_TEXT_CONFIG({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_BODY_36, .fontSize = 36})); CLAY(CLAY_ID("RendererSpacerRight"), { .layout = { .sizing = { CLAY_SIZING_GROW(.max = 32) }} }) {} if (ACTIVE_RENDERER_INDEX == 0) { RendererButtonActive(CLAY_STRING("HTML Renderer")); @@ -313,14 +313,14 @@ void RendererPageMobile() { } void DebuggerPageDesktop() { - 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(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(CLAY_ID("DebuggerDesktop"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIT(.min = (float)windowHeight - 50) }, .padding = { 82, 82, 32, 32 }, .childGap = 64,.childAlignment = { .y = CLAY_ALIGN_Y_CENTER} }, .backgroundColor = COLOR_RED }) { + CLAY(CLAY_ID("DebuggerLeftText"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.5) }, .childGap = 8 , .layoutDirection = CLAY_TOP_TO_BOTTOM} }) { + CLAY_TEXT(CLAY_STRING("Integrated Debug Tools"), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_TITLE_56,.fontSize = 52 })); 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("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("Clay includes built in \"Chrome Inspector\"-style debug tooling."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); + CLAY_TEXT(CLAY_STRING("View your layout hierarchy and config in real time."), CLAY_TEXT_CONFIG({ .textColor = COLOR_LIGHT, .fontId = FONT_ID_BODY_36, .fontSize = 28 })); 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({ .textColor = COLOR_ORANGE, .fontId = FONT_ID_TITLE_36, .fontSize = 32 })); } CLAY(CLAY_ID("DebuggerRightImageOuter"), { .layout = { .sizing = { CLAY_SIZING_PERCENT(0.50) }, .childAlignment = {CLAY_ALIGN_X_CENTER} } }) { 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,8 +340,8 @@ float animationLerpValue = -1.0f; Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) { Clay_BeginLayout(); - CLAY(CLAY_ID("OuterContainer"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) { - 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(CLAY_ID("OuterContainer"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = COLOR_LIGHT }) { + CLAY(CLAY_ID("Header"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(50) }, .padding = { 32, 32 } , .childGap = 16, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER }} }) { CLAY_TEXT(CLAY_STRING("Clay"), &headerTextConfig); CLAY(CLAY_ID("Spacer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) } } }) {} if (!mobileScreen) { @@ -350,36 +350,42 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) { .userData = FrameAllocateCustomData((CustomHTMLData) { .link = CLAY_STRING("https://github.com/nicbarker/clay/tree/main/examples") }), - .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} })); + .textColor = {61, 26, 5, 255}, + .fontId = FONT_ID_BODY_24, .fontSize = 24 })); } CLAY(CLAY_ID("LinkDocsOuter"), { .layout = { .padding = {8, 8} } }) { CLAY_TEXT(CLAY_STRING("Docs"), CLAY_TEXT_CONFIG({ .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} }) + .textColor = {61, 26, 5, 255}, + .fontId = FONT_ID_BODY_24, .fontSize = 24 }) ); } } CLAY_AUTO_ID({ .layout = { .padding = {16, 16, 6, 6} }, .backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT, - .border = { .width = {2, 2, 2, 2}, .color = COLOR_RED }, .cornerRadius = CLAY_CORNER_RADIUS(10), + .border = {.color = COLOR_RED, .width = {2, 2, 2, 2}}, .userData = FrameAllocateCustomData((CustomHTMLData) { .link = CLAY_STRING("https://discord.gg/b4FTWkxdvT") }), }) { CLAY_TEXT(CLAY_STRING("Discord"), CLAY_TEXT_CONFIG({ .userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true }), - .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} })); + .textColor = {61, 26, 5, 255}, + .fontId = FONT_ID_BODY_24, .fontSize = 24 })); } CLAY_AUTO_ID({ .layout = { .padding = {16, 16, 6, 6} }, .backgroundColor = Clay_Hovered() ? COLOR_LIGHT_HOVER : COLOR_LIGHT, - .border = { .width = {2, 2, 2, 2}, .color = COLOR_RED }, .cornerRadius = CLAY_CORNER_RADIUS(10), + .border = { .color = COLOR_RED, .width = {2, 2, 2, 2} }, .userData = FrameAllocateCustomData((CustomHTMLData) { .link = CLAY_STRING("https://github.com/nicbarker/clay") }), }) { CLAY_TEXT(CLAY_STRING("Github"), CLAY_TEXT_CONFIG({ .userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true }), - .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {61, 26, 5, 255} })); + .textColor = {61, 26, 5, 255}, + .fontId = FONT_ID_BODY_24, + .fontSize = 24, + })); } } Clay_LayoutConfig topBorderConfig = (Clay_LayoutConfig) { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_FIXED(4) }}; @@ -391,7 +397,7 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) { CLAY(CLAY_ID("OuterScrollContainer"), { .layout = { .sizing = { CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0) }, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }, - .border = { .width = { .betweenChildren = 2 }, .color = COLOR_RED } + .border = { .color = COLOR_RED , .width = { .betweenChildren = 2 }} }) { if (mobileScreen) { LandingPageMobile(); @@ -420,10 +426,10 @@ Clay_RenderCommandArray CreateLayout(bool mobileScreen, float lerpValue) { } float scrollHeight = scrollData.scrollContainerDimensions.height - 12; CLAY(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 }, .layout = { .sizing = {CLAY_SIZING_FIXED(10), CLAY_SIZING_FIXED((scrollHeight / scrollData.contentDimensions.height) * scrollHeight)} }, .backgroundColor = scrollbarColor, - .cornerRadius = CLAY_CORNER_RADIUS(5) + .cornerRadius = CLAY_CORNER_RADIUS(5), + .floating = { .offset = { .x = -6, .y = -(scrollData.scrollPosition->y / scrollData.contentDimensions.height) * scrollHeight + 6}, .parentId = Clay_GetElementId(CLAY_STRING("OuterScrollContainer")).id, .zIndex = 1, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP }, .attachTo = CLAY_ATTACH_TO_PARENT }, }) {} } return Clay_EndLayout(); diff --git a/examples/introducing-clay-video-demo/main.c b/examples/introducing-clay-video-demo/main.c index 89dd50f..2016a70 100644 --- a/examples/introducing-clay-video-demo/main.c +++ b/examples/introducing-clay-video-demo/main.c @@ -14,8 +14,8 @@ int main(void) { uint64_t clayRequiredMemory = Clay_MinMemorySize(); Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory)); Clay_Initialize(clayMemory, (Clay_Dimensions) { - .width = GetScreenWidth(), - .height = GetScreenHeight() + .width = (float)GetScreenWidth(), + .height = (float)GetScreenHeight() }, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published Font fonts[1]; fonts[FONT_ID_BODY_16] = LoadFontEx("resources/Roboto-Regular.ttf", 48, 0, 400); @@ -27,8 +27,8 @@ int main(void) { while (!WindowShouldClose()) { // Run once per frame Clay_SetLayoutDimensions((Clay_Dimensions) { - .width = GetScreenWidth(), - .height = GetScreenHeight() + .width = (float)GetScreenWidth(), + .height = (float)GetScreenHeight() }); Vector2 mousePosition = GetMousePosition(); diff --git a/examples/playdate-project-example/clay-video-demo-playdate.c b/examples/playdate-project-example/clay-video-demo-playdate.c index 190c637..69e237d 100644 --- a/examples/playdate-project-example/clay-video-demo-playdate.c +++ b/examples/playdate-project-example/clay-video-demo-playdate.c @@ -25,7 +25,7 @@ void RenderHeaderButton(Clay_String text) { }) { CLAY_TEXT( text, - CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BUTTON, .textColor = COLOR_WHITE }) + CLAY_TEXT_CONFIG({ .textColor = COLOR_WHITE, .fontId = FONT_ID_BUTTON }) ); } } @@ -44,7 +44,7 @@ typedef struct { #define MAX_DOCUMENTS 3 Document documentsRaw[MAX_DOCUMENTS]; -DocumentArray documents = { .length = MAX_DOCUMENTS, .documents = documentsRaw }; +DocumentArray documents = { .documents = documentsRaw, .length = MAX_DOCUMENTS }; void ClayVideoDemoPlaydate_Initialize(PlaydateAPI* pd) { documents.documents[0] = (Document){ @@ -208,25 +208,25 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI Clay_BorderElementConfig contentBorders = { .color = COLOR_BLACK, - .width = { .top = 1, .left = 1, .right = 1, .bottom = 1 } + .width = { .left = 1, .right = 1, .top = 1, .bottom = 1 } }; // Build UI here CLAY(CLAY_ID("OuterContainer"), { - .backgroundColor = COLOR_WHITE, .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = layoutExpand, .padding = CLAY_PADDING_ALL(8), - .childGap = 4 - } + .childGap = 4, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, + .backgroundColor = COLOR_WHITE, }) { // Child elements go inside braces CLAY(CLAY_ID("HeaderBar"), { .layout = { .sizing = { + .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(30), - .width = CLAY_SIZING_GROW(0) }, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } @@ -243,8 +243,8 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI CLAY_TEXT( CLAY_STRING("File"), CLAY_TEXT_CONFIG({ + .textColor = COLOR_WHITE, .fontId = FONT_ID_BUTTON, - .textColor = COLOR_WHITE }) ); } @@ -259,17 +259,17 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI .layout = { .sizing = layoutExpand, .childGap = 8 }, }) { CLAY(CLAY_ID("Sidebar"), { - .border = contentBorders, - .cornerRadius = CLAY_CORNER_RADIUS(4), .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .padding = CLAY_PADDING_ALL(8), - .childGap = 4, .sizing = { .width = CLAY_SIZING_FIXED(125), .height = CLAY_SIZING_GROW(0) - } - } + }, + .padding = CLAY_PADDING_ALL(8), + .childGap = 4, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, + .cornerRadius = CLAY_CORNER_RADIUS(4), + .border = contentBorders, }) { for (int i = 0; i < documents.length; i++) { Document document = documents.documents[i]; @@ -287,23 +287,23 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI CLAY_TEXT( document.title, CLAY_TEXT_CONFIG({ + .textColor = COLOR_WHITE, .fontId = FONT_ID_BUTTON, - .textColor = COLOR_WHITE }) ); } } else { CLAY_AUTO_ID({ .layout = sidebarButtonLayout, - .backgroundColor = (Clay_Color){ 0, 0, 0, Clay_Hovered() ? 120 : 0 }, + .backgroundColor = (Clay_Color){ 0, 0, 0, Clay_Hovered() ? 120.0f : 0.0f }, .cornerRadius = CLAY_CORNER_RADIUS(4), .border = contentBorders }) { CLAY_TEXT( document.title, CLAY_TEXT_CONFIG({ - .fontId = FONT_ID_BUTTON, .textColor = COLOR_BLACK, + .fontId = FONT_ID_BUTTON, }) ); } @@ -312,27 +312,27 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI } CLAY(CLAY_ID("MainContent"), { - .border = contentBorders, + .layout = { + .sizing = layoutExpand, + .padding = CLAY_PADDING_ALL(8), + .childGap = 8, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, .cornerRadius = CLAY_CORNER_RADIUS(4), .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }, - .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .childGap = 8, - .padding = CLAY_PADDING_ALL(8), - .sizing = layoutExpand - } + .border = contentBorders, }) { Document selectedDocument = documents.documents[selectedDocumentIndex]; CLAY_AUTO_ID({ .layout = { - .layoutDirection = CLAY_LEFT_TO_RIGHT, .childGap = 4, - .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_BOTTOM } + .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_BOTTOM }, + .layoutDirection = CLAY_LEFT_TO_RIGHT, } }) { CLAY_TEXT( selectedDocument.title, - CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY, .textColor = COLOR_BLACK }) + CLAY_TEXT_CONFIG({ .textColor = COLOR_BLACK, .fontId = FONT_ID_BODY }) ); CLAY_AUTO_ID({ .layout = { @@ -346,7 +346,7 @@ Clay_RenderCommandArray ClayVideoDemoPlaydate_CreateLayout(int selectedDocumentI } CLAY_TEXT( selectedDocument.contents, - CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY, .textColor = COLOR_BLACK }) + CLAY_TEXT_CONFIG({ .textColor = COLOR_BLACK, .fontId = FONT_ID_BODY }) ); } } diff --git a/examples/raylib-multi-context/main.c b/examples/raylib-multi-context/main.c index dfbc1a3..d7ff90a 100644 --- a/examples/raylib-multi-context/main.c +++ b/examples/raylib-multi-context/main.c @@ -12,8 +12,8 @@ Clay_RenderCommandArray CreateLayout(Clay_Context* context, ClayVideoDemo_Data * Clay_SetDebugModeEnabled(true); // Run once per frame Clay_SetLayoutDimensions((Clay_Dimensions) { - .width = GetScreenWidth(), - .height = GetScreenHeight() / 2 + .width = (float)GetScreenWidth(), + .height = (float)GetScreenHeight() / 2 }); Vector2 mousePosition = GetMousePosition(); mousePosition.y -= data->yOffset; @@ -48,22 +48,22 @@ int main(void) { Clay_Arena clayMemoryTop = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory)); Clay_Context *clayContextTop = Clay_Initialize(clayMemoryTop, (Clay_Dimensions) { - .width = GetScreenWidth(), - .height = GetScreenHeight() / 2 + .width = (float)GetScreenWidth(), + .height = (float)GetScreenHeight() / 2 }, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published ClayVideoDemo_Data dataTop = ClayVideoDemo_Initialize(); Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts); Clay_Arena clayMemoryBottom = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory)); Clay_Context *clayContextBottom = Clay_Initialize(clayMemoryBottom, (Clay_Dimensions) { - .width = GetScreenWidth(), - .height = GetScreenHeight() / 2 + .width = (float)GetScreenWidth(), + .height = (float)GetScreenHeight() / 2 }, (Clay_ErrorHandler) { HandleClayErrors }); // This final argument is new since the video was published ClayVideoDemo_Data dataBottom = ClayVideoDemo_Initialize(); Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts); while (!WindowShouldClose()) { - dataBottom.yOffset = GetScreenHeight() / 2; + dataBottom.yOffset = (float)GetScreenHeight() / 2; Clay_RenderCommandArray renderCommandsTop = CreateLayout(clayContextTop, &dataTop); Clay_RenderCommandArray renderCommandsBottom = CreateLayout(clayContextBottom, &dataBottom); BeginDrawing(); diff --git a/examples/raylib-sidebar-scrolling-container/main.c b/examples/raylib-sidebar-scrolling-container/main.c index 3adda43..ccba062 100644 --- a/examples/raylib-sidebar-scrolling-container/main.c +++ b/examples/raylib-sidebar-scrolling-container/main.c @@ -11,7 +11,7 @@ Texture2D profilePicture; #define RAYLIB_VECTOR2_TO_CLAY_VECTOR2(vector) (Clay_Vector2) { .x = vector.x, .y = vector.y } Clay_String profileText = CLAY_STRING_CONST("Profile Page one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen"); -Clay_TextElementConfig headerTextConfig = { .fontId = 1, .letterSpacing = 5, .fontSize = 16, .textColor = {0,0,0,255} }; +Clay_TextElementConfig headerTextConfig = { .textColor = {0,0,0,255}, .fontId = 1, .fontSize = 16, .letterSpacing = 5 }; void HandleHeaderButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData) { if (pointerData.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { @@ -34,7 +34,7 @@ void RenderHeaderButton(Clay_String text) { } Clay_LayoutConfig dropdownTextItemLayout = { .padding = {8, 8, 4, 4} }; -Clay_TextElementConfig dropdownTextElementConfig = { .fontSize = 24, .textColor = {255,255,255,255} }; +Clay_TextElementConfig dropdownTextElementConfig = { .textColor = {255,255,255,255}, .fontSize = 24 }; void RenderDropdownTextItem(int index) { CLAY_AUTO_ID({ .layout = dropdownTextItemLayout, .backgroundColor = {180, 180, 180, 255} }) { @@ -45,10 +45,10 @@ void RenderDropdownTextItem(int index) { Clay_RenderCommandArray CreateLayout(void) { Clay_BeginLayout(); CLAY(CLAY_ID("OuterContainer"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, .padding = { 16, 16, 16, 16 }, .childGap = 16 }, .backgroundColor = {200, 200, 200, 255} }) { - CLAY(CLAY_ID("SideBar"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = {16, 16, 16, 16 }, .childGap = 16 }, .backgroundColor = {150, 150, 255, 255} }) { + CLAY(CLAY_ID("SideBar"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = { 16, 16, 16, 16 }, .childGap = 16, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = {150, 150, 255, 255} }) { CLAY(CLAY_ID("ProfilePictureOuter"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = { 8, 8, 8, 8 }, .childGap = 8, .childAlignment = { .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = {130, 130, 255, 255} }) { CLAY(CLAY_ID("ProfilePicture"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) } }, .image = { .imageData = &profilePicture }}) {} - CLAY_TEXT(profileText, CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0, 0, 0, 255}, .textAlignment = CLAY_TEXT_ALIGN_RIGHT })); + CLAY_TEXT(profileText, CLAY_TEXT_CONFIG({ .textColor = {0, 0, 0, 255}, .fontSize = 24, .textAlignment = CLAY_TEXT_ALIGN_RIGHT })); } CLAY(CLAY_ID("SidebarBlob1"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}, .backgroundColor = {110, 110, 255, 255} }) {} CLAY(CLAY_ID("SidebarBlob2"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}, .backgroundColor = {110, 110, 255, 255} }) {} @@ -56,14 +56,14 @@ Clay_RenderCommandArray CreateLayout(void) { CLAY(CLAY_ID("SidebarBlob4"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50) }}, .backgroundColor = {110, 110, 255, 255} }) {} } - CLAY(CLAY_ID("RightPanel"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, .childGap = 16 }}) { - CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { .x = CLAY_ALIGN_X_RIGHT }, .padding = {8, 8, 8, 8 }, .childGap = 8 }, .backgroundColor = {180, 180, 180, 255} }) { + CLAY(CLAY_ID("RightPanel"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, .childGap = 16, .layoutDirection = CLAY_TOP_TO_BOTTOM }}) { + CLAY_AUTO_ID({ .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {8, 8, 8, 8 }, .childGap = 8, .childAlignment = { .x = CLAY_ALIGN_X_RIGHT } }, .backgroundColor = {180, 180, 180, 255} }) { RenderHeaderButton(CLAY_STRING("Header Item 1")); RenderHeaderButton(CLAY_STRING("Header Item 2")); RenderHeaderButton(CLAY_STRING("Header Item 3")); } CLAY(CLAY_ID("MainContent"), { - .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM, .padding = {16, 16, 16, 16}, .childGap = 16, .sizing = { .width = CLAY_SIZING_GROW(0) } }, + .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {16, 16, 16, 16}, .childGap = 16, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = {200, 200, 255, 255}, .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }, }) @@ -71,46 +71,46 @@ Clay_RenderCommandArray CreateLayout(void) { CLAY(CLAY_ID("FloatingContainer"), { .layout = { .sizing = { .width = CLAY_SIZING_PERCENT(0.5), .height = CLAY_SIZING_FIXED(300) }, .padding = { 16, 16, 16, 16 }}, .backgroundColor = { 140, 80, 200, 200 }, - .floating = { .attachTo = CLAY_ATTACH_TO_PARENT, .zIndex = 1, .attachPoints = { CLAY_ATTACH_POINT_CENTER_TOP, CLAY_ATTACH_POINT_CENTER_TOP }, .offset = {0, 0} }, - .border = { .width = CLAY_BORDER_OUTSIDE(2), .color = {80, 80, 80, 255} }, + .floating = { .offset = {0, 0}, .zIndex = 1, .attachPoints = { CLAY_ATTACH_POINT_CENTER_TOP, CLAY_ATTACH_POINT_CENTER_TOP }, .attachTo = CLAY_ATTACH_TO_PARENT }, + .border = { .color = {80, 80, 80, 255}, .width = CLAY_BORDER_OUTSIDE(2) }, }) { - CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255,255,255,255} })); + CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .textColor = {255,255,255,255}, .fontSize = 24 })); } CLAY_TEXT(CLAY_STRING("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt."), - CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_24, .fontSize = 24, .textColor = {0,0,0,255} })); + CLAY_TEXT_CONFIG({ .textColor = {0,0,0,255}, .fontId = FONT_ID_BODY_24, .fontSize = 24 })); - CLAY(CLAY_ID("Photos2"), { .layout = { .childGap = 16, .padding = { 16, 16, 16, 16 }}, .backgroundColor = {180, 180, 220, Clay_Hovered() ? 120 : 255} }) { + CLAY(CLAY_ID("Photos2"), { .layout = { .padding = { 16, 16, 16, 16 }, .childGap = 16}, .backgroundColor = {180, 180, 220, Clay_Hovered() ? 120.0f : 255.0f} }) { CLAY(CLAY_ID("Picture4"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120), .height = CLAY_SIZING_FIXED(120) }}, .image = { .imageData = &profilePicture }}) {} CLAY(CLAY_ID("Picture5"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120), .height = CLAY_SIZING_FIXED(120) }}, .image = { .imageData = &profilePicture }}) {} CLAY(CLAY_ID("Picture6"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120), .height = CLAY_SIZING_FIXED(120) }}, .image = { .imageData = &profilePicture }}) {} } CLAY_TEXT(CLAY_STRING("Faucibus purus in massa tempor nec. Nec ullamcorper sit amet risus nullam eget felis eget nunc. Diam vulputate ut pharetra sit amet aliquam id diam. Lacus suspendisse faucibus interdum posuere lorem. A diam sollicitudin tempor id. Amet massa vitae tortor condimentum lacinia. Aliquet nibh praesent tristique magna."), - CLAY_TEXT_CONFIG({ .fontSize = 24, .lineHeight = 60, .textColor = {0,0,0,255}, .textAlignment = CLAY_TEXT_ALIGN_CENTER })); + CLAY_TEXT_CONFIG({ .textColor = {0,0,0,255}, .fontSize = 24, .lineHeight = 60, .textAlignment = CLAY_TEXT_ALIGN_CENTER })); CLAY_TEXT(CLAY_STRING("Suspendisse in est ante in nibh. Amet venenatis urna cursus eget nunc scelerisque viverra. Elementum sagittis vitae et leo duis ut diam quam nulla. Enim nulla aliquet porttitor lacus. Pellentesque habitant morbi tristique senectus et. Facilisi nullam vehicula ipsum a arcu cursus vitae.\nSem fringilla ut morbi tincidunt. Euismod quis viverra nibh cras pulvinar mattis nunc sed. Velit sed ullamcorper morbi tincidunt ornare massa. Varius quam quisque id diam vel quam. Nulla pellentesque dignissim enim sit amet venenatis. Enim lobortis scelerisque fermentum dui faucibus in. Pretium viverra suspendisse potenti nullam ac tortor vitae. Lectus vestibulum mattis ullamcorper velit sed. Eget mauris pharetra et ultrices neque ornare aenean euismod elementum. Habitant morbi tristique senectus et. Integer vitae justo eget magna fermentum iaculis eu. Semper quis lectus nulla at volutpat diam. Enim praesent elementum facilisis leo. Massa vitae tortor condimentum lacinia quis vel."), - CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0,0,0,255} })); + CLAY_TEXT_CONFIG({ .textColor = {0,0,0,255}, .fontSize = 24 })); - CLAY(CLAY_ID("Photos"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }, .childGap = 16, .padding = {16, 16, 16, 16} }, .backgroundColor = {180, 180, 220, 255} }) { - CLAY(CLAY_ID("Picture2"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120) }}, .aspectRatio = 1, .image = { .imageData = &profilePicture }}) {} - CLAY(CLAY_ID("Picture1"), { .layout = { .childAlignment = { .x = CLAY_ALIGN_X_CENTER }, .layoutDirection = CLAY_TOP_TO_BOTTOM, .padding = {8, 8, 8, 8} }, .backgroundColor = {170, 170, 220, 255} }) { + CLAY(CLAY_ID("Photos"), { .layout = { .sizing = { .width = CLAY_SIZING_GROW(0) }, .padding = {16, 16, 16, 16}, .childGap = 16, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = {180, 180, 220, 255} }) { + CLAY(CLAY_ID("Picture2"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120) }}, .aspectRatio = {1}, .image = { .imageData = &profilePicture }}) {} + CLAY(CLAY_ID("Picture1"), { .layout = { .padding = {8, 8, 8, 8}, .childAlignment = { .x = CLAY_ALIGN_X_CENTER }, .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = {170, 170, 220, 255} }) { CLAY(CLAY_ID("ProfilePicture2"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = { .imageData = &profilePicture }}) {} - CLAY_TEXT(CLAY_STRING("Image caption below"), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0,0,0,255} })); + CLAY_TEXT(CLAY_STRING("Image caption below"), CLAY_TEXT_CONFIG({ .textColor = {0,0,0,255}, .fontSize = 24 })); } - CLAY(CLAY_ID("Picture3"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120) }}, .aspectRatio = 1, .image = { .imageData = &profilePicture }}) {} + CLAY(CLAY_ID("Picture3"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(120) }}, .aspectRatio = {1}, .image = { .imageData = &profilePicture }}) {} } CLAY_TEXT(CLAY_STRING("Amet cursus sit amet dictum sit amet justo donec. Et malesuada fames ac turpis egestas maecenas. A lacus vestibulum sed arcu non odio euismod lacinia. Gravida neque convallis a cras. Dui nunc mattis enim ut tellus elementum sagittis vitae et. Orci sagittis eu volutpat odio facilisis mauris. Neque gravida in fermentum et sollicitudin ac orci. Ultrices dui sapien eget mi proin sed libero. Euismod quis viverra nibh cras pulvinar mattis. Diam volutpat commodo sed egestas egestas. In fermentum posuere urna nec tincidunt praesent semper. Integer eget aliquet nibh praesent tristique magna.\nId cursus metus aliquam eleifend mi in. Sed pulvinar proin gravida hendrerit lectus a. Etiam tempor orci eu lobortis elementum nibh tellus. Nullam vehicula ipsum a arcu cursus vitae. Elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus. Condimentum lacinia quis vel eros donec ac odio. Mattis pellentesque id nibh tortor id aliquet lectus. Turpis egestas integer eget aliquet nibh praesent tristique. Porttitor massa id neque aliquam vestibulum morbi. Mauris commodo quis imperdiet massa tincidunt nunc pulvinar sapien et. Nunc scelerisque viverra mauris in aliquam sem fringilla. Suspendisse ultrices gravida dictum fusce ut placerat orci nulla.\nLacus laoreet non curabitur gravida arcu ac tortor dignissim. Urna nec tincidunt praesent semper feugiat nibh sed pulvinar. Tristique senectus et netus et malesuada fames ac. Nunc aliquet bibendum enim facilisis gravida. Egestas maecenas pharetra convallis posuere morbi leo urna molestie. Sapien nec sagittis aliquam malesuada bibendum arcu vitae elementum curabitur. Ac turpis egestas maecenas pharetra convallis posuere morbi leo urna. Viverra vitae congue eu consequat. Aliquet enim tortor at auctor urna. Ornare massa eget egestas purus viverra accumsan in nisl nisi. Elit pellentesque habitant morbi tristique senectus et netus et malesuada.\nSuspendisse ultrices gravida dictum fusce ut placerat orci nulla pellentesque. Lobortis feugiat vivamus at augue eget arcu. Vitae justo eget magna fermentum iaculis eu. Gravida rutrum quisque non tellus orci. Ipsum faucibus vitae aliquet nec. Nullam non nisi est sit amet. Nunc consequat interdum varius sit amet mattis vulputate enim. Sem fringilla ut morbi tincidunt augue interdum. Vitae purus faucibus ornare suspendisse. Massa tincidunt nunc pulvinar sapien et. Fringilla ut morbi tincidunt augue interdum velit euismod in. Donec massa sapien faucibus et. Est placerat in egestas erat imperdiet. Gravida rutrum quisque non tellus. Morbi non arcu risus quis varius quam quisque id diam. Habitant morbi tristique senectus et netus et malesuada fames ac. Eget lorem dolor sed viverra.\nOrnare massa eget egestas purus viverra. Varius vel pharetra vel turpis nunc eget lorem. Consectetur purus ut faucibus pulvinar elementum. Placerat in egestas erat imperdiet sed euismod nisi. Interdum velit euismod in pellentesque massa placerat duis ultricies lacus. Aliquam nulla facilisi cras fermentum odio eu. Est pellentesque elit ullamcorper dignissim cras tincidunt. Nunc sed id semper risus in hendrerit gravida rutrum. A pellentesque sit amet porttitor eget dolor morbi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames. Nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper. Sed id semper risus in hendrerit gravida. Tincidunt praesent semper feugiat nibh. Aliquet lectus proin nibh nisl condimentum id venenatis a. Enim sit amet venenatis urna cursus eget. In egestas erat imperdiet sed euismod nisi porta lorem mollis. Lacinia quis vel eros donec ac odio tempor orci. Donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum arcu. Erat pellentesque adipiscing commodo elit at.\nEgestas sed sed risus pretium quam vulputate. Vitae congue mauris rhoncus aenean vel elit scelerisque mauris pellentesque. Aliquam malesuada bibendum arcu vitae elementum. Congue mauris rhoncus aenean vel elit scelerisque mauris. Pellentesque dignissim enim sit amet venenatis urna cursus. Et malesuada fames ac turpis egestas sed tempus urna. Vel fringilla est ullamcorper eget nulla facilisi etiam dignissim. Nibh cras pulvinar mattis nunc sed blandit libero. Fringilla est ullamcorper eget nulla facilisi etiam dignissim. Aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin. Mauris pharetra et ultrices neque ornare aenean euismod elementum. Ornare quam viverra orci sagittis eu. Odio ut sem nulla pharetra diam sit amet nisl suscipit. Ornare lectus sit amet est. Ullamcorper sit amet risus nullam eget. Tincidunt lobortis feugiat vivamus at augue eget arcu dictum.\nUrna nec tincidunt praesent semper feugiat nibh. Ut venenatis tellus in metus vulputate eu scelerisque felis. Cursus risus at ultrices mi tempus. In pellentesque massa placerat duis ultricies lacus sed turpis. Platea dictumst quisque sagittis purus. Cras adipiscing enim eu turpis egestas. Egestas sed tempus urna et pharetra pharetra. Netus et malesuada fames ac turpis egestas integer eget aliquet. Ac turpis egestas sed tempus. Sed lectus vestibulum mattis ullamcorper velit sed. Ante metus dictum at tempor commodo ullamcorper a. Augue neque gravida in fermentum et sollicitudin ac. Praesent semper feugiat nibh sed pulvinar proin gravida. Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. Neque gravida in fermentum et sollicitudin ac orci phasellus egestas.\nRidiculus mus mauris vitae ultricies. Morbi quis commodo odio aenean. Duis ultricies lacus sed turpis. Non pulvinar neque laoreet suspendisse interdum consectetur. Scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Volutpat est velit egestas dui id ornare arcu odio ut. Viverra tellus in hac habitasse platea dictumst vestibulum rhoncus est. Vestibulum lectus mauris ultrices eros. Sed blandit libero volutpat sed cras ornare. Id leo in vitae turpis massa sed elementum tempus. Gravida dictum fusce ut placerat orci nulla pellentesque. Pretium quam vulputate dignissim suspendisse in. Nisl suscipit adipiscing bibendum est ultricies integer quis auctor. Risus viverra adipiscing at in tellus. Turpis nunc eget lorem dolor sed viverra ipsum. Senectus et netus et malesuada fames ac. Habitasse platea dictumst vestibulum rhoncus est. Nunc sed id semper risus in hendrerit gravida. Felis eget velit aliquet sagittis id. Eget felis eget nunc lobortis.\nMaecenas pharetra convallis posuere morbi leo. Maecenas volutpat blandit aliquam etiam. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Pulvinar mattis nunc sed blandit libero volutpat sed. Feugiat in ante metus dictum at tempor commodo ullamcorper. Vel pharetra vel turpis nunc eget lorem dolor. Est placerat in egestas erat imperdiet sed euismod. Quisque non tellus orci ac auctor augue mauris augue. Placerat vestibulum lectus mauris ultrices eros in cursus turpis. Enim nunc faucibus a pellentesque sit. Adipiscing vitae proin sagittis nisl. Iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Aliquam sem fringilla ut morbi.\nArcu odio ut sem nulla pharetra diam sit amet nisl. Non diam phasellus vestibulum lorem sed. At erat pellentesque adipiscing commodo elit at. Lacus luctus accumsan tortor posuere ac ut consequat. Et malesuada fames ac turpis egestas integer. Tristique magna sit amet purus. A condimentum vitae sapien pellentesque habitant. Quis varius quam quisque id diam vel quam. Est ullamcorper eget nulla facilisi etiam dignissim diam quis. Augue interdum velit euismod in pellentesque massa. Elit scelerisque mauris pellentesque pulvinar pellentesque habitant. Vulputate eu scelerisque felis imperdiet. Nibh tellus molestie nunc non blandit massa. Velit euismod in pellentesque massa placerat. Sed cras ornare arcu dui. Ut sem viverra aliquet eget sit. Eu lobortis elementum nibh tellus molestie nunc non. Blandit libero volutpat sed cras ornare arcu dui vivamus.\nSit amet aliquam id diam maecenas. Amet risus nullam eget felis eget nunc lobortis mattis aliquam. Magna sit amet purus gravida. Egestas purus viverra accumsan in nisl nisi. Leo duis ut diam quam. Ante metus dictum at tempor commodo ullamcorper. Ac turpis egestas integer eget. Fames ac turpis egestas integer eget aliquet nibh. Sem integer vitae justo eget magna fermentum. Semper auctor neque vitae tempus quam pellentesque nec nam aliquam. Vestibulum mattis ullamcorper velit sed. Consectetur adipiscing elit duis tristique sollicitudin nibh. Massa id neque aliquam vestibulum morbi blandit cursus risus.\nCursus sit amet dictum sit amet justo donec enim diam. Egestas erat imperdiet sed euismod. Nullam vehicula ipsum a arcu cursus vitae congue mauris. Habitasse platea dictumst vestibulum rhoncus est pellentesque elit. Duis ultricies lacus sed turpis tincidunt id aliquet risus feugiat. Faucibus ornare suspendisse sed nisi lacus sed viverra. Pretium fusce id velit ut tortor pretium viverra. Fermentum odio eu feugiat pretium nibh ipsum consequat nisl vel. Senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Aenean sed adipiscing diam donec adipiscing tristique risus nec feugiat. Quis vel eros donec ac odio. Id interdum velit laoreet id donec ultrices tincidunt.\nMassa id neque aliquam vestibulum morbi blandit cursus risus at. Enim tortor at auctor urna nunc id cursus metus. Lorem ipsum dolor sit amet consectetur. At quis risus sed vulputate odio. Facilisis mauris sit amet massa vitae tortor condimentum lacinia quis. Et malesuada fames ac turpis egestas maecenas. Bibendum arcu vitae elementum curabitur vitae nunc sed velit dignissim. Viverra orci sagittis eu volutpat odio facilisis mauris. Adipiscing bibendum est ultricies integer quis auctor elit sed. Neque viverra justo nec ultrices dui sapien. Elementum nibh tellus molestie nunc non blandit massa enim. Euismod elementum nisi quis eleifend quam adipiscing vitae proin sagittis. Faucibus ornare suspendisse sed nisi. Quis viverra nibh cras pulvinar mattis nunc sed blandit. Tristique senectus et netus et. Magnis dis parturient montes nascetur ridiculus mus.\nDolor magna eget est lorem ipsum dolor. Nibh sit amet commodo nulla. Donec pretium vulputate sapien nec sagittis aliquam malesuada. Cras adipiscing enim eu turpis egestas pretium. Cras ornare arcu dui vivamus arcu felis bibendum ut tristique. Mus mauris vitae ultricies leo integer. In nulla posuere sollicitudin aliquam ultrices sagittis orci. Quis hendrerit dolor magna eget. Nisl tincidunt eget nullam non. Vitae congue eu consequat ac felis donec et odio. Vivamus at augue eget arcu dictum varius duis at. Ornare quam viverra orci sagittis.\nErat nam at lectus urna duis convallis. Massa placerat duis ultricies lacus sed turpis tincidunt id aliquet. Est ullamcorper eget nulla facilisi etiam dignissim diam. Arcu vitae elementum curabitur vitae nunc sed velit dignissim sodales. Tortor vitae purus faucibus ornare suspendisse sed nisi lacus. Neque viverra justo nec ultrices dui sapien eget mi proin. Viverra accumsan in nisl nisi scelerisque eu ultrices. Consequat interdum varius sit amet mattis. In aliquam sem fringilla ut morbi. Eget arcu dictum varius duis at. Nulla aliquet porttitor lacus luctus accumsan tortor posuere. Arcu bibendum at varius vel pharetra vel turpis. Hac habitasse platea dictumst quisque sagittis purus sit amet. Sapien eget mi proin sed libero enim sed. Quam elementum pulvinar etiam non quam lacus suspendisse faucibus interdum. Semper viverra nam libero justo. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Et malesuada fames ac turpis egestas maecenas pharetra convallis posuere.\nTurpis egestas sed tempus urna et pharetra pharetra massa. Gravida in fermentum et sollicitudin ac orci phasellus. Ornare suspendisse sed nisi lacus sed viverra tellus in. Fames ac turpis egestas maecenas pharetra convallis posuere. Mi proin sed libero enim sed faucibus turpis. Sit amet mauris commodo quis imperdiet massa tincidunt nunc. Ut etiam sit amet nisl purus in mollis nunc. Habitasse platea dictumst quisque sagittis purus sit amet volutpat consequat. Eget aliquet nibh praesent tristique magna. Sit amet est placerat in egestas erat. Commodo sed egestas egestas fringilla. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Et molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Dignissim convallis aenean et tortor at risus viverra. Morbi blandit cursus risus at ultrices mi. Ac turpis egestas integer eget aliquet nibh praesent tristique magna.\nVolutpat sed cras ornare arcu dui. Egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam. Viverra justo nec ultrices dui sapien. Amet risus nullam eget felis eget nunc lobortis. Metus aliquam eleifend mi in. Ut eu sem integer vitae. Auctor elit sed vulputate mi sit amet. Nisl nisi scelerisque eu ultrices. Dictum fusce ut placerat orci nulla. Pellentesque habitant morbi tristique senectus et. Auctor elit sed vulputate mi sit. Tincidunt arcu non sodales neque. Mi in nulla posuere sollicitudin aliquam. Morbi non arcu risus quis varius quam quisque id diam. Cras adipiscing enim eu turpis egestas pretium aenean pharetra magna. At auctor urna nunc id cursus metus aliquam. Mauris a diam maecenas sed enim ut sem viverra. Nunc scelerisque viverra mauris in. In iaculis nunc sed augue lacus viverra vitae congue eu. Volutpat blandit aliquam etiam erat velit scelerisque in dictum non."), - CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {0,0,0,255} })); + CLAY_TEXT_CONFIG({ .textColor = {0,0,0,255}, .fontSize = 24 })); } } - - CLAY(CLAY_ID("Blob4Floating2"), { .floating = { .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID, .zIndex = 1, .parentId = Clay_GetElementId(CLAY_STRING("SidebarBlob4")).id } }) { + + CLAY(CLAY_ID("Blob4Floating2"), { .floating = { .parentId = Clay_GetElementId(CLAY_STRING("SidebarBlob4")).id, .zIndex = 1, .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID } }) { CLAY(CLAY_ID("ScrollContainer"), { .layout = { .sizing = { .height = CLAY_SIZING_FIXED(200) }, .childGap = 2 }, .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() } }) { - CLAY(CLAY_ID("FloatingContainer2"), { .layout.sizing.height = CLAY_SIZING_GROW(), .floating = { .attachTo = CLAY_ATTACH_TO_PARENT, .zIndex = 1 } }) { + CLAY(CLAY_ID("FloatingContainer2"), { .layout = {.sizing = {.height = CLAY_SIZING_GROW()}}, .floating = { .zIndex = 1, .attachTo = CLAY_ATTACH_TO_PARENT} }) { CLAY(CLAY_ID("FloatingContainerInner"), { .layout = { .sizing = { .width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW() }, .padding = {16, 16, 16, 16} }, .backgroundColor = {140,80, 200, 200} }) { - CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .fontSize = 24, .textColor = {255,255,255,255} })); + CLAY_TEXT(CLAY_STRING("I'm an inline floating container."), CLAY_TEXT_CONFIG({ .textColor = {255,255,255,255}, .fontSize = 24 })); } } CLAY(CLAY_ID("ScrollContainerInner"), { .layout = { .layoutDirection = CLAY_TOP_TO_BOTTOM }, .backgroundColor = {160, 160, 160, 255} }) { @@ -124,11 +124,11 @@ Clay_RenderCommandArray CreateLayout(void) { if (scrollData.found) { CLAY(CLAY_ID("ScrollBar"), { .floating = { - .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID, .offset = { .y = -(scrollData.scrollPosition->y / scrollData.contentDimensions.height) * scrollData.scrollContainerDimensions.height }, - .zIndex = 1, .parentId = Clay_GetElementId(CLAY_STRING("MainContent")).id, - .attachPoints = { .element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP } + .zIndex = 1, + .attachPoints = { .element = CLAY_ATTACH_POINT_RIGHT_TOP, .parent = CLAY_ATTACH_POINT_RIGHT_TOP }, + .attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID, } }) { CLAY(CLAY_ID("ScrollBarButton"), { diff --git a/examples/shared-layouts/clay-video-demo.c b/examples/shared-layouts/clay-video-demo.c index c1880e2..3df15c2 100644 --- a/examples/shared-layouts/clay-video-demo.c +++ b/examples/shared-layouts/clay-video-demo.c @@ -11,9 +11,9 @@ void RenderHeaderButton(Clay_String text) { .cornerRadius = CLAY_CORNER_RADIUS(5) }) { CLAY_TEXT(text, CLAY_TEXT_CONFIG({ + .textColor = { 255, 255, 255, 255 }, .fontId = FONT_ID_BODY_16, .fontSize = 16, - .textColor = { 255, 255, 255, 255 } })); } } @@ -21,9 +21,9 @@ void RenderHeaderButton(Clay_String text) { void RenderDropdownMenuItem(Clay_String text) { CLAY_AUTO_ID({.layout = { .padding = CLAY_PADDING_ALL(16)}}) { CLAY_TEXT(text, CLAY_TEXT_CONFIG({ + .textColor = { 255, 255, 255, 255 }, .fontId = FONT_ID_BODY_16, .fontSize = 16, - .textColor = { 255, 255, 255, 255 } })); } } @@ -41,8 +41,8 @@ typedef struct { Document documentsRaw[5]; DocumentArray documents = { + .documents = documentsRaw, .length = 5, - .documents = documentsRaw }; typedef struct { @@ -103,20 +103,20 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { // Build UI here CLAY(CLAY_ID("OuterContainer"), { - .backgroundColor = {43, 41, 51, 255 }, .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = layoutExpand, .padding = CLAY_PADDING_ALL(16), - .childGap = 16 - } + .childGap = 16, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, + .backgroundColor = {43, 41, 51, 255 }, }) { // Child elements go inside braces CLAY(CLAY_ID("HeaderBar"), { .layout = { .sizing = { + .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(60), - .width = CLAY_SIZING_GROW(0) }, .padding = { 16, 16, 0, 0 }, .childGap = 16, @@ -134,9 +134,9 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { .cornerRadius = CLAY_CORNER_RADIUS(5) }) { CLAY_TEXT(CLAY_STRING("File"), CLAY_TEXT_CONFIG({ + .textColor = { 255, 255, 255, 255 }, .fontId = FONT_ID_BODY_16, .fontSize = 16, - .textColor = { 255, 255, 255, 255 } })); bool fileMenuVisible = @@ -146,22 +146,22 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { if (fileMenuVisible) { // Below has been changed slightly to fix the small bug where the menu would dismiss when mousing over the top gap CLAY(CLAY_ID("FileMenu"), { + .layout = { + .padding = {0, 0, 8, 8 } + }, .floating = { - .attachTo = CLAY_ATTACH_TO_PARENT, .attachPoints = { .parent = CLAY_ATTACH_POINT_LEFT_BOTTOM }, + .attachTo = CLAY_ATTACH_TO_PARENT, }, - .layout = { - .padding = {0, 0, 8, 8 } - } }) { CLAY_AUTO_ID({ .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIXED(200) }, + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, .backgroundColor = {40, 40, 40, 255 }, .cornerRadius = CLAY_CORNER_RADIUS(8) @@ -185,16 +185,16 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { .layout = { .sizing = layoutExpand, .childGap = 16 } }) { CLAY(CLAY_ID("Sidebar"), { - .backgroundColor = contentBackgroundColor, .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .padding = CLAY_PADDING_ALL(16), - .childGap = 8, .sizing = { .width = CLAY_SIZING_FIXED(250), .height = CLAY_SIZING_GROW(0) - } - } + }, + .padding = CLAY_PADDING_ALL(16), + .childGap = 8, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, + .backgroundColor = contentBackgroundColor, }) { for (int i = 0; i < documents.length; i++) { Document document = documents.documents[i]; @@ -210,21 +210,21 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { .cornerRadius = CLAY_CORNER_RADIUS(8) }) { CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ + .textColor = { 255, 255, 255, 255 }, .fontId = FONT_ID_BODY_16, .fontSize = 20, - .textColor = { 255, 255, 255, 255 } })); } } else { SidebarClickData *clickData = (SidebarClickData *)(data->frameArena.memory + data->frameArena.offset); *clickData = (SidebarClickData) { .requestedDocumentIndex = i, .selectedDocumentIndex = &data->selectedDocumentIndex }; data->frameArena.offset += sizeof(SidebarClickData); - CLAY_AUTO_ID({ .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.0f : 0.0f }, .cornerRadius = CLAY_CORNER_RADIUS(8) }) { Clay_OnHover(HandleSidebarInteraction, (intptr_t)clickData); CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ + .textColor = { 255, 255, 255, 255 }, .fontId = FONT_ID_BODY_16, .fontSize = 20, - .textColor = { 255, 255, 255, 255 } })); } } @@ -232,25 +232,25 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { } CLAY(CLAY_ID("MainContent"), { + .layout = { + .sizing = layoutExpand, + .padding = CLAY_PADDING_ALL(16), + .childGap = 16, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, .backgroundColor = contentBackgroundColor, .clip = { .vertical = true, .childOffset = Clay_GetScrollOffset() }, - .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, - .childGap = 16, - .padding = CLAY_PADDING_ALL(16), - .sizing = layoutExpand - } }) { Document selectedDocument = documents.documents[data->selectedDocumentIndex]; CLAY_TEXT(selectedDocument.title, CLAY_TEXT_CONFIG({ + .textColor = COLOR_WHITE, .fontId = FONT_ID_BODY_16, .fontSize = 24, - .textColor = COLOR_WHITE })); CLAY_TEXT(selectedDocument.contents, CLAY_TEXT_CONFIG({ + .textColor = COLOR_WHITE, .fontId = FONT_ID_BODY_16, .fontSize = 24, - .textColor = COLOR_WHITE })); } } @@ -261,4 +261,4 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { Clay_RenderCommandArray_Get(&renderCommands, i)->boundingBox.y += data->yOffset; } return renderCommands; -} \ No newline at end of file +} diff --git a/examples/sokol-corner-radius/main.c b/examples/sokol-corner-radius/main.c index 6ae11a5..9f3d6f4 100644 --- a/examples/sokol-corner-radius/main.c +++ b/examples/sokol-corner-radius/main.c @@ -34,32 +34,32 @@ Clay_RenderCommandArray CornerRadiusTest(){ .height = CLAY_SIZING_GROW(0) }; CLAY(CLAY_ID("OuterContainer"), { - .backgroundColor = {43, 41, 51, 255}, .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = layoutExpand, .padding = {0, 0, 20, 20}, - .childGap = 20 - } + .childGap = 20, + .layoutDirection = CLAY_TOP_TO_BOTTOM, + }, + .backgroundColor = {43, 41, 51, 255}, }) { for(int i = 0; i < 6; ++i){ CLAY(CLAY_IDI("Row", i), { .layout = { - .layoutDirection = CLAY_LEFT_TO_RIGHT, .sizing = layoutExpand, .padding = {20, 20, 0, 0}, - .childGap = 20 + .childGap = 20, + .layoutDirection = CLAY_LEFT_TO_RIGHT, } }) { for(int j = 0; j < 6; ++j){ CLAY(CLAY_IDI("Tile", i*6+j), { + .layout = { .sizing = layoutExpand }, .backgroundColor = {120, 140, 255, 128}, - .cornerRadius = {(i%3)*15, (j%3)*15, (i/2)*15, (j/2)*15}, + .cornerRadius = {(float)(i%3)*15, (float)(j%3)*15, ((float)i/2)*15, ((float)j/2)*15}, .border = { .color = {120, 140, 255, 255}, .width = {3, 9, 6, 12, 0}, }, - .layout = { .sizing = layoutExpand } }); } } diff --git a/examples/termbox2-demo/main.c b/examples/termbox2-demo/main.c index 430b0f4..62be7e6 100644 --- a/examples/termbox2-demo/main.c +++ b/examples/termbox2-demo/main.c @@ -61,11 +61,11 @@ void component_text_pair(const char *key, const char *value) size_t keylen = strlen(key); size_t vallen = strlen(value); Clay_String keytext = (Clay_String) { - .length = keylen, + .length = (int32_t)keylen, .chars = key, }; Clay_String valtext = (Clay_String) { - .length = vallen, + .length = (int32_t)vallen, .chars = value, }; Clay_TextElementConfig *textconfig = @@ -74,15 +74,17 @@ void component_text_pair(const char *key, const char *value) .layout = { .sizing = { .width = { - .size.minMax = { - .min = strlen("Border chars CLAY_TB_IMAGE_MODE_UNICODE_FAST") * Clay_Termbox_Cell_Width(), + .size = { + .minMax = { + .min = strlen("Border chars CLAY_TB_IMAGE_MODE_UNICODE_FAST") * Clay_Termbox_Cell_Width(), + } } }, } }, }) { CLAY_TEXT(keytext, textconfig); - CLAY_AUTO_ID({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { } + CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(1)} } }) { } CLAY_TEXT(valtext, textconfig); } @@ -92,27 +94,27 @@ void component_termbox_settings(void) { CLAY(CLAY_ID("Termbox Settings"), { .floating = { - .attachTo = CLAY_ATTACH_TO_PARENT, + .offset = { 0, 0 }, .zIndex = 1, .attachPoints = { CLAY_ATTACH_POINT_CENTER_CENTER, CLAY_ATTACH_POINT_CENTER_TOP }, - .offset = { 0, 0 } + .attachTo = CLAY_ATTACH_TO_PARENT, }, }) { CLAY_AUTO_ID({ .layout = { - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, .padding = { - 6 * Clay_Termbox_Cell_Width(), - 6 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), + (uint16_t)(6 * Clay_Termbox_Cell_Width()), + (uint16_t)(6 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), } }, + .backgroundColor = { 0x7f, 0x00, 0x00, 0x7f }, .border = { + .color = { 0x00, 0x00, 0x00, 0xff }, .width = CLAY_BORDER_ALL(1), - .color = { 0x00, 0x00, 0x00, 0xff } }, - .backgroundColor = { 0x7f, 0x00, 0x00, 0x7f } }) { const char *color_mode = NULL; switch (clay_tb_color_mode) { @@ -246,46 +248,46 @@ void component_color_palette(void) { CLAY_AUTO_ID({ .layout = { - .childGap = 16, .padding = { - 2 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), - } + (uint16_t)(2 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + }, + .childGap = 16, }, + .backgroundColor = { 0x7f, 0x7f, 0x7f, 0xff }, .border = { + .color = { 0x00, 0x00, 0x00, 0xff }, .width = CLAY_BORDER_OUTSIDE(2), - .color = { 0x00, 0x00, 0x00, 0xff } }, - .backgroundColor = { 0x7f, 0x7f, 0x7f, 0xff } }) { for (int type = 0; type < 2; ++type) { CLAY_AUTO_ID({ .layout ={ + .sizing = {CLAY_SIZING_FIT()}, + .childGap = (uint16_t)Clay_Termbox_Cell_Height(), .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = CLAY_SIZING_FIT(), - .childGap = Clay_Termbox_Cell_Height() }, }) { for (float ri = 0; ri < 4; ri += 1) { CLAY_AUTO_ID({ .layout ={ - .sizing = CLAY_SIZING_FIT(), - .childGap = Clay_Termbox_Cell_Width() + .sizing = {CLAY_SIZING_FIT()}, + .childGap = (uint16_t)Clay_Termbox_Cell_Width() }, }) { for (float r = ri * 0x44; r < (ri + 1) * 0x44; r += 0x22) { CLAY_AUTO_ID({ .layout ={ + .sizing = {CLAY_SIZING_FIT()}, .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = CLAY_SIZING_FIT(), }, }) { for (float g = 0; g < 0xff; g += 0x22) { CLAY_AUTO_ID({ .layout ={ - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, }, }) { for (float b = 0; b < 0xff; b += 0x22) { @@ -325,24 +327,24 @@ void component_unicode_text(void) { CLAY_AUTO_ID({ .layout = { - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, .padding = { - 2 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), + (uint16_t)(2 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), } }, .backgroundColor = { 0xcc, 0xbb, 0xaa, 0xff }, .border = { // This border should still be displayed in CLAY_TB_BORDER_MODE_ROUND mode - .width = { - 0.75 * Clay_Termbox_Cell_Width(), - 0.75 * Clay_Termbox_Cell_Width(), - 0.75 * Clay_Termbox_Cell_Height(), - 0.75 * Clay_Termbox_Cell_Height(), - }, .color = { 0x33, 0x33, 0x33, 0xff }, + .width = { + (uint16_t)(0.75 * Clay_Termbox_Cell_Width()), + (uint16_t)(0.75 * Clay_Termbox_Cell_Width()), + (uint16_t)(0.75 * Clay_Termbox_Cell_Height()), + (uint16_t)(0.75 * Clay_Termbox_Cell_Height()), + }, }, }) { CLAY_TEXT( @@ -379,12 +381,12 @@ void component_keybinds(void) { CLAY_AUTO_ID({ .layout = { - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, .padding = { - 4 * Clay_Termbox_Cell_Width(), - 4 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), + (uint16_t)(4 * Clay_Termbox_Cell_Width()), + (uint16_t)(4 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), } }, .backgroundColor = { 0x00, 0x7f, 0x7f, 0xff } @@ -412,13 +414,13 @@ void component_image(clay_tb_image *image, int width) CLAY_AUTO_ID({ .layout = { .sizing = { - .width = (0 == width) ? CLAY_SIZING_GROW() : CLAY_SIZING_FIXED(width), + .width = (0 == width) ? CLAY_SIZING_GROW() : CLAY_SIZING_FIXED((float)width), }, }, + .aspectRatio = { 512.0 / 406.0 }, .image = { .imageData = image, }, - .aspectRatio = { 512.0 / 406.0 } }) { } } @@ -469,35 +471,35 @@ void component_bordered_text(void) { CLAY_AUTO_ID({ .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, .sizing = { .width = CLAY_SIZING_FIT(450), .height = CLAY_SIZING_FIT(), }, - .padding = CLAY_PADDING_ALL(32) + .padding = CLAY_PADDING_ALL(32), + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, .backgroundColor = { 0x24, 0x55, 0x34, 0xff }, }) { CLAY_AUTO_ID({ - .border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0xaa, 0x00, 0x00, 0xff } }, + .border = { .color = { 0xaa, 0x00, 0x00, 0xff }, .width = { 1, 1, 1, 1, 1 } }, }) { CLAY_TEXT( CLAY_STRING("Test"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } })); } CLAY_AUTO_ID({ - .border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0xaa, 0x00, 0xff } }, + .border = { .color = { 0x00, 0xaa, 0x00, 0xff }, .width = { 1, 1, 1, 1, 1 } }, }) { CLAY_TEXT(CLAY_STRING("of the border width"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } })); } CLAY_AUTO_ID({ - .border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } }, + .border = { .color = { 0x00, 0x00, 0xaa, 0xff }, .width = { 1, 1, 1, 1, 1 } }, }) { CLAY_TEXT(CLAY_STRING("and overlap for multiple lines\nof text"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } })); } CLAY_AUTO_ID({ - .border = { .width = { 1, 1, 1, 1, 1 }, .color = { 0x00, 0x00, 0xaa, 0xff } }, + .border = { .color = { 0x00, 0x00, 0xaa, 0xff }, .width = { 1, 1, 1, 1, 1 } }, }) { CLAY_TEXT(CLAY_STRING("this text\nis long enough\nto display all\n borders\naround it"), CLAY_TEXT_CONFIG({ .textColor = { 0xff, 0xff, 0xff, 0xff } })); @@ -509,31 +511,31 @@ Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image { Clay_BeginLayout(); CLAY_AUTO_ID({ - .clip = { - .vertical = false, - .horizontal = true, - .childOffset = Clay_GetScrollOffset(), - }, .layout = { .sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }, + .childGap = 64, .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER }, - .childGap = 64 }, - .backgroundColor = { 0x24, 0x24, 0x24, 0xff } + .backgroundColor = { 0x24, 0x24, 0x24, 0xff }, + .clip = { + .horizontal = true, + .vertical = false, + .childOffset = Clay_GetScrollOffset(), + }, }) { CLAY_AUTO_ID({ .layout = { + .sizing = {CLAY_SIZING_FIT()}, .childAlignment = { .x = CLAY_ALIGN_X_RIGHT, }, .layoutDirection = CLAY_TOP_TO_BOTTOM, - .sizing = CLAY_SIZING_FIT(), }, }) { component_keybinds(); @@ -541,9 +543,9 @@ Clay_RenderCommandArray CreateLayout(clay_tb_image *image1, clay_tb_image *image } CLAY_AUTO_ID({ .layout = { - .layoutDirection = CLAY_TOP_TO_BOTTOM, + .sizing = {CLAY_SIZING_FIT()}, .childGap = 32, - .sizing = CLAY_SIZING_FIT(), + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, }) { component_termbox_settings(); diff --git a/examples/termbox2-image-demo/main.c b/examples/termbox2-image-demo/main.c index 08dd389..e321240 100644 --- a/examples/termbox2-image-demo/main.c +++ b/examples/termbox2-image-demo/main.c @@ -104,11 +104,11 @@ void component_text_pair(const char *key, const char *value) size_t keylen = strlen(key); size_t vallen = strlen(value); Clay_String keytext = (Clay_String) { - .length = keylen, + .length = (int32_t)keylen, .chars = key, }; Clay_String valtext = (Clay_String) { - .length = vallen, + .length = (int32_t)vallen, .chars = value, }; Clay_TextElementConfig *textconfig = @@ -117,15 +117,17 @@ void component_text_pair(const char *key, const char *value) .layout = { .sizing = { .width = { - .size.minMax = { - .min = strlen("Border chars CLAY_TB_IMAGE_MODE_UNICODE_FAST") * Clay_Termbox_Cell_Width(), + .size = { + .minMax = { + .min = strlen("Border chars CLAY_TB_IMAGE_MODE_UNICODE_FAST") * Clay_Termbox_Cell_Width(), + } } }, } }, }) { CLAY_TEXT(keytext, textconfig); - CLAY_AUTO_ID({ .layout = { .sizing = CLAY_SIZING_GROW(1) } }) { } + CLAY_AUTO_ID({ .layout = { .sizing = {CLAY_SIZING_GROW(1)} } }) { } CLAY_TEXT(valtext, textconfig); } @@ -135,19 +137,19 @@ void component_termbox_settings(void) { CLAY_AUTO_ID({ .layout = { - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, .padding = { - 6 * Clay_Termbox_Cell_Width(), - 6 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), + (uint16_t)(6 * Clay_Termbox_Cell_Width()), + (uint16_t)(6 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), } }, + .backgroundColor = { 0x7f, 0x00, 0x00, 0x7f }, .border = { + .color = { 0x00, 0x00, 0x00, 0xff }, .width = CLAY_BORDER_ALL(1), - .color = { 0x00, 0x00, 0x00, 0xff } }, - .backgroundColor = { 0x7f, 0x00, 0x00, 0x7f } }) { const char *color_mode = NULL; switch (clay_tb_color_mode) { @@ -280,12 +282,12 @@ void component_keybinds(void) { CLAY_AUTO_ID({ .layout = { - .sizing = CLAY_SIZING_FIT(), + .sizing = {CLAY_SIZING_FIT()}, .padding = { - 4 * Clay_Termbox_Cell_Width(), - 4 * Clay_Termbox_Cell_Width(), - 2 * Clay_Termbox_Cell_Height(), - 2 * Clay_Termbox_Cell_Height(), + (uint16_t)(4 * Clay_Termbox_Cell_Width()), + (uint16_t)(4 * Clay_Termbox_Cell_Width()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), + (uint16_t)(2 * Clay_Termbox_Cell_Height()), } }, .backgroundColor = { 0x00, 0x7f, 0x7f, 0xff } @@ -317,12 +319,12 @@ void component_image(img_group *img_pair) .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }, - .layoutDirection = CLAY_TOP_TO_BOTTOM, + .childGap = (uint16_t)(1 * Clay_Termbox_Cell_Height()), .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }, - .childGap = 1 * Clay_Termbox_Cell_Height() + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, .backgroundColor = { 0x24, 0x24, 0x24, 0xff } }) { @@ -332,10 +334,10 @@ void component_image(img_group *img_pair) .width = CLAY_SIZING_GROW(), }, }, + .aspectRatio = { (float)img_pair->width / img_pair->height }, .image = { .imageData = &img_pair->image, }, - .aspectRatio = { (float)img_pair->width / img_pair->height } }) { } component_keybinds(); } @@ -348,12 +350,12 @@ void component_image_small(img_group **img_pairs, int count, int selected_index) .sizing = { .width = CLAY_SIZING_PERCENT(0.25), }, - .layoutDirection = CLAY_TOP_TO_BOTTOM, .childGap = 20, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER }, + .layoutDirection = CLAY_TOP_TO_BOTTOM, }, }) { CLAY_AUTO_ID({ @@ -362,10 +364,10 @@ void component_image_small(img_group **img_pairs, int count, int selected_index) .width = CLAY_SIZING_PERCENT(0.7), }, }, + .aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height }, .image = { .imageData = &img_pairs[selected_index]->image_1, }, - .aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height } }) { } CLAY_AUTO_ID({ .layout = { @@ -373,10 +375,10 @@ void component_image_small(img_group **img_pairs, int count, int selected_index) .width = CLAY_SIZING_GROW(), }, }, + .aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height }, .image = { .imageData = &img_pairs[selected_index]->image_2, }, - .aspectRatio = { (float)img_pairs[selected_index]->width / img_pairs[selected_index]->height } }) { } component_termbox_settings(); } @@ -390,8 +392,8 @@ void component_thumbnails(img_group **img_pairs, int count, int selected_index) .width = CLAY_SIZING_PERCENT(0.1), .height = CLAY_SIZING_GROW() }, + .childGap = 20, .layoutDirection = CLAY_TOP_TO_BOTTOM, - .childGap = 20 }, .backgroundColor = { 0x42, 0x42, 0x42, 0xff } }) { @@ -399,8 +401,8 @@ void component_thumbnails(img_group **img_pairs, int count, int selected_index) Clay_BorderElementConfig border; if (i == selected_index) { border = (Clay_BorderElementConfig) { + .color = { 0x00, 0x30, 0xc0, 0x8f }, .width =CLAY_BORDER_OUTSIDE(10), - .color = { 0x00, 0x30, 0xc0, 0x8f } }; } else { border = (Clay_BorderElementConfig) { @@ -413,11 +415,11 @@ void component_thumbnails(img_group **img_pairs, int count, int selected_index) .width = CLAY_SIZING_GROW(), }, }, - .border = border, + .aspectRatio = { (float)img_pairs[i]->width / img_pairs[i]->height }, .image = { .imageData = &img_pairs[i]->thumbnail, }, - .aspectRatio = { (float)img_pairs[i]->width / img_pairs[i]->height } + .border = border, }) { } } } @@ -434,11 +436,11 @@ Clay_RenderCommandArray CreateLayout(struct img_group **imgs) .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_GROW() }, + .childGap = 64, .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER }, - .childGap = 64 }, .backgroundColor = { 0x24, 0x24, 0x24, 0xff } }) { diff --git a/examples/win32_gdi/main.c b/examples/win32_gdi/main.c index e2e44fd..340716d 100644 --- a/examples/win32_gdi/main.c +++ b/examples/win32_gdi/main.c @@ -64,7 +64,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) zDelta = zDelta * .012; } - Clay_UpdateScrollContainers(true, (Clay_Vector2){.x = 0, .y = zDelta}, dt); + Clay_UpdateScrollContainers(true, (Clay_Vector2){.x = 0, .y = (float)zDelta}, dt); InvalidateRect(hwnd, NULL, false); // force a wm_paint event break; @@ -79,7 +79,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) short mouseY = GET_Y_LPARAM(lParam); short mouseButtons = LOWORD(wParam); - Clay_SetPointerState((Clay_Vector2){mouseX, mouseY}, mouseButtons & 0b01); + Clay_SetPointerState((Clay_Vector2){(float)mouseX, (float)mouseY}, mouseButtons & 0b01); InvalidateRect(hwnd, NULL, false); // force a wm_paint event break; @@ -91,7 +91,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) RECT r = {0}; if (GetClientRect(hwnd, &r)) { - Clay_Dimensions dim = (Clay_Dimensions){.height = r.bottom - r.top, .width = r.right - r.left}; + Clay_Dimensions dim = (Clay_Dimensions){.width = (float)r.right - r.left, .height = (float)r.bottom - r.top}; Clay_SetLayoutDimensions(dim); } @@ -113,7 +113,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; } - printf("Key Pressed: %d\r\n", wParam); + printf("Key Pressed: %llu\r\n", wParam); InvalidateRect(hwnd, NULL, false); // force a wm_paint event break; diff --git a/renderers/cairo/clay_renderer_cairo.c b/renderers/cairo/clay_renderer_cairo.c index 15696ad..7cf16d6 100644 --- a/renderers/cairo/clay_renderer_cairo.c +++ b/renderers/cairo/clay_renderer_cairo.c @@ -1,5 +1,5 @@ // Copyright (c) 2024 Justin Andreas Lacoste (@27justin) -// +// // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the // use of this software. @@ -95,7 +95,7 @@ static inline Clay_Dimensions Clay_Cairo_MeasureText(Clay_StringSlice str, Clay_ } // Ensure string is null-terminated for Cairo - Clay_String toTerminate = (Clay_String){ .chars = str.chars, .length = str.length, .isStaticallyAllocated = false }; + Clay_String toTerminate = (Clay_String){ .isStaticallyAllocated = false, .length = str.length, .chars = str.chars }; char *text = Clay_Cairo__NullTerminate(&toTerminate); char *font_family = fonts[config->fontId]; diff --git a/renderers/win32_gdi/clay_renderer_gdi.c b/renderers/win32_gdi/clay_renderer_gdi.c index d9f8504..2f574b6 100644 --- a/renderers/win32_gdi/clay_renderer_gdi.c +++ b/renderers/win32_gdi/clay_renderer_gdi.c @@ -111,7 +111,7 @@ static inline Clay_Color ColorBlend(Clay_Color base, Clay_Color overlay, float f // Avoid division by zero and fully transparent cases if (out_a <= 0.0f) { - return (Clay_Color) { .a = 0, .r = 0, .g = 0, .b = 0 }; + return (Clay_Color) {.r = 0, .g = 0, .b = 0, .a = 0 }; } blended.r = (overlay.r * overlay_a + base.r * base_a * (1.0f - overlay_a)) / out_a; @@ -214,7 +214,7 @@ static void CreateHDCSubstitute(HDCSubstitute* phdcs, HDC hdcSrc, PRECT prc) } // Select the DIB section into the memory DC - phdcs->hbmMemPrev = SelectObject(phdcs->hdcMem, phdcs->hbmMem); + phdcs->hbmMemPrev = (HBITMAP)SelectObject(phdcs->hdcMem, phdcs->hbmMem); // Copy the content of the target DC to the memory DC BitBlt(phdcs->hdcMem, 0, 0, phdcs->size.cx, phdcs->size.cy, hdcSrc, prc->left, prc->top, SRCCOPY); @@ -329,7 +329,7 @@ void Clay_Win32_Render(HWND hwnd, Clay_RenderCommandArray renderCommands, HFONT* uint16_t font_id = renderCommand->renderData.text.fontId; HFONT hFont = fonts[font_id]; - HFONT hPrevFont = SelectObject(renderer_hdcMem, hFont); + HFONT hPrevFont = (HFONT)SelectObject(renderer_hdcMem, hFont); // Actually draw text DrawTextA(renderer_hdcMem, renderCommand->renderData.text.stringContents.chars, @@ -438,7 +438,7 @@ void Clay_Win32_Render(HWND hwnd, Clay_RenderCommandArray renderCommands, HFONT* HPEN bottomPen = CreatePen(PS_SOLID, brd.width.bottom, RGB(brd.color.r, brd.color.g, brd.color.b)); HPEN rightPen = CreatePen(PS_SOLID, brd.width.right, RGB(brd.color.r, brd.color.g, brd.color.b)); - HPEN oldPen = SelectObject(renderer_hdcMem, topPen); + HPEN oldPen = (HPEN)SelectObject(renderer_hdcMem, topPen); if (brd.cornerRadius.topLeft == 0) { @@ -536,7 +536,7 @@ static inline Clay_Dimensions Clay_Win32_MeasureText(Clay_StringSlice text, Clay if (hTempDC != NULL) { - HFONT hPrevFont = SelectObject(hTempDC, hFont); + HFONT hPrevFont = (HFONT)SelectObject(hTempDC, hFont); SIZE size; GetTextExtentPoint32(hTempDC, text.chars, text.length, &size);