A layout that assigns margins to children based on their initial position and size.
This layout calculates and assigns margin values for its children based on those children's initial position and size. Because the margins are calculated from the initial position and size, this layout appears to have no effect until the associated scene view is resized. At that point, the margins are applied to maintain the relative position and size of items.
For example, a child placed in the bottom right corner of the screen will remain in the bottom right corner even if the associated scene view is resized, and a child that covers most of the width of the associated scene view will become wider if the associated scene view is made wider.
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 |
|---|---|---|---|
| detect-fill-parent | true | true, false | Indicates whether the layout will automatically assign 'fill-parent:true' properties to children that are large enough (at initialization time). See 'Fill Parent' farther down for details. |
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.
Margins
Margins for children are calculated automatically based on the position and size of those children at layout initialization. Those margins are then used, when the associated scene view is resized, to properly position and size the children. Note that the gravity and 'fill parent' properties of the child affect which margins are taken into consideration during layout. See the 'gravity' and 'fill parent' sections farther down for details.
Custom (non-0) margins can be specified for children. If this layout detects a non-0 margin on one of the children, the layout will avoid automatically calculating and assigning margin values for that child. Automatic assignment of gravity and 'fill parent' properties will also be skipped when custom margins are assigned.
Gravity
The gravity value specified in this layout is ignored. Instead, the layout calculates a gravity value for each child based on its initial position. This is done by dividing the associated scene view into 3 rows and 3 columns. One of 9 possible gravity values are assigned depending on where the center of the child is within those rows and columns. For example, if the child's center is in the top-right cell then the child will be assigned a top-right gravity.
Fill Parent
By default, this layout automatically detects which children should be marked as 'fill parent.' This is done by dividing the associated scene view into 3 rows and 3 columns, and seeing where the top-left and bottom-right corners of the child are initially. If a child's top side is within the first row and its bottom side is within the last row, then that child is marked as having a height that fills its parent. If a child's left side is within the first column and its right side is within the last column, then that child is marked as having a width that fills its parent. Note that the width and height 'fill parent' properties are separate: it is possible for a child to fill width and not fill height.
Text
In order for the text nodes to keep their initial position, this layout ignores the actual size of text nodes (as reported by the CYISceneNode::GetSize() function). Instead, this layout calculates margins relative to the text nodes' position. For 'box text' text nodes, the box size is used in addition to the text nodes' position. A side effect of this is that if a user specifies custom margins for a test node when using this layout, those custom margins may not behave like they do with other layout types. Consequently, it recommended to avoid specifying custom margins on text nodes.
#include <layout/YiAutoLayout.h>

Protected Member Functions | |
| virtual void | Configure () override |
| virtual void | ChildAdded (CYISceneNode *pChild) override |
| virtual void | ApplyPosition (CYISceneNode *pNode, const glm::vec3 &vPosition) override |
Protected Member Functions inherited from CYIStackLayout | |
| virtual void | OnMeasure (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) override |
| virtual void | OnApplyMeasurements () override |
Protected Member Functions inherited from CYIAnimatingLayout | |
| virtual void | OnMeasurementsApplied () override |
| virtual const CYIRuntimeTypeInfo & | GetLayoutConfigType () const 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 | |
Public Types inherited from CYILayout | |
| enum | POSITIONING_MODE { SET_POSITION_DIRECTLY, DO_NOT_SET_POSITION_DIRECTLY } |
| typedef CYILayoutConfig::CubeOffset | Padding |
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 |
| CYIAutoLayout::CYIAutoLayout | ( | ) |
|
virtual |
|
overrideprotectedvirtual |
Applies the position vPosition to the scene node pChild. This function, by default, simply calls CYISceneNode::SetPosition. It can be overridden in subclasses to support animating position changes for child scene nodes.
Reimplemented from CYIAnimatingLayout.
|
overrideprotectedvirtual |
Called when a child (pChild) is added to the scene node associated with this layout instance.
Reimplemented from CYIAnimatingLayout.
|
overrideprotectedvirtual |
Extracts relevant properties the associated scene node and configures this layout with said properties.
Reimplemented from CYIAnimatingLayout.
| bool CYIAutoLayout::IsDetectingFillParent | ( | ) | const |
| void CYIAutoLayout::SetDetectFillParent | ( | bool | bDetectFillParent | ) |
Sets the 'detect fill parent' property to bDetectFillParent. When set to true, this layout will automatically set 'fill parent' on children whose dimensions are large enough.