separated marker function for reusability
This commit is contained in:
+4
-40
@@ -1443,12 +1443,8 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo
|
||||
}
|
||||
|
||||
void Timeline::set_marker() {
|
||||
// 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;
|
||||
|
||||
// determine if any clips are selected, and if so add markers to clips rather than the sequence
|
||||
QVector<Clip*> clips_selected;
|
||||
QVector<int> clips_selected;
|
||||
bool clip_mode = false;
|
||||
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
@@ -1459,7 +1455,7 @@ void Timeline::set_marker() {
|
||||
// only add markers if the playhead is inside the clip
|
||||
if (sequence->playhead >= c->timeline_in
|
||||
&& sequence->playhead <= c->timeline_out) {
|
||||
clips_selected.append(c);
|
||||
clips_selected.append(i);
|
||||
}
|
||||
|
||||
// we are definitely adding markers to clips though
|
||||
@@ -1474,41 +1470,9 @@ void Timeline::set_marker() {
|
||||
return;
|
||||
}
|
||||
|
||||
QString marker_name;
|
||||
// pass off to internal set marker function
|
||||
set_marker_internal(sequence, clips_selected);
|
||||
|
||||
// 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 we've decided to add a marker
|
||||
if (add_marker) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// 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() {
|
||||
|
||||
+5
-1
@@ -476,7 +476,11 @@ void Viewer::update_parents(bool reload_fx) {
|
||||
}
|
||||
|
||||
int Viewer::get_playback_speed() {
|
||||
return playback_speed;
|
||||
return playback_speed;
|
||||
}
|
||||
|
||||
void Viewer::set_marker() {
|
||||
set_marker_internal(seq);
|
||||
}
|
||||
|
||||
void Viewer::resizeEvent(QResizeEvent *) {
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
Sequence* seq;
|
||||
QVector<Marker>* marker_ref;
|
||||
|
||||
void set_marker();
|
||||
|
||||
TimelineHeader* headers;
|
||||
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
#include "marker.h"
|
||||
|
||||
#include "io/config.h"
|
||||
#include "project/undo.h"
|
||||
#include "mainwindow.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/clip.h"
|
||||
#include "panels/panels.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QCoreApplication>
|
||||
|
||||
void draw_marker(QPainter &p, int x, int y, int bottom, bool selected, bool flipped) {
|
||||
const QPoint points[5] = {
|
||||
QPoint(x, bottom),
|
||||
@@ -16,3 +26,64 @@ void draw_marker(QPainter &p, int x, int y, int bottom, bool selected, bool flip
|
||||
}
|
||||
p.drawPolygon(points, 5);
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
|
||||
// if clips is empty, the marker is being added to the sequence
|
||||
|
||||
// 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;
|
||||
|
||||
QString marker_name;
|
||||
|
||||
// if (config.set_name_with_marker) is false (set above), ask for a marker name
|
||||
if (!add_marker) {
|
||||
QInputDialog d(mainWindow);
|
||||
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
|
||||
d.setLabelText(clips.size() > 0
|
||||
? QCoreApplication::translate("Marker", "Set clip marker name:")
|
||||
: QCoreApplication::translate("Marker", "Set sequence marker name:"));
|
||||
d.setInputMode(QInputDialog::TextInput);
|
||||
add_marker = (d.exec() == QDialog::Accepted);
|
||||
marker_name = d.textValue();
|
||||
}
|
||||
|
||||
// if we've decided to add a marker
|
||||
if (add_marker) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
if (clips.size() > 0) {
|
||||
|
||||
// add a marker action for each clip
|
||||
foreach (int i, clips) {
|
||||
Clip* c = seq->clips.at(i);
|
||||
ca->append(new AddMarkerAction(false,
|
||||
c,
|
||||
seq->playhead - c->timeline_in + c->clip_in,
|
||||
marker_name));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// if no clips are selected, we're adding a marker to the sequence
|
||||
ca->append(new AddMarkerAction(true, seq, seq->playhead, marker_name));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// push action
|
||||
undo_stack.push(ca);
|
||||
|
||||
// redraw UI for new markers
|
||||
update_ui(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence* seq) {
|
||||
// create empty clip array
|
||||
QVector<int> clips;
|
||||
|
||||
set_marker_internal(seq, clips);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
|
||||
struct Sequence;
|
||||
|
||||
struct Marker {
|
||||
long frame;
|
||||
QString name;
|
||||
@@ -13,4 +15,7 @@ struct Marker {
|
||||
|
||||
void draw_marker(QPainter& p, int x, int y, int bottom, bool selected, bool flipped);
|
||||
|
||||
void set_marker_internal(Sequence* seq, const QVector<int>& clips);
|
||||
void set_marker_internal(Sequence* seq);
|
||||
|
||||
#endif // MARKER_H
|
||||
|
||||
Reference in New Issue
Block a user