# Module `wibox.layout.constraint`

### Info:

- Author: Lukáš Hrázký
- Copyright: 2012 Lukáš Hrázký
- Release: v3.5.1

## Functions

constraint:draw (wibox, cr, width, height) | Draw a constraint layout
constraint:fit (width, height) | Fit a constraint layout into the given space
constraint:set_widget (widget) | Set the widget that this layout adds a constraint on.
constraint:set_strategy (val) | Set the strategy to use for the constraining.
constraint:set_width (val) | Set the maximum width to val.
constraint:set_height (val) | Set the maximum height to val.
constraint:reset () | Reset this layout.
new (widget, strategy, width, height) | Returns a new constraint layout.

## Functions

constraint:draw (wibox, cr, width, height)
  Draw a constraint layout

  ### Parameters:

  - wibox
  - cr
  - width
  - height
constraint:fit (width, height)
  Fit a constraint layout into the given space

  ### Parameters:

  - width
  - height
constraint:set_widget (widget)
  Set the widget that this layout adds a constraint on.

  ### Parameters:

  - widget
constraint:set_strategy (val)
  Set the strategy to use for the constraining. Valid values are 'max', 'min' or 'exact'. Throws an error on invalid values.

  ### Parameters:

  - val
constraint:set_width (val)
  Set the maximum width to val. nil for no width limit.

  ### Parameters:

  - val
constraint:set_height (val)
  Set the maximum height to val. nil for no height limit.

  ### Parameters:

  - val
constraint:reset ()
  Reset this layout. The widget will be unreferenced, strategy set to "max" and the constraints set to nil.
new (widget, strategy, width, height)
  Returns a new constraint layout. This layout will constraint the size of a widget according to the strategy. Note that this will only work for layouts that respect the widget's size, eg. fixed layout. In layouts that don't (fully) respect widget's requested size, the inner widget still might get drawn with a size that does not fit the constraint, eg. in flex layout.

  ### Parameters:

  - widget A widget to use (optional)
  - strategy How to constraint the size. 'max' (default), 'min' or 'exact'. (optional)
  - width The maximum width of the widget. nil for no limit. (optional)
  - height The maximum height of the widget. nil for no limit. (optional)

generated by LDoc 1.3