From ce99c8fef0437fef6091dcd66182e79cc3d9fa54 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 2 Feb 2019 12:39:54 +1100 Subject: [PATCH] fixed #394 --- panels/timeline.cpp | 98 ++++++++++++++++++++++++------------------ ui/renderfunctions.cpp | 2 - 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/panels/timeline.cpp b/panels/timeline.cpp index d6241668e..1e7b80225 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -1426,14 +1426,14 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo } else if (c->get_closing_transition() != nullptr && snap_to_point(c->timeline_out - c->get_closing_transition()->get_true_length(), l)) { return true; - } else { - // try to snap to clip markers - for (int j=0;jmarkers.size();j++) { - if (snap_to_point(c->markers.at(j).frame + c->timeline_in - c->clip_in, l)) { - return true; - } - } - } + } else { + // try to snap to clip markers + for (int j=0;jmarkers.size();j++) { + if (snap_to_point(c->markers.at(j).frame + c->timeline_in - c->clip_in, l)) { + return true; + } + } + } } } } @@ -1441,46 +1441,60 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo } void Timeline::set_marker() { - bool add_marker = !config.set_name_with_marker; - QString marker_name; + // add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name + // however if (config.set_name_with_marker) is true, we don't need a marker name so we just add + bool add_marker = !config.set_name_with_marker; - std::vector clips_selected; - bool clip_mode = false; + // determine if any clips are selected, and if so add markers to clips rather than the sequence + QVector clips_selected; + bool clip_mode = false; - for (int i=0;iclips.size();i++) { - Clip* c = sequence->clips.at(i); - if (c != nullptr && is_clip_selected(c, true)) { - clips_selected.push_back(c); - clip_mode=true; - } - } + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != nullptr + && is_clip_selected(c, true) + && sequence->playhead >= c->timeline_in + && sequence->playhead <= c->timeline_out) { + clips_selected.append(c); + clip_mode = true; + } + } - ComboAction* ca = new ComboAction(); + QString marker_name; - if (!add_marker) { - QInputDialog d(this); - d.setWindowTitle(tr("Set Marker")); - d.setLabelText(clip_mode? tr("Set clip marker name:"): tr("Set sequence marker name:")); - d.setInputMode(QInputDialog::TextInput); - add_marker = (d.exec() == QDialog::Accepted); - marker_name = d.textValue(); - } + // if (config.set_name_with_marker) is false (set above), ask for a marker name + if (!add_marker) { + QInputDialog d(this); + d.setWindowTitle(tr("Set Marker")); + d.setLabelText(clip_mode? tr("Set clip marker name:"): tr("Set sequence marker name:")); + d.setInputMode(QInputDialog::TextInput); + add_marker = (d.exec() == QDialog::Accepted); + marker_name = d.textValue(); + } - if (add_marker) { - foreach (Clip* c, clips_selected){ - ca->append(new AddMarkerAction(false, - c, - sequence->playhead - c->timeline_in + c->clip_in, - marker_name)); - } - // if no clips are selected, we're adding a marker to the sequence - if (!clip_mode) { - ca->append(new AddMarkerAction(true, sequence, sequence->playhead, marker_name)); - } + // if we've decided to add a marker + if (add_marker) { + ComboAction* ca = new ComboAction(); - undo_stack.push(ca); - repaint_timeline(); - } + // add an action for each clip + foreach (Clip* c, clips_selected) { + ca->append(new AddMarkerAction(false, + c, + sequence->playhead - c->timeline_in + c->clip_in, + marker_name)); + } + + // if no clips are selected, we're adding a marker to the sequence + if (!clip_mode) { + ca->append(new AddMarkerAction(true, sequence, sequence->playhead, marker_name)); + } + + // push action + undo_stack.push(ca); + + // redraw timeline + repaint_timeline(); + } } void Timeline::toggle_links() { diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp index aad5d9bbd..bb8cd863b 100644 --- a/ui/renderfunctions.cpp +++ b/ui/renderfunctions.cpp @@ -513,8 +513,6 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { full_blit(); -// glColor4f(1.0, 1.0, 1.0, 1.0); - params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); } else { // load background texture into texture unit 0