LayoutGridSetJustifyItems

Syntax

Success = LayoutGridSetJustifyItems(Layout, JustifyItems)

Description

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

Parameters

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

JustifyItems
The item justification constant.

#PG_Grid_JustifyItems_Start     : Items align to the start (left) of their cell. (Default)
#PG_Grid_JustifyItems_Center    : Items are centered horizontally within their cell.
#PG_Grid_JustifyItems_End       : Items align to the end (right) of their cell.
; Note: CSS Grid also has 'stretch', which is often the default if not otherwise specified,
;       but it's not listed here. ProGUI might default to stretch implicitly if width is Auto.

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 how individual items are positioned horizontally inside the grid area assigned to them. Individual items can override this default using WidgetSetJustify().

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

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

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

  ; Define columns wider than the widgets
  LayoutGridSetColumn(RootLayout, 1, 150)
  LayoutGridSetColumn(RootLayout, 2, 150)

  ; Center items horizontally within their cells
  LayoutGridSetJustifyItems(RootLayout, #PG_Grid_JustifyItems_Center)

  ; Add widgets (smaller than column width)
  Widget1 = CreateWidget(0, 0, 80, 40) : WidgetSetColumnStart(Widget1, 1)
  Widget2 = CreateWidget(0, 0, 60, 40) : WidgetSetColumnStart(Widget2, 2)

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

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

StopProGUI()

See Also

LayoutSetType, LayoutGridGetJustifyItems, LayoutGridSetAlignItems, LayoutGridSetJustifyContent, WidgetSetJustify

Supported OS

Windows, Linux