a m a z i n g new effects API

This commit is contained in:
itsmattkc
2018-08-20 00:04:35 +10:00
parent 14648d2e51
commit 5fc4a42db2
15 changed files with 30 additions and 59 deletions
-8
View File
@@ -20,14 +20,6 @@ PanEffect::PanEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_PAN_EFFECT) {
connect(pan_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
void PanEffect::refresh() {}
Effect* PanEffect::copy(Clip* c) {
PanEffect* p = new PanEffect(c);
copy_field_keyframes(p);
return p;
}
void PanEffect::process_audio(quint8 *samples, int nb_bytes) {
double pval = pan_val->get_double_value(-1);
if (pval != 0) {
+2 -4
View File
@@ -5,10 +5,8 @@
class PanEffect : public Effect {
public:
PanEffect(Clip* c);
void refresh();
void process_audio(quint8* samples, int nb_bytes);
Effect* copy(Clip* c);
PanEffect(Clip* c);
void process_audio(quint8* samples, int nb_bytes);
EffectField* pan_val;
};
-8
View File
@@ -21,14 +21,6 @@ VolumeEffect::VolumeEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_VOLUME_
connect(volume_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
void VolumeEffect::refresh() {}
Effect* VolumeEffect::copy(Clip* c) {
VolumeEffect* v = new VolumeEffect(c);
copy_field_keyframes(v);
return v;
}
void VolumeEffect::process_audio(quint8* samples, int nb_bytes) {
double vol_val = volume_val->get_double_value(-1);
if (vol_val != 100) {
+2 -4
View File
@@ -5,10 +5,8 @@
class VolumeEffect : public Effect {
public:
VolumeEffect(Clip* c);
void refresh();
void process_audio(quint8* samples, int nb_bytes);
Effect* copy(Clip* c);
VolumeEffect(Clip* c);
void process_audio(quint8* samples, int nb_bytes);
EffectField* volume_val;
};
+19 -1
View File
@@ -101,10 +101,12 @@ Effect::~Effect() {
void Effect::copy_field_keyframes(Effect* e) {
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
e->rows.at(i)->keyframing = rows.at(i)->keyframing;
e->rows.at(i)->keyframe_times = rows.at(i)->keyframe_times;
e->rows.at(i)->keyframe_types = rows.at(i)->keyframe_types;
for (int j=0;j<row->fieldCount();j++) {
EffectField* field = row->field(j);
e->rows.at(i)->field(j)->set_current_data(field->get_current_data());
e->rows.at(i)->field(j)->keyframe_data = field->keyframe_data;
}
}
@@ -229,7 +231,12 @@ void Effect::save(QXmlStreamWriter* stream) {
}
}
Effect* Effect::copy(Clip*) {return NULL;}
Effect* Effect::copy(Clip* c) {
Effect* copy = create_effect(id, c);
copy_field_keyframes(copy);
return copy;
}
void Effect::process_image(long, QImage&) {}
void Effect::process_gl(long, QOpenGLShaderProgram&, int*, int*) {}
void Effect::process_audio(uint8_t*, int) {}
@@ -364,6 +371,17 @@ QVariant EffectField::get_current_data() {
return QVariant();
}
void EffectField::set_current_data(const QVariant& data) {
switch (type) {
case EFFECT_FIELD_DOUBLE: return static_cast<LabelSlider*>(ui_element)->set_value(data.toDouble(), false); break;
case EFFECT_FIELD_COLOR: return static_cast<ColorButton*>(ui_element)->set_color(data.value<QColor>()); break;
case EFFECT_FIELD_STRING: return static_cast<QTextEdit*>(ui_element)->setPlainText(data.toString()); break;
case EFFECT_FIELD_BOOL: return static_cast<QCheckBox*>(ui_element)->setChecked(data.toBool()); break;
case EFFECT_FIELD_COMBO: return static_cast<ComboBoxEx*>(ui_element)->setCurrentIndexEx(data.toInt()); break;
case EFFECT_FIELD_FONT: return static_cast<FontCombobox*>(ui_element)->setCurrentTextEx(data.toString()); break;
}
}
void EffectField::set_keyframe_data(int i) {
if (i == -1) {
keyframe_data.append(get_current_data());
+2 -1
View File
@@ -61,6 +61,7 @@ public:
int type;
QVariant get_current_data();
void set_current_data(const QVariant&);
void set_keyframe_data(int i);
void get_keyframe_data(long frame, int* before, int *after, double* d);
void validate_keyframe_data(long frame);
@@ -151,7 +152,7 @@ public:
virtual void refresh();
virtual Effect* copy(Clip* c);
Effect* copy(Clip* c);
void copy_field_keyframes(Effect *e);
void load(QXmlStreamReader* stream);
-6
View File
@@ -22,12 +22,6 @@ InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_
connect(amount_val, SIGNAL(changed()), this, SLOT(field_changed()));
}
Effect* InvertEffect::copy(Clip* c) {
InvertEffect* i = new InvertEffect(c);
copy_field_keyframes(i);
return i;
}
void InvertEffect::process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y) {
double value = amount_val->get_double_value(p)*0.01;
+1 -2
View File
@@ -9,8 +9,7 @@ class InvertEffect : public Effect {
Q_OBJECT
public:
InvertEffect(Clip* c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int *anchor_x, int *anchor_y);
Effect* copy(Clip *c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int *anchor_x, int *anchor_y);
EffectField* amount_val;
private:
-6
View File
@@ -49,12 +49,6 @@ void ShakeEffect::refresh() {
}
}
Effect* ShakeEffect::copy(Clip* c) {
ShakeEffect* e = new ShakeEffect(c);
copy_field_keyframes(e);
return e;
}
void ShakeEffect::process_gl(long p, QOpenGLShaderProgram&, int*, int*) {
if (shake_progress > shake_limit) {
double ival = intensity_val->get_double_value(p);
+1 -2
View File
@@ -7,8 +7,7 @@ class ShakeEffect : public Effect {
Q_OBJECT
public:
ShakeEffect(Clip* c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
Effect* copy(Clip *c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
EffectField* intensity_val;
EffectField* rotation_val;
-6
View File
@@ -357,9 +357,3 @@ void TextEffect::process_image(long frame, QImage& img) {
p.setBrush(set_color_button->get_color_value(frame));
p.drawPath(path);
}
Effect* TextEffect::copy(Clip* c) {
TextEffect* e = new TextEffect(c);
copy_field_keyframes(e);
return e;
}
+1 -2
View File
@@ -9,8 +9,7 @@ class TextEffect : public Effect {
Q_OBJECT
public:
TextEffect(Clip* c);
void process_image(long frame, QImage& img);
Effect* copy(Clip* c);
void process_image(long frame, QImage& img);
EffectField* text_val;
EffectField* size_val;
-6
View File
@@ -78,12 +78,6 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_T
connect(uniform_scale_field, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
}
Effect* TransformEffect::copy(Clip* c) {
TransformEffect* t = new TransformEffect(c);
copy_field_keyframes(t);
return t;
}
void TransformEffect::refresh() {
if (parent_clip->sequence != NULL) {
double default_pos_x = parent_clip->sequence->width/2;
+1 -2
View File
@@ -8,8 +8,7 @@ class TransformEffect : public Effect {
public:
TransformEffect(Clip* c);
void refresh();
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
Effect* copy(Clip *c);
void process_gl(long p, QOpenGLShaderProgram& shader_prog, int* anchor_x, int* anchor_y);
EffectField* position_x;
EffectField* position_y;
+1 -1
View File
@@ -283,7 +283,7 @@ bool EffectControls::is_focused() {
EffectsArea::EffectsArea(QWidget* parent) : QWidget(parent) {}
void EffectsArea::resizeEvent(QResizeEvent *event) {
void EffectsArea::resizeEvent(QResizeEvent*) {
parent_widget->setMinimumWidth(sizeHint().width());
keyframe_area->setMinimumHeight(height() - header->height());
}