Syntax
Success = LayoutGridSetJustifyContent(Layout, JustifyContent)
Description
Sets how the entire grid structure is aligned horizontally within the layout container, especially when the total width of the grid columns (plus gaps) is less than the container's width. This is analogous to the `justify-content` property in CSS Grid.
Parameters
Layout
The handle of the Grid layout object. If #Null, it targets
the current layout.
JustifyContent
The content justification constant.
#PG_Grid_JustifyContent_Start : Grid is packed toward the start (left). (Default)
#PG_Grid_JustifyContent_Center : Grid is centered horizontally.
#PG_Grid_JustifyContent_End : Grid is packed toward the end (right).
#PG_Grid_JustifyContent_SpaceAround : Space is distributed evenly around columns (half-size space at ends).
#PG_Grid_JustifyContent_SpaceBetween : Space is distributed evenly between columns; first column at start, last at end.
#PG_Grid_JustifyContent_SpaceEvenly : Space is distributed evenly between and around columns.
Return Value
Returns #True if the justification 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 horizontal axis.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 500, 300, "Grid Justify Content")
If MyWindow
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Grid)
LayoutSetPadding(RootLayout, 10)
LayoutGridSetGapSize(RootLayout, 10)
; Define fewer columns than will fill the space
LayoutGridSetColumn(RootLayout, 1, 100)
LayoutGridSetColumn(RootLayout, 2, 100)
; Center the entire grid horizontally
LayoutGridSetJustifyContent(RootLayout, #PG_Grid_JustifyContent_Center)
; Add widgets
Widget1 = CreateWidget(0, 0, 0, 50) : WidgetSetColumnStart(Widget1, 1)
Widget2 = CreateWidget(0, 0, 0, 50) : WidgetSetColumnStart(Widget2, 2)
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
LayoutSetType, LayoutGridGetJustifyContent, LayoutGridSetAlignContent, LayoutGridSetJustifyItems
Supported OS
Windows, Linux