added length field for transitions

This commit is contained in:
itsmattkc
2018-11-25 09:44:16 +11:00
parent 7d11c9fbab
commit 313b9d1a1b
11 changed files with 114 additions and 76 deletions
+3 -3
View File
@@ -181,7 +181,7 @@ Clip::~Clip() {
long Clip::get_clip_in_with_transition() {
if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) {
// we must be the secondary clip, so return (timeline in - length)
return clip_in - get_opening_transition()->length;
return clip_in - get_opening_transition()->get_true_length();
}
return clip_in;
}
@@ -189,7 +189,7 @@ long Clip::get_clip_in_with_transition() {
long Clip::get_timeline_in_with_transition() {
if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) {
// we must be the secondary clip, so return (timeline in - length)
return timeline_in - get_opening_transition()->length;
return timeline_in - get_opening_transition()->get_true_length();
}
return timeline_in;
}
@@ -197,7 +197,7 @@ long Clip::get_timeline_in_with_transition() {
long Clip::get_timeline_out_with_transition() {
if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip != NULL) {
// we must be the primary clip, so return (timeline out + length2)
return timeline_out + get_closing_transition()->length;
return timeline_out + get_closing_transition()->get_true_length();
} else {
return timeline_out;
}
+24 -24
View File
@@ -220,7 +220,6 @@ void EffectInit::run() {
Effect::Effect(Clip* c, const EffectMeta *em) :
parent_clip(c),
meta(em),
length(30),
enable_shader(false),
enable_coords(false),
enable_superimpose(false),
@@ -446,8 +445,8 @@ void Effect::copy_field_keyframes(Effect* e) {
}
}
EffectRow* Effect::add_row(const QString& name) {
EffectRow* row = new EffectRow(this, ui_layout, name, rows.size());
EffectRow* Effect::add_row(const QString& name, bool savable) {
EffectRow* row = new EffectRow(this, savable, ui_layout, name, rows.size());
rows.append(row);
return row;
}
@@ -668,31 +667,32 @@ void Effect::load(QXmlStreamReader& stream) {
void Effect::save(QXmlStreamWriter& stream) {
stream.writeAttribute("name", meta->name);
stream.writeAttribute("enabled", QString::number(is_enabled()));
stream.writeAttribute("length", QString::number(length));
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
stream.writeStartElement("row"); // row
stream.writeStartElement("keyframes"); // keyframes
stream.writeAttribute("enabled", QString::number(row->isKeyframing()));
for (int j=0;j<row->keyframe_times.size();j++) {
stream.writeStartElement("key"); // key
stream.writeAttribute("frame", QString::number(row->keyframe_times.at(j)));
stream.writeAttribute("type", QString::number(row->keyframe_types.at(j)));
stream.writeEndElement(); // key
if (row->savable) {
stream.writeStartElement("row"); // row
stream.writeStartElement("keyframes"); // keyframes
stream.writeAttribute("enabled", QString::number(row->isKeyframing()));
for (int j=0;j<row->keyframe_times.size();j++) {
stream.writeStartElement("key"); // key
stream.writeAttribute("frame", QString::number(row->keyframe_times.at(j)));
stream.writeAttribute("type", QString::number(row->keyframe_types.at(j)));
stream.writeEndElement(); // key
}
stream.writeEndElement(); // keyframes
for (int j=0;j<row->fieldCount();j++) {
EffectField* field = row->field(j);
stream.writeStartElement("field"); // field
stream.writeAttribute("id", field->id);
stream.writeAttribute("value", save_data_to_string(field->type, field->get_current_data()));
for (int k=0;k<field->keyframe_data.size();k++) {
stream.writeTextElement("key", save_data_to_string(field->type, field->keyframe_data.at(k)));
}
stream.writeEndElement(); // field
}
stream.writeEndElement(); // row
}
stream.writeEndElement(); // keyframes
for (int j=0;j<row->fieldCount();j++) {
EffectField* field = row->field(j);
stream.writeStartElement("field"); // field
stream.writeAttribute("id", field->id);
stream.writeAttribute("value", save_data_to_string(field->type, field->get_current_data()));
for (int k=0;k<field->keyframe_data.size();k++) {
stream.writeTextElement("key", save_data_to_string(field->type, field->keyframe_data.at(k)));
}
stream.writeEndElement(); // field
}
stream.writeEndElement(); // row
}
}
+1 -2
View File
@@ -113,12 +113,11 @@ public:
~Effect();
Clip* parent_clip;
const EffectMeta* meta;
long length; // used only for transitions
int id;
QString name;
CollapsibleWidget* container;
EffectRow* add_row(const QString &name);
EffectRow* add_row(const QString &name, bool savable = true);
EffectRow* row(int i);
int row_count();
+2 -1
View File
@@ -14,8 +14,9 @@
#include "effect.h"
#include "ui/viewerwidget.h"
EffectRow::EffectRow(Effect *parent, QGridLayout *uilayout, const QString &n, int row) :
EffectRow::EffectRow(Effect *parent, bool save, QGridLayout *uilayout, const QString &n, int row) :
parent_effect(parent),
savable(save),
keyframing(false),
ui(uilayout),
name(n),
+2 -1
View File
@@ -14,7 +14,7 @@ class QPushButton;
class EffectRow : public QObject {
Q_OBJECT
public:
EffectRow(Effect* parent, QGridLayout* uilayout, const QString& n, int row);
EffectRow(Effect* parent, bool save, QGridLayout* uilayout, const QString& n, int row);
~EffectRow();
EffectField* add_field(int type, const QString &id, int colspan = 1);
EffectField* field(int i);
@@ -24,6 +24,7 @@ public:
void delete_keyframe_at_time(KeyframeDelete* kd, long time);
QLabel* label;
Effect* parent_effect;
bool savable;
bool isKeyframing();
void setKeyframing(bool);
+31 -2
View File
@@ -11,10 +11,25 @@
#include "effects/internal/logarithmicfadetransition.h"
#include "effects/internal/cubetransition.h"
#include "ui/labelslider.h"
#include "panels/panels.h"
#include "panels/timeline.h"
#include <QMessageBox>
Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) : Effect(c, em), secondary_clip(s) {
// add_row("Length:", false)->add_field(EFFECT_FIELD_DOUBLE, "length");
Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) :
Effect(c, em), secondary_clip(s),
length(30)
{
length_field = add_row("Length:", false)->add_field(EFFECT_FIELD_DOUBLE, "length");
connect(length_field, SIGNAL(changed()), this, SLOT(set_length_from_slider()));
length_field->set_double_default_value(30);
length_field->set_double_minimum_value(0);
LabelSlider* length_ui_ele = static_cast<LabelSlider*>(length_field->ui_element);
length_ui_ele->set_display_type(LABELSLIDER_FRAMENUMBER);
length_ui_ele->set_frame_rate(parent_clip->sequence->frame_rate);
}
int Transition::copy(Clip *c, Clip* s) {
@@ -23,6 +38,15 @@ int Transition::copy(Clip *c, Clip* s) {
return copy_index;
}
void Transition::set_length(long l) {
length = l;
length_field->set_double_value(l);
}
long Transition::get_true_length() {
return length;
}
long Transition::get_length() {
if (secondary_clip != NULL) {
return length * 2;
@@ -30,6 +54,11 @@ long Transition::get_length() {
return length;
}
void Transition::set_length_from_slider() {
set_length(length_field->get_double_value(0));
update_ui(false);
}
Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) {
if (!em->filename.isEmpty()) {
// load effect from file
+8
View File
@@ -17,11 +17,19 @@
int create_transition(Clip* c, Clip* s, const EffectMeta* em);
class Transition : public Effect {
Q_OBJECT
public:
Transition(Clip* c, Clip* s, const EffectMeta* em);
int copy(Clip* c, Clip* s);
Clip* secondary_clip;
void set_length(long l);
long get_true_length();
long get_length();
private slots:
void set_length_from_slider();
private:
long length; // used only for transitions
EffectField* length_field;
};
#endif // TRANSITION_H
+5 -5
View File
@@ -258,7 +258,7 @@ void AddTransitionCommand::redo() {
secondary->closing_transition = clip->opening_transition;
}
if (length > 0) {
clip->get_opening_transition()->length = length;
clip->get_opening_transition()->set_length(length);
}
} else {
old_ptransition = clip->closing_transition;
@@ -268,7 +268,7 @@ void AddTransitionCommand::redo() {
secondary->opening_transition = clip->closing_transition;
}
if (length > 0) {
clip->get_closing_transition()->length = length;
clip->get_closing_transition()->set_length(length);
}
}
mainWindow->setWindowModified(true);
@@ -283,14 +283,14 @@ ModifyTransitionCommand::ModifyTransitionCommand(Clip* c, int itype, long ilengt
void ModifyTransitionCommand::undo() {
Transition* t = (type == TA_OPENING_TRANSITION) ? clip->get_opening_transition() : clip->get_closing_transition();
t->length = old_length;
t->set_length(old_length);
mainWindow->setWindowModified(old_project_changed);
}
void ModifyTransitionCommand::redo() {
Transition* t = (type == TA_OPENING_TRANSITION) ? clip->get_opening_transition() : clip->get_closing_transition();
old_length = t->length;
t->length = new_length;
old_length = t->get_true_length();
t->set_length(new_length);
mainWindow->setWindowModified(true);
}