d89ef83551
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.
77 lines
3.5 KiB
C
77 lines
3.5 KiB
C
#include "clay.h"
|
|
#include "layout.h"
|
|
#include "context.h"
|
|
|
|
|
|
// TODO: what is the document layout class even needed for? couldn't we just have any layout as the root?
|
|
static struct clay_layout_class_s layout_class_document = {};
|
|
|
|
|
|
static clay_prop_definition_in prop_numeric_single = {
|
|
.allow_int = true,
|
|
.allow_float = true,
|
|
.allow_units = CLAY_PROP_UNIT_ANY_UNIT,
|
|
};
|
|
|
|
static clay_prop_definition_in prop_numeric_two = {
|
|
.allow_int = true,
|
|
.allow_float = true,
|
|
.allow_units = CLAY_PROP_UNIT_ANY_UNIT,
|
|
.max_values = 2,
|
|
};
|
|
|
|
static clay_prop_definition_in prop_numeric_four = {
|
|
.allow_int = true,
|
|
.allow_float = true,
|
|
.allow_units = CLAY_PROP_UNIT_ANY_UNIT,
|
|
.max_values = 4,
|
|
};
|
|
|
|
static clay_prop_definition_in prop_numeric_eight = {
|
|
.allow_int = true,
|
|
.allow_float = true,
|
|
.allow_units = CLAY_PROP_UNIT_ANY_UNIT,
|
|
.max_values = 8,
|
|
};
|
|
|
|
static clay_prop_definition_in prop_color_single = {
|
|
.allow_color = true,
|
|
};
|
|
static clay_prop_definition_in prop_color_four = {
|
|
.allow_color = true,
|
|
.max_values = 4,
|
|
};
|
|
|
|
|
|
void clay_document_register(clay_ctx ctx) {
|
|
clay_ctx_register_layout_class(ctx, "document", &layout_class_document);
|
|
|
|
clay_ctx_register_global_property(ctx, "width", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "height", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "padding", &prop_numeric_four);
|
|
clay_ctx_register_global_property(ctx, "padding-left", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "padding-right", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "padding-top", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "padding-bottom", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "margin", &prop_numeric_four);
|
|
clay_ctx_register_global_property(ctx, "margin-left", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "margin-right", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "margin-top", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "margin-bottom", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "background-color", &prop_color_single);
|
|
clay_ctx_register_global_property(ctx, "border-width", &prop_numeric_four);
|
|
clay_ctx_register_global_property(ctx, "border-width-left", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "border-width-right", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "border-width-top", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "border-width-bottom", &prop_numeric_single);
|
|
clay_ctx_register_global_property(ctx, "border-color", &prop_color_four);
|
|
clay_ctx_register_global_property(ctx, "border-color-left", &prop_color_single);
|
|
clay_ctx_register_global_property(ctx, "border-color-right", &prop_color_single);
|
|
clay_ctx_register_global_property(ctx, "border-color-top", &prop_color_single);
|
|
clay_ctx_register_global_property(ctx, "border-color-bottom", &prop_color_single);
|
|
clay_ctx_register_global_property(ctx, "border-radius", &prop_numeric_eight);
|
|
clay_ctx_register_global_property(ctx, "border-radius-top-left", &prop_numeric_two);
|
|
clay_ctx_register_global_property(ctx, "border-radius-top-right", &prop_numeric_two);
|
|
clay_ctx_register_global_property(ctx, "border-radius-bottom-right", &prop_numeric_two);
|
|
clay_ctx_register_global_property(ctx, "border-radius-bottom-left", &prop_numeric_two);
|
|
} |