A linear layout that switches between horizontal and vertical orientations based on a configurable condition.
Instances of this layout implement a linear layout that switches between horizontal and vertical orientations based on a condition. The available conditions are detailed in the Condition section.
By default, the x and y components of the configured gravity value are flipped when the condition is detected as having changed. For example, if the original 'gravity' value of the layout is 'left' and the orientation changes to vertical, the gravity value will be modified to 'top'. If this is undesirable, the SetFlipGravityOnConditionChange() function can be used to disable automatic modification of the gravity value.
In some cases, it may be desirable to use the 'opposite' orientation than what the selected condition prescribes. For example, the condition may imply a 'vertical' orientation but a 'horizontal' orientation is preferred. In those cases, the SetUseInvertCondition() function can be used to cause the opposite orientation to be used.
This layout respects the padding layout configuration option and the margin per-node layout configuration option.
These values are applied to the comment field of the container composition. All properties are optional.
| Label | Default value | Accepted values | Description |
|---|---|---|---|
| condition | surface | special* | The condition which determines which orientation the linear layout should use. See the Condition section for details. |
| flip-gravity | true | true, false | If true, the gravity layout value is flipped when the condition is detected as having changed. If false, the gravity layout value remains unchanged. |
| invert-condition | false | true, false | If true, conditions that would normally result in a horizontal orientation will instead result in a vertical orientation (and vice-versa). |
The parent layout class may define more properties that can be used.
This class has no configurable per-child properties, except for those of the parent class.
The condition configured on this layout is used to determine which orientation the layout should be in. The following table lists the available conditions, along with a short description of each.
| Enum Value | Template Comment Values | Description |
|---|---|---|
| CYIAutoLinearLayout::SURFACE | surface | The current surface determines the orientation. |
| CYIAutoLinearLayout::MEASURE_SPEC | measure-spec | The measure specs received through the CYILayout::Measure function determines the orientation. |
| CYIAutoLinearLayout::PROGRAMMATIC | programmatic | The orientation is specified manually through the CYILinearLayout::SetOrientation function. |
When the CYIAutoLinearLayout::SURFACE condition is selected, the current surface is used to determine the layout orientation. If the surface's height is larger than its width, the CYILinearLayout::ORIENTATION_VERTICAL orientation is used. Otherwise, the CYILinearLayout::ORIENTATION_HORIZONTAL is used.
When the CYIAutoLinearLayout::MEASURE_SPEC condition is selected, the measure specs received through the CYILayout::Measure function are used to determine the orientation. The measure specs received by the CYILayout::Measure function may be fixed (e.g. if the parent of the associated scene node does not have a layout applied to it), or may be dynamic. The measure specs may also be CYISceneNode::MEASURE_UNSPECIFIED (in the case where the parent of the associated scene node has a layout and is configured to 'fit content').
When neither the width nor the height measure specs are CYISceneNode::MEASURE_UNSPECIFIED, the two measure spec sizes are compared to determine the layout orientation. If the height is larger than the width, the CYILinearLayout::ORIENTATION_VERTICAL orientation is used. Otherwise, the CYILinearLayout::ORIENTATION_HORIZONTAL is used.
If the width measure spec is CYISceneNode::MEASURE_UNSPECIFIED and the height measure spec is not, the CYILinearLayout::ORIENTATION_HORIZONTAL is used. If the height measure spec is CYISceneNode::MEASURE_UNSPECIFIED and the width measure spec is not, the CYILinearLayout::ORIENTATION_VERTICAL is used. If both the width measure spec and the height measure spec are CYISceneNode::MEASURE_UNSPECIFIED, the size constraints are used to determine the orientation. When no constraints are set, the resulting orientation is CYILinearLayout::ORIENTATION_HORIZONTAL.
When the CYIAutoLinearLayout::PROGRAMMATIC condition is selected, the orientation of the layout is not modified by the layout itself. Users can use the CYILinearLayout::SetOrientation() function to set the layout to a specific orientation.
#include <layout/YiAutoLinearLayout.h>

Public Types | |
| enum | CONDITION { SURFACE, MEASURE_SPEC, PROGRAMMATIC } |
Public Types inherited from CYILinearLayout | |
| enum | ORIENTATION { ORIENTATION_HORIZONTAL, ORIENTATION_VERTICAL, ORIENTATION_SHAFT } |
| enum | OVERFLOW_MODE { OVERFLOW_IGNORE, OVERFLOW_OFFSCREEN, OVERFLOW_WRAP, OVERFLOW_WRAP_AND_MOVE_OFFSCREEN } |
| enum | LINE_GRAVITY { LINE_GRAVITY_DEFAULT, LINE_GRAVITY_START, LINE_GRAVITY_MIDDLE, LINE_GRAVITY_END, LINE_GRAVITY_JUSTIFY } |
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 | OnSceneViewAttached () override |
| virtual void | OnMeasure (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec) override |
Protected Member Functions inherited from CYILinearLayout | |
| virtual void | OnApplyMeasurements () override |
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 | 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 |
Protected Attributes | |
| CONDITION | m_eCondition |
| bool | m_bFlipGravityOnConditionChange |
| bool | m_bInvertCondition |
Protected Attributes inherited from CYILinearLayout | |
| float | m_fSpacing |
| bool | m_bJustify |
| ORIENTATION | m_eOrientation |
| OVERFLOW_MODE | m_eOverflowMode |
| LINE_GRAVITY | m_eLineGravity |
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 |
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) |
A condition used to determine the orientation used by a CYIAutoLinearLayout.
| CYIAutoLinearLayout::CYIAutoLinearLayout | ( | ) |
|
virtual |
|
overrideprotectedvirtual |
Extracts relevant properties the associated scene node and configures this layout with said properties.
Reimplemented from CYILinearLayout.
| CONDITION CYIAutoLinearLayout::GetCondition | ( | ) | const |
| bool CYIAutoLinearLayout::IsFlippingGravityOnConditionChange | ( | ) | const |
| bool CYIAutoLinearLayout::IsUsingInvertedCondition | ( | ) | const |
|
overrideprotectedvirtual |
Measures the associated scene node, considering its layout configuration constraints (if available) and the provided measure specifications.
Reimplemented from CYILinearLayout.
|
overrideprotectedvirtual |
A function called after a scene view has been attached to this layout.
Reimplemented from CYILayout.
| void CYIAutoLinearLayout::SetCondition | ( | CONDITION | eCondition | ) |
Sets the condition used by this layout to determine its orientation to eCondition. By default, the condition is CYIAutoLinearLayout::SURFACE.
| void CYIAutoLinearLayout::SetFlipGravityOnConditionChange | ( | bool | bFlipGravity | ) |
When bFlipGravity is true, the components of this layout's gravity are flipped when the condition is detected as having changed. When bFlipGravity is false, the gravity value is left unmodified. By default, the components of this layout's gravity are flipped when the condition is detected as having changed.
| void CYIAutoLinearLayout::SetUseInvertedCondition | ( | bool | bUseInvertedCondition | ) |
When bUseInvertedCondition is true, the condition values that would normally result in an CYILinearLayout::ORIENTATION_HORIZONTAL orientation instead result in an CYILinearLayout::ORIENTATION_VERTICAL orientation, and vice versa. By default, the condition values are not inverted.
|
protected |
|
protected |
|
protected |