You.i Engine
CYIAnimatingLayout Class Reference

Detailed Description

A layout that can animate its children's position and size.

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
move-time 0 time value* The time spent moving the children into position.
size-time 0 time value* The time spent animating the size of the children.
time-interpolator CYIInterpolateQuadEaseInEaseOut special* The time interpolator used when animating the position and size of children. Has no effect when move-time and size-time are 0.

The parent layout class may define more properties that can be used.

See also
CYILayout

Children View Template Comments Specification

These values are applied to the comment field of the to-be-laid-out children. All properties are optional.

Label Default value Accepted values Description
layout-animations true true, false Indicates whether layout animations (e.g. position and size animations) should be applied to this child. Setting this property is equivalent to setting both the animate-position and animation-size properties.
animate-position true true, false Indicates whether position layout animations should be applied to this child.
animation-size true true, false Indicates whether size layout animations should be applied to this child.

The parent layout class may define more properties that can be used.

See also
CYILayout

Time Values

Time values are specified as a floating-point value in milliseconds by default. However, a suffix can be used to specify a time in other units. The following suffixes are supported:

Suffix Meaning Examples
(none) milliseconds 45, 45.0
ms milliseconds 45 ms, 45ms, 45.0ms
s seconds 45 s, 45s, 4.5s
min minutes 45 min, 45min, 4.5min
h hours 45 h, 45h, 4.5h
Warning
Time values are internally represented as milliseconds. Therefore, specifying a value of 4.6ms is equivalent to specifying a value of 4ms, and specifying a value of 4.0006s is equivalent to specifying a value of 4000ms.

Time Interpolators

The time-interpolator property sets an animation interpolator class. That interpolator is used if either move-time or size-time is non-0. When the layout determines that the position or size of one of its children has to change, the interpolator is used to apply an animation (which will take move-time or size-time milliseconds to complete).

For the list of available time interpolator classes, see CYITimeInterpolator.

See also
CYILayout

#include <layout/YiAnimatingLayout.h>

Inheritance diagram for CYIAnimatingLayout:

Public Member Functions

 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
 

Protected Member Functions

virtual void Configure () override
 
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 OnSceneViewAttached ()
 
virtual void OnMeasure (const CYISceneNode::MeasureSpec &widthSpec, const CYISceneNode::MeasureSpec &heightSpec, const CYISceneNode::MeasureSpec &depthSpec)=0
 
virtual void OnApplyMeasurements ()=0
 
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
 

Additional Inherited Members

- Public Types inherited from CYILayout
enum  PositioningMode {
  PositioningMode::SetPositionDirectly,
  PositioningMode::DoNotSetPositionDirectly
}
 
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 &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)
 
- 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
 

Constructor & Destructor Documentation

◆ CYIAnimatingLayout()

CYIAnimatingLayout::CYIAnimatingLayout ( )

◆ ~CYIAnimatingLayout()

virtual CYIAnimatingLayout::~CYIAnimatingLayout ( )
virtual

Member Function Documentation

◆ ApplyPosition()

virtual void CYIAnimatingLayout::ApplyPosition ( CYISceneNode pChild,
const glm::vec3 &  position 
)
overrideprotectedvirtual

Applies the position position 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 CYILayout.

Reimplemented in CYIAutoLayout.

◆ ApplySize()

virtual void CYIAnimatingLayout::ApplySize ( CYISceneNode pChild,
const glm::vec3 &  size 
)
overrideprotectedvirtual

Applies the size size to the scene node pChild. This function, by default, simply calls CYISceneNode::SetSize. It can be overridden in subclasses to support animating size changes for child scene nodes.

Reimplemented from CYILayout.

◆ ChildAdded()

virtual void CYIAnimatingLayout::ChildAdded ( CYISceneNode pChild)
overridevirtual

Called when a child (pChild) is added to the scene node associated with this layout instance.

Note
Subclasses that override this method must call the parent class' ChildAdded method.

Reimplemented from CYILayout.

Reimplemented in CYIAutoLayout.

◆ ChildRemoved()

virtual void CYIAnimatingLayout::ChildRemoved ( CYISceneNode pChild)
overridevirtual

Called when a child (pChild) is removed from the scene node associated with this layout instance.

Note
Subclasses that override this method must call the parent class' ChildRemoved method.

Reimplemented from CYILayout.

◆ ChildVisibilityChanged()

virtual void CYIAnimatingLayout::ChildVisibilityChanged ( CYISceneNode pChild)
overridevirtual

Called when the local visibility of a child (pChild) has changed in the scene node associated with this layout instance.

Note
Subclasses that override this method must call the parent class' ChildVisibilityChanged method.

