Syntax
Success = LayoutGridSetAlignContent(Layout, AlignContent)
Description
Sets how the entire grid structure is aligned vertically within the layout container, especially when the total height of the grid rows (plus gaps) is less than the container's height. This is analogous to the `align-content` property in CSS Grid.
Parameters
Layout
The handle of the Grid layout object. If #Null, it targets
the current layout.
AlignContent
The content alignment constant.
#PG_Grid_AlignContent_Start : Grid is packed toward the start (top). (Default)
#PG_Grid_AlignContent_Center : Grid is centered vertically.
#PG_Grid_AlignContent_End : Grid is packed toward the end (bottom).
#PG_Grid_AlignContent_SpaceAround : Space is distributed evenly around rows (half-size space at ends).
#PG_Grid_AlignContent_SpaceBetween : Space is distributed evenly between rows; first row at start, last at end.
#PG_Grid_AlignContent_SpaceEvenly : Space is distributed evenly between and around rows.
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 the
alignment of the grid as a whole within its container along the vertical axis.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 400, "Grid Align Content")
If MyWindow
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Grid)
LayoutSetPadding(RootLayout, 10)
LayoutGridSetGapSize(RootLayout, 10)
; Define fewer rows than will fill the space
LayoutGridSetRow(RootLayout, 1, 50)
LayoutGridSetRow(RootLayout, 2, 50)
; Center the entire grid vertically
LayoutGridSetAlignContent(RootLayout, #PG_Grid_AlignContent_Center)
; Add widgets
Widget1 = CreateWidget(0, 0, 100, 50) : WidgetSetRowStart(Widget1, 1)
Widget2 = CreateWidget(0, 0, 200, 50) : WidgetSetRowStart(Widget2, 2)
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
LayoutSetType, LayoutGridGetAlignContent, LayoutGridSetJustifyContent, LayoutGridSetAlignItems
Supported OS
Windows, Linux