LayoutFlexSetDirection

Syntax

Success = LayoutFlexSetDirection(Layout, Direction)

Description

Sets the main axis direction for a Flexbox layout container. This determines whether items are laid out horizontally (row) or vertically (column), and in which direction (normal or reverse).

Parameters

Layout
The handle of the Flexbox layout object. If #Null, it targets the current layout.

Direction
The direction constant.

#PG_Flex_Direction_Row           : Items flow left-to-right. (Default)
#PG_Flex_Direction_RowReverse    : Items flow right-to-left.
#PG_Flex_Direction_Column        : Items flow top-to-bottom.
#PG_Flex_Direction_ColumnReverse : Items flow bottom-to-top.

Return Value

Returns #True if the direction was successfully set, or #False if the layout handle or direction constant was invalid.

Remarks

This property only applies to layouts whose type is #PG_Layout_Type_Flex. Changing the direction fundamentally alters how items are arranged and how properties like justification and alignment behave.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 300, "Flex Direction")

If MyWindow
  RootLayout = WindowGetLayout(MyWindow)
  LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
  LayoutSetPadding(RootLayout, 10)

  ; Default is Row, let's make it Column
  LayoutFlexSetDirection(RootLayout, #PG_Flex_Direction_Column)

  Widget1 = CreateWidget(0, 0, 100, 30)
  Widget2 = CreateWidget(0, 0, 100, 30)
  Widget3 = CreateWidget(0, 0, 100, 30)

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

LayoutSetType, LayoutFlexGetDirection, LayoutFlexSetWrap, LayoutFlexSetJustify, LayoutFlexSetAlignItems

Supported OS

Windows, Linux