Reimplemented from CYILayout.

◆ Configure()

virtual void CYIAnimatingLayout::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 CYILayout.

Reimplemented in CYIGridLayout, CYILinearLayout, CYIAutoLinearLayout, CYIAutoLayout, CYIScalingLayout, CYIColumnLayout, CYIRowLayout, and CYIShaftLayout.

◆ DisableAnimationsOnNextLayout()

void CYIAnimatingLayout::DisableAnimationsOnNextLayout ( bool  disable = true)

Disables all layout animations for the next call to ApplyMeasurements. This function is used to disable in-layout animations (such as size and position animations) in cases where such an animation would not be desirable. One such case would be when a view with a layout is first displayed: if layout animations were used, the children would animate from undefined positions and sizes.

Note
By default, animations are disabled on the first call to ApplyMeasurements on instances of CYIAnimatingLayout. If animations should be played on the first call to ApplyMeasurements, this function can be called with the disable parameter set to false.

◆ DisableAnimationsOnNextLayoutFor()

void CYIAnimatingLayout::DisableAnimationsOnNextLayoutFor ( CYISceneNode pChild,
bool  disable = true 
)

Disables layout animation for pChild for the next call to ApplyMeasurements. This function is used to disable in-layout animations (such as size and position) for a specific child node in cases where such an animation would not be desirable. One such case would be when a child is added to a view with a layout: if animations were played, the child would animate from an undefined position and size.

Note
By default, animations are disabled when a child is first added to a view with a layout. If the animations should be played, this function can be called with the disable parameter set to false.

◆ GetLayoutConfigType()

virtual const CYIRuntimeTypeInfo& CYIAnimatingLayout::GetLayoutConfigType ( ) const
overrideprotectedvirtual

Returns the type of layout config objects used by this layout.

Note
Subclasses should override this method if the laid-out objects can have custom configuration values. Remember to base the new class on the parent class's CYILayoutConfig class.

Reimplemented from CYILayout.

Reimplemented in CYIGridLayout.

◆ GetMovingTimeMs()

uint32_t CYIAnimatingLayout::GetMovingTimeMs ( ) const

◆ GetSizingTimeMs()

uint32_t CYIAnimatingLayout::GetSizingTimeMs ( ) const

◆ GetTimeInterpolator() [1/2]

CYITimeInterpolator* CYIAnimatingLayout::GetTimeInterpolator ( )

◆ GetTimeInterpolator() [2/2]

const CYITimeInterpolator* CYIAnimatingLayout::GetTimeInterpolator ( ) const

◆ OnMeasurementsApplied()

virtual void CYIAnimatingLayout::OnMeasurementsApplied ( )
overrideprotectedvirtual

A function called after OnApplyMeasurements has been called. This can be used in abstract classes to do post-measurements-application handling.

Reimplemented from CYILayout.

◆ SetMovingTime()

void CYIAnimatingLayout::SetMovingTime ( uint32_t  movingTimeMs)

Sets the moving time, in milliseconds, to movingTimeMs. The moving time is used when applying layouts to move children into position. If a non-0 value is specified, an animation lasting movingTimeMs milliseconds will be played to move the children into position. The currently-configured time interpolator will be used for the animation.

Note
Setting a value of 0 will disable move animations.
See also
CYIAnimatingLayout::SetTimeInterpolator

◆ SetSizingTime()

void CYIAnimatingLayout::SetSizingTime ( uint32_t  sizingTimeMs)

Sets the sizing time, in milliseconds, to sizingTimeMs. The sizing time is used when applying layouts to change the size of children. If a non-0 value is specified, an animation lasting sizingTimeMs milliseconds will be played to change the size of children. The currently-configured time interpolator will be used for the animation.

Note
Setting a value of 0 will disable size animations.
See also
CYIAnimatingLayout::SetTimeInterpolator

◆ SetTimeInterpolator()

void CYIAnimatingLayout::SetTimeInterpolator ( std::unique_ptr< CYITimeInterpolator pInterpolator)

Sets the time interpolator used for animations to pInterpolator. The time interpolator is used when animating children's position or size. By default, when no time interpolator is assigned to this class, the CYIInterpolateQuadEaseInEaseOut interpolator is used. If this function is called with a nullptr pInterpolator, then the currently-assigned interpolator will be deleted and this layout will revert to the CYIInterpolateQuadEaseInEaseOut interpolator.

Warning
If a time interpolator already existed prior to calling this function, the existing time interpolator will be deleted. Because property animations use a raw pointer to the same interpolator, every position and size property animation on the children of the associated scene node will be stopped to avoid a possible deleted memory access.

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