decoupled ui from effect row
This commit is contained in:
@@ -11,8 +11,8 @@ public:
|
||||
|
||||
bool GetBoolAt(double timecode);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
};
|
||||
|
||||
#endif // BOOLFIELD_H
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "buttonfield.h"
|
||||
|
||||
ButtonField::ButtonField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI)
|
||||
{
|
||||
SetValueAt(0, string);
|
||||
}
|
||||
|
||||
void ButtonField::SetCheckable(bool c)
|
||||
{
|
||||
checkable_ = c;
|
||||
}
|
||||
|
||||
void ButtonField::SetChecked(bool c)
|
||||
{
|
||||
checked_ = c;
|
||||
emit CheckedChanged(c);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef BUTTONFIELD_H
|
||||
#define BUTTONFIELD_H
|
||||
|
||||
#include "effectfield.h"
|
||||
|
||||
class ButtonField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ButtonField(EffectRow* parent, const QString& string);
|
||||
|
||||
void SetCheckable(bool c);
|
||||
void SetChecked(bool c);
|
||||
signals:
|
||||
void CheckedChanged(bool);
|
||||
private:
|
||||
bool checkable_;
|
||||
bool checked_;
|
||||
};
|
||||
|
||||
#endif // BUTTONFIELD_H
|
||||
@@ -11,8 +11,8 @@ public:
|
||||
|
||||
QColor GetColorAt(double timecode);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
};
|
||||
|
||||
#endif // COLORFIELD_H
|
||||
|
||||
@@ -13,13 +13,3 @@ void ComboField::AddItem(const QString &text, const QVariant &data)
|
||||
|
||||
items_.append(item);
|
||||
}
|
||||
|
||||
QVariant ComboField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
QString ComboField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@ public:
|
||||
|
||||
void AddItem(const QString& text, const QVariant& data);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
|
||||
signals:
|
||||
void IndexChanged(int i);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t)
|
||||
{
|
||||
// EffectField MUST be created with a parent.
|
||||
Q_ASSERT(parent != nullptr);
|
||||
Q_ASSERT(!i.isEmpty());
|
||||
Q_ASSERT(!i.isEmpty() || t == EFFECT_FIELD_UI);
|
||||
|
||||
parent->AddField(this);
|
||||
/*
|
||||
@@ -141,6 +141,16 @@ void EffectField::SetColumnSpan(int i)
|
||||
colspan_ = i;
|
||||
}
|
||||
|
||||
QVariant EffectField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
QString EffectField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
QVariant EffectField::GetValueAt(double timecode)
|
||||
{
|
||||
Q_ASSERT(!keyframes.isEmpty());
|
||||
@@ -172,15 +182,15 @@ QVariant EffectField::GetValueAt(double timecode)
|
||||
// bezier interpolation
|
||||
if (before_key.type == EFFECT_KEYFRAME_BEZIER && after_key.type == EFFECT_KEYFRAME_BEZIER) {
|
||||
// cubic bezier
|
||||
double t = cubic_t_from_x(timecode*GetParentRow()->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time);
|
||||
double t = cubic_t_from_x(timecode*GetParentRow()->GetParentEffect()->parent_clip->sequence->frame_rate, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time);
|
||||
value = cubic_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl+after_key.pre_handle_y, after_dbl, t);
|
||||
} else if (after_key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
|
||||
// last keyframe is the bezier one
|
||||
double t = quad_t_from_x(timecode*GetParentRow()->parent_effect->parent_clip->sequence->frame_rate, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time);
|
||||
double t = quad_t_from_x(timecode*GetParentRow()->GetParentEffect()->parent_clip->sequence->frame_rate, before_key.time, before_key.time+GetValidKeyframeHandlePosition(before_keyframe, true), after_key.time);
|
||||
value = quad_from_t(before_dbl, before_dbl+before_key.post_handle_y, after_dbl, t);
|
||||
} else {
|
||||
// this keyframe is the bezier one
|
||||
double t = quad_t_from_x(timecode*GetParentRow()->parent_effect->parent_clip->sequence->frame_rate, before_key.time, after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time);
|
||||
double t = quad_t_from_x(timecode*GetParentRow()->GetParentEffect()->parent_clip->sequence->frame_rate, before_key.time, after_key.time+GetValidKeyframeHandlePosition(after_keyframe, false), after_key.time);
|
||||
value = quad_from_t(before_dbl, after_dbl+after_key.pre_handle_y, after_dbl, t);
|
||||
}
|
||||
} else {
|
||||
@@ -223,7 +233,7 @@ void EffectField::SetValueAt(double timecode, const QVariant &value)
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetParentRow()->isKeyframing()) {
|
||||
if (GetParentRow()->IsKeyframing()) {
|
||||
// create keyframe here
|
||||
} else {
|
||||
keyframes.first().data = value;
|
||||
@@ -289,11 +299,11 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) {
|
||||
}
|
||||
|
||||
double EffectField::frameToTimecode(long frame) {
|
||||
return (double(frame) / GetParentRow()->parent_effect->parent_clip->sequence->frame_rate);
|
||||
return (double(frame) / GetParentRow()->GetParentEffect()->parent_clip->sequence->frame_rate);
|
||||
}
|
||||
|
||||
long EffectField::timecodeToFrame(double timecode) {
|
||||
return qRound(timecode * GetParentRow()->parent_effect->parent_clip->sequence->frame_rate);
|
||||
return qRound(timecode * GetParentRow()->GetParentEffect()->parent_clip->sequence->frame_rate);
|
||||
}
|
||||
|
||||
void EffectField::get_keyframe_data(double timecode, int &before, int &after, double &progress) {
|
||||
@@ -333,7 +343,7 @@ void EffectField::get_keyframe_data(double timecode, int &before, int &after, do
|
||||
}
|
||||
|
||||
bool EffectField::HasKeyframes() {
|
||||
return (GetParentRow()->isKeyframing() && keyframes.size() > 1);
|
||||
return (GetParentRow()->IsKeyframing() && keyframes.size() > 1);
|
||||
}
|
||||
|
||||
void EffectField::ui_element_change() {
|
||||
|
||||
@@ -40,7 +40,8 @@ public:
|
||||
EFFECT_FIELD_BOOL,
|
||||
EFFECT_FIELD_COMBO,
|
||||
EFFECT_FIELD_FONT,
|
||||
EFFECT_FIELD_FILE
|
||||
EFFECT_FIELD_FILE,
|
||||
EFFECT_FIELD_UI
|
||||
};
|
||||
|
||||
EffectField(EffectRow* parent, const QString& i, EffectFieldType t);
|
||||
@@ -57,8 +58,8 @@ public:
|
||||
int GetColumnSpan();
|
||||
void SetColumnSpan(int i);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) = 0;
|
||||
virtual QString ConvertValueToString(const QVariant& v) = 0;
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
|
||||
double GetValidKeyframeHandlePosition(int key, bool post);
|
||||
|
||||
|
||||
@@ -10,13 +10,3 @@ QString FileField::GetFileAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QVariant FileField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
QString FileField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ public:
|
||||
FileField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetFileAt(double timecode);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
};
|
||||
|
||||
#endif // FILEFIELD_H
|
||||
|
||||
@@ -10,13 +10,3 @@ QString FontField::GetFontAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QVariant FontField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
QString FontField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@ public:
|
||||
FontField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetFontAt(double timecode);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
};
|
||||
|
||||
#endif // FONTFIELD_H
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "labelfield.h"
|
||||
|
||||
LabelField::LabelField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI)
|
||||
{
|
||||
SetValueAt(0, string);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef LABELFIELD_H
|
||||
#define LABELFIELD_H
|
||||
|
||||
#include "effectfield.h"
|
||||
|
||||
class LabelField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LabelField(EffectRow* parent, const QString& string);
|
||||
};
|
||||
|
||||
#endif // LABELFIELD_H
|
||||
@@ -10,13 +10,3 @@ QString StringField::GetStringAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QVariant StringField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
QString StringField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.toString();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ public:
|
||||
StringField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetStringAt(double timecode);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
};
|
||||
|
||||
#endif // STRINGFIELD_H
|
||||
|
||||
Reference in New Issue
Block a user