Files
Basalt/docs/objects/Flexbox.md
Robert Jelic 631eef525c Flexbox docs
Updated the flexbox documentation for the current flexbox implementation
2023-05-19 15:50:05 +02:00

2.7 KiB

A Flexbox is a layout container designed to facilitate the creation of flexible and responsive UI designs. It allows you to efficiently arrange and align its child elements within it.

The Flexbox Container is still a WIP and i will add more methods from the CSS Flexbox Implementation.

In addition to the methods inherited from ScrollableFrame, Frame, Container, VisualObject and Object, Flexbox has the following methods:

setSpacing Defines the gap between child objects within the Flexbox
getSpacing Returns the current gap size between child objects
setDirection Sets the direction for the arrangement of child objects (row/column)
getDirection Returns the currently set arrangement direction of child objects
setJustifyContent Sets the alignment of child objects along the main axis (flex-start, center, flex-end, space-between, space-around, space-evenly)
getJustifyContent Returns the current alignment setting for child objects along the main axis
setWrap Determines if child objects should wrap onto the next line when they run out of space
getWrap Returns the current wrapping behavior for child objects
updateLayout Manually triggers a layout update for the Flexbox
addBreak Introduces a line break within the Flexbox, forcing subsequent child objects to the next line

Child objects added via the Flexbox have the following additional methods:

getFlexGrow Returns the flex grow factor of the child object
setFlexGrow Sets the flex grow factor of the child object
getFlexShrink Returns the flex shrink factor of the child object
setFlexShrink Sets the flex shrink factor of the child object
getFlexBasis Returns the flex basis of the child object
setFlexBasis Sets the flex basis of the child object

Example

Here's an example of how to create a Flexbox object:

local main = basalt.createFrame()
local main = basalt.createFrame()
local flexbox = main:addFlexbox()
  :setDirection("column")
  :setJustifyContent("space-between")
  :setSpacing(5)
  :setWrap("wrap")

flexbox:addButton()

Alternatively, you can create a flexbox using an XML layout:

<flexbox direction="column" justifyContent="space-between" spacing="1" wrap="wrap">