add convenience function to box layout to set all margins

This commit is contained in:
hippoz 2023-05-24 21:11:00 +03:00
parent fd482ff455
commit 8b56dcd3dd
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED
2 changed files with 9 additions and 0 deletions

View file

@ -143,6 +143,14 @@ int box_layout_handle(UINode *component, enum UIEvent ev, size_t d, void *p)
return 0; return 0;
} }
void box_layout_set_margins(UIBoxLayoutNode *layout, double margin)
{
layout->margin_top = margin;
layout->margin_left = margin;
layout->margin_bottom = margin;
layout->margin_right = margin;
}
UIBoxLayoutNode *box_layout_new(UINode *parent, enum UIDirection direction) UIBoxLayoutNode *box_layout_new(UINode *parent, enum UIDirection direction)
{ {
UIBoxLayoutNode *n = malloc(sizeof(UIBoxLayoutNode)); UIBoxLayoutNode *n = malloc(sizeof(UIBoxLayoutNode));

View file

@ -10,6 +10,7 @@ typedef struct UIBoxLayoutNode {
} UIBoxLayoutNode; } UIBoxLayoutNode;
UIBoxLayoutNode *box_layout_new(UINode *parent, enum UIDirection direction); UIBoxLayoutNode *box_layout_new(UINode *parent, enum UIDirection direction);
void box_layout_set_margins(UIBoxLayoutNode *layout, double margin);
int box_layout_handle(UINode *component, enum UIEvent ev, size_t d, void *p); int box_layout_handle(UINode *component, enum UIEvent ev, size_t d, void *p);
#endif // _UI__BOX_LAYOUT_NODE_H #endif // _UI__BOX_LAYOUT_NODE_H