LayoutFlexSetAlignItems

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.
; #PG_Flex_AlignItems_Baseline  : Items are aligned such that their baselines align. (Currently not fully implemented/reliable)

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")

If MyWindow
  RootLayout = WindowGetLayout(MyWindow)
  LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
  LayoutSetPadding(RootLayout, 10)
  LayoutFlexSetDirection(RootLayout, #PG_Flex_Direction_Row) ; Row direction (cross axis is vertical)

  ; Align items to the center of the cross axis (vertically centered)
  LayoutFlexSetAlignItems(RootLayout, #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_Window_ScreenCentered)

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

StopProGUI()

See Also

LayoutSetType, LayoutFlexGetAlignItems, LayoutFlexSetDirection, LayoutFlexSetJustify, LayoutFlexSetAlignContent, WidgetSetAlign

Supported OS

Windows, Linux