fixed deleting transitions
This commit is contained in:
+6
-6
@@ -657,7 +657,7 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) {
|
||||
post->sequence->hard_delete_transition(post, TA_OPENING_TRANSITION);
|
||||
}
|
||||
if (pre->get_closing_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(pre, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition));
|
||||
if (pre->get_closing_transition()->secondary_clip == NULL) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength()));
|
||||
}
|
||||
|
||||
@@ -782,10 +782,10 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
if (c != NULL && c->track == s.track && !c->undeletable) {
|
||||
if (selection_contains_transition(s, c, TA_OPENING_TRANSITION)) {
|
||||
// delete opening transition
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
} else if (selection_contains_transition(s, c, TA_CLOSING_TRANSITION)) {
|
||||
// delete closing transition
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
} else if (c->timeline_in >= s.in && c->timeline_out <= s.out) {
|
||||
// clips falls entirely within deletion area
|
||||
ca->append(new DeleteClipAction(sequence, j));
|
||||
@@ -803,7 +803,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
if (s.in < c->timeline_out - c->get_closing_transition()->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, c->get_closing_transition()->get_true_length() - (c->timeline_out - s.in)));
|
||||
}
|
||||
@@ -814,7 +814,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
if (s.out > c->timeline_in + c->get_opening_transition()->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, c->get_opening_transition()->get_true_length() - (s.out - c->timeline_in)));
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ bool Timeline::split_selection(ComboAction* ca) {
|
||||
}
|
||||
|
||||
if (clip->get_closing_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(clip, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(clip->sequence, clip->closing_transition));
|
||||
|
||||
split_A->sequence->hard_delete_transition(split_A, TA_CLOSING_TRANSITION);
|
||||
}
|
||||
|
||||
+27
-12
@@ -296,10 +296,12 @@ void ModifyTransitionCommand::redo() {
|
||||
mainWindow->setWindowModified(true);
|
||||
}
|
||||
|
||||
DeleteTransitionCommand::DeleteTransitionCommand(Clip* c, int itype) :
|
||||
clip(c),
|
||||
type(itype),
|
||||
DeleteTransitionCommand::DeleteTransitionCommand(Sequence* s, int transition_index) :
|
||||
seq(s),
|
||||
index(transition_index),
|
||||
transition(NULL),
|
||||
otc(NULL),
|
||||
ctc(NULL),
|
||||
old_project_changed(mainWindow->isWindowModified())
|
||||
{}
|
||||
|
||||
@@ -308,20 +310,33 @@ DeleteTransitionCommand::~DeleteTransitionCommand() {
|
||||
}
|
||||
|
||||
void DeleteTransitionCommand::undo() {
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
clip->opening_transition = old_index;
|
||||
} else {
|
||||
clip->closing_transition = old_index;
|
||||
}
|
||||
clip->sequence->transitions[old_index] = transition;
|
||||
seq->transitions[index] = transition;
|
||||
|
||||
if (otc != NULL) otc->opening_transition = index;
|
||||
if (ctc != NULL) ctc->closing_transition = index;
|
||||
|
||||
transition = NULL;
|
||||
mainWindow->setWindowModified(old_project_changed);
|
||||
}
|
||||
|
||||
void DeleteTransitionCommand::redo() {
|
||||
old_index = (type == TA_OPENING_TRANSITION) ? clip->opening_transition : clip->closing_transition;
|
||||
transition = clip->sequence->transitions.at(old_index);
|
||||
clip->sequence->transitions[old_index] = NULL;
|
||||
for (int i=0;i<seq->clips.size();i++) {
|
||||
Clip* c = seq->clips.at(i);
|
||||
if (c != NULL) {
|
||||
if (c->opening_transition == index) {
|
||||
otc = c;
|
||||
c->opening_transition = -1;
|
||||
}
|
||||
if (c->closing_transition == index) {
|
||||
ctc = c;
|
||||
c->closing_transition = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
transition = seq->transitions.at(index);
|
||||
seq->transitions[index] = NULL;
|
||||
|
||||
mainWindow->setWindowModified(true);
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -132,15 +132,16 @@ private:
|
||||
|
||||
class DeleteTransitionCommand : public QUndoCommand {
|
||||
public:
|
||||
DeleteTransitionCommand(Clip* c, int itype);
|
||||
DeleteTransitionCommand(Sequence* s, int transition_index);
|
||||
~DeleteTransitionCommand();
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
Clip* clip;
|
||||
int type;
|
||||
Sequence* seq;
|
||||
int index;
|
||||
Transition* transition;
|
||||
int old_index;
|
||||
Clip* otc;
|
||||
Clip* ctc;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
|
||||
@@ -702,22 +702,22 @@ void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transitio
|
||||
// make room for transition
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
if (delete_old_transitions && c->get_opening_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
}
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
if (transition_end >= c->timeline_out) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
} else if (transition_end > c->timeline_out - c->get_closing_transition()->get_true_length()) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, c->timeline_out - transition_end));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (delete_old_transitions && c->get_closing_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
}
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
if (transition_start <= c->timeline_in) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
} else if (transition_start < c->timeline_in + c->get_opening_transition()->get_true_length()) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, transition_start - c->timeline_in));
|
||||
}
|
||||
@@ -944,7 +944,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
max_open_length -= c->get_closing_transition()->get_true_length();
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
} else if (c->get_opening_transition()->get_true_length() > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, max_open_length));
|
||||
}
|
||||
@@ -955,7 +955,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
max_open_length -= c->get_opening_transition()->get_true_length();
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
} else if (c->get_closing_transition()->get_true_length() > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, max_open_length));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user