LayoutGridSetAlignItems

Syntax

Success = LayoutGridSetAlignItems(Layout, AlignItems)

Description

Sets the default vertical alignment for items *within* their grid cell (or spanned area) in a Grid layout container. This is analogous to the `align-items` property in CSS Grid.

Parameters

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

AlignItems
The item alignment constant.

#PG_Grid_AlignItems_Start     : Items align to the start (top) of their cell. (Default)
#PG_Grid_AlignItems_Center    : Items are centered vertically within their cell.
#PG_Grid_AlignItems_End       : Items align to the end (bottom) of their cell.
; Note: CSS Grid also has 'stretch', which is the default if not otherwise specified,
;       ProGUI defaults to stretch implicitly if height is Auto (#Null).

Return Value

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

Remarks

This property only applies to layouts whose type is #PG_Layout_Type_Grid. It controls how individual items are positioned vertically inside the grid area assigned to them. Individual items can override this default using WidgetSetAlign().

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 300, "Grid Align Items")

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

  ; Define rows taller than the widgets
  LayoutGridSetRow(RootLayout, 1, 100)
  LayoutGridSetRow(RootLayout, 2, 100)

  ; Center items vertically within their cells
  LayoutGridSetAlignItems(RootLayout, #PG_Grid_AlignItems_Center)

  ; Add widgets (shorter than row height)
  Widget1 = CreateWidget(0, 0, 80, 40) : WidgetSetRowStart(Widget1, 1)
  Widget2 = CreateWidget(0, 0, 60, 30) : WidgetSetRowStart(Widget2, 2)

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

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

StopProGUI()

See Also

LayoutSetType, LayoutGridGetAlignItems, LayoutGridSetJustifyItems, LayoutGridSetAlignContent, WidgetSetAlign

Supported OS

Windows, Linux