82 lines
2.8 KiB
C
82 lines
2.8 KiB
C
#include "clay.h"
|
|
#include "clay-layout.h"
|
|
#include "clay-context.h"
|
|
|
|
static void cleanup_flex(clay layout);
|
|
|
|
static void init_flex(clay layout);
|
|
|
|
static void debug_flex(clay layout);
|
|
|
|
static struct layout_class layout_class_flex = {
|
|
.init = &init_flex,
|
|
.cleanup = &cleanup_flex,
|
|
.debug = &debug_flex,
|
|
};
|
|
|
|
static void init_flex(clay layout) {
|
|
// todo: anything?
|
|
}
|
|
|
|
static void cleanup_flex(clay layout) {
|
|
// todo: anything?
|
|
}
|
|
|
|
static void debug_flex(clay layout) {
|
|
printf("flex:\n");
|
|
clay_property_value direction_prop = clay_get_prop(layout, "direction");
|
|
clay_property_value wrap_prop = clay_get_prop(layout, "wrap");
|
|
clay_property_value align_items_prop = clay_get_prop(layout, "align-items");
|
|
clay_property_value align_content_prop = clay_get_prop(layout, "align-content");
|
|
clay_property_value gap_prop = clay_get_prop(layout, "gap");
|
|
clay_property_value padding_prop = clay_get_prop(layout, "padding");
|
|
clay_property_value contents_prop = clay_get_prop(layout, "contents");
|
|
|
|
if (direction_prop->type == CLAY_PROPERTY_POINTER) {
|
|
printf(" direction: %s\n", (char*)direction_prop->pointer_val);
|
|
}
|
|
if (wrap_prop->type == CLAY_PROPERTY_POINTER) {
|
|
printf(" wrap: %s\n", (char*)wrap_prop->pointer_val);
|
|
}
|
|
if (align_items_prop->type == CLAY_PROPERTY_POINTER) {
|
|
printf(" align-items: %s\n", (char*)align_items_prop->pointer_val);
|
|
}
|
|
if (align_content_prop->type == CLAY_PROPERTY_POINTER) {
|
|
printf(" align-content: %s\n", (char*)align_content_prop->pointer_val);
|
|
}
|
|
if (gap_prop->type == CLAY_PROPERTY_INT) {
|
|
printf(" gap: %d\n", gap_prop->int_val);
|
|
}
|
|
if (padding_prop->type == CLAY_PROPERTY_INT) {
|
|
printf(" padding: %d\n", padding_prop->int_val);
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
if (contents_prop->type == CLAY_PROPERTY_POINTER) {
|
|
clay* ptr = (clay*)contents_prop->pointer_val;
|
|
while(*ptr != NULL) {
|
|
clay content = *ptr;
|
|
content->class.debug(content);
|
|
ptr += 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
clay clay_create_flex(clay_ctx ctx) {
|
|
return clay_create_layout(ctx, layout_class_flex);
|
|
}
|
|
|
|
|
|
void clay_flex_register_props(clay_ctx ctx) {
|
|
clay_ctx_register_property(ctx, "direction", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "wrap", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "align-items", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "align-content", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "gap", CLAY_PROPERTY_INT);
|
|
clay_ctx_register_property(ctx, "padding", CLAY_PROPERTY_INT);
|
|
clay_ctx_register_property(ctx, "contents", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "flex:grow", CLAY_PROPERTY_POINTER);
|
|
clay_ctx_register_property(ctx, "flex:shrink", CLAY_PROPERTY_POINTER);
|
|
} |