Syntax
Success = LayoutFlexSetJustify(Layout, Justify)
Description
Sets how space is distributed between and around items along the main axis of a Flexbox layout container. This is analogous to the `justify-content` property in CSS Flexbox.
Parameters
Layout
The handle of the Flexbox layout object. If #Null, it targets the current layout.
Justify
The justification constant.
#PG_Flex_Justify_Start : Items are packed toward the start of the main axis. (Default)
#PG_Flex_Justify_Center : Items are centered along the main axis.
#PG_Flex_Justify_End : Items are packed toward the end of the main axis.
#PG_Flex_Justify_SpaceAround : Items are evenly distributed with space around them (half-size space at ends).
#PG_Flex_Justify_SpaceBetween : Items are evenly distributed; first item at the start, last item at the end.
Return Value
Returns #True if the justification mode was successfully set, or #False if the layout handle or justification constant was invalid.
Remarks
This property only applies to layouts whose type is #PG_Layout_Type_Flex. The effect depends on the flex direction and whether items overflow the container (wrapping).
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 500, 200, "Flex Justify")
If MyWindow
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
LayoutSetPadding(RootLayout, 10)
LayoutFlexSetDirection(RootLayout, #PG_Flex_Direction_Row) ; Lay out in a row
; Justify content with space between items
LayoutFlexSetJustify(RootLayout, #PG_Flex_Justify_SpaceBetween)
; Add widgets
Widget1 = CreateWidget(0, 0, 80, 40)
Widget2 = CreateWidget(0, 0, 80, 40)
Widget3 = CreateWidget(0, 0, 80, 40)
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
LayoutSetType, LayoutFlexGetJustify, LayoutFlexSetDirection, LayoutFlexSetAlignItems, LayoutFlexSetAlignContent
Supported OS
Windows, Linux