A layout that scales its children to fill their container.
This layout behaves like a CYIStackLayout, but with one major difference: after the children have been measured, this layout sets, on the children, a scaling factor that would cause the children to 'fill' their container. The 'scale mode' property can be used to specify how the children are scaled.
It is not necessary to set 'fill parent' on the children of this layout in order for the children to be scaled. However, setting 'fill parent' on the children modifies the behaviour of the scaling layout. If 'fill parent' is set on both the horizontal and vertical dimensions of a child, then no scaling is applied to that child. If 'fill parent' is applied to either of the horizontal or vertical dimensions of a child, then the child is resized to fill the parent in that dimension and the scaling layout will scale that calculated size. As a result, the 'fit' and 'fill' scaling modes have no effect when 'fill parent' is specified on a single dimension of a child.
The 'fit content' property can be specified on the layout. When 'fit content' is specified on both the horizontal and vertical dimensions, it results in a minimally-sized container. When used on a single dimension, the container is expanded to reduce the 'empty spaces' after scaling the children.
Container View Template Comments Specification
These values are applied to the comment field of the container composition. All properties are optional.
| Label | Default value | Accepted values | Description |
|---|---|---|---|
| scale-mode | stretch | stretch, fit, fill, none | The scaling mode for the children.
|
The parent layout class may define more properties that can be used.
Children View Template Comments Specification
This class has no configurable per-child properties, except for those of the parent class.
#include <layout/YiScalingLayout.h>

