ValueUnit
A pair of a floating point number and a unit (ValueUnit<T>
) where T
represents the unit type.
If the unit is not provided it will default to a sensible value depending on the type.
For example a UIMeasurement
defaults to px
and a UIAngle
defaults to deg
Different unit postfixes are available for different ValueUnit T
values. The possible postfix
values are listed in the following tables.
Element Relative Size
Unit | Shorthand | Description |
---|---|---|
Width | w | The width of the element |
Height | h | The height of the element |
Percent | % | A percentage based value, the value that this is relative to changes based on the property usage. See individual properties to see what the % relative value is |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
BackgroundImageWidth | bw | The width of the currently assigned background texture in unscaled texels |
BackgroundImageHeight | bh | The height of the currently assigned background texture in unscaled texels |
MinWidthHeight | mnwh | The minimum of the target's width or height |
MaxWidthHeight | mxwh | The maximum of the target's width or height |
Alignment Offset
Unit | Shorthand | Description |
---|---|---|
Width | w | The width of the element |
Height | h | The height of the element |
ContentHeight | cnth | The content height of the element |
ContentWidth | cntw | The content width of the element |
Em | em | The em size resolved for this element |
ParentWidth | pw | The post layout width of the parent element or the view size if parent is null |
ParentHeight | ph | The post layout height of the parent element or the view size if parent is null |
ParentContentAreaWidth | pcaw | The parent's width (or viewport width if parent is null) minus any border and padding on the horizontal axis |
ParentContentAreaHeight | pcah | The parent's height (or viewport height if parent is null) minus any border and padding on the vertical axis |
ContentAreaWidth | caw | The post layout width of the element minus any padding and border on the horizontal axis |
ContentAreaHeight | cah | The post layout height of the element minus any padding and border on the vertical axis |
Percent | % | A percentage based value, the value that this is relative to changes based on the property usage. See individual properties to see what the % relative value is |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
ScreenWidth | sw | The total screen width in dpi scaled pixels |
ScreenHeight | sh | The total screen height in dpi scaled pixels |
ViewportWidth | vw | The width of the view that an element belongs to in dpi scaled pixels |
ViewportHeight | vh | The height of the view that an element belongs to in dpi scaled pixels |
BackgroundImageWidth | bw | The width of the currently assigned background texture in unscaled texels |
BackgroundImageHeight | bh | The height of the currently assigned background texture in unscaled texels |
Texture Relative Size
Unit | Shorthand | Description |
---|---|---|
Percent | % | A percentage based value, the value that this is relative to changes based on the property usage. See individual properties to see what the % relative value is |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
ImageWidth | bw | The width of the currently assigned background texture in unscaled texels |
ImageHeight | bh | The height of the currently assigned background texture in unscaled texels |
Font Size
Unit | Shorthand | Description |
---|---|---|
Em | em | The em size resolved for this element |
Rem | rem | The root em size resolved for this element |
Point | pt | A size specified in units defined by the currently assigned font file or the default font if none is assigned |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
Measurement
Unit | Shorthand | Description |
---|---|---|
Content | cnt | The content size of the element |
Em | em | The em size resolved for this element |
LineHeight | lh | The line height of the element computed from the current font size |
ParentSize | psz | The size of the parent. Note that if there exists a paradox where the parent sizes itself based on content size and some child sizes itself based on the parent size. In this case the child will set its size to zero. This paradox is only applicable for layout |
Percent | % | A percentage based value, the value that this is relative to changes based on the property usage. See individual properties to see what the % relative value is |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
ViewportWidth | vw | The width of the view that an element belongs to in dpi scaled pixels |
ViewportHeight | vh | The height of the view that an element belongs to in dpi scaled pixels |
BackgroundImageWidth | bw | The width of the currently assigned background texture in unscaled texels |
BackgroundImageHeight | bh | The height of the currently assigned background texture in unscaled texels |
Stretch | s | A portion of 'remaining space' that should be attributed to this element. |
ApplicationWidth | aw | The total width of the root view in dpi scaled pixels |
ApplicationHeight | ah | The total width of the root view in dpi scaled pixels |
MaxChild | mx | The size of the largest child |
MinChild | mn | The size of the smallest child |
StretchContent | strcnt | A unit that reserves at least 1x the content size and then adds n stretch pieces |
FitContent | fc | Not Supported |
FillRemaining | fr | A fixed percentage of the remaining space in a layout before stretch values are distributed |
Size Constraint
Unit | Shorthand | Description |
---|---|---|
Content | cnt | The content size of the element |
Em | em | The em size resolved for this element |
LineHeight | lh | The line height of the element computed from the current font size |
ParentSize | psz | The size of the parent. Note that if there exists a paradox where the parent sizes itself based on content size and some child sizes itself based on the parent size. In this case the child will set its size to zero. This paradox is only applicable for layout |
Percent | % | A percentage based value, the value that this is relative to changes based on the property usage. See individual properties to see what the % relative value is |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
ViewportWidth | vw | The width of the view that an element belongs to in dpi scaled pixels |
ViewportHeight | vh | The height of the view that an element belongs to in dpi scaled pixels |
BackgroundImageWidth | bw | The width of the currently assigned background texture in unscaled texels |
BackgroundImageHeight | bh | The height of the currently assigned background texture in unscaled texels |
ApplicationWidth | aw | The total width of the root view in dpi scaled pixels |
ApplicationHeight | ah | The total width of the root view in dpi scaled pixels |
MaxChild | mx | The size of the largest child |
MinChild | mn | The size of the smallest child |
Space Size
Unit | Shorthand | Description |
---|---|---|
Em | em | The em size resolved for this element |
Pixel | px | A fixed pixel value that accounts for any dpi scaling |
ViewportWidth | vw | The width of the view that an element belongs to in dpi scaled pixels |
ViewportHeight | vh | The height of the view that an element belongs to in dpi scaled pixels |
Stretch | s | A portion of 'remaining space' that should be attributed to this element. |
ApplicationWidth | aw | The total width of the root view in dpi scaled pixels |
ApplicationHeight | ah | The total width of the root view in dpi scaled pixels |
Examples
style value_units {
PaddingLeft = 1s;
PreferredWidth = 2.5cnt;
TextFontSize = 3em;
AlignmentOffsetX = 0.5w;
}