WidgetSetMinHeight

Syntax

Success = WidgetSetMinHeight(Widget, Height.d)

Description

Sets the minimum height constraint for the specified widget in device-independent pixels (DIPs).

Parameters

Widget
The handle of the ProGUI widget.

Height.d
The minimum height value in DIPs. Use #PG_Widget_FitContent (-1) to set the minimum height based on the widget's content (e.g., the overflow height of a child layout). Set to 0 to remove the minimum height constraint.

Return Value

Returns #True if the minimum height was successfully set, or #False if the widget handle was invalid.

Remarks

The layout engine will not shrink the widget's height below this value, unless the container itself is smaller than the minimum height. This takes precedence over the ideal height if the ideal height is smaller. Setting the minimum height triggers a layout update.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 100, "MinHeight Example")
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
LayoutFlexSetDirection(RootLayout, #PG_Flex_Direction_Column)
LayoutSetPadding(RootLayout, 10)

If MyWindow
  Widget1 = CreateWidget(0, 0, 100, 80) ; Start taller
  WidgetSetClass(Widget1, "widget1")
  WidgetSetMinHeight(Widget1, 40) ; Set a minimum height
  WidgetSetMargin(Widget1, 5)

  Widget2 = CreateWidget(0, 0, 100, 20) ; Start shorter than minHeight of Widget1
  WidgetSetClass(Widget2, "widget2")
  WidgetSetMargin(Widget2, 5)

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Debug "Initial Widget 1 Height: " + StrD(WidgetGetHeight(Widget1)) ; Should be 80
  Debug "Initial Widget 2 Height: " + StrD(WidgetGetHeight(Widget2)) ; Should be 20
  
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_LeftClick
      ; Now try to set Widget1's height below its minimum
      WidgetSetHeight(Widget1, 10)
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

WidgetGetMinHeight, WidgetSetMinWidth, WidgetSetHeight, WidgetGetHeight

Supported OS

Windows, Linux