You.i Engine
CYIAutoLinearLayout Class Reference

Detailed Description

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.

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
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.

See also
CYILinearLayout

Children View Template Comments Specification

This class has no configurable per-child properties, except for those of the parent class.

See also
CYILinearLayout

Condition

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::Condition::Surface surface The current surface determines the orientation.
CYIAutoLinearLayout::Condition::MeasureSpec measure-spec The measure specs received through the CYILayout::Measure function determines the orientation.
CYIAutoLinearLayout::Condition::Programmatic programmatic The orientation is specified manually through the CYILinearLayout::SetOrientation function.

Surface Condition

When the CYIAutoLinearLayout::Condition::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.

Measure Spec Condition

When the CYIAutoLinearLayout::Condition::MeasureSpec 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::MeasureMode::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::MeasureMode::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.

Note
The layout constraints set on the associated scene view may affect the width and height used to determine the layout orientation. For example, if a width measure spec of 100.0f is received and a height measure spec of 200.0f is received but the associated scene view has a configured maximum height constraint of 50.0f set, then the resulting layout orientation will be CYILinearLayout::Orientation::Horizontal.

If the width measure spec is CYISceneNode::MeasureMode::Unspecified and the height measure spec is not, the CYILinearLayout::Orientation::Horizontal is used. If the height measure spec is CYISceneNode::MeasureMode::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::MeasureMode::Unspecified, the size constraints are used to determine the orientation. When no constraints are set, the resulting orientation is CYILinearLayout::Orientation::Horizontal.

Note
When both the width measure spec and the height measure spec are CYISceneNode::MeasureMode::Unspecified but the depth measure spec is not CYISceneNode::MeasureMode::Unspecified, the resulting orientation is CYILinearLayout::Orientation::Shaft. This is the only case where the shaft orientation is used.

Programmatic Condition

When the CYIAutoLinearLayout::Condition::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.

Note
Calling CYILinearLayout::SetOrientation() does not cause the layout to be dirtied. The CYISceneNode::RequestLayout() function should be called on the associated scene view when the CYILinearLayout::SetOrientation() function is called with a new orientation.
When the CYIAutoLinearLayout::Condition::Programmatic condition is used, the configured 'use inverted condition' flag (as set through the SetUseInvertCondition() function) is ignored.
See also
CYILinearLayout

#include <layout/YiAutoLinearLayout.h>

Inheritance diagram for CYIAutoLinearLayout:

Public Types

enum  Condition {
  Condition::Surface,
  Condition::MeasureSpec,
  Condition::Programmatic
}
 
- Public Types inherited from CYILinearLayout
enum  Orientation {
  Orientation::Horizontal,
  Orientation::Vertical,
  Orientation::Shaft
}
 
enum  Overflow {
  Overflow::Ignore,
  Overflow::Hide,
  Overflow::Wrap,
  Overflow::WrapAndHide
}
 
enum  LineGravity {
  LineGravity::Default,
  LineGravity::Start,
  LineGravity::Middle,
  LineGravity::End,
  LineGravity::Justify
}
 
- Public Types inherited from CYILayout
enum  PositioningMode {
  PositioningMode::SetPositionDirectly,
  PositioningMode::DoNotSetPositionDirectly
}
 
typedef CYILayoutConfig::CubeOffset Padding
 

Public Member Functions

 CYIAutoLinearLayout ()
 
virtual ~CYIAutoLinearLayout ()
 
void SetCondition (Condition condition)
 
Condition GetCondition () const
 
void SetFlipGravityOnConditionChange (bool flipGravity)
 
bool IsFlippingGravityOnConditionChange () const
 
void SetUseInvertedCondition (bool useInvertedCondition)
 
bool IsUsingInvertedCondition () const
 
- Public Member Functions inherited from CYILinearLayout
 CYILinearLayout ()
 
virtual ~CYILinearLayout ()
 
void SetSpacing (float spacing)
 
float GetSpacing () const
 
void SetJustify (bool justify)
 
bool IsUsingJustify () const
 
void SetOrientation (Orientation orientation)
 
Orientation GetOrientation () const
 
void SetOverflowMode (Overflow mode)
 
Overflow GetOverflowMode () const
 
void SetLineGravity (LineGravity lineGravity)
 
LineGravity GetLineGravity () const
 
- Public Member Functions inherited from CYIAnimatingLayout
 CYIAnimatingLayout ()
 
virtual ~CYIAnimatingLayout ()
 
void DisableAnimationsOnNextLayout (bool disable=true)
 
void DisableAnimationsOnNextLayoutFor (CYISceneNode *pChild, bool disable=true)
 
virtual void ChildAdded (CYISceneNode *pChild) override
 
