Percentages: flexible coordinates, sizing methods¶
The window system allows you to specify any percentage of the size of the parent when specifying almost any size, offset, and coordinates.
For example, you can specify that the width of a control is 75% of the window size.
This allows you to write windows without losing layout even if the screen size changes.
How to describe¶
Write the percentage by enclosing it in {…}. Values are percentages. You can also write expressions for offset and percent values.
Offset¶
Specifies only the offset.
The following example specifies a size of 40 x 40:.
SIZE = 20 * 2,16 + 24;
{percentage}¶
You can also specify a percentage only.
In the following example, if the screen size is 960 x 640, a size of 480 x 320 is specified.
SIZE = {50},{25 + 25};
offset + {percentage}¶
{percentage} + offset¶
Used to specify offsets and percentages.
In the following example, if the screen size is 960 x 640, a size of 520 x 360 is specified.
SIZE = 40 + {20 + 30},20 * 2{50}; or SIZE = {20 + 30} + 40,{50} + 20 * 2;
Wrong description example¶
You cannot include more than one percentage or offset.
SIZE = 10 + {20} + 30,40; SIZE = 40 + {20} + {30},40; SIZE = 40 + 0.5 * {20},40;Both are incorrect descriptions.