updated NodeKeyframe class to QObject for easier signal/slot handling
While the keyframes themselves are relatively simple, their usage is quite complex and using QObjects as their base will help a ton of UI and backend functionality.
This commit is contained in:
@@ -25,7 +25,6 @@ NodeKeyframe::NodeKeyframe() :
|
||||
value_(0),
|
||||
type_(kLinear)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NodeKeyframe::NodeKeyframe(const rational &time, const QVariant &value, const NodeKeyframe::Type &type) :
|
||||
@@ -43,6 +42,7 @@ const rational &NodeKeyframe::time() const
|
||||
void NodeKeyframe::set_time(const rational &time)
|
||||
{
|
||||
time_ = time;
|
||||
emit TimeChanged(time_);
|
||||
}
|
||||
|
||||
const QVariant &NodeKeyframe::value() const
|
||||
@@ -53,6 +53,7 @@ const QVariant &NodeKeyframe::value() const
|
||||
void NodeKeyframe::set_value(const QVariant &value)
|
||||
{
|
||||
value_ = value;
|
||||
emit ValueChanged(value_);
|
||||
}
|
||||
|
||||
const NodeKeyframe::Type &NodeKeyframe::type() const
|
||||
@@ -63,4 +64,5 @@ const NodeKeyframe::Type &NodeKeyframe::type() const
|
||||
void NodeKeyframe::set_type(const NodeKeyframe::Type &type)
|
||||
{
|
||||
type_ = type;
|
||||
emit TypeChanged(type_);
|
||||
}
|
||||
|
||||
+22
-1
@@ -21,15 +21,20 @@
|
||||
#ifndef NODEKEYFRAME_H
|
||||
#define NODEKEYFRAME_H
|
||||
|
||||
#include <memory>
|
||||
#include <QVariant>
|
||||
|
||||
#include "common/rational.h"
|
||||
|
||||
class NodeKeyframe;
|
||||
using NodeKeyframePtr = std::shared_ptr<NodeKeyframe>;
|
||||
|
||||
/**
|
||||
* @brief A point of data to be used at a certain time and interpolated with other data
|
||||
*/
|
||||
class NodeKeyframe
|
||||
class NodeKeyframe : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -71,6 +76,22 @@ public:
|
||||
const Type& type() const;
|
||||
void set_type(const Type& type);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's time is changed
|
||||
*/
|
||||
void TimeChanged(const rational& time);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's value is changed
|
||||
*/
|
||||
void ValueChanged(const QVariant& value);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's value is changed
|
||||
*/
|
||||
void TypeChanged(const Type& type);
|
||||
|
||||
private:
|
||||
rational time_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user