began refactoring keyframe times

This commit is contained in:
itsmattkc
2019-01-02 16:12:10 +11:00
parent 9934ec5777
commit 05524153ab
3 changed files with 37 additions and 52 deletions
+6 -14
View File
@@ -309,25 +309,17 @@ void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_t
track);
}
QVector<EffectRow*> key_rows;
QVector<int> key_indices;
QVector<long> key_old;
QVector<long> key_new;
// move keyframes
for (int i=0;i<effects.size();i++) {
Effect* e = effects.at(i);
for (int j=0;j<e->row_count();j++) {
EffectRow* r = e->row(j);
for (int k=0;k<r->keyframe_times.size();k++) {
key_rows.append(r);
key_indices.at(k);
key_old.append(r->keyframe_times.at(k));
key_new.append(r->keyframe_times.at(k) * multiplier);
for (int l=0;l<r->fieldCount();l++) {
EffectField* f = r->field(l);
for (int k=0;k<f->keyframes.size();k++) {
ca->append(new SetLong(&f->keyframes[k].time, f->keyframes[k].time, f->keyframes[k].time * multiplier));
}
}
}
}
if (key_rows.size() > 0) {
ca->append(new KeyframeMove(key_rows, key_indices, key_old, key_new));
}
}
+17 -22
View File
@@ -737,28 +737,6 @@ void MediaRename::redo() {
mainWindow->setWindowModified(true);
}
KeyframeMove::KeyframeMove(const QVector<EffectRow*>& irows, const QVector<int>& ikeyframes, const QVector<long>& iold_values, const QVector<long>& inew_values) :
rows(irows),
keyframes(ikeyframes),
old_values(iold_values),
new_values(inew_values),
old_project_changed(mainWindow->isWindowModified())
{}
void KeyframeMove::undo() {
for (int i=0;i<rows.size();i++) {
rows.at(i)->keyframe_times[keyframes.at(i)] = old_values.at(i);
}
mainWindow->setWindowModified(old_project_changed);
}
void KeyframeMove::redo() {
for (int i=0;i<rows.size();i++) {
rows.at(i)->keyframe_times[keyframes.at(i)] = new_values.at(i);
}
mainWindow->setWindowModified(true);
}
KeyframeDelete::KeyframeDelete() :
disable_keyframes_on_row(NULL),
old_project_changed(mainWindow->isWindowModified()),
@@ -1332,3 +1310,20 @@ void SetQVariant::undo() {
void SetQVariant::redo() {
*target = new_val;
}
SetLong::SetLong(long *pointer, long old_value, long new_value) :
p(pointer),
oldval(old_value),
newval(new_value),
old_project_changed(mainWindow->isWindowModified())
{}
void SetLong::undo() {
*p = oldval;
mainWindow->setWindowModified(old_project_changed);
}
void SetLong::redo() {
*p = newval;
mainWindow->setWindowModified(true);
}
+14 -16
View File
@@ -17,6 +17,7 @@ struct EffectMeta;
#include "project/marker.h"
#include "project/selection.h"
#include "project/effectfield.h"
#include <QUndoStack>
#include <QUndoCommand>
@@ -328,19 +329,6 @@ private:
QString to;
};
class KeyframeMove : public QUndoCommand {
public:
KeyframeMove(const QVector<EffectRow*>& rows, const QVector<int>& keyframes, const QVector<long>& old_values, const QVector<long>& new_values);
void undo();
void redo();
private:
QVector<EffectRow*> rows;
QVector<int> keyframes;
QVector<long> old_values;
QVector<long> new_values;
bool old_project_changed;
};
class KeyframeDelete : public QUndoCommand {
public:
KeyframeDelete();
@@ -351,9 +339,7 @@ public:
void redo();
private:
bool old_project_changed;
QVector<long> deleted_keyframe_times;
QVector<int> deleted_keyframe_types;
QVector<QVariant> deleted_keyframe_data;
QVector<EffectKeyframe> deleted_keyframe_times;
bool sorted;
};
@@ -524,6 +510,18 @@ private:
bool old_project_changed;
};
class SetLong : public QUndoCommand {
public:
SetLong(long* pointer, long old_value, long new_value);
void undo();
void redo();
private:
long* p;
long oldval;
long newval;
bool old_project_changed;
};
class SetDouble : public QUndoCommand {
public:
SetDouble(double* pointer, double new_value);