Sizing and Layout
Layout
Typically, you set a box's size with the following style attributes:
box->style.width = UI_px(100);
box->style.height = UI_ratio(4);
This is the preferred size of the box along each axis. After layout, the actual size may have been shrunk due to space constraints.
In addition, you may provide a minSize and a maxSize. These values must be in pixels and will be enforced at the very end of the layout pass.
You may also specify the strictness of a given size. This determines how much of the size may be reduced when needed. 0.0 means the box may be reduced as much as needed and 1.0 means the size cannot be reduced at all.
For example:
box->style.width = UI_px(100); // default strictness is 0.0
box->style.width.strictness = 1.0; // box cannot shrink at all during layout
Fixed Size and Position
If you would like to set a boxes position or size directly, you may use:
- the flag
UIBoxFlag_FixedSizewithbox->fixedSize - the flag
UIBoxFlag_Floatingwithbox->fixedPosition
If the box has a fixed position along an axis, it will be place absolutely relative to the top-left corner of its parent. If the box has a fixed size along an axis, it's size will be exactly determined by the size (in pixels).