virtual void ChildRemoved (CYISceneNode *pChild) override
 
virtual void ChildVisibilityChanged (CYISceneNode *pChild) override
 
void SetMovingTime (uint32_t movingTimeMs)
 
uint32_t GetMovingTimeMs () const
 
void SetSizingTime (uint32_t sizingTimeMs)
 
uint32_t GetSizingTimeMs () const
 
void SetTimeInterpolator (std::unique_ptr< CYITimeInterpolator > pInterpolator)
 
CYITimeInterpolatorGetTimeInterpolator ()
 
const CYITimeInterpolatorGetTimeInterpolator () const
 
- Public Member Functions inherited from CYILayout
 CYILayout ()
 
virtual ~CYILayout ()
 
void AttachTo (CYISceneView *pView)
 
void ConfigureFromAttachedNode ()
 
void DetachFromNode ()
 
CYISceneNodeGetAssociatedSceneNode () const
 
void Measure (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec)
 
void ApplyMeasurements ()
 
void SetPositioningMode (PositioningMode positioningMode)
 
PositioningMode GetPositioningMode () const
 
void SetPadding (const Padding &padding)
 
const PaddingGetPadding () const
 
void SetUseReverseChildrenOrder (bool useReverseChildrenOrder)
 
bool IsUsingReverseChildrenOrder () const
 
void SetGravity (const glm::vec3 &layoutGravity)
 
void SetGravity (CYILayoutConfig::Gravity gravity)
 
const glm::vec3 & GetGravity () const
 
- Public Member Functions inherited from CYISignalHandler
 CYISignalHandler ()
 
 CYISignalHandler (const CYISignalHandler &rSignalHandler)
 
virtual ~CYISignalHandler ()
 
CYISignalHandleroperator= (const CYISignalHandler &rSignalHandler)
 
void MoveToThread (CYIThread *pThread)
 This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More...
 
CYIThreadHandle GetThreadAffinity () const
 
void SetThreadAffinity (const CYIThreadHandle &rThreadAffinity)
 
virtual bool IsConnected () const
 
virtual bool IsConnected (const CYISignalBase &rSignal) const
 
void Disconnect (CYISignalBase &rSignal)
 
void DisconnectFromAllSignals ()
 
- Public Member Functions inherited from CYIThread::Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void OnThreadStarted (CYIThread *)
 
virtual void OnThreadTerminated (CYIThread *)
 
virtual void OnThreadFinished (CYIThread *)
 

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 CYIRuntimeTypeInfoGetLayoutConfigType () const override
 
virtual void ApplyPosition (CYISceneNode *pChild, const glm::vec3 &position) override
 
virtual void ApplySize (CYISceneNode *pChild, const glm::vec3 &size) 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< CYILayoutStateCreateLayoutStateInstance () const
 
void CreateLayoutObjectsFor (CYISceneNode *pNode) const
 
CYISceneNodeGetChild (size_t index) const
 
void ApplyMeasurementsToBackgroundChildren ()
 
const PaddingGetPaddingForChild (const CYISceneNode *pChild) const
 

Protected Attributes

Condition m_condition
 
bool m_flipGravityOnConditionChange
 
bool m_invertCondition
 
- Protected Attributes inherited from CYILinearLayout
float m_spacing
 
bool m_justify
 
Orientation m_orientation
 
Overflow m_overflowMode
 
LineGravity m_lineGravity
 
- Protected Attributes inherited from CYILayout
CYISceneViewm_pNode
 In most cases, this variable is used as a node (thus the name m_pNode ) More...
 
Padding m_padding
 
bool m_reverseChildrenOrder
 
glm::vec3 m_gravity
 
PositioningMode m_positioningMode
 

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 &scale, CYISceneNode::MeasureSpec *pWidthSpec, CYISceneNode::MeasureSpec *pHeightSpec, CYISceneNode::MeasureSpec *pDepthSpec)
 
static float CalculateDimension (const CYISceneNode::MeasureSpec &spec, const CYILayoutConfig::SizeConstraint &constraint, float currentValue)
 
- Protected Types inherited from CYILayout
enum  Dimensions {
  Dimensions::None = 0x0,
  Dimensions::X = 0x1,
  Dimensions::Y = 0x2,
  Dimensions::Z = 0x4,
  Dimensions::AllButX = Y | Z,
  Dimensions::AllButY = X | Z,
  Dimensions::AllButZ = X | Y,
  Dimensions::All = X | Y | 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 &childScale)
 
static CYISceneNode::MeasureSpec CalculateChildMeasureSpec (const CYISceneNode::MeasureSpec &parentMeasureSpec, float padding, const CYILayoutConfig::SizeConstraint &childConstraint, float childScale)
 
