One of the best parts of OpenPyro is the layout engine. OpenPyro controls can be sized in a variety of ways that especially makes fluid layouts really easy.
All OpenPyro controls support the following dimension properties:
- Explicit Dimensions (explicitWidth, explicitHeight)
- Percent Unused Dimensions (percentUnusedWidth, percentUnusedHeight)
- Percent Dimensions (percentWidth, percentHeight)
- Child Based Validation
Any combination of these properties is valid. For example, a control can have an explicitWidth and a percentUnusedHeight and will be sized correctly.
1) Explicit Dimensions:
Setting a control's width and height property to actual neumerical values sets its internal _explicitWidth, _explicitHeight property. Controls sized this way will always remain at the dimension they were originally sized at.
2)Percent Unused Dimensions:
Percent Unused Dimensions are set by setting the percentUnusedWidth and the percentUnusedHeight property of the control When such a control is placed in a UIContainer, the actual size that the container is sized at will be based on what space is left after all the explicitly sized controls have been placed.
It should be noted that its the layout applied to the control is responsible for translating the percent value to an actual pixel value (to know more about layouts check out the Layouts page).
Lets demonstrate with an example:
If you have a UIContainer of width 400 and height 300, and have two children inside it, one with a width/height of 200×250 and another with a percentWidth of 100%, and if the container has an HLayout applied to it, the layout looks at the first control, and realizes that once it will place it, it will only have (400 - 200) pixels left. So then when it places the second container, 100% width will translate to the 400-200=200 value. However if the layout applied is VLayout, it realizes that since its going to place the second control under the first one, the width of the first control has no bearing on the sizing of the second control and so the 100% value is translated to the complete 400px value.
Percent Dimensions (percentWidth, percentHeight)
OpenPyro controls can also be sized based on just the percentHeight/percentWidth of the parent control. These dimensions are computed based on the the parent UIContainer without any regard to the other children in the container.
Child Based Validation
In case none of the percent/explicit width/height properties are set, UIControls can look at their children, and once they have been sized, will compute its own width/height. This is especially useful with text based controls like Labels that may use the width of the text inside it to compute its own width.