Syntax
Success = WidgetSetAlign(Widget, Align)Description
Sets the alignment property for an individual widget within its parent layout container. Alignment controls how the widget is positioned along the cross-axis of the layout (e.g., vertically in a row, horizontally in a column) relative to other items in the same line or the container itself.
Parameters
Widget
The handle of the ProGUI widget to modify.
Align
The desired alignment setting. Possible values:
#PG_Widget_Align_Start : Aligns the widget to the start of the cross-axis.
#PG_Widget_Align_Center : Centers the widget along the cross-axis.
#PG_Widget_Align_End : Aligns the widget to the end of the cross-axis.
; Note: A value of 0 or #False might revert to the default alignment (often stretch or start).
Return Value
Returns #True if the alignment was successfully set, or
#False if the widget handle or alignment flag was
invalid.
Remarks
This function sets the `align-self` property for the widget's corresponding layout item. It overrides the default alignment specified by the parent layout's `AlignItems` (for Flexbox) or `AlignGridItems` (for Grid) properties. Setting this property triggers a layout update.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 200, "Widget Align Example", #PG_Window_Default | #PG_Window_LayoutGrid) ; Use a grid layout
LayoutSetPadding(#Null, 10) ; Set the current layout padding
LayoutGridSetColumn(#Null, 3)
LayoutGridSetAlignItems(#Null, #PG_Grid_AlignItems_Center)
If MyWindow
Widget1 = CreateWidget(0, 0, 80, 30)
WidgetSetClass(Widget1, "widget1")
WidgetSetMargin(Widget1, 5)
; Widget1 will use the default center alignment
Widget2 = CreateWidget(0, 0, 80, 50) ; Taller widget
WidgetSetClass(Widget2, "widget2")
WidgetSetMargin(Widget2, 5)
WidgetSetAlign(Widget2, #PG_Widget_Align_Start) ; Override to align at the top
Widget3 = CreateWidget(0, 0, 80, 20) ; Shorter widget
WidgetSetClass(Widget3, "widget3")
WidgetSetMargin(Widget3, 5)
WidgetSetAlign(Widget3, #PG_Widget_Align_End) ; Override to align at the bottom
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
WidgetGetAlign, WidgetSetJustify, LayoutFlexSetAlignItems, LayoutGridSetAlignItems
Supported OS
Windows, Linux