Syntax
Success = LayoutFlexSetAlignItems(Layout, AlignItems)Description
Sets the default alignment for items along the cross axis of the current line within a Flexbox layout container. This is analogous to the `align-items` property in CSS Flexbox.
Parameters
Layout
The handle of the Flexbox layout object. If #Null, it
targets the current layout.
AlignItems
The alignment constant.
#PG_Flex_AlignItems_Stretch : Items are stretched to fill the container along the cross axis (respecting min/max sizes). (Default)
#PG_Flex_AlignItems_Start : Items are packed toward the start of the cross axis.
#PG_Flex_AlignItems_Center : Items are centered along the cross axis.
#PG_Flex_AlignItems_End : Items are packed toward the end of the cross axis.
Return Value
Returns #True if the alignment mode was successfully
set, or #False if the layout handle or alignment constant
was invalid.
Remarks
This property only applies to layouts whose type is
#PG_Layout_Type_Flex. The "cross axis" is perpendicular to
the main axis set by LayoutFlexSetDirection() (e.g.,
if direction is Row, cross axis is vertical). Individual items can
override this default using WidgetSetAlign().
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 200, "Flex Align Items", #PG_Window_Default | #PG_Window_LayoutFlex) ; Create with a flex layout
If MyWindow
LayoutSetPadding(#Null, 10) ; Set current layout padding
LayoutFlexSetDirection(#Null, #PG_Flex_Direction_Row) ; Row direction (cross axis is vertical)
; Align items to the center of the cross axis (vertically centered)
LayoutFlexSetAlignItems(#Null, #PG_Flex_AlignItems_Center)
; Add widgets of different heights
Widget1 = CreateWidget(0, 0, 80, 30)
Widget2 = CreateWidget(0, 0, 80, 60)
Widget3 = CreateWidget(0, 0, 80, 40)
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
LayoutSetType, LayoutFlexGetAlignItems, LayoutFlexSetDirection, LayoutFlexSetJustify, LayoutFlexSetAlignContent, WidgetSetAlign
Supported OS
Windows, Linux