BSB Developer Docs
Loading...
Searching...
No Matches
flex_layout.h File Reference

A widget that arranges its elements in flexible rows or columns. More...

#include <gui/widget.h>

Go to the source code of this file.

Typedefs

typedef struct FlexLayout FlexLayout
 FlexLayout opaque structure.
 

Enumerations

enum  FlexLayoutType { FlexLayoutTypeRow , FlexLayoutTypeColumn , FlexLayoutTypeMax }
 Enumeration of possible flow types. More...
 
enum  FlexLayoutAlign {
  FlexLayoutAlignStart , FlexLayoutAlignEnd , FlexLayoutAlignCenter , FlexLayoutAlignSpaceEvenly ,
  FlexLayoutAlignSpaceAround , FlexLayoutAlignSpaceBetween
}
 Enumeration of possible item alignments. More...
 

Functions

FlexLayout * flex_layout_alloc (Widget *parent, FlexLayoutType type)
 Create a new FlexLayout instance.
 
void flex_layout_free (FlexLayout *instance)
 Delete a FlexLayout instance.
 
Widget * flex_layout_get_base (FlexLayout *instance)
 Get a pointer to the base class instance.
 
void flex_layout_set_spacing (FlexLayout *instance, int32_t spacing)
 Set the spacing between child elements.
 
void flex_layout_set_wrap (FlexLayout *instance, bool wrap)
 Set the wrap behaviour of a FlexLayout instance.
 
void flex_layout_set_reverse (FlexLayout *instance, bool reverse)
 Set the order of elements a FlexLayout instance.
 
void flex_layout_set_align (FlexLayout *instance, FlexLayoutAlign main, FlexLayoutAlign cross, FlexLayoutAlign track_cross)
 Sets alignment, distribution and placement of child items.
 
void flex_layout_set_child_widget_grow (FlexLayout *instance, Widget *child, uint8_t grow)
 Set how much space child widget will take in flex layout.
 

Detailed Description

A widget that arranges its elements in flexible rows or columns.

To add a widget to a FlexLayout, pass it as the parent during your widget's creation.

Enumeration Type Documentation

◆ FlexLayoutAlign

Enumeration of possible item alignments.

See flex_layout_set_align for more info

Enumerator
FlexLayoutAlignStart 

Align items to start of axis.

FlexLayoutAlignEnd 

Align items to start of axis.

FlexLayoutAlignCenter 

Align items to middle of axis.

FlexLayoutAlignSpaceEvenly 

Distribute items evenly along axis, with equal spacing between them, and equal spacing between them and ends of the axis.

FlexLayoutAlignSpaceAround 

Distribute items evenly along axis, with equal spacing between them, and half spacing between them and ends of the axis.

FlexLayoutAlignSpaceBetween 

Distribute items evenly along axis, with equal spacing between them, and zero spacing between them and ends of the axis.

◆ FlexLayoutType

Enumeration of possible flow types.

Enumerator
FlexLayoutTypeRow 

Arrange elements in a row.

FlexLayoutTypeColumn 

Arrange elements in a column.

FlexLayoutTypeMax 

Special value, not to be used in user code.

Function Documentation

◆ flex_layout_alloc()

FlexLayout * flex_layout_alloc ( Widget * parent,
FlexLayoutType type )

Create a new FlexLayout instance.

Parameters
[in,out]parentpointer to the parent Widget instance
[in]typevalue determining the layout behaviour (row or column)
Returns
pointer to the newly created FlexLayout instance

◆ flex_layout_free()

void flex_layout_free ( FlexLayout * instance)

Delete a FlexLayout instance.

Parameters
[in,out]instancepointer to the FlexLayout instance to be deleted

◆ flex_layout_get_base()

Widget * flex_layout_get_base ( FlexLayout * instance)

Get a pointer to the base class instance.

The return value can be used in all Widget methods.

Parameters
[in,out]instancepointer to the FlexLayout instance to be queried
Returns
pointer to the base class instance

◆ flex_layout_set_align()

void flex_layout_set_align ( FlexLayout * instance,
FlexLayoutAlign main,
FlexLayoutAlign cross,
FlexLayoutAlign track_cross )

Sets alignment, distribution and placement of child items.

Resources:

Parameters
[in,out]instancepointer to the FlexLayout instance to be modified
[in]mainPlacement of items along main axis. See https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-justify-content
[in]crossPlacement of items along cross axis. Doesn't accept the FlexLayoutAlignSpaceX variants of the enum. See https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-align-items
[in]track_crossPlacement of tracks along the cross axis. See https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-align-content

◆ flex_layout_set_child_widget_grow()

void flex_layout_set_child_widget_grow ( FlexLayout * instance,
Widget * child,
uint8_t grow )

Set how much space child widget will take in flex layout.

Parameters
[in,out]instancepointer to the FlexLayout instance to be modified
[in,out]childpointer to the widget instance to be modified, must be child if FlexLayout
[in]grownew grow value needs to be > 1 or 0 to disable grow on the child.

◆ flex_layout_set_reverse()

void flex_layout_set_reverse ( FlexLayout * instance,
bool reverse )

Set the order of elements a FlexLayout instance.

If reverse is false (the default), the widgets will be shown in the order of addition.

Parameters
[in,out]instancepointer to the FlexLayout instance to be modified
[in]reversearrange elements in reverse order if true, regular order otherwise

◆ flex_layout_set_spacing()

void flex_layout_set_spacing ( FlexLayout * instance,
int32_t spacing )

Set the spacing between child elements.

Parameters
[in,out]instancepointer to the FlexLayout instance to be modified
[in]spacingspacing between elements, in pixels

◆ flex_layout_set_wrap()

void flex_layout_set_wrap ( FlexLayout * instance,
bool wrap )

Set the wrap behaviour of a FlexLayout instance.

Parameters
[in,out]instancepointer to the FlexLayout instance to be modified
[in]wrapwrap overflowing elements if true, do now wrap otherwise