#include "clay.h" #include "clay-layout.h" #include "clay-context.h" #include "clay-color.h" static void cleanup_text(clay layout); static void init_text(clay layout); static void debug_text(clay layout); static struct layout_class layout_class_text = { .cleanup = &cleanup_text, .init = &init_text, .debug = &debug_text, }; static void init_text(clay layout) { // todo: anything? } static void cleanup_text(clay layout) { // todo: anything? } static void debug_text(clay layout) { printf("text:\n"); clay_property_value content_prop = clay_get_prop(layout, "content"); clay_property_value bgcolor_prop = clay_get_prop(layout, "bg-color"); clay_property_value width_prop = clay_get_prop(layout, "width"); clay_property_value flex_grow_prop = clay_get_prop(layout, "flex:grow"); clay_property_value flex_shrink_prop = clay_get_prop(layout, "flex:shrink"); clay_property_value align_prop = clay_get_prop(layout, "align"); clay_property_value vertical_align_prop = clay_get_prop(layout, "vertical-align"); if (content_prop->type == CLAY_PROPERTY_POINTER) { printf(" content: %s\n", (char*)content_prop->pointer_val); } if (bgcolor_prop->type == CLAY_PROPERTY_POINTER) { clay_color *color = (clay_color*)bgcolor_prop->pointer_val; printf(" bg-color: (%d, %d, %d, %d)\n", color->r, color->g, color->b, color->a); } if (width_prop->type == CLAY_PROPERTY_INT) { printf(" width: %d\n", width_prop->int_val); } if (flex_grow_prop->type == CLAY_PROPERTY_INT) { printf(" flex-grow: %d\n", flex_grow_prop->int_val); } if (flex_shrink_prop->type == CLAY_PROPERTY_INT) { printf(" flex-shrink: %d\n", flex_shrink_prop->int_val); } if (align_prop->type == CLAY_PROPERTY_POINTER) { printf(" align: %s\n", (char*)align_prop->pointer_val); } if (vertical_align_prop->type == CLAY_PROPERTY_POINTER) { printf(" vertical-align: %s\n", (char*)vertical_align_prop->pointer_val); } } clay clay_create_text(clay_ctx ctx) { return clay_create_layout(ctx, layout_class_text); } void clay_text_register_props(clay_ctx ctx) { clay_ctx_register_property(ctx, "align", CLAY_PROPERTY_POINTER); clay_ctx_register_property(ctx, "vertical-align", CLAY_PROPERTY_POINTER); }