diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index a3e19b681..dda3eab99 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -61,7 +61,7 @@ void NewSequenceDialog::on_buttonBox_accepted() s->audio_frequency = ui->audio_frequency_combobox->currentData().toInt(); s->audio_layout = AV_CH_LAYOUT_STEREO; - panel_project->new_sequence(s); + panel_project->new_sequence(s, true); } void NewSequenceDialog::on_comboBox_currentIndexChanged(int index) diff --git a/panels/project.cpp b/panels/project.cpp index 51313d153..709b86d3c 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -82,12 +82,12 @@ void Project::duplicate_selected() { for (int i=0;itype == MEDIA_TYPE_SEQUENCE) { - new_sequence(m->sequence->copy()); + new_sequence(m->sequence->copy(), false); } } } -void Project::new_sequence(Sequence *s) { +void Project::new_sequence(Sequence *s, bool open) { Media* m = new Media(); m->type = MEDIA_TYPE_SEQUENCE; m->sequence = s; @@ -102,7 +102,7 @@ void Project::new_sequence(Sequence *s) { project_changed = true; - set_sequence(s); + if (open) set_sequence(s); } Media* Project::import_file(QString file) { @@ -425,7 +425,8 @@ void Project::load_project() { } } - new_sequence(temp_seq); + temp_seq->reset_undo(); + new_sequence(temp_seq, false); state = LOAD_STATE_IDLE; } else if (stream.isStartElement()) { if (stream.name() == "name") { diff --git a/panels/project.h b/panels/project.h index c529727e2..7f89e7c8b 100644 --- a/panels/project.h +++ b/panels/project.h @@ -29,7 +29,7 @@ public: void clear(); Media* import_file(QString url); void import_dialog(); - void new_sequence(Sequence* s); + void new_sequence(Sequence* s, bool open); QString get_next_sequence_name(); void delete_media(QTreeWidgetItem* item); void delete_selected_media(); diff --git a/project/sequence.cpp b/project/sequence.cpp index 8a26281d5..a84652574 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -6,8 +6,7 @@ #include Sequence::Sequence() { - undo_pointer = -1; - undo_add_current(); + reset_undo(); } Sequence::~Sequence() { @@ -128,6 +127,15 @@ int Sequence::split_clip(int p, long frame) { return -1; } +void Sequence::reset_undo() { + while (undo_stack.size() > 0) { + delete undo_stack.last(); + undo_stack.removeLast(); + } + undo_pointer = -1; + undo_add_current(); +} + void Sequence::undo_add_current() { if (undo_stack.size() == UNDO_LIMIT) { delete undo_stack.at(0); diff --git a/project/sequence.h b/project/sequence.h index 8f39ec1ed..1616bafef 100644 --- a/project/sequence.h +++ b/project/sequence.h @@ -26,6 +26,7 @@ public: int audio_frequency; int audio_layout; + void reset_undo(); void undo_add_current(); void undo(); void redo(); diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 133797ec9..77a046934 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -394,14 +394,13 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } panel_timeline->redraw_all_clips(true); - } else if (panel_timeline->selecting) { - // remove duplicate selections - panel_timeline->clean_up_selections(panel_timeline->selections); - repaint = true; - } else if (panel_timeline->rect_select_proc) { + } else if (panel_timeline->selecting || panel_timeline->rect_select_proc) { repaint = true; } + // remove duplicate selections + panel_timeline->clean_up_selections(panel_timeline->selections); + // destroy all ghosts panel_timeline->ghosts.clear(); @@ -535,13 +534,17 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { if (panel_timeline->trim_target > -1) { // if trimming // trim ops + // first try to snap + for (int i=0;ighosts.size();i++) { + Ghost& g = panel_timeline->ghosts[i]; + validate_snapping(g, &frame_diff); + } + // validate ghosts for (int i=0;ighosts.size();i++) { Ghost& g = panel_timeline->ghosts[i]; Clip* c = sequence->get_clip(g.clip); - validate_snapping(g, &frame_diff); - if (g.trim_in) { // prevent clip length from being less than 1 frame long validator = g.ghost_length - frame_diff; @@ -608,7 +611,6 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { // resize selections for (int i=0;iselections.size();i++) { Selection& s = panel_timeline->selections[i]; - if (panel_timeline->trim_in_point) { s.in = s.old_in + frame_diff; } else {