65 lines
1.9 KiB
C
65 lines
1.9 KiB
C
#include <stddef.h>
|
|
#include "clay.h"
|
|
#include "clay-color.h"
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
clay_ctx ctx = clay_create_context();
|
|
|
|
clay_color c1 = clay_color_rgba(4, 231, 98, 128);
|
|
clay_color c2 = clay_color_rgba(34, 49, 39, 128);
|
|
clay_color c3 = clay_color_rgba(220, 0, 115, 128);
|
|
clay_color c4 = clay_color_rgba(0, 139, 248, 128);
|
|
clay_color c5 = clay_color_rgba(71, 0, 99, 128);
|
|
clay_color cbg = clay_color_rgba(206, 249, 242, 255);
|
|
|
|
clay t1 = clay_create_text(ctx);
|
|
clay_set(t1, "content", "ITEM 1");
|
|
clay_set(t1, "bg-color", &c1);
|
|
clay_set(t1, "width", 100);
|
|
clay_set(t1, "flex:grow", 1);
|
|
clay_set(t1, "flex:shrink", 1);
|
|
clay_set(t1, "align", "center");
|
|
clay_set(t1, "vertical-align", "middle");
|
|
|
|
clay t2 = clay_clone(t1);
|
|
|
|
clay_set(t2, "content", "ITEM 2");
|
|
clay_set(t2, "bg-color", &c2);
|
|
clay_set(t2, "width", 300);
|
|
|
|
clay t3 = clay_clone(t1);
|
|
clay_set(t3, "content", "ITEM 3");
|
|
clay_set(t3, "bg-color", &c3);
|
|
clay_set(t3, "width", 200);
|
|
|
|
clay t4 = clay_clone(t1);
|
|
clay_set(t4, "content", "ITEM 4");
|
|
clay_set(t4, "bg-color", &c4);
|
|
clay_set(t4, "width", 400);
|
|
|
|
clay t5 = clay_clone(t1);
|
|
clay_set(t5, "content", "ITEM 5");
|
|
clay_set(t5, "bg-color", &c5);
|
|
clay_set(t5, "width", 250);
|
|
|
|
|
|
clay flex = clay_create_flex(ctx);
|
|
clay_set(flex, "direction", "row");
|
|
clay_set(flex, "wrap", "wrap");
|
|
clay_set(flex, "align-items", "stretch");
|
|
clay_set(flex, "align-content", "stretch");
|
|
clay_set(flex, "gap", 20);
|
|
clay_set(flex, "padding", 20);
|
|
clay_set(flex, "contents", (clay[]) {t1, t2, t3, t4, t5, NULL});
|
|
|
|
clay doc = clay_create_document(ctx);
|
|
clay_set(doc, "width", 800);
|
|
clay_set(doc, "height", 400);
|
|
clay_set(doc, "bg-color", &cbg);
|
|
clay_set(doc, "content", flex);
|
|
|
|
clay_debug_layout(doc);
|
|
|
|
clay_destroy_context(ctx);
|
|
} |