Magnum::Ui::AbstractAnimator class new in Git master

Base for animators.

Derived classes

class AbstractDataAnimator new in Git master
Base for data animators.
class AbstractGenericAnimator new in Git master
Base for generic animators.
class AbstractNodeAnimator new in Git master
Base for node animators.
class AbstractStyleAnimator new in Git master
Base for style animators.

Constructors, destructors, conversion operators

AbstractAnimator(AnimatorHandle handle) explicit
Constructor.
AbstractAnimator(const AbstractAnimator&) deleted
Copying is not allowed.
AbstractAnimator(AbstractAnimator&&) noexcept
Move constructor.

Public functions

auto operator=(const AbstractAnimator&) -> AbstractAnimator& deleted
Copying is not allowed.
auto operator=(AbstractAnimator&&) -> AbstractAnimator& noexcept
Move assignment.
auto handle() const -> AnimatorHandle
Animator handle.
auto features() const -> AnimatorFeatures
Features exposed by an animator.
auto layer() const -> LayerHandle
Layer handle a data animator is associated with.
auto state() const -> AnimatorStates
Animator state.
auto time() const -> Nanoseconds
Animator time.
auto capacity() const -> std::size_t
Current capacity of the data storage.
auto usedCount() const -> std::size_t
Count of used items in the data storage.
auto isHandleValid(AnimatorDataHandle handle) const -> bool
Whether an animation handle is valid.
auto isHandleValid(AnimationHandle handle) const -> bool
Whether an animation handle is valid.
auto duration(AnimationHandle handle) const -> Nanoseconds
Duration of one animation play.
auto duration(AnimatorDataHandle handle) const -> Nanoseconds
Duration of one animation play assuming it belongs to this animator.
auto repeatCount(AnimationHandle handle) const -> UnsignedInt
Animation repeat count.
auto repeatCount(AnimatorDataHandle handle) const -> UnsignedInt
Animation repeat count assuming it belongs to this animator.
void setRepeatCount(AnimationHandle handle, UnsignedInt count)
Set animation repeat count.
void setRepeatCount(AnimatorDataHandle handle, UnsignedInt count)
Set animation repeat count assuming it belongs to this animator.
auto flags(AnimationHandle handle) const -> AnimationFlags
Animation flags.
auto flags(AnimatorDataHandle handle) const -> AnimationFlags
Animation flags assuming it belongs to this animator.
void setFlags(AnimationHandle handle, AnimationFlags flags)
Set animation flags.
void setFlags(AnimatorDataHandle handle, AnimationFlags flags)
Set animation flags assuming it belongs to this animator.
void addFlags(AnimationHandle handle, AnimationFlags flags)
Add animation flags.
void addFlags(AnimatorDataHandle handle, AnimationFlags flags)
Add animation flags assuming it belongs to this animator.
void clearFlags(AnimationHandle handle, AnimationFlags flags)
Clear animation flags.
void clearFlags(AnimatorDataHandle handle, AnimationFlags flags)
Clear animation flags assuming it belongs to this animator.
auto played(AnimationHandle handle) const -> Nanoseconds
Time at which an animation is played.
auto played(AnimatorDataHandle handle) const -> Nanoseconds
Time at which an animation is played assuming it belongs to this animator.
auto paused(AnimationHandle handle) const -> Nanoseconds
Animation paused time.
auto paused(AnimatorDataHandle handle) const -> Nanoseconds
Animation paused time assuming it belongs to this animator.
auto stopped(AnimationHandle handle) const -> Nanoseconds
Animation stopped time.
auto stopped(AnimatorDataHandle handle) const -> Nanoseconds
Animation stopped time assuming it belongs to this animator.
void attach(AnimationHandle animation, NodeHandle node)
Attach an animation to a node.
void attach(AnimatorDataHandle animation, NodeHandle node)
Attach an animation to a node assuming it belongs to this animator.
auto node(AnimationHandle handle) const -> NodeHandle
Node handle an animation is attached to.
auto node(AnimatorDataHandle handle) const -> NodeHandle
Node handle an animation is attached to assuming the animation belongs to this animator.
auto nodes() const -> Containers::StridedArrayView1D<const NodeHandle>
Node attachments for all animations.
void attach(AnimationHandle animation, DataHandle data)
Attach an animation to a data.
void attach(AnimatorDataHandle animation, DataHandle data)
Attach an animation to a data assuming the animation belongs to this animator.
void attach(AnimationHandle animation, LayerDataHandle data)
Attach an animation to a data assuming the data belongs to a layer registered with this animator.
void attach(AnimatorDataHandle animation, LayerDataHandle data)
Attach an animation to a data assuming the animation belongs to this animator and the data belongs to a layer registered with this animator.
auto data(AnimationHandle handle) const -> DataHandle
Data handle an animation is attached to.
auto data(AnimatorDataHandle handle) const -> DataHandle
Data handle an animation is attached to assuming the animation belongs to this animator.
auto layerData() const -> Containers::StridedArrayView1D<const LayerDataHandle>
Layer data attachments for all animations.
auto state(AnimationHandle handle) const -> AnimationState
Animation state.
auto state(AnimatorDataHandle handle) const -> AnimationState
Animation state assuming it belongs to this animator.
auto factor(AnimationHandle handle) const -> Float
Animation interpolation factor.
auto factor(AnimatorDataHandle handle) const -> Float
Animation interpolation factor assuming it belongs to this animator.
void play(AnimationHandle handle, Nanoseconds time)
Play an animation or resume a paused one.
void play(AnimatorDataHandle handle, Nanoseconds time)
Play an animation or resume a paused one assuming it belongs to this animator.
void pause(AnimationHandle handle, Nanoseconds time)
Pause an animation.
void pause(AnimatorDataHandle handle, Nanoseconds time)
Pause an animation assuming it belongs to this animator.
void stop(AnimationHandle handle, Nanoseconds time)
Stop an animation.
void stop(AnimatorDataHandle handle, Nanoseconds time)
Stop an animation assuming it belongs to this animator.
auto generations() const -> Containers::StridedArrayView1D<const UnsignedShort>
Generation counters for all data.
void clean(Containers::BitArrayView animationIdsToRemove)
Clean no longer valid animations.
void cleanNodes(const Containers::StridedArrayView1D<const UnsignedShort>& nodeHandleGenerations)
Clean animations attached to no longer valid nodes.
void cleanData(const Containers::StridedArrayView1D<const UnsignedShort>& dataHandleGenerations)
Clean animations attached to no longer valid data.
auto update(Nanoseconds time, Containers::MutableBitArrayView active, const Containers::StridedArrayView1D<Float>& factors, Containers::MutableBitArrayView remove) -> Containers::Pair<bool, bool>
Update the internal state and calculate factors for animation advance.

Protected functions

auto create(Nanoseconds played, Nanoseconds duration, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) -> AnimationHandle
Create an animation.
auto create(Nanoseconds played, Nanoseconds duration, AnimationFlags flags) -> AnimationHandle
Create an animation.
auto create(Nanoseconds played, Nanoseconds duration, NodeHandle node, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) -> AnimationHandle
Create an animation attached to a node.
auto create(Nanoseconds played, Nanoseconds duration, NodeHandle node, AnimationFlags flags) -> AnimationHandle
Create an animation attached to a node.
auto create(Nanoseconds played, Nanoseconds duration, DataHandle data, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) -> AnimationHandle
Create an animation attached to a data.
auto create(Nanoseconds played, Nanoseconds duration, DataHandle data, AnimationFlags flags) -> AnimationHandle
Create an animation attached to a data.
auto create(Nanoseconds played, Nanoseconds duration, LayerDataHandle data, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) -> AnimationHandle
Create an animation attached to a data assuming the data belongs to the layer the animator is registered with.
auto create(Nanoseconds played, Nanoseconds duration, LayerDataHandle data, AnimationFlags flags) -> AnimationHandle
Create an animation attached to a data assuming the data belongs to the layer the animator is registered with.
void remove(AnimationHandle handle)
Remove an animation.
void remove(AnimatorDataHandle handle)
Remove an animation assuming it belongs to this animator.

Private functions

auto doFeatures() const -> AnimatorFeatures pure virtual
Implementation for features()
void doClean(Containers::BitArrayView animationIdsToRemove) virtual
Clean no longer valid animations.

Function documentation

Magnum::Ui::AbstractAnimator::AbstractAnimator(AnimatorHandle handle) explicit

Constructor.

Parameters
handle Handle returned by AbstractUserInterface::createAnimator()

Magnum::Ui::AbstractAnimator::AbstractAnimator(AbstractAnimator&&) noexcept

Move constructor.

Performs a destructive move, i.e. the original object isn't usable afterwards anymore.

AnimatorHandle Magnum::Ui::AbstractAnimator::handle() const

Animator handle.

Returns the handle passed to the constructor.

LayerHandle Magnum::Ui::AbstractAnimator::layer() const

Layer handle a data animator is associated with.

Expects that the animator supports AnimatorFeature::DataAttachment. If the animator isn't an AbstractGenericAnimator, AbstractDataAnimator or an AbstractStyleAnimator and AbstractGenericAnimator::setLayer(), AbstractLayer::assignAnimator(AbstractDataAnimator&) const or AbstractLayer::assignAnimator(AbstractStyleAnimator&) const wasn't called yet, returns LayerHandle::Null.

AnimatorStates Magnum::Ui::AbstractAnimator::state() const

Animator state.

See the AnimatorState enum for more information. By default no flags are set.

Nanoseconds Magnum::Ui::AbstractAnimator::time() const

Animator time.

Time value last passed to update(). Initial value is 0_nsec.

std::size_t Magnum::Ui::AbstractAnimator::capacity() const

Current capacity of the data storage.

Can be at most 1048576. If create() is called and there's no free slots left, the internal storage gets grown.

std::size_t Magnum::Ui::AbstractAnimator::usedCount() const

Count of used items in the data storage.

Always at most capacity(). Expired handles are counted among used as well. The operation is done with a $ \mathcal{O}(n) $ complexity where $ n $ is capacity().

bool Magnum::Ui::AbstractAnimator::isHandleValid(AnimatorDataHandle handle) const

Whether an animation handle is valid.

A handle is valid if it has been returned from create() before and remove() wasn't called on it yet. For AnimatorDataHandle::Null always returns false.

bool Magnum::Ui::AbstractAnimator::isHandleValid(AnimationHandle handle) const

Whether an animation handle is valid.

A shorthand for extracting an AnimatorHandle from handle using animationHandleAnimator(), comparing it to handle() and if it's the same, calling isHandleValid(AnimatorDataHandle) const with an AnimatorDataHandle extracted from handle using animationHandleData(). See these functions for more information. For AnimationHandle::Null, AnimatorHandle::Null or AnimatorDataHandle::Null always returns false.

Nanoseconds Magnum::Ui::AbstractAnimator::duration(AnimationHandle handle) const

Duration of one animation play.

Expects that handle is valid. The duration is specified with create() and is always positive. The duration, together with played(AnimationHandle) const, paused(AnimationHandle) const, stopped(AnimationHandle) const, repeatCount(AnimationHandle) const and time() is used to decide on a particular AnimationState for given animation. See also duration(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

Nanoseconds Magnum::Ui::AbstractAnimator::duration(AnimatorDataHandle handle) const

Duration of one animation play assuming it belongs to this animator.

Like duration(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

UnsignedInt Magnum::Ui::AbstractAnimator::repeatCount(AnimationHandle handle) const

Animation repeat count.

Expects that handle is valid. The repeat count is specified with create() and can be subsequently modified with setRepeatCount(). Value of 0 means the animation is repeated indefinitely. The repeat count, together with duration(AnimationHandle) const, played(AnimationHandle) const, paused(AnimationHandle) const, stopped(AnimationHandle) const and time() is used to decide on a particular AnimationState for given animation. See also repeatCount(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

UnsignedInt Magnum::Ui::AbstractAnimator::repeatCount(AnimatorDataHandle handle) const

Animation repeat count assuming it belongs to this animator.

Like repeatCount(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::setRepeatCount(AnimationHandle handle, UnsignedInt count)

Set animation repeat count.

Expects that handle is valid. Use 0 for an indefinitely repeating animation. The repeat count, together with duration(AnimationHandle) const, played(AnimationHandle) const, paused(AnimationHandle) const, stopped(AnimationHandle) const and time() is subsequently used to decide on a particular AnimationState for given animation. See also setRepeatCount(AnimatorDataHandle, UnsignedInt) which is a simpler operation if the animation is already known to belong to this animator.

Compared to create() or play(), a change in repeat count doesn't change the animation to AnimationState::Scheduled, AnimationState::Playing or AnimationState::Paused if it wasn't there already, thus calling this function never causes AnimatorState::NeedsAdvance to be set.

void Magnum::Ui::AbstractAnimator::setRepeatCount(AnimatorDataHandle handle, UnsignedInt count)

Set animation repeat count assuming it belongs to this animator.

Like setRepeatCount(AnimationHandle, UnsignedInt) but without checking that handle indeed belongs to this animator. See its documentation for more information.

AnimationFlags Magnum::Ui::AbstractAnimator::flags(AnimationHandle handle) const

Animation flags.

Expects that handle is valid. The flags are specified with create() and can be subsequently modified with setFlags(), addFlags() or clearFlags(). See also flags(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

AnimationFlags Magnum::Ui::AbstractAnimator::flags(AnimatorDataHandle handle) const

Animation flags assuming it belongs to this animator.

Like flags(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::setFlags(AnimationHandle handle, AnimationFlags flags)

Set animation flags.

Expects that handle is valid. See also setFlags(AnimatorDataHandle, AnimationFlags) which is a simpler operation if the animation is already known to belong to this animator.

Compared to create(), play() or pause(), a change in flags never causes the animation to become AnimationState::Scheduled, AnimationState::Playing or AnimationState::Paused if it wasn't before already, thus calling this function doesn't cause AnimatorState::NeedsAdvance to be set.

void Magnum::Ui::AbstractAnimator::setFlags(AnimatorDataHandle handle, AnimationFlags flags)

Set animation flags assuming it belongs to this animator.

Like setFlags(AnimationHandle, AnimationFlags) but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::addFlags(AnimationHandle handle, AnimationFlags flags)

Add animation flags.

Calls setFlags(AnimationHandle, AnimationFlags) with the existing flags ORed with flags. Useful for preserving previously set flags. See also addFlags(AnimatorDataHandle, AnimationFlags) which is a simpler operation if the animation is already known to belong to this animator.

void Magnum::Ui::AbstractAnimator::addFlags(AnimatorDataHandle handle, AnimationFlags flags)

Add animation flags assuming it belongs to this animator.

Like addFlags(AnimationHandle, AnimationFlags) but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::clearFlags(AnimationHandle handle, AnimationFlags flags)

Clear animation flags.

Calls setFlags(AnimationHandle, AnimationFlags) with the existing flags ANDed with the inverse of flags. Useful for removing a subset of previously set flags. See also clearFlags(AnimatorDataHandle, AnimationFlags) which is a simpler operation if the animation is already known to belong to this animator.

void Magnum::Ui::AbstractAnimator::clearFlags(AnimatorDataHandle handle, AnimationFlags flags)

Clear animation flags assuming it belongs to this animator.

Like clearFlags(AnimationHandle, AnimationFlags) but without checking that handle indeed belongs to this animator. See its documentation for more information.

Nanoseconds Magnum::Ui::AbstractAnimator::played(AnimationHandle handle) const

Time at which an animation is played.

Expects that handle is valid. The time an animation is played at is specified with create() and is subsequently affected by calling play() or stop(). The specified time, together with duration(AnimationHandle) const, repeatCount(AnimationHandle) const, paused(AnimationHandle) const, stopped(AnimationHandle) const and time() is used to decide on a particular AnimationState for given animation. See also played(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

Nanoseconds Magnum::Ui::AbstractAnimator::played(AnimatorDataHandle handle) const

Time at which an animation is played assuming it belongs to this animator.

Like played(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

Nanoseconds Magnum::Ui::AbstractAnimator::paused(AnimationHandle handle) const

Animation paused time.

Expects that handle is valid. The paused time is initially Nanoseconds::max() and is affected by calling play() or pause(). The paused time, together with duration(AnimationHandle) const, repeatCount(AnimationHandle) const, played(AnimationHandle) const, stopped(AnimationHandle) const and time() is used to decide on a particular AnimationState for given animation. See also paused(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

Nanoseconds Magnum::Ui::AbstractAnimator::paused(AnimatorDataHandle handle) const

Animation paused time assuming it belongs to this animator.

Like paused(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

Nanoseconds Magnum::Ui::AbstractAnimator::stopped(AnimationHandle handle) const

Animation stopped time.

Expects that handle is valid. The stopped time is initially Nanoseconds::max() and is affected by calling play() or stop(). The stopped time, together with played(AnimationHandle) const, paused(AnimationHandle) const, duration(AnimationHandle) const, repeatCount(AnimationHandle) const and time() is used to decide on a particular AnimationState for given animation. See also stopped(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

Nanoseconds Magnum::Ui::AbstractAnimator::stopped(AnimatorDataHandle handle) const

Animation stopped time assuming it belongs to this animator.

Like stopped(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::attach(AnimationHandle animation, NodeHandle node)

Attach an animation to a node.

Makes the animation handle tied to a particular node, meaning it'll get scheduled for removal during the next cleanNodes() call when AbstractUserInterface::removeNode() is called for node or any parent node.

Expects that animation is valid and that the animator supports AnimatorFeature::NodeAttachment. The node can be anything including NodeHandle::Null, but if it's non-null and not valid the animation will be scheduled for deletion during the next cleanNodes() call. If the animation is already attached to some node, this will overwrite the previous attachment — i.e., it's not possible to have the same animation attached to multiple nodes. The inverse, attaching multiple different animation handles to a single node, is supported however.

Unlike with e.g. AbstractLayer::attach(), calling this function does not cause any AnimatorState to be set.

void Magnum::Ui::AbstractAnimator::attach(AnimatorDataHandle animation, NodeHandle node)

Attach an animation to a node assuming it belongs to this animator.

Like attach(AnimationHandle, NodeHandle) but without checking that animation indeed belongs to this animator. See its documentation for more information.

NodeHandle Magnum::Ui::AbstractAnimator::node(AnimationHandle handle) const

Node handle an animation is attached to.

Expects that handle is valid and that the animator supports AnimatorFeature::NodeAttachment. If the animation isn't attached to any node, returns NodeHandle::Null.

The returned handle may be invalid if either the animation got attached to an invalid node in the first place or the node or any of its parents were removed and AbstractUserInterface::clean() wasn't called since.

NodeHandle Magnum::Ui::AbstractAnimator::node(AnimatorDataHandle handle) const

Node handle an animation is attached to assuming the animation belongs to this animator.

Like node(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

Containers::StridedArrayView1D<const NodeHandle> Magnum::Ui::AbstractAnimator::nodes() const

Node attachments for all animations.

Expects that the animator supports AnimatorFeature::NodeAttachment. Meant to be used by animator implementations to map animation IDs to node handles if needed. Size of the returned view is the same as capacity(). Items that are NodeHandle::Null are either animations with no node attachments or corresponding to animations that are freed.

void Magnum::Ui::AbstractAnimator::attach(AnimationHandle animation, DataHandle data)

Attach an animation to a data.

Makes the animation handle tied to a particular data, meaning it'll get scheduled for removal during the next cleanData() call when AbstractLayer::remove() is called for data or when it gets removed as a consequence of a node removal.

Expects that animation is valid and that the animator supports AnimatorFeature::DataAttachment. The data is expected to be either DataHandle::Null or with the layer part matching layer(). Other than that it can be anything but if it's not DataHandle::Null and not valid the animation will be scheduled for deletion during the next cleanData() call. If the animation is already attached to some data, this will overwrite the previous attachment — i.e., it's not possible to have the same animation attached to multiple data. The inverse, attaching multiple different animation handles to a single data, is supported however.

Unlike with e.g. AbstractLayer::attach(), calling this function does not cause any AnimatorState to be set.

void Magnum::Ui::AbstractAnimator::attach(AnimatorDataHandle animation, DataHandle data)

Attach an animation to a data assuming the animation belongs to this animator.

Like attach(AnimationHandle, DataHandle) but without checking that animation indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::attach(AnimationHandle animation, LayerDataHandle data)

Attach an animation to a data assuming the data belongs to a layer registered with this animator.

Like attach(AnimationHandle, DataHandle) but without checking that data is indeed coming from layer(). See its documentation for more information. Calling this function with LayerDataHandle::Null is equivalent to calling attach(AnimationHandle, DataHandle) with DataHandle::Null.

void Magnum::Ui::AbstractAnimator::attach(AnimatorDataHandle animation, LayerDataHandle data)

Attach an animation to a data assuming the animation belongs to this animator and the data belongs to a layer registered with this animator.

Like attach(AnimationHandle, DataHandle) but without checking that animation indeed belongs to this animator and that that data is indeed coming from layer(). See its documentation for more information. Calling this function with LayerDataHandle::Null is equivalent to calling attach(AnimationHandle, DataHandle) with DataHandle::Null.

DataHandle Magnum::Ui::AbstractAnimator::data(AnimationHandle handle) const

Data handle an animation is attached to.

Expects that handle is valid and that the animator supports AnimatorFeature::DataAttachment. If the animation isn't attached to any data, returns DataHandle::Null, otherwise the layer portion of the handle is always equal to layer().

The returned handle may be invalid if either the animation got attached to an invalid data in the first place or the data was removed and AbstractUserInterface::clean() wasn't called since.

DataHandle Magnum::Ui::AbstractAnimator::data(AnimatorDataHandle handle) const

Data handle an animation is attached to assuming the animation belongs to this animator.

Like data(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

Containers::StridedArrayView1D<const LayerDataHandle> Magnum::Ui::AbstractAnimator::layerData() const

Layer data attachments for all animations.

Expects that the animator supports AnimatorFeature::DataAttachment. Meant to be used by animator implementations to map animation IDs to data handles if needed. Size of the returned view is the same as capacity(). Items that are LayerDataHandle::Null are either animations with no data attachments or corresponding to animations that are freed. Use dataHandle(LayerHandle, LayerDataHandle) with layer() to convert given handle to a DataHandle if needed.

AnimationState Magnum::Ui::AbstractAnimator::state(AnimationHandle handle) const

Animation state.

Expects that handle is valid. Calculated based on the value of time() recorded in last update(), duration(AnimationHandle) const, repeatCount(AnimationHandle) const, played(AnimationHandle) const, paused(AnimationHandle) const and stopped(AnimationHandle) const for a particular animation. See also state(AnimatorDataHandle) const which is a simpler operation if the animation is already known to belong to this animator.

AnimationState Magnum::Ui::AbstractAnimator::state(AnimatorDataHandle handle) const

Animation state assuming it belongs to this animator.

Like state(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

Float Magnum::Ui::AbstractAnimator::factor(AnimationHandle handle) const

Animation interpolation factor.

Expects that handle is valid. Calculated based on the value of time() recorded in last update(), duration(AnimationHandle) const, repeatCount(AnimationHandle) const, played(AnimationHandle) const, paused(AnimationHandle) const and stopped(AnimationHandle) const for a particular animation. The returned value is always in the $ [0, 1] $ range and matches what would be returned from update() for given animation at time(). For AnimationState::Scheduled always returns 0.0f, for AnimationState::Stopped 1.0f.

Float Magnum::Ui::AbstractAnimator::factor(AnimatorDataHandle handle) const

Animation interpolation factor assuming it belongs to this animator.

Like factor(AnimationHandle) const but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::play(AnimationHandle handle, Nanoseconds time)

Play an animation or resume a paused one.

Expects that handle is valid. The function effectively just updates the value of played(AnimationHandle) const and sets both paused(AnimationHandle) const and stopped(AnimationHandle) const to Nanoseconds::max(). The actual AnimationState is then decided based on these three times together with duration(AnimationHandle) const, repeatCount(AnimationHandle) const and time().

If calling this function resulted in the animation being AnimationState::Scheduled or AnimationState::Playing, the AnimatorState::NeedsAdvance flag is set.

void Magnum::Ui::AbstractAnimator::play(AnimatorDataHandle handle, Nanoseconds time)

Play an animation or resume a paused one assuming it belongs to this animator.

Like play(AnimationHandle, Nanoseconds) but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::pause(AnimationHandle handle, Nanoseconds time)

Pause an animation.

Expects that handle is valid. The function effectively just updates the value of paused(AnimationHandle) const; the actual AnimationState is then decided based on the paused time together with duration(AnimationHandle) const, repeatCount(AnimationHandle) const, played(AnimationHandle) const, stopped(AnimationHandle) const and time().

If calling this function resulted in the animation being AnimationState::Scheduled, AnimationState::Playing (for example if the pause time is moved to the future) or AnimationState::Paused, the AnimatorState::NeedsAdvance flag is set.

void Magnum::Ui::AbstractAnimator::pause(AnimatorDataHandle handle, Nanoseconds time)

Pause an animation assuming it belongs to this animator.

Like pause(AnimationHandle, Nanoseconds) but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::stop(AnimationHandle handle, Nanoseconds time)

Stop an animation.

Expects that handle is valid. The function effectively just updates the value of stopped(AnimationHandle) const; the actual AnimationState is then decided based on the stopped time together with duration(AnimationHandle) const, repeatCount(AnimationHandle) const, played(AnimationHandle) const, paused(AnimationHandle) const and time().

Compared to create(), play() or pause(), a change in stopped time never causes the animation to become AnimationState::Scheduled, AnimationState::Playing or AnimationState::Paused if it wasn't before already, thus calling this function doesn't cause AnimatorState::NeedsAdvance to be set.

void Magnum::Ui::AbstractAnimator::stop(AnimatorDataHandle handle, Nanoseconds time)

Stop an animation assuming it belongs to this animator.

Like stop(AnimationHandle, Nanoseconds) but without checking that handle indeed belongs to this animator. See its documentation for more information.

Containers::StridedArrayView1D<const UnsignedShort> Magnum::Ui::AbstractAnimator::generations() const

Generation counters for all data.

Meant to be used by code that only gets data IDs or masks but needs the full AnimationHandle / AnimatorDataHandle. Size of the returned view is the same as capacity().

void Magnum::Ui::AbstractAnimator::clean(Containers::BitArrayView animationIdsToRemove)

Clean no longer valid animations.

Used internally from subclass implementations such as AbstractGenericAnimator::advance(), which is called from AbstractUserInterface::advanceAnimations(). Exposed just for testing purposes, there should be no need to call this function directly and doing so may cause internal AbstractUserInterface state update to misbehave. Expects that the animationIdsToRemove view has the same size as capacity().

Animations which have a corresponding bit set in animationIdsToRemove are removed. Delegates to doClean(), see its documentation for more information about the arguments.

void Magnum::Ui::AbstractAnimator::cleanNodes(const Containers::StridedArrayView1D<const UnsignedShort>& nodeHandleGenerations)

Clean animations attached to no longer valid nodes.

Used internally from AbstractUserInterface::clean(). Exposed just for testing purposes, there should be no need to call this function directly and doing so may cause internal AbstractUserInterface state update to misbehave. Expects that the animator supports AnimatorFeature::NodeAttachment, assumes that nodeHandleGenerations contains handle generation counters for all nodes, where the index is implicitly the handle ID. They're used to decide about node attachment validity, animations with invalid node attachments are then removed. Delegates to doClean(), see its documentation for more information about the arguments.

void Magnum::Ui::AbstractAnimator::cleanData(const Containers::StridedArrayView1D<const UnsignedShort>& dataHandleGenerations)

Clean animations attached to no longer valid data.

Used internally from AbstractUserInterface::clean(). Exposed just for testing purposes, there should be no need to call this function directly and doing so may cause internal AbstractUserInterface state update to misbehave. Expects that the animator supports AnimatorFeature::DataAttachment, assumes that dataHandleGenerations contains handle generation counters for all data in layer matching layer(), where the index is implicitly the handle ID. They're used to decide about data attachment validity, animations with invalid data attachments are then removed. Delegates to clean() and subsequently doClean(), see their documentation for more information.

Containers::Pair<bool, bool> Magnum::Ui::AbstractAnimator::update(Nanoseconds time, Containers::MutableBitArrayView active, const Containers::StridedArrayView1D<Float>& factors, Containers::MutableBitArrayView remove)

Update the internal state and calculate factors for animation advance.

Parameters
time in Time to which to calculate the factors
active out Where to put a mask of active animations
factors out Where to put animation interpolation factors
remove out Where to put a mask of animations to remove
Returns Whether any bits are set in active and in remove

Used by AbstractUserInterface::advanceAnimations() and by AbstractLayer::advanceAnimations() implementations to generate data to subsequently pass to animator implementations. Expects that time is greater or equal to time() and size of active, factors and remove is the same as capacity().

The active view gets filled with a mask of animations that are AnimationState::Playing at time or which changed to AnimationState::Paused or AnimationState::Stopped at time compared to time(), factors get filled with interpolation factors for active animations and remove gets filled with a mask of animations that are AnimationState::Stopped at time and don't have AnimationFlag::KeepOncePlayed. See documentation of AnimationState values for how the state transition behaves.

If the first return value is true, the active, factors and remove views are meant to be passed to subclass implementations such as AbstractGenericAnimator::advance() or AbstractNodeAnimator::advance(), if the second return value is true, the remove view is then meant to be passed to clean().

Calling this function updates time() and sets AnimatorState::NeedsAdvance if and only if there are AnimationState::Scheduled, AnimationState::Playing or AnimationState::Paused animations at time. However note that behavior of this function is independent of state() — it performs the update and fills the output views regardless of what flags are set.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) protected

Create an animation.

Parameters
played Time at which the animation is played. Use Nanoseconds::max() for creating a stopped animation.
duration Duration of a single play of the animation
repeatCount Repeat count. Use 0 for an indefinitely repeating animation.
flags Flags
Returns New animation handle

Allocates a new handle in a free slot in the internal storage or grows the storage if there's no free slots left. Expects that there's at most 1048576 animations. The returned handle can be removed again with remove().

The duration is expected to be a positive value. The value of played, duration and repeatCount together with time() is then used to decide on a particular AnimationState for given animation; if it results in AnimationState::Scheduled or AnimationState::Playing, the AnimatorState::NeedsAdvance flag is set. The subclass is meant to wrap this function in a public API and perform appropriate initialization work there.

If the animator advertises AnimatorFeature::NodeAttachment, the node attachment is set to NodeHandle::Null; if the animator advertises AnimatorFeature::DataAttachment, the data attachment is set to DataHandle::Null. Use create(Nanoseconds, Nanoseconds, NodeHandle, UnsignedInt, AnimationFlags) / create(Nanoseconds, Nanoseconds, DataHandle, UnsignedInt, AnimationFlags) to directly attach to a node / data, or call attach(AnimationHandle, NodeHandle) / attach(AnimationHandle, DataHandle) to attach the animation afterwards.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, AnimationFlags flags) protected

Create an animation.

Same as calling create(Nanoseconds, Nanoseconds, UnsignedInt, AnimationFlags) with repeatCount set to 1.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, NodeHandle node, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) protected

Create an animation attached to a node.

Parameters
played Time at which the animation is played. Use Nanoseconds::max() for creating a stopped animation.
duration Duration of a single play of the animation
node Node the animation is attached to. Use NodeHandle::Null to create an animation that isn't attached to any node.
repeatCount Repeat count. Use 0 for an indefinitely repeating animation.
flags Flags
Returns New animation handle

Expects that the animator supports AnimatorFeature::NodeAttachment. Apart from that behaves the same as create(Nanoseconds, Nanoseconds, UnsignedInt, AnimationFlags), see its documentation for more information. If node is not NodeHandle::Null, directly attaches the created animation to given animation, equivalent to calling attach(AnimationHandle, NodeHandle).

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, NodeHandle node, AnimationFlags flags) protected

Create an animation attached to a node.

Same as calling create(Nanoseconds, Nanoseconds, NodeHandle, UnsignedInt, AnimationFlags) with repeatCount set to 1.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, DataHandle data, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) protected

Create an animation attached to a data.

Parameters
played Time at which the animation is played. Use Nanoseconds::max() for creating a stopped animation.
duration Duration of a single play of the animation
data Data the animation is attached to. Use DataHandle::Null to create an animation that isn't attached to any data.
repeatCount Repeat count. Use 0 for an indefinitely repeating animation.
flags Flags
Returns New animation handle

Expects that the animator supports AnimatorFeature::DataAttachment, that layer() isn't LayerHandle::Null and that data is either DataHandle::Null or the layer part of it matches layer(). Apart from that behaves the same as create(Nanoseconds, Nanoseconds, UnsignedInt, AnimationFlags), see its documentation for more information. If data is not DataHandle::Null, directly attaches the created animation to given data, equivalent to calling attach(AnimationHandle, DataHandle).

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, DataHandle data, AnimationFlags flags) protected

Create an animation attached to a data.

Same as calling create(Nanoseconds, Nanoseconds, DataHandle, UnsignedInt, AnimationFlags) with repeatCount set to 1.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, LayerDataHandle data, UnsignedInt repeatCount = 1, AnimationFlags flags = {}) protected

Create an animation attached to a data assuming the data belongs to the layer the animator is registered with.

Compared to create(Nanoseconds, Nanoseconds, DataHandle, UnsignedInt, AnimationFlags) also requires that layer() isn't LayerHandle::Null but then assumes the data is coming from a layer with a handle equal to layer(). Calling this function with LayerDataHandle::Null is equivalent to calling create(Nanoseconds, Nanoseconds, DataHandle, UnsignedInt, AnimationFlags) with DataHandle::Null.

AnimationHandle Magnum::Ui::AbstractAnimator::create(Nanoseconds played, Nanoseconds duration, LayerDataHandle data, AnimationFlags flags) protected

Create an animation attached to a data assuming the data belongs to the layer the animator is registered with.

Same as calling create(Nanoseconds, Nanoseconds, LayerDataHandle, UnsignedInt, AnimationFlags) with repeatCount set to 1.

void Magnum::Ui::AbstractAnimator::remove(AnimationHandle handle) protected

Remove an animation.

Expects that handle is valid. After this call, isHandleValid(AnimationHandle) const returns false for handle. See also remove(AnimatorDataHandle) which is a simpler operation if the data is already known to belong to this animator.

Compared to create(), play() or pause(), removing an animation never causes any animation to become AnimationState::Scheduled, AnimationState::Playing or AnimationState::Paused if it wasn't before already, thus calling this function doesn't cause AnimatorState::NeedsAdvance to be set. Which means nothing triggers a subsequent clean() — instead the subclass is meant to wrap this function in a public API and perform appropriate cleanup work on its own data there.

void Magnum::Ui::AbstractAnimator::remove(AnimatorDataHandle handle) protected

Remove an animation assuming it belongs to this animator.

Like remove(AnimationHandle) but without checking that handle indeed belongs to this animator. See its documentation for more information.

void Magnum::Ui::AbstractAnimator::doClean(Containers::BitArrayView animationIdsToRemove) virtual private

Clean no longer valid animations.

Parameters
animationIdsToRemove Animation IDs to remove

Implementation for clean(), which is called from subclass implementations such as AbstractGenericAnimator::advance(), which is then called from AbstractUserInterface::advanceAnimations() whenever there are any stopped animations that are meant to be removed, i.e. without the AnimationFlag::KeepOncePlayed. If the animator supports AnimatorFeature::NodeAttachment / DataAttachment, attachments of to-be-removed animations accessible via nodes() / layerData(), are still preserved when this function is called, and set to null only afterwards.

This function is also called from cleanNodes() / cleanData(), which is called from AbstractUserInterface::clean() (and transitively from AbstractUserInterface::update()) whenever UserInterfaceState::NeedsNodeClean / NeedsDataClean or any of the states that imply it are present in AbstractUserInterface::state(). In that case however, node / data attachments of to-be-removed animations are already set to null when this function is called, as it's assumed cleanNodes() / cleanData() is called when the handles are already invalid.

The animationIdsToRemove view has the same size as capacity() and is guaranteed to have bits set only for valid animation IDs, i.e. animation IDs that are already removed are not set.

This function may get also called with animationIdsToRemove having all bits zero.

Default implementation does nothing.