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.
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.
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 |
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.
#include <layout/YiAnimatingLayout.h>
Protected Member Functions | |
virtual void | Configure () override |
virtual void | OnMeasurementsApplied () override |
virtual const CYIRuntimeTypeInfo & | GetLayoutConfigType () const override |
virtual void | ApplyPosition (CYISceneNode *pChild, const glm::vec3 &position) override |
virtual void | ApplySize (CYISceneNode *pChild, const glm::vec3 &size) override |
![]() | |
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< CYILayoutState > | CreateLayoutStateInstance () const |
void | CreateLayoutObjectsFor (CYISceneNode *pNode) const |
CYISceneNode * | GetChild (size_t index) const |
void | ApplyMeasurementsToBackgroundChildren () |
const Padding & | GetPaddingForChild (const CYISceneNode *pChild) const |
Additional Inherited Members | |
![]() | |
enum | PositioningMode { PositioningMode::SetPositionDirectly, PositioningMode::DoNotSetPositionDirectly } |
typedef CYILayoutConfig::CubeOffset | Padding |
![]() | |
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) |
![]() | |
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 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 ¤tTopLeftPosition, 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 ¤tChildPosition) |
static void | MeasureBackgroundChildren (CYISceneNode *pNode, const glm::vec3 &size) |
![]() | |
CYISceneView * | m_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 |
CYIAnimatingLayout::CYIAnimatingLayout | ( | ) |
|
virtual |
|
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.
|
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.
|
overridevirtual |
Called when a child (pChild) is added to the scene node associated with this layout instance.
Reimplemented from CYILayout.
Reimplemented in CYIAutoLayout.
|
overridevirtual |
Called when a child (pChild) is removed from the scene node associated with this layout instance.
Reimplemented from CYILayout.
|
overridevirtual |
Called when the local visibility of a child (pChild) has changed in the scene node associated with this layout instance.
Reimplemented from CYILayout.
|
overrideprotectedvirtual |
Extracts relevant properties the associated scene node and configures this layout with said properties.
Reimplemented from CYILayout.
Reimplemented in CYIGridLayout, CYILinearLayout, CYIAutoLinearLayout, CYIAutoLayout, CYIScalingLayout, CYIColumnLayout, CYIRowLayout, and CYIShaftLayout.
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.
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.
|
overrideprotectedvirtual |
Returns the type of layout config objects used by this layout.
Reimplemented from CYILayout.
Reimplemented in CYIGridLayout.
uint32_t CYIAnimatingLayout::GetMovingTimeMs | ( | ) | const |
uint32_t CYIAnimatingLayout::GetSizingTimeMs | ( | ) | const |
CYITimeInterpolator* CYIAnimatingLayout::GetTimeInterpolator | ( | ) |
const CYITimeInterpolator* CYIAnimatingLayout::GetTimeInterpolator | ( | ) | const |
|
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.
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.
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.
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.