static bool UpdateMeasureSpecsForFitContent (const CYISceneNode *pNode, CYISceneNode::MeasureSpec *widthSpec, CYISceneNode::MeasureSpec *heightSpec, CYISceneNode::MeasureSpec *depthSpec)
 
static void RemeasureChildrenForFillParent (const CYISceneNode *pNode, const glm::vec3 &parentMeasuredSize, const Padding &padding, Dimensions dimensionsToRemeasure)
 
static glm::vec3 GetAdjustedPosition (const glm::vec3 &desiredTopLeftPosition, const CYISceneNode *pChild)
 
static glm::vec3 GetUnadjustedPosition (const glm::vec3 &currentTopLeftPosition, const CYISceneNode *pChild)
 
static glm::vec3 GetAdjustedMeasuredSize (const CYISceneNode *pChild)
 
static glm::vec3 GetTopLeftPositionWithGravity (const glm::vec3 &layoutGravity, const glm::vec3 &childGravity, const glm::vec3 &containerTopLeft, const glm::vec3 &containerSize, const CYILayout::Padding &padding, const glm::vec3 &childSize, const CYILayoutConfig::Margin &margin, const glm::vec3 &currentChildPosition)
 
static void MeasureBackgroundChildren (CYISceneNode *pNode, const glm::vec3 &size)
 

Member Enumeration Documentation

◆ Condition

A condition used to determine the orientation used by a CYIAutoLinearLayout.

Enumerator
Surface 

Use the current surface's dimensions to determine the orientation.

MeasureSpec 

Use the measure specs received by the layout to determine the orientation.

Programmatic 

Use the user-specified orientation value.

Constructor & Destructor Documentation

◆ CYIAutoLinearLayout()

CYIAutoLinearLayout::CYIAutoLinearLayout ( )

◆ ~CYIAutoLinearLayout()

virtual CYIAutoLinearLayout::~CYIAutoLinearLayout ( )
virtual

Member Function Documentation

◆ Configure()

virtual void CYIAutoLinearLayout::Configure ( )
overrideprotectedvirtual

Extracts relevant properties the associated scene node and configures this layout with said properties.

Note
Subclasses should override this method if they have custom configuration values. Remember to call the parent Configure function.

Reimplemented from CYILinearLayout.

◆ GetCondition()

Condition CYIAutoLinearLayout::GetCondition ( ) const
See also
SetCondition

◆ IsFlippingGravityOnConditionChange()

bool CYIAutoLinearLayout::IsFlippingGravityOnConditionChange ( ) const

◆ IsUsingInvertedCondition()

bool CYIAutoLinearLayout::IsUsingInvertedCondition ( ) const

◆ OnMeasure()

virtual void CYIAutoLinearLayout::OnMeasure ( const CYISceneNode::MeasureSpec widthSpec,
const CYISceneNode::MeasureSpec heightSpec,
const CYISceneNode::MeasureSpec depthSpec 
)
overrideprotectedvirtual

Measures the associated scene node, considering its layout configuration constraints (if available) and the provided measure specifications.

Warning
Implementations of this function are required to ensure that the Measure function of each child scene node is called at least once, even if those children are hidden or are non-laid-out.
Note
Typically, if OnMeasure is overridden then OnApplyMeasurements must also be overridden.
See also
CYILayout::Measure

Reimplemented from CYILinearLayout.

◆ OnSceneViewAttached()

virtual void CYIAutoLinearLayout::OnSceneViewAttached ( )
overrideprotectedvirtual

A function called after a scene view has been attached to this layout.

Reimplemented from CYILayout.

◆ SetCondition()

void CYIAutoLinearLayout::SetCondition ( Condition  condition)

Sets the condition used by this layout to determine its orientation to condition. By default, the condition is CYIAutoLinearLayout::Condition::Surface.

◆ SetFlipGravityOnConditionChange()

void CYIAutoLinearLayout::SetFlipGravityOnConditionChange ( bool  flipGravity)

When flipGravity is true, the components of this layout's gravity are flipped when the condition is detected as having changed. When flipGravity 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.

See also
SetCondition

◆ SetUseInvertedCondition()

void CYIAutoLinearLayout::SetUseInvertedCondition ( bool  useInvertedCondition)

When useInvertedCondition 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.

Note
This flag has no effect when the condition is CYIAutoLinearLayout::Condition::Programmatic.

Member Data Documentation

◆ m_condition

Condition CYIAutoLinearLayout::m_condition
protected

◆ m_flipGravityOnConditionChange

bool CYIAutoLinearLayout::m_flipGravityOnConditionChange
protected

◆ m_invertCondition

bool CYIAutoLinearLayout::m_invertCondition
protected

The documentation for this class was generated from the following file: