Parameters
The following is a list of metrics one can supply for a widget on the Mac. All values are in unit pixels. All values default to 0.
Name | Structure | Notes |
size | [ width, height ] | Base size of the widget |
adjust_position | [ left, top ] | Number of pixels to push the widget. Positive values move the widget away from the origin of the window. |
adjust_size | [ width, height ] | Adjustments made to the base size of the widget. The adjusted size is passed to the OS so the resulting widget is the base size originally intended. |
adjust_baseline | value | Adjustment of the baseline. Positive values move the baseline away from the origin of the window. |
outset | [ left, top, right, bottom ] | Amount of outset for a given edge of the widget. These amounts affect the base size and position of the widget when the bounds of the widget are set. See Placement Pipeline. |
frame | [ left, top, right, bottom ] | Amount of frame for a given edge of the widget. |
inset | [ left, top, right, bottom ] | Amount of inset for a given edge of the widget. |
spacing | value | If there is text in the widget, this is the spacing needed between the widget's visual element and the text for the widget. Example: check_box has a nonzero spacing, but button has a spacing of 0 (because the text overlays the visual element). |
Metrics Pipelines
Measurement Pipeline
- All the possible text strings for the widget are measured. The largest width, height and baseline are preserved on a per-element basis (i.e., it is possible for one piece of text to contribute the max width and another to contribute the max height)
- The base height of the widget is set to
size.height - adjust_size.height
- The base width of the widget is set to
size.width - adjust_size.width
- If text width is nonzero then
text_width + spacing
is added to the base width of the widget
- If there is a valid text baseline value the baseline of the result is set to
text_baseline + adjust_baseline
- The
outset.left
is added to the resultant left outset
- The
outset.left + outset.right
is subtracted from the resultant right outset
- The
outset.top
is added to the resultant top outset
- The
outset.top + outset.bottom
is subtracted from the resultant bottom outset
- Resultant frame is set from
frame
- Resultant inset is set from
inset
- The resultant extents is returned
Placement Pipeline
adjust_position.left - extents.outset.left
is added to the left position of the widget
adjust_position.top - extents.outset.top
is added to the top position of the widget
- The height of the widget is increased by
adjust_size.height + extents.outset.top + extents.outset.bottom
- The width of the widget is increased by
adjust_size.width + extents.outset.left + extents.outset.right
- The bounds of the widget are set