fixed snapping bug causing 0 frame clips to occur

This commit is contained in:
itsmattkc
2018-07-08 14:55:52 +01:00
parent 4b29e19a3e
commit ef31d6a29d
6 changed files with 28 additions and 16 deletions
+1 -1
View File
@@ -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)
+5 -4
View File
@@ -82,12 +82,12 @@ void Project::duplicate_selected() {
for (int i=0;i<items.size();i++) {
Media* m = get_media_from_tree(items.at(i));
if (m->type == 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") {
+1 -1
View File
@@ -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();
+10 -2
View File
@@ -6,8 +6,7 @@
#include <QDebug>
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);
+1
View File
@@ -26,6 +26,7 @@ public:
int audio_frequency;
int audio_layout;
void reset_undo();
void undo_add_current();
void undo();
void redo();
+10 -8
View File
@@ -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;i<panel_timeline->ghosts.size();i++) {
Ghost& g = panel_timeline->ghosts[i];
validate_snapping(g, &frame_diff);
}
// validate ghosts
for (int i=0;i<panel_timeline->ghosts.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;i<panel_timeline->selections.size();i++) {
Selection& s = panel_timeline->selections[i];
if (panel_timeline->trim_in_point) {
s.in = s.old_in + frame_diff;
} else {