basic undo support added

This commit is contained in:
itsmattkc
2018-06-07 20:40:56 -07:00
parent 6130d0d91e
commit 544c77828a
8 changed files with 80 additions and 4 deletions
+27
View File
@@ -5,6 +5,7 @@
#include <QDebug>
Sequence::Sequence() {
undo_pointer = -1;
}
Sequence::~Sequence() {
@@ -120,3 +121,29 @@ void Sequence::split_at_playhead(long frame) {
}
}
}
void Sequence::undo_add_current() {
undo_pointer++;
undo_stack.resize(undo_pointer);
undo_stack.append(clips);
qDebug() << "a pointer:" << undo_pointer << undo_stack.size();
}
void Sequence::undo() {
if (undo_pointer > 0) {
undo_pointer--;
clips = undo_stack[undo_pointer];
} else {
qDebug() << "[INFO] No more undos";
}
qDebug() << "u pointer:" << undo_pointer << undo_stack.size();
}
void Sequence::redo() {
if (undo_pointer == undo_stack.size() - 1) {
qDebug() << "[INFO] No more redos";
} else {
undo_pointer++;
clips = undo_stack[undo_pointer];
}
qDebug() << "r pointer:" << undo_pointer << undo_stack.size();
}
+10
View File
@@ -1,6 +1,8 @@
#ifndef SEQUENCE_H
#define SEQUENCE_H
#define UNDO_LIMIT 100
#include <QVector>
#include "project/clip.h"
@@ -25,8 +27,16 @@ public:
float frame_rate;
int audio_frequency;
int audio_layout;
void undo_add_current();
void undo();
void redo();
private:
QList<Clip> clips;
QVector<QList<Clip>> undo_stack;
int undo_pointer;
int undo_stack_start;
};
#endif // SEQUENCE_H