From 4152fbecb6ee8360575aa4c24e9cedf822f159dc Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 25 Mar 2026 19:59:14 -0700 Subject: Implement vertical and horizontal layouts. Use widget position properly when rendering. Toolbar, buttons and edit bars WIP --- src/widget/layout.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/widget/layout.c (limited to 'src/widget/layout.c') diff --git a/src/widget/layout.c b/src/widget/layout.c new file mode 100644 index 0000000..c529c56 --- /dev/null +++ b/src/widget/layout.c @@ -0,0 +1,25 @@ +#include "widget.h" + +static uiStretch StretchFromDirection(uiLayoutDirection direction) { + switch (direction) { + case uiHorizontal: + return uiStretchX; + case uiVertical: + return uiStretchY; + } + assert(false); + return uiStretchNone; +} + +uiLayout* uiMakeLayout(uiPtr parent, uiLayoutDirection direction) { + uiLayout* layout = UI_NEW(uiLayout); + + *layout = (uiLayout){ + .widget = (uiWidget){.type = uiTypeLayout, + .stretch = StretchFromDirection(direction)}, + .direction = direction, + }; + WidgetSetParent(uiMakeLayoutPtr(layout), parent); + + return layout; +} -- cgit v1.2.3