most clip marker work completed #333

This commit is contained in:
itsmattkc
2019-02-01 02:53:54 +11:00
parent 0513749b9d
commit db92e5231f
11 changed files with 149 additions and 50 deletions
+5
View File
@@ -5,6 +5,8 @@
#include <QMutex>
#include <QVector>
#include "marker.h"
#define SKIP_TYPE_DISCARD 0
#define SKIP_TYPE_SEEK 1
@@ -73,6 +75,9 @@ struct Clip
bool maintain_audio_pitch;
bool autoscale;
// markers
QVector<Marker> markers;
// other variables (should be deep copied/duplicated in copy())
QList<Effect*> effects;
QVector<int> linked;
+17
View File
@@ -1 +1,18 @@
#include "marker.h"
void draw_marker(QPainter &p, int x, int y, int bottom, bool selected, bool flipped) {
const QPoint points[5] = {
QPoint(x, bottom),
QPoint(x + MARKER_SIZE, bottom - MARKER_SIZE),
QPoint(x + MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, bottom - MARKER_SIZE)
};
p.setPen(Qt::black);
if (selected) {
p.setBrush(QColor(208, 255, 208));
} else {
p.setBrush(QColor(128, 224, 128));
}
p.drawPolygon(points, 5);
}
+5
View File
@@ -1,11 +1,16 @@
#ifndef MARKER_H
#define MARKER_H
#define MARKER_SIZE 4
#include <QString>
#include <QPainter>
struct Marker {
long frame;
QString name;
};
void draw_marker(QPainter& p, int x, int y, int bottom, bool selected, bool flipped);
#endif // MARKER_H
+19 -9
View File
@@ -803,18 +803,23 @@ void SetAutoscaleAction::redo() {
mainWindow->setWindowModified(true);
}
AddMarkerAction::AddMarkerAction(Sequence* s, long t, QString n) :
seq(s),
AddMarkerAction::AddMarkerAction(bool is_sequence, void* s, long t, QString n) :
is_sequence_internal(is_sequence),
target(s),
time(t),
name(n),
old_project_changed(mainWindow->isWindowModified())
{}
void AddMarkerAction::undo() {
QVector<Marker>& markers = is_sequence_internal ?
static_cast<Sequence*>(target)->markers :
static_cast<Clip*>(target)->markers;
if (index == -1) {
seq->markers.removeLast();
markers.removeLast();
} else {
seq->markers[index].name = old_name;
markers[index].name = old_name;
}
mainWindow->setWindowModified(old_project_changed);
@@ -822,8 +827,13 @@ void AddMarkerAction::undo() {
void AddMarkerAction::redo() {
index = -1;
for (int i=0;i<seq->markers.size();i++) {
if (seq->markers.at(i).frame == time) {
QVector<Marker>& markers = is_sequence_internal ?
static_cast<Sequence*>(target)->markers :
static_cast<Clip*>(target)->markers;
for (int i=0;i<markers.size();i++) {
if (markers.at(i).frame == time) {
index = i;
break;
}
@@ -832,10 +842,10 @@ void AddMarkerAction::redo() {
if (index == -1) {
Marker m;
m.frame = time;
seq->markers.append(m);
markers.append(m);
} else {
old_name = seq->markers.at(index).name;
seq->markers[index].name = name;
old_name = markers.at(index).name;
markers[index].name = name;
}
mainWindow->setWindowModified(true);
+3 -2
View File
@@ -384,11 +384,12 @@ private:
class AddMarkerAction : public QUndoCommand {
public:
AddMarkerAction(Sequence* s, long t, QString n);
AddMarkerAction(bool is_sequence, void* s, long t, QString n);
void undo();
void redo();
private:
Sequence* seq;
bool is_sequence_internal;
void* target;
long time;
QString name;
QString old_name;