made speed changes undoable

This commit is contained in:
itsmattkc
2018-10-06 17:16:30 +10:00
parent b749d3409b
commit d0dc2661d9
7 changed files with 308 additions and 55 deletions
+11 -4
View File
@@ -34,7 +34,8 @@ Clip::Clip(Sequence* s) :
texture(NULL),
fbo(NULL),
autoscale(config.autoscale_by_default),
maintain_audio_pitch(false)
maintain_audio_pitch(false),
reverse(false)
{
reset();
}
@@ -57,6 +58,8 @@ Clip* Clip::copy(Sequence* s) {
copy->media_stream = media_stream;
copy->autoscale = autoscale;
copy->speed = speed;
copy->maintain_audio_pitch = maintain_audio_pitch;
copy->reverse = reverse;
for (int i=0;i<effects.size();i++) {
copy->effects.append(effects.at(i)->copy(copy));
@@ -183,7 +186,8 @@ void Clip::recalculateMaxLength() {
case MEDIA_TYPE_FOOTAGE:
{
Media* m = static_cast<Media*>(media);
if (m->get_stream_from_file_index(track < 0, media_stream)->infinite_length) {
MediaStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL && ms->infinite_length) {
calculated_length = LONG_MAX;
} else {
calculated_length = m->get_length_in_frames(fr);
@@ -195,9 +199,12 @@ void Clip::recalculateMaxLength() {
Sequence* s = static_cast<Sequence*>(media);
calculated_length = refactor_frame_number(s->getEndFrame(), s->frame_rate, fr);
}
case MEDIA_TYPE_SOLID:
case MEDIA_TYPE_TONE:
break;
/*case MEDIA_TYPE_SOLID:
case MEDIA_TYPE_TONE:*/
default:
calculated_length = LONG_MAX;
break;
}
}
+2 -2
View File
@@ -72,6 +72,7 @@ struct Clip
int getWidth();
int getHeight();
double speed;
bool reverse;
long calculated_length;
// other variables (should be "duplicated" in copy())
@@ -102,8 +103,7 @@ struct Clip
ClipCache cache_A;
ClipCache cache_B;
QMutex lock;
QMutex open_lock;
int last_cached_frame;
QMutex open_lock;
// converters/filters
AVFilterGraph* filter_graph;
+30
View File
@@ -1458,3 +1458,33 @@ void DeleteMarkerAction::redo() {
}
sorted = true;
}
SetSpeedAction::SetSpeedAction(Clip* c, double speed) :
clip(c),
old_speed(c->speed),
new_speed(speed)
{}
void SetSpeedAction::undo() {
clip->speed = old_speed;
clip->recalculateMaxLength();
}
void SetSpeedAction::redo() {
clip->speed = new_speed;
clip->recalculateMaxLength();
}
SetBool::SetBool(bool* b, bool setting) :
boolean(b),
old_setting(*b),
new_setting(setting)
{}
void SetBool::undo() {
*boolean = old_setting;
}
void SetBool::redo() {
*boolean = new_setting;
}
+22
View File
@@ -502,4 +502,26 @@ private:
bool sorted;
};
class SetSpeedAction : public QUndoCommand {
public:
SetSpeedAction(Clip* c, double speed);
void undo();
void redo();
private:
Clip* clip;
double old_speed;
double new_speed;
};
class SetBool : public QUndoCommand {
public:
SetBool(bool* b, bool setting);
void undo();
void redo();
private:
bool* boolean;
bool old_setting;
bool new_setting;
};
#endif // UNDO_H