fully implemented clip markers, fixes #333
This commit is contained in:
+18
-8
@@ -387,10 +387,10 @@ void MainWindow::show_debug_log() {
|
||||
void MainWindow::delete_slot() {
|
||||
if (panel_timeline->headers->hasFocus()) {
|
||||
panel_timeline->headers->delete_markers();
|
||||
} else if (panel_footage_viewer->headers->hasFocus()) {
|
||||
panel_footage_viewer->headers->delete_markers();
|
||||
} else if (panel_sequence_viewer->headers->hasFocus()) {
|
||||
panel_sequence_viewer->headers->delete_markers();
|
||||
} else if (panel_footage_viewer->headers->hasFocus()) {
|
||||
panel_footage_viewer->headers->delete_markers();
|
||||
} else if (panel_sequence_viewer->headers->hasFocus()) {
|
||||
panel_sequence_viewer->headers->delete_markers();
|
||||
} else if (panel_timeline->focused()) {
|
||||
panel_timeline->delete_selection(sequence->selections, false);
|
||||
} else if (panel_effect_controls->is_focused()) {
|
||||
@@ -775,9 +775,9 @@ void MainWindow::setup_menus() {
|
||||
playback_menu->addAction(tr("Go to In Point"), this, SLOT(go_to_in()), QKeySequence("Shift+I"))->setProperty("id", "gotoin");
|
||||
playback_menu->addAction(tr("Go to Out Point"), this, SLOT(go_to_out()), QKeySequence("Shift+O"))->setProperty("id", "gotoout");
|
||||
playback_menu->addSeparator();
|
||||
playback_menu->addAction(tr("Shuttle Left"), this, SLOT(decrease_speed()), QKeySequence("J"))->setProperty("id", "decspeed");
|
||||
playback_menu->addAction(tr("Shuttle Stop"), this, SLOT(pause()), QKeySequence("K"))->setProperty("id", "pause");
|
||||
playback_menu->addAction(tr("Shuttle Right"), this, SLOT(increase_speed()), QKeySequence("L"))->setProperty("id", "incspeed");
|
||||
playback_menu->addAction(tr("Shuttle Left"), this, SLOT(decrease_speed()), QKeySequence("J"))->setProperty("id", "decspeed");
|
||||
playback_menu->addAction(tr("Shuttle Stop"), this, SLOT(pause()), QKeySequence("K"))->setProperty("id", "pause");
|
||||
playback_menu->addAction(tr("Shuttle Right"), this, SLOT(increase_speed()), QKeySequence("L"))->setProperty("id", "incspeed");
|
||||
playback_menu->addSeparator();
|
||||
|
||||
loop_action = playback_menu->addAction(tr("Loop"), this, SLOT(toggle_bool_action()));
|
||||
@@ -1523,7 +1523,17 @@ void MainWindow::set_tsa_custom() {
|
||||
}
|
||||
|
||||
void MainWindow::set_marker() {
|
||||
if (sequence != nullptr) panel_timeline->set_marker();
|
||||
if (sequence != nullptr) {
|
||||
QDockWidget* focused_panel = get_focused_panel();
|
||||
|
||||
if (focused_panel == panel_timeline) {
|
||||
panel_timeline->set_marker();
|
||||
} else if (focused_panel == panel_footage_viewer) {
|
||||
panel_footage_viewer->set_marker();
|
||||
} else if (focused_panel == panel_sequence_viewer) {
|
||||
panel_sequence_viewer->set_marker();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggle_enable_clips() {
|
||||
|
||||
+72
-54
@@ -6,84 +6,102 @@
|
||||
#include "project/sequence.h"
|
||||
#include "project/clip.h"
|
||||
#include "panels/panels.h"
|
||||
#include "panels/viewer.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),
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
|
||||
// if clips is empty, the marker is being added to the sequence
|
||||
// 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;
|
||||
// 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;
|
||||
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 (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) {
|
||||
// if we've decided to add a marker
|
||||
if (add_marker) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
if (clips.size() > 0) {
|
||||
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));
|
||||
}
|
||||
// add a marker action for each clip
|
||||
foreach (int i, clips) {
|
||||
Clip* c = seq->clips.at(i);
|
||||
ca->append(new AddMarkerAction(&c->get_markers(),
|
||||
seq->playhead - c->timeline_in + c->clip_in,
|
||||
marker_name));
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
// if no clips are selected, we're adding a marker to the sequence
|
||||
ca->append(new AddMarkerAction(true, seq, seq->playhead, marker_name));
|
||||
// if no clips are selected, we're adding a marker to the sequence
|
||||
|
||||
}
|
||||
// kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is attached to
|
||||
if (seq == panel_footage_viewer->seq) {
|
||||
|
||||
// get correct marker reference from footage viewer
|
||||
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else if (seq == panel_sequence_viewer->seq) {
|
||||
|
||||
// get correct marker reference from sequence viewer
|
||||
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else {
|
||||
|
||||
// fallback to using markers from sequence provided
|
||||
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// push action
|
||||
undo_stack.push(ca);
|
||||
// push action
|
||||
undo_stack.push(ca);
|
||||
|
||||
// redraw UI for new markers
|
||||
update_ui(false);
|
||||
// redraw UI for new markers
|
||||
update_ui(false);
|
||||
panel_footage_viewer->update_viewer();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence* seq) {
|
||||
// create empty clip array
|
||||
QVector<int> clips;
|
||||
// create empty clip array
|
||||
QVector<int> clips;
|
||||
|
||||
set_marker_internal(seq, clips);
|
||||
set_marker_internal(seq, clips);
|
||||
}
|
||||
|
||||
+13
-22
@@ -804,23 +804,18 @@ void SetAutoscaleAction::redo() {
|
||||
mainWindow->setWindowModified(true);
|
||||
}
|
||||
|
||||
AddMarkerAction::AddMarkerAction(bool is_sequence, void* s, long t, QString n) :
|
||||
is_sequence_internal(is_sequence),
|
||||
target(s),
|
||||
AddMarkerAction::AddMarkerAction(QVector<Marker>* m, long t, QString n) :
|
||||
active_array(m),
|
||||
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)->get_markers();
|
||||
|
||||
if (index == -1) {
|
||||
markers.removeLast();
|
||||
active_array->removeLast();
|
||||
} else {
|
||||
markers[index].name = old_name;
|
||||
active_array[0][index].name = old_name;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(old_project_changed);
|
||||
@@ -829,12 +824,8 @@ void AddMarkerAction::undo() {
|
||||
void AddMarkerAction::redo() {
|
||||
index = -1;
|
||||
|
||||
QVector<Marker>& markers = is_sequence_internal ?
|
||||
static_cast<Sequence*>(target)->markers :
|
||||
static_cast<Clip*>(target)->get_markers();
|
||||
|
||||
for (int i=0;i<markers.size();i++) {
|
||||
if (markers.at(i).frame == time) {
|
||||
for (int i=0;i<active_array->size();i++) {
|
||||
if (active_array->at(i).frame == time) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
@@ -844,10 +835,10 @@ void AddMarkerAction::redo() {
|
||||
Marker m;
|
||||
m.frame = time;
|
||||
m.name = name;
|
||||
markers.append(m);
|
||||
active_array->append(m);
|
||||
} else {
|
||||
old_name = markers.at(index).name;
|
||||
markers[index].name = name;
|
||||
old_name = active_array->at(index).name;
|
||||
active_array[0][index].name = name;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(true);
|
||||
@@ -871,14 +862,14 @@ void MoveMarkerAction::redo() {
|
||||
}
|
||||
|
||||
DeleteMarkerAction::DeleteMarkerAction(QVector<Marker> *m) :
|
||||
active_array(m),
|
||||
active_array(m),
|
||||
sorted(false),
|
||||
old_project_changed(mainWindow->isWindowModified())
|
||||
{}
|
||||
|
||||
void DeleteMarkerAction::undo() {
|
||||
for (int i=markers.size()-1;i>=0;i--) {
|
||||
active_array->insert(markers.at(i), copies.at(i));
|
||||
active_array->insert(markers.at(i), copies.at(i));
|
||||
}
|
||||
mainWindow->setWindowModified(old_project_changed);
|
||||
}
|
||||
@@ -887,14 +878,14 @@ void DeleteMarkerAction::redo() {
|
||||
for (int i=0;i<markers.size();i++) {
|
||||
// correct future removals
|
||||
if (!sorted) {
|
||||
copies.append(active_array->at(markers.at(i)));
|
||||
copies.append(active_array->at(markers.at(i)));
|
||||
for (int j=i+1;j<markers.size();j++) {
|
||||
if (markers.at(j) > markers.at(i)) {
|
||||
markers[j]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
active_array->removeAt(markers.at(i));
|
||||
active_array->removeAt(markers.at(i));
|
||||
}
|
||||
sorted = true;
|
||||
mainWindow->setWindowModified(true);
|
||||
|
||||
+4
-5
@@ -384,12 +384,11 @@ private:
|
||||
|
||||
class AddMarkerAction : public QUndoCommand {
|
||||
public:
|
||||
AddMarkerAction(bool is_sequence, void* s, long t, QString n);
|
||||
AddMarkerAction(QVector<Marker>* m, long t, QString n);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
bool is_sequence_internal;
|
||||
void* target;
|
||||
QVector<Marker>* active_array;
|
||||
long time;
|
||||
QString name;
|
||||
QString old_name;
|
||||
@@ -411,12 +410,12 @@ private:
|
||||
|
||||
class DeleteMarkerAction : public QUndoCommand {
|
||||
public:
|
||||
DeleteMarkerAction(QVector<Marker>* m);
|
||||
DeleteMarkerAction(QVector<Marker>* m);
|
||||
void undo();
|
||||
void redo();
|
||||
QVector<int> markers;
|
||||
private:
|
||||
QVector<Marker>* active_array;
|
||||
QVector<Marker>* active_array;
|
||||
QVector<Marker> copies;
|
||||
bool sorted;
|
||||
bool old_project_changed;
|
||||
|
||||
+12
-12
@@ -93,20 +93,20 @@ void ViewerWidget::set_waveform_scroll(int s) {
|
||||
if (waveform) {
|
||||
waveform_scroll = s;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::set_fullscreen(int screen) {
|
||||
if (screen >= 0 && screen < QGuiApplication::screens().size()) {
|
||||
QScreen* selected_screen = QGuiApplication::screens().at(screen);
|
||||
window->showFullScreen();
|
||||
window->setGeometry(selected_screen->geometry());
|
||||
if (screen >= 0 && screen < QGuiApplication::screens().size()) {
|
||||
QScreen* selected_screen = QGuiApplication::screens().at(screen);
|
||||
window->showFullScreen();
|
||||
window->setGeometry(selected_screen->geometry());
|
||||
|
||||
// HACK: window seems to show with distorted texture on first showing, so we queue an update after it's shown
|
||||
QTimer::singleShot(100, window, SLOT(update()));
|
||||
} else {
|
||||
qCritical() << "Failed to find requested screen" << screen << "to set fullscreen to";
|
||||
}
|
||||
// HACK: window seems to show with distorted texture on first showing, so we queue an update after it's shown
|
||||
QTimer::singleShot(100, window, SLOT(update()));
|
||||
} else {
|
||||
qCritical() << "Failed to find requested screen" << screen << "to set fullscreen to";
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::show_context_menu() {
|
||||
@@ -183,7 +183,7 @@ void ViewerWidget::fullscreen_menu_action(QAction *action) {
|
||||
if (action->data().isNull()) {
|
||||
window->hide();
|
||||
} else {
|
||||
set_fullscreen(action->data().toInt());
|
||||
set_fullscreen(action->data().toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,7 +567,7 @@ void ViewerWidget::paintGL() {
|
||||
makeCurrent();
|
||||
|
||||
// clear to solid black
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// set color multipler to straight white
|
||||
|
||||
Reference in New Issue
Block a user