first pass with unsolved text wrapping bug

This commit is contained in:
johan0A 2025-01-13 00:06:27 +01:00
parent d4e1d84e5b
commit f6a86434e2
8 changed files with 679 additions and 185 deletions

View file

@ -55,23 +55,22 @@ var window_height: isize = 0;
var window_width: isize = 0;
fn LandingPageBlob(index: u32, font_size: u16, font_id: u16, color: cl.Color, image_size: f32, max_width: f32, text: []const u8, image: *rl.Texture2D) void {
if (cl.OPEN(&.{
cl.UI(&.{
.IDI("HeroBlob", index),
.layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = max_width }) }, .padding = .all(16), .child_gap = 16, .child_alignment = .{ .y = .CENTER } }),
.border(.outside(color, 2, 10)),
})) {
defer cl.CLOSE();
cl.singleElem(&.{
})({
cl.UI(&.{
.IDI("CheckImage", index),
.layout(.{ .sizing = .{ .w = .fixed(image_size) } }),
.image(.{ .image_data = image, .source_dimensions = .{ .w = 128, .h = 128 } }),
});
})({});
cl.text(text, cl.Config.text(.{ .font_size = font_size, .font_id = font_id, .color = color }));
}
});
}
fn landingPageDesktop() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("LandingPage1Desktop"),
.layout(.{
.sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 70) }) },
@ -79,9 +78,8 @@ fn landingPageDesktop() void {
.padding = .{ .x = 50 },
.child_gap = 16,
}),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("LandingPage1"),
.layout(.{
.sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 70) }) },
@ -91,53 +89,49 @@ fn landingPageDesktop() void {
.child_gap = 32,
}),
.border(.{ .left = border_data, .right = border_data }),
})) {
defer cl.CLOSE();
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_ZIG_LOGO, 64, 510, "The official Clay website recreated with zclay: clay-zig-bindings", &zig_logo_image6);
})({
LandingPageBlob(0, 30, FONT_ID_BODY_30, COLOR_ZIG_LOGO, 64, 510, "The official Clay website recreated with zclay: clay-zig-bindings", &zig_logo_image6);
if (cl.OPEN(&.{
cl.UI(&.{
.ID("ClayPresentation"),
.layout(.{
.sizing = .grow,
.child_alignment = .{ .y = .CENTER },
.child_gap = 16,
}),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("LeftText"),
.layout(.{ .sizing = .{ .w = .percent(0.55) }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }),
})) {
defer cl.CLOSE();
})({
cl.text(
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
cl.Config.text(.{ .font_size = 56, .font_id = FONT_ID_TITLE_56, .color = COLOR_RED }),
);
cl.singleElem(&.{ .ID("Spacer"), .layout(.{ .sizing = .{ .w = .grow, .h = .fixed(32) } }) });
cl.UI(&.{ .ID("ClayPresentation_Spacer"), .layout(.{ .sizing = .{ .w = .grow, .h = .fixed(32) } }) })({});
cl.text(
"Clay is laying out this webpage .right now!",
"Clay is laying out this webpage right now!",
cl.Config.text(.{ .font_size = 36, .font_id = FONT_ID_BODY_36, .color = COLOR_ORANGE }),
);
}
});
if (cl.OPEN(&.{
cl.UI(&.{
.ID("HeroImageOuter"),
.layout(.{ .sizing = .{ .w = .percent(0.45) }, .direction = .TOP_TO_BOTTOM, .child_alignment = .{ .x = .CENTER }, .child_gap = 16 }),
})) {
defer cl.CLOSE();
})({
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_5, 32, 480, "High performance", &checkImage5);
LandingPageBlob(2, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_4, 32, 480, "Flexbox-style responsive layout", &checkImage4);
LandingPageBlob(3, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_3, 32, 480, "Declarative syntax", &checkImage3);
LandingPageBlob(4, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_2, 32, 480, "Single .h file for C/C++", &checkImage2);
LandingPageBlob(5, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_1, 32, 480, "Compile to 15kb .wasm", &checkImage1);
}
}
}
}
});
});
});
});
}
fn landingPageMobile() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("LandingPage1Mobile"),
.layout(.{
.sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 70) }) },
@ -146,42 +140,39 @@ fn landingPageMobile() void {
.padding = .{ .x = 16, .y = 32 },
.child_gap = 16,
}),
})) {
defer cl.CLOSE();
})({
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_ZIG_LOGO, 64, 510, "The official Clay website recreated with zclay: clay-zig-bindings", &zig_logo_image6);
if (cl.OPEN(&.{
cl.UI(&.{
.ID("LeftText"),
.layout(.{ .sizing = .{ .w = .grow }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }),
})) {
defer cl.CLOSE();
})({
cl.text(
"Clay is a flex-box style UI auto layout library in C, with declarative syntax and microsecond performance.",
cl.Config.text(.{ .font_size = 56, .font_id = FONT_ID_TITLE_56, .color = COLOR_RED }),
);
cl.singleElem(&.{ .ID("Spacer"), .layout(.{ .sizing = .{ .w = .grow, .h = .fixed(32) } }) });
cl.UI(&.{ .ID("LeftText_Spacer"), .layout(.{ .sizing = .{ .w = .grow, .h = .fixed(32) } }) })({});
cl.text(
"Clay is laying out this webpage .right now!",
cl.Config.text(.{ .font_size = 36, .font_id = FONT_ID_BODY_36, .color = COLOR_ORANGE }),
);
}
});
if (cl.OPEN(&.{
cl.UI(&.{
.ID("HeroImageOuter"),
.layout(.{ .sizing = .{ .w = .grow }, .direction = .TOP_TO_BOTTOM, .child_alignment = .{ .x = .CENTER }, .child_gap = 16 }),
})) {
defer cl.CLOSE();
})({
LandingPageBlob(1, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_5, 32, 480, "High performance", &checkImage5);
LandingPageBlob(2, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_4, 32, 480, "Flexbox-style responsive layout", &checkImage4);
LandingPageBlob(3, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_3, 32, 480, "Declarative syntax", &checkImage3);
LandingPageBlob(4, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_2, 32, 480, "Single .h file for C/C++", &checkImage2);
LandingPageBlob(5, 30, FONT_ID_BODY_30, COLOR_BLOB_BORDER_1, 32, 480, "Compile to 15kb .wasm", &checkImage1);
}
}
});
});
}
fn featureBlocks(width_sizing: cl.SizingAxis, outer_padding: u16) void {
const text_config = cl.Config.text(.{ .font_size = 24, .font_id = FONT_ID_BODY_24, .color = COLOR_RED });
if (cl.OPEN(&.{
cl.UI(&.{
.ID("HFileBoxOuter"),
.layout(.{
.direction = .TOP_TO_BOTTOM,
@ -190,20 +181,18 @@ fn featureBlocks(width_sizing: cl.SizingAxis, outer_padding: u16) void {
.padding = .{ .x = outer_padding, .y = 32 },
.child_gap = 8,
}),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("HFileIncludeOuter"),
.layout(.{ .padding = .{ .x = 8, .y = 4 } }),
.rectangle(.{ .color = COLOR_RED, .corner_radius = .all(8) }),
})) {
defer cl.CLOSE();
})({
cl.text("#include cl.h", .text(.{ .font_size = 24, .font_id = FONT_ID_BODY_24, .color = COLOR_LIGHT }));
}
});
cl.text("~2000 lines of C99.", text_config);
cl.text("Zero dependencies, including no C standard library", text_config);
}
if (cl.OPEN(&.{
});
cl.UI(&.{
.ID("BringYourOwnRendererOuter"),
.layout(.{
.direction = .TOP_TO_BOTTOM,
@ -212,84 +201,77 @@ fn featureBlocks(width_sizing: cl.SizingAxis, outer_padding: u16) void {
.padding = .{ .x = outer_padding, .y = 32 },
.child_gap = 8,
}),
})) {
defer cl.CLOSE();
})({
cl.text("Renderer agnostic.", .text(.{ .font_size = 24, .font_id = FONT_ID_BODY_24, .color = COLOR_ORANGE }));
cl.text("Layout with clay, then render with Raylib, WebGL Canvas or even as HTML.", text_config);
cl.text("Flexible output for easy compositing in your custom engine or environment.", text_config);
}
});
}
fn featureBlocksDesktop() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("FeatureBlocksOuter"),
.layout(.{
.sizing = .{ .w = .grow },
.child_alignment = .{ .y = .CENTER },
}),
.border(.{ .between_children = .{ .width = 2, .color = COLOR_RED } }),
})) {
defer cl.CLOSE();
})({
featureBlocks(.percent(0.5), 50);
}
});
}
fn featureBlocksMobile() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("FeatureBlocksOuter"),
.layout(.{
.sizing = .{ .w = .grow },
.direction = .TOP_TO_BOTTOM,
}),
.border(.{ .between_children = .{ .width = 2, .color = COLOR_RED } }),
})) {
defer cl.CLOSE();
})({
featureBlocks(.grow, 16);
}
});
}
fn declarativeSyntaxPage(title_text_config: cl.TextElementConfig, width_sizing: cl.SizingAxis) void {
if (cl.OPEN(&.{ .ID("SyntaxPageLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })) {
defer cl.CLOSE();
cl.UI(&.{ .ID("SyntaxPageLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })({
cl.text("Declarative Syntax", .text(title_text_config));
cl.singleElem(&.{
cl.UI(&.{
.ID("SyntaxSpacer"),
.layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 16 }) } }),
});
})({});
const text_conf = cl.Config.text(.{ .font_size = 28, .font_id = FONT_ID_BODY_28, .color = COLOR_RED });
cl.text("Flexible and readable declarative syntax with nested UI element hierarchies.", text_conf);
cl.text("Mix elements with standard C code like loops, conditionals and functions.", text_conf);
cl.text("Create your own library of re-usable components from UI primitives like text, images and rectangles.", text_conf);
}
if (cl.OPEN(&.{ .ID("SyntaxPageRightImageOuter"), .layout(.{ .sizing = .{ .w = width_sizing }, .child_alignment = .{ .x = .CENTER } }) })) {
defer cl.CLOSE();
cl.singleElem(&.{
});
cl.UI(&.{ .ID("SyntaxPageRightImageOuter"), .layout(.{ .sizing = .{ .w = width_sizing }, .child_alignment = .{ .x = .CENTER } }) })({
cl.UI(&.{
.ID("SyntaxPageRightImage"),
.layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 568 }) } }),
.image(.{ .image_data = &syntaxImage, .source_dimensions = .{ .h = 1136, .w = 1194 } }),
});
}
})({});
});
}
fn declarativeSyntaxPageDesktop() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("SyntaxPageDesktop"),
.layout(.{ .sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 50) }) }, .child_alignment = .{ .y = .CENTER }, .padding = .{ .x = 50 } }),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("SyntaxPage"),
.layout(.{ .sizing = .{ .w = .grow, .h = .grow }, .child_alignment = .{ .y = .CENTER }, .padding = .all(32), .child_gap = 32 }),
.border(.{ .left = .{ .width = 2, .color = COLOR_RED }, .right = .{ .width = 2, .color = COLOR_RED } }),
})) {
defer cl.CLOSE();
})({
declarativeSyntaxPage(.{ .font_size = 52, .font_id = FONT_ID_TITLE_52, .color = COLOR_RED }, .percent(0.5));
}
}
});
});
}
fn declarativeSyntaxPageMobile() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("SyntaxPageMobile"),
.layout(.{
.direction = .TOP_TO_BOTTOM,
@ -298,10 +280,9 @@ fn declarativeSyntaxPageMobile() void {
.padding = .{ .x = 16, .y = 32 },
.child_gap = 16,
}),
})) {
defer cl.CLOSE();
})({
declarativeSyntaxPage(.{ .font_size = 48, .font_id = FONT_ID_TITLE_48, .color = COLOR_RED }, .grow);
}
});
}
fn colorLerp(a: cl.Color, b: cl.Color, amount: f32) cl.Color {
@ -311,10 +292,9 @@ fn colorLerp(a: cl.Color, b: cl.Color, amount: f32) cl.Color {
const LOREM_IPSUM_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
fn highPerformancePage(lerp_value: f32, title_text_tonfig: cl.TextElementConfig, width_sizing: cl.SizingAxis) void {
if (cl.OPEN(&.{ .ID("PerformanceLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })) {
defer cl.CLOSE();
cl.UI(&.{ .ID("PerformanceLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })({
cl.text("High Performance", .text(title_text_tonfig));
cl.singleElem(&.{ .ID("PerformanceSyntaxSpacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 16 }) } }) });
cl.UI(&.{ .ID("PerformanceSyntaxSpacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 16 }) } }) })({});
cl.text(
"Fast enough to recompute your entire UI every frame.",
.text(.{ .font_size = 28, .font_id = FONT_ID_BODY_36, .color = COLOR_LIGHT }),
@ -327,37 +307,33 @@ fn highPerformancePage(lerp_value: f32, title_text_tonfig: cl.TextElementConfig,
"Simplify animations and reactive UI design by avoiding the standard performance hacks.",
.text(.{ .font_size = 28, .font_id = FONT_ID_BODY_36, .color = COLOR_LIGHT }),
);
}
if (cl.OPEN(&.{ .ID("PerformanceRightImageOuter"), .layout(.{ .sizing = .{ .w = width_sizing }, .child_alignment = .{ .x = .CENTER } }) })) {
defer cl.CLOSE();
if (cl.OPEN(&.{
});
cl.UI(&.{ .ID("PerformanceRightImageOuter"), .layout(.{ .sizing = .{ .w = width_sizing }, .child_alignment = .{ .x = .CENTER } }) })({
cl.UI(&.{
.ID("PerformanceRightBorder"),
.layout(.{ .sizing = .{ .w = .grow, .h = .fixed(400) } }),
.border(.all(COLOR_LIGHT, 2, 0)),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("AnimationDemoContainerLeft"),
.layout(.{ .sizing = .{ .w = .percent(0.35 + 0.3 * lerp_value), .h = .grow }, .child_alignment = .{ .y = .CENTER }, .padding = .all(16) }),
.rectangle(.{ .color = colorLerp(COLOR_RED, COLOR_ORANGE, lerp_value) }),
})) {
defer cl.CLOSE();
})({
cl.text(LOREM_IPSUM_TEXT, .text(.{ .font_size = 16, .font_id = FONT_ID_BODY_16, .color = COLOR_LIGHT }));
}
if (cl.OPEN(&.{
});
cl.UI(&.{
.ID("AnimationDemoContainerRight"),
.layout(.{ .sizing = .{ .w = .grow, .h = .grow }, .child_alignment = .{ .y = .CENTER }, .padding = .all(16) }),
.rectangle(.{ .color = colorLerp(COLOR_ORANGE, COLOR_RED, lerp_value) }),
})) {
defer cl.CLOSE();
})({
cl.text(LOREM_IPSUM_TEXT, .text(.{ .font_size = 16, .font_id = FONT_ID_BODY_16, .color = COLOR_LIGHT }));
}
}
}
});
});
});
}
fn highPerformancePageDesktop(lerp_value: f32) void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("PerformanceDesktop"),
.layout(.{
.sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 50) }) },
@ -366,14 +342,13 @@ fn highPerformancePageDesktop(lerp_value: f32) void {
.child_gap = 64,
}),
.rectangle(.{ .color = COLOR_RED }),
})) {
defer cl.CLOSE();
})({
highPerformancePage(lerp_value, .{ .font_size = 52, .font_id = FONT_ID_TITLE_52, .color = COLOR_LIGHT }, .percent(0.5));
}
});
}
fn highPerformancePageMobile(lerp_value: f32) void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("PerformanceMobile"),
.layout(
.{
@ -385,41 +360,36 @@ fn highPerformancePageMobile(lerp_value: f32) void {
},
),
.rectangle(.{ .color = COLOR_RED }),
})) {
defer cl.CLOSE();
})({
highPerformancePage(lerp_value, .{ .font_size = 48, .font_id = FONT_ID_TITLE_48, .color = COLOR_LIGHT }, .grow);
}
});
}
fn rendererButtonActive(text: []const u8) void {
if (cl.OPEN(&.{
cl.UI(&.{
.layout(.{ .sizing = .{ .w = .fixed(300) }, .padding = .all(16) }),
.rectangle(.{ .color = COLOR_RED, .corner_radius = .all(10) }),
})) {
defer cl.CLOSE();
})({
cl.text(text, .text(.{ .font_size = 28, .font_id = FONT_ID_BODY_28, .color = COLOR_LIGHT }));
}
});
}
fn rendererButtonInactive(index: u32, text: []const u8) void {
if (cl.OPEN(&.{ .layout(.{}), .outside(.{ 2, COLOR_RED }, 10) })) {
defer cl.CLOSE();
if (cl.OPEN(&.{
cl.UI(&.{ .layout(.{}), .outside(.{ 2, COLOR_RED }, 10) })({
cl.UI(&.{
.ID("RendererButtonInactiveInner", index),
.layout(.{ .sizing = .{ .w = .fixed(300) }, .padding = .all(16) }),
.rectangle(.{ .color = COLOR_LIGHT, .corner_radius = .all(10) }),
})) {
defer cl.CLOSE();
})({
cl.text(text, .text(.{ .font_size = 28, .font_id = FONT_ID_BODY_28, .color = COLOR_RED }));
}
}
});
});
}
fn rendererPage(title_text_config: cl.TextElementConfig, width_sizing: cl.SizingAxis) void {
if (cl.OPEN(&.{ .ID("RendererLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })) {
defer cl.CLOSE();
cl.UI(&.{ .ID("RendererLeftText"), .layout(.{ .sizing = .{ .w = width_sizing }, .direction = .TOP_TO_BOTTOM, .child_gap = 8 }) })({
cl.text("Renderer & Platform Agnostic", .text(title_text_config));
cl.singleElem(&.{ .ID("Spacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 16 }) } }) });
cl.UI(&.{ .ID("RendererLeftText_Spacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 16 }) } }) })({});
cl.text(
"Clay outputs a sorted array of primitive render commands, such as RECTANGLE, TEXT or IMAGE.",
.text(.{ .font_size = 28, .font_id = FONT_ID_BODY_36, .color = COLOR_RED }),
@ -432,41 +402,38 @@ fn rendererPage(title_text_config: cl.TextElementConfig, width_sizing: cl.Sizing
"There's even an HTML renderer - you're looking at it .right now!",
.text(.{ .font_size = 28, .font_id = FONT_ID_BODY_36, .color = COLOR_RED }),
);
}
if (cl.OPEN(&.{
});
cl.UI(&.{
.ID("RendererRightText"),
.layout(.{ .sizing = .{ .w = width_sizing }, .child_alignment = .{ .x = .CENTER }, .direction = .TOP_TO_BOTTOM, .child_gap = 16 }),
})) {
defer cl.CLOSE();
})({
cl.text("Try changing renderer!", .text(.{ .font_size = 36, .font_id = FONT_ID_BODY_36, .color = COLOR_ORANGE }));
cl.singleElem(&.{ .ID("Spacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 32 }) } }) });
cl.UI(&.{ .ID("Spacer"), .layout(.{ .sizing = .{ .w = .growMinMax(.{ .max = 32 }) } }) })({});
rendererButtonActive("Raylib Renderer");
}
});
}
fn rendererPageDesktop() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("RendererPageDesktop"),
.layout(.{
.sizing = .{ .w = .grow, .h = .fitMinMax(.{ .min = @floatFromInt(window_height - 50) }) },
.child_alignment = .{ .y = .CENTER },
.padding = .{ .x = 50 },
}),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("RendererPage"),
.layout(.{ .sizing = .grow, .child_alignment = .{ .y = .CENTER }, .padding = .all(32), .child_gap = 32 }),
.border(.{ .left = .{ .width = 2, .color = COLOR_RED }, .right = .{ .width = 2, .color = COLOR_RED } }),
})) {
defer cl.CLOSE();
})({
rendererPage(.{ .font_size = 52, .font_id = FONT_ID_TITLE_52, .color = COLOR_RED }, .percent(0.5));
}
}
});
});
}
fn rendererPageMobile() void {
if (cl.OPEN(&.{
cl.UI(&.{
.ID("RendererMobile"),
.layout(
.{
@ -478,23 +445,21 @@ fn rendererPageMobile() void {
},
),
.rectangle(.{ .color = COLOR_LIGHT }),
})) {
defer cl.CLOSE();
})({
rendererPage(.{ .font_size = 52, .font_id = FONT_ID_TITLE_52, .color = COLOR_RED }, .grow);
}
});
}
fn createLayout(lerp_value: f32) cl.ClayArray(cl.RenderCommand) {
const mobileScreen = window_width < 750;
cl.beginLayout();
if (cl.OPEN(&.{
cl.UI(&.{
.ID("OuterContainer"),
.layout(.{ .sizing = .grow, .direction = .TOP_TO_BOTTOM }),
.rectangle(.{ .color = COLOR_LIGHT }),
})) {
defer cl.CLOSE();
if (cl.OPEN(&.{
})({
cl.UI(&.{
.ID("Header"),
.layout(.{
.sizing = .{ .h = .fixed(50), .w = .grow },
@ -502,27 +467,24 @@ fn createLayout(lerp_value: f32) cl.ClayArray(cl.RenderCommand) {
.padding = .{ .x = 32 },
.child_gap = 24,
}),
})) {
defer cl.CLOSE();
})({
cl.text("Clay", cl.Config.text(.{
.font_id = FONT_ID_BODY_24,
.font_size = 24,
.color = .{ 61, 26, 5, 255 },
}));
cl.singleElem(&.{ .ID("HeaderSpacer"), .layout(.{ .sizing = .{ .w = .grow } }) });
cl.UI(&.{ .ID("HeaderSpacer"), .layout(.{ .sizing = .{ .w = .grow } }) })({});
if (!mobileScreen) {
if (cl.OPEN(&.{ .ID("LinkExamplesInner"), .layout(.{}), .rectangle(.{ .color = .{ 0, 0, 0, 0 } }) })) {
defer cl.CLOSE();
cl.UI(&.{ .ID("LinkExamplesInner"), .layout(.{}), .rectangle(.{ .color = .{ 0, 0, 0, 0 } }) })({
cl.text("Examples", cl.Config.text(.{ .font_id = FONT_ID_BODY_24, .font_size = 24, .color = .{ 61, 26, 5, 255 } }));
}
if (cl.OPEN(&.{ .ID("LinkDocsOuter"), .layout(.{}), .rectangle(.{ .color = .{ 0, 0, 0, 0 } }) })) {
defer cl.CLOSE();
});
cl.UI(&.{ .ID("LinkDocsOuter"), .layout(.{}), .rectangle(.{ .color = .{ 0, 0, 0, 0 } }) })({
cl.text("Docs", cl.Config.text(.{ .font_id = FONT_ID_BODY_24, .font_size = 24, .color = .{ 61, 26, 5, 255 } }));
}
});
}
if (cl.OPEN(&.{
cl.UI(&.{
.ID("LinkGithubOuter"),
.layout(.{ .padding = .{ .x = 32, .y = 6 } }),
.border(.outside(COLOR_RED, 2, 10)),
@ -530,30 +492,28 @@ fn createLayout(lerp_value: f32) cl.ClayArray(cl.RenderCommand) {
.corner_radius = .all(10),
.color = if (cl.pointerOver(cl.getElementId("LinkGithubOuter"))) COLOR_LIGHT_HOVER else COLOR_LIGHT,
}),
})) {
defer cl.CLOSE();
})({
cl.text(
"Github",
cl.Config.text(.{ .font_id = FONT_ID_BODY_24, .font_size = 24, .color = .{ 61, 26, 5, 255 } }),
);
}
}
});
});
inline for (COLORS_TOP_BORDER, 0..) |color, i| {
cl.singleElem(&.{
cl.UI(&.{
.ID("TopBorder" ++ .{i}),
.layout(.{ .sizing = .{ .h = .fixed(4), .w = .grow } }),
.rectangle(.{ .color = color }),
});
})({});
}
if (cl.OPEN(&.{
cl.UI(&.{
.ID("ScrollContainerBackgroundRectangle"),
.scroll(.{ .vertical = true }),
.layout(.{ .sizing = .grow, .direction = .TOP_TO_BOTTOM }),
.rectangle(.{ .color = COLOR_LIGHT }),
.border(.{ .between_children = .{ .width = 2, .color = COLOR_RED } }),
})) {
defer cl.CLOSE();
})({
if (!mobileScreen) {
landingPageDesktop();
featureBlocksDesktop();
@ -567,8 +527,8 @@ fn createLayout(lerp_value: f32) cl.ClayArray(cl.RenderCommand) {
highPerformancePageMobile(lerp_value);
rendererPageMobile();
}
}
}
});
});
return cl.endLayout();
}
@ -601,7 +561,7 @@ pub fn main() anyerror!void {
});
rl.initWindow(1000, 1000, "Raylib zig Example");
rl.setWindowMinSize(300, 100);
rl.setTargetFPS(120);
rl.setTargetFPS(60);
// load assets
loadFont(@embedFile("resources/Calistoga-Regular.ttf"), FONT_ID_TITLE_56, 56);