Public Types | |
| enum | SCALE_MODE { SCALE_STRETCH, SCALE_FIT, SCALE_FILL, SCALE_NONE } |
Public Types inherited from CYILayout | |
| enum | POSITIONING_MODE { SET_POSITION_DIRECTLY, DO_NOT_SET_POSITION_DIRECTLY } |
| typedef CYILayoutConfig::CubeOffset | Padding |
Protected Member Functions | |
| virtual void | Configure () override |
| virtual void | OnMeasure (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) override |
| virtual void | OnApplyMeasurements () override |
| virtual void | ApplyScale (CYISceneNode *pChild, const glm::vec3 &vScale) |
Protected Member Functions inherited from CYIAnimatingLayout | |
| virtual void | OnMeasurementsApplied () override |
| virtual const CYIRuntimeTypeInfo & | GetLayoutConfigType () const override |
| virtual void | ApplyPosition (CYISceneNode *pChild, const glm::vec3 &vPosition) override |
| virtual void | ApplySize (CYISceneNode *pChild, const glm::vec3 &vSize) override |
Protected Member Functions inherited from CYILayout | |
| virtual void | OnSceneViewAttached () |
| virtual void | OnMeasurementsCalculated (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) |
| virtual std::unique_ptr< CYILayoutState > | CreateLayoutStateInstance () const |
| void | CreateLayoutObjectsFor (CYISceneNode *pNode) const |
| CYISceneNode * | GetChild (uint32_t uIndex) const |
| void | ApplyMeasurementsToBackgroundChildren () |
| const Padding & | GetPaddingForChild (const CYISceneNode *pChild) const |
Protected Member Functions inherited from CYIScriptableRTTIObject | |
| virtual std::pair< const CYIRuntimeTypeInfo *, const void * > | GetRuntimeTypeInfoWithObject () const =0 |
Additional Inherited Members | |
Static Public Member Functions inherited from CYILayout | |
| static void | RegisterAllLayouts () |
| static bool | IsLayoutable (const CYISceneNode *pNode) |
| static glm::vec3 | GetDefaultSize (const CYISceneNode *pNode, const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) |
| static void | UpdateMeasuredSizeForFitContent (const CYISceneNode *pNode, glm::vec3 *pMeasuredSize, const glm::vec3 &contentSize, const Padding &padding, const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) |
| static void | UnscaleMeasureSpecs (const glm::vec3 &vScale, CYISceneNode::MeasureSpec *pWidthSpec, CYISceneNode::MeasureSpec *pHeightSpec, CYISceneNode::MeasureSpec *pDepthSpec) |
| static float | CalculateDimension (const CYISceneNode::MeasureSpec &spec, const CYILayoutConfig::SizeConstraint &constraint, float fCurrentValue) |
Protected Types inherited from CYILayout | |
| enum | DIMENSIONS { DIMENSIONS_NONE = 0x0, DIMENSIONS_X = 0x1, DIMENSIONS_Y = 0x2, DIMENSIONS_Z = 0x4, DIMENSIONS_ALL_BUT_X = DIMENSIONS_Y | DIMENSIONS_Z, DIMENSIONS_ALL_BUT_Y = DIMENSIONS_X | DIMENSIONS_Z, DIMENSIONS_ALL_BUT_Z = DIMENSIONS_X | DIMENSIONS_Y, DIMENSIONS_ALL = DIMENSIONS_X | DIMENSIONS_Y | DIMENSIONS_Z } |
Static Protected Member Functions inherited from CYILayout | |
| static void | MeasureChildWithMargins (CYISceneNode *pChild, const CYISceneNode::MeasureSpec &parentWidthSpec, const CYISceneNode::MeasureSpec &parentHeightSpec, const CYISceneNode::MeasureSpec &parentDepthSpec, const Padding &padding) |
| static void | MeasureChildWithMargins (CYISceneNode *pChild, const CYISceneNode::MeasureSpec &parentWidthSpec, const CYISceneNode::MeasureSpec &parentHeightSpec, const CYISceneNode::MeasureSpec &parentDepthSpec, const Padding &padding, const glm::vec3 &vChildScale) |
| static CYISceneNode::MeasureSpec | CalculateChildMeasureSpec (const CYISceneNode::MeasureSpec &parentMeasureSpec, float fPadding, const CYILayoutConfig::SizeConstraint &childConstraint, float fChildScale) |
| static bool | UpdateMeasureSpecsForFitContent (const CYISceneNode *pNode, CYISceneNode::MeasureSpec *widthSpec, CYISceneNode::MeasureSpec *heightSpec, CYISceneNode::MeasureSpec *depthSpec) |
| static void | RemeasureChildrenForFillParent (const CYISceneNode *pNode, const glm::vec3 &vParentMeasuredSize, const Padding &padding, DIMENSIONS eDimensionsToRemeasure) |
| static glm::vec3 | GetAdjustedPosition (const glm::vec3 &vDesiredTopLeftPosition, const CYISceneNode *pChild) |
| static glm::vec3 | GetUnadjustedPosition (const glm::vec3 &vCurrentTopLeftPosition, const CYISceneNode *pChild) |
| static glm::vec3 | GetAdjustedMeasuredSize (const CYISceneNode *pChild) |
| static glm::vec3 | GetTopLeftPositionWithGravity (const glm::vec3 &vLayoutGravity, const glm::vec3 &vChildGravity, const glm::vec3 &vContainerTopLeft, const glm::vec3 &vContainerSize, const CYILayout::Padding &padding, const glm::vec3 &vChildSize, const CYILayoutConfig::Margin &margin, const glm::vec3 &vCurrentChildPosition) |
| static void | MeasureBackgroundChildren (CYISceneNode *pNode, const glm::vec3 &vSize) |
Protected Attributes inherited from CYILayout | |
| CYISceneView * | m_pNode |
| In most cases, this variable is used as a node (thus the name m_pNode ) More... | |
| Padding | m_padding |
| bool | m_bReverseChildrenOrder |
| glm::vec3 | m_vGravity |
| POSITIONING_MODE | m_ePositioningMode |
The various possible scaling modes for this layout.
| CYIScalingLayout::CYIScalingLayout | ( | ) |
|
virtual |
|
protectedvirtual |
Applies the scale vScale to the scene node pChild. This function, by default, simply calls CYISceneNode::SetScale. It can be overridden in subclasses to support animating scale changes for child scene nodes.
|
overrideprotectedvirtual |
Extracts relevant properties the associated scene node and configures this layout with said properties.
Reimplemented from CYIAnimatingLayout.
| SCALE_MODE CYIScalingLayout::GetScalingMode | ( | ) | const |
|
overrideprotectedvirtual |
Applies the measured sizes of the associate scene node's children.
Reimplemented from CYIStackLayout.
|
overrideprotectedvirtual |
Measures the associated scene node, considering its layout configuration constraints (if available) and the provided measure specifications.
Reimplemented from CYIStackLayout.
| void CYIScalingLayout::SetScalingMode | ( | SCALE_MODE | eMode | ) |
Sets the scaling mode to eMode.