blob: 35a9859cdf0131f404f33d4b43ecb832b236a5a3 [file]
#ifndef _RIVE_KEYED_PROPERTY_HPP_
#define _RIVE_KEYED_PROPERTY_HPP_
#include "rive/generated/animation/keyed_property_base.hpp"
#include <vector>
namespace rive
{
class KeyFrame;
class KeyedCallbackReporter;
class LinearAnimationInstance;
class KeyedProperty : public KeyedPropertyBase
{
public:
KeyedProperty();
~KeyedProperty() override;
void addKeyFrame(std::unique_ptr<KeyFrame>);
StatusCode onAddedClean(CoreContext* context) override;
StatusCode onAddedDirty(CoreContext* context) override;
/// Report any keyframes that occured between secondsFrom and secondsTo.
void reportKeyedCallbacks(KeyedCallbackReporter* reporter,
uint32_t objectId,
float secondsFrom,
float secondsTo,
bool isAtStartFrame) const;
/// Apply interpolating key frames. `context` is the running
/// LinearAnimationInstance, propagated so scripted interpolators can vend
/// per-(LAI, keyframe) stateful clones. Default-null keeps direct callers
/// (tests, hold animations) source-compatible.
void apply(Core* object,
float time,
float mix,
const LinearAnimationInstance* context = nullptr);
StatusCode import(ImportStack& importStack) override;
KeyFrame* first() const
{
if (m_keyFrames.size() > 0)
{
return m_keyFrames.front().get();
}
return nullptr;
}
private:
int closestFrameIndex(float seconds, int exactOffset = 0) const;
std::vector<std::unique_ptr<KeyFrame>> m_keyFrames;
};
} // namespace rive
#endif