clay/src/demo.c
Gwendolyn d89ef83551 Reworked property system completely.
Properties can now have values of different types, and they are registered with their name, either to a layout class or globally.
Layout classes are also registered with their name.
2023-02-08 01:09:21 +01:00

69 lines
2 KiB
C

#include <stddef.h>
#include "clay.h"
#include "color.h"
#include "layout.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 t1 = clay_create(ctx, "text");
clay_set(t1, "text", "ITEM 1");
clay_set(t1, "background-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, "text", "ITEM 2");
clay_set(t2, "background-color", c2);
clay_set(t2, "width", 300);
clay t3 = clay_clone(t1);
clay_set(t3, "text", "ITEM 3");
clay_set(t3, "background-color", c3);
clay_set(t3, "width", 200);
clay t4 = clay_clone(t1);
clay_set(t4, "text", "ITEM 4");
clay_set(t4, "background-color", c4);
clay_set(t4, "width", 400);
clay t5 = clay_clone(t1);
clay_set(t5, "text", "ITEM 5");
clay_set(t5, "background-color", c5);
clay_set(t5, "width", 250);
clay flex = clay_create(ctx, "flex");
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_append_child(flex, t1);
clay_append_child(flex, t2);
clay_append_child(flex, t3);
clay_append_child(flex, t4);
clay_append_child(flex, t5);
clay doc = clay_create(ctx, "document");
clay_set(doc, "width", 800);
clay_set(doc, "height", 400);
clay_set(doc, "background-color", "#cef9f2ff");
clay_append_child(doc, flex);
clay_print_layout_tree(doc);
clay_destroy_context(ctx);
}