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", #PG_Window_Default | #PG_Window_LayoutGrid) ; Create with a grid layout
If MyWindow
LayoutSetPadding(#Null, 10) ; Set current layout padding
LayoutGridSetGapSize(#Null, 10)
; Define rows taller than the widgets
LayoutGridSetRow(#Null, 1, 100)
LayoutGridSetRow(#Null, 2, 100)
; Center items vertically within their cells
LayoutGridSetAlignItems(#Null, #PG_Grid_AlignItems_Center)
; Add widgets (shorter than row height)
Widget1 = CreateWidget(0, 0, 80, 40)
Widget2 = CreateWidget(0, 0, 60, 30)
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
LayoutSetType, LayoutGridGetAlignItems, LayoutGridSetJustifyItems, LayoutGridSetAlignContent, WidgetSetAlign
Supported OS
Windows, Linux