#include "saffron_layout.h" #include "saffron_api.h" #include #include #include #include #include #include SaffronBox* saffron_box_new(SaffronOrientation orientation, SaffronHorizontalAlignment halign, SaffronVerticalAlignment valign, int spacing, int padding, int margin) { SaffronBox* box = malloc(sizeof(SaffronBox)); if (!box) return NULL; saffron_widget_init((SaffronWidget*)box); box->orientation = orientation; box->halign = halign; box->valign = valign; box->spacing = spacing; box->padding = padding; box->margin = margin; return box; } void saffron_box_layout(SaffronBox* box) { if (!box || ((SaffronWidget*)box)->child_count == 0) return; int content_x = ((SaffronWidget*)box)->x + box->margin; int content_y = ((SaffronWidget*)box)->y + box->margin; int content_w = ((SaffronWidget*)box)->w - (box->margin * 2); int content_h = ((SaffronWidget*)box)->h - (box->margin * 2); int inner_x = content_x + box->padding; int inner_y = content_y + box->padding; int inner_w = content_w - (box->padding * 2); int inner_h = content_h - (box->padding * 2); /* TODO actually make it layout */ return; }