Lumen.Layout libraryclient
Part of Lumen
The layout engine of Lumen: a flexbox without shrinking. A container (view, scroll)
lays its children out along its direction: each child takes the size its style asks for or
the size of its content, children with flex share the space that is left, justify
distributes any remaining space, align places the children across the direction and wrap
starts new lines when they do not fit. The sizes come from the resolved styles
(Lumen.Style) that the reconciler stores on the panels as lumen_style; a panel that
defines lumen_measure(max_w, max_h) reports the size of its content, any other panel is
taken at its current size.
Summary
Functions
lumen_children list, or of all of its children when the list is missing.Functions
Lists the children of a container that take part in the layout: the valid, visible panels
of its lumen_children list, or of all of its children when the list is missing.
Parameters
- container Panel
- children List<Panel> optional, defaults to
nilthe children to filter,container.lumen_childrenorcontainer:GetChildren()if nil
Returns
- List<Panel>
Lumen.Layout.flex(style, children, avail_w, avail_h, apply)
client packages/lumen/lib/cl_layout.lua:92Lays out children as a flex container would, or only measures the size they need.
-- In the PerformLayout of a container:
Lumen.Layout.flex(self.lumen_style, Lumen.Layout.children_of(self), w, h, true)
-- To measure the content of a container:
local content_w, content_h = Lumen.Layout.flex(self.lumen_style, children, max_w, max_h, false)
Parameters
- style Map resolved style of the container
- children List<Panel> children to lay out
- avail_w Number width of the container, nil if it is unconstrained
- avail_h Number height of the container, nil if it is unconstrained
- apply Boolean position and size the children; false only measures
Returns
- Number width the content needs, padding included
- Number height likewise
Measures a panel: the size its style asks for, with the content filling in the dimensions that are auto, kept within the minimum and maximum of the style.
Parameters
- panel Panel
- max_w Number width available to the panel, nil if unconstrained
- max_h Number height available to the panel, nil if unconstrained
Returns
- Number width
- Number height
Returns the resolved style of a panel.
Parameters
- panel Panel
Returns
- Map resolved style, an empty one for panels without