From 34fc8b81d206e33a7f1bbce8e31871b854e4da5a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 30 Dec 2018 20:23:57 +1100 Subject: [PATCH] removed all ui files --- dialogs/aboutdialog.cpp | 29 +- dialogs/aboutdialog.h | 8 - dialogs/aboutdialog.ui | 80 --- dialogs/demonotice.cpp | 35 +- dialogs/demonotice.h | 9 - dialogs/demonotice.ui | 97 --- dialogs/exportdialog.cpp | 461 +++++++++----- dialogs/exportdialog.h | 62 +- dialogs/exportdialog.ui | 317 ---------- dialogs/loaddialog.cpp | 27 +- dialogs/newsequencedialog.cpp | 281 ++++++--- dialogs/newsequencedialog.h | 33 +- dialogs/newsequencedialog.ui | 370 ------------ dialogs/preferencesdialog.cpp | 205 +++++-- dialogs/preferencesdialog.h | 48 +- dialogs/preferencesdialog.ui | 179 ------ mainwindow.cpp | 28 +- olive.pro | 14 +- panels/project.cpp | 5 +- panels/project.h | 4 - panels/timeline.cpp | 437 ++++++++++---- panels/timeline.h | 77 +-- panels/timeline.ui | 538 ----------------- panels/viewer.cpp | 11 +- panels/viewer.h | 10 +- playback/audio.cpp | 109 ++-- ui/timelinewidget.cpp | 6 +- ui/viewerwidget.cpp | 1067 +++++++++++++++++---------------- 28 files changed, 1777 insertions(+), 2770 deletions(-) delete mode 100644 dialogs/aboutdialog.ui delete mode 100644 dialogs/demonotice.ui delete mode 100644 dialogs/exportdialog.ui delete mode 100644 dialogs/newsequencedialog.ui delete mode 100644 dialogs/preferencesdialog.ui delete mode 100644 panels/timeline.ui diff --git a/dialogs/aboutdialog.cpp b/dialogs/aboutdialog.cpp index 40a2096c6..7d1bdb7e9 100644 --- a/dialogs/aboutdialog.cpp +++ b/dialogs/aboutdialog.cpp @@ -1,14 +1,27 @@ #include "aboutdialog.h" -#include "ui_aboutdialog.h" + +#include +#include +#include AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) + QDialog(parent) { - ui->setupUi(this); -} + setWindowTitle("About Olive"); + setMaximumWidth(360); -AboutDialog::~AboutDialog() -{ - delete ui; + QVBoxLayout* layout = new QVBoxLayout(); + layout->setSpacing(20); + setLayout(layout); + + QLabel* label = new QLabel("

https://www.olivevideoeditor.org/

Olive is a non-linear video editor. This software is free and protected by the GNU GPL.

Olive Team is obliged to inform users that Olive source code is available for download from its website.

Olive uses (at least) the following libraries in accordance with the GNU GPL/LGPL:

Qt, FFmpeg, libass, libfreetype, libmp3lame, libopenjpeg, libopus, libtheora, libtwolame, libvpx, libwavpack, libwebp, libx264, libx265, lzma, bzlib, zlib, libvidstab, libvorbis.

"); + label->setAlignment(Qt::AlignCenter); + label->setWordWrap(true); + layout->addWidget(label); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, this); + buttons->setCenterButtons(true); + layout->addWidget(buttons); + + connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); } diff --git a/dialogs/aboutdialog.h b/dialogs/aboutdialog.h index 18a87e537..5ecf637a9 100644 --- a/dialogs/aboutdialog.h +++ b/dialogs/aboutdialog.h @@ -3,20 +3,12 @@ #include -namespace Ui { -class AboutDialog; -} - class AboutDialog : public QDialog { Q_OBJECT public: explicit AboutDialog(QWidget *parent = 0); - ~AboutDialog(); - -private: - Ui::AboutDialog *ui; }; #endif // ABOUTDIALOG_H diff --git a/dialogs/aboutdialog.ui b/dialogs/aboutdialog.ui deleted file mode 100644 index e56d0baa1..000000000 --- a/dialogs/aboutdialog.ui +++ /dev/null @@ -1,80 +0,0 @@ - - - AboutDialog - - - - 0 - 0 - 358 - 422 - - - - About Olive - - - - - - <html><head/><body><p><img src=":/icons/olive-splash.png"/></p><p><a href="https://www.olivevideoeditor.org/"><span style=" text-decoration: underline; color:#007af4;">https://www.olivevideoeditor.org/</span></a></p><p>Olive is a non-linear video editor. This software is free and protected by the GNU GPL.</p><p>Olive Team is obliged to inform users that Olive source code is available for download from its website.</p><p>Olive uses (at least) the following libraries in accordance with the GNU GPL/LGPL:</p><p>Qt, FFmpeg, libass, libfreetype, libmp3lame, libopenjpeg, libopus, libtheora, libtwolame, libvpx, libwavpack, libwebp, libx264, libx265, lzma, bzlib, zlib, libvidstab, libvorbis.</p></body></html> - - - Qt::AlignCenter - - - true - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - true - - - - - - - - - buttonBox - accepted() - AboutDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AboutDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/dialogs/demonotice.cpp b/dialogs/demonotice.cpp index 95826803a..d16f9bd47 100644 --- a/dialogs/demonotice.cpp +++ b/dialogs/demonotice.cpp @@ -1,14 +1,33 @@ #include "demonotice.h" -#include "ui_demonotice.h" + +#include +#include +#include DemoNotice::DemoNotice(QWidget *parent) : - QDialog(parent), - ui(new Ui::DemoNotice) + QDialog(parent) { - ui->setupUi(this); -} + setWindowTitle("Welcome to Olive!"); + setMaximumWidth(600); -DemoNotice::~DemoNotice() -{ - delete ui; + QVBoxLayout* vlayout = new QVBoxLayout(); + setLayout(vlayout); + + QHBoxLayout* layout = new QHBoxLayout(); + layout->setMargin(10); + layout->setSpacing(20); + + QLabel* icon = new QLabel("

"); + layout->addWidget(icon); + + QLabel* text = new QLabel("

Welcome to Olive!

Olive is a free open-source video editor released under the GNU GPL. If you have paid for this software, you have been scammed.

This software is currently in ALPHA which means it is unstable and very likely to crash, have bugs, and have missing features. We offer no warranty so use at your own risk. Please report any bugs or feature requests at www.olivevideoeditor.org

Thank you for trying Olive and we hope you enjoy it!

"); + text->setWordWrap(true); + layout->addWidget(text); + + vlayout->addLayout(layout); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, this); + buttons->setCenterButtons(true); + connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); + vlayout->addWidget(buttons); } diff --git a/dialogs/demonotice.h b/dialogs/demonotice.h index 34cf6fcb2..ec57e13e5 100644 --- a/dialogs/demonotice.h +++ b/dialogs/demonotice.h @@ -3,20 +3,11 @@ #include -namespace Ui { -class DemoNotice; -} - class DemoNotice : public QDialog { Q_OBJECT - public: explicit DemoNotice(QWidget *parent = 0); - ~DemoNotice(); - -private: - Ui::DemoNotice *ui; }; #endif // DEMONOTICE_H diff --git a/dialogs/demonotice.ui b/dialogs/demonotice.ui deleted file mode 100644 index fa7ff3e64..000000000 --- a/dialogs/demonotice.ui +++ /dev/null @@ -1,97 +0,0 @@ - - - DemoNotice - - - - 0 - 0 - 511 - 249 - - - - Welcome - - - - - - 12 - - - - - - 0 - 0 - - - - <html><head/><body><p><img src=":/icons/olive-splash.png"/></p></body></html> - - - - - - - <html><head/><body><p><span style=" font-size:14pt;">Welcome to Olive!</span></p><p>Olive is a free open-source video editor released under the GNU GPL. If you have paid for this software, you have been scammed.</p><p>This software is currently in ALPHA which means it is unstable and very likely to crash, have bugs, and have missing features. We offer no warranty so use at your own risk. Please report any bugs or feature requests at <a href="https://olivevideoeditor.org/"><span style=" text-decoration: underline; color:#007af4;">www.olivevideoeditor.org</span></a></p><p>Thank you for trying Olive and we hope you enjoy it!</p></body></html> - - - true - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - true - - - - - - - - - buttonBox - accepted() - DemoNotice - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DemoNotice - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 20b010913..44835dacd 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -1,5 +1,4 @@ #include "exportdialog.h" -#include "ui_exportdialog.h" #include #include @@ -7,6 +6,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "debug.h" #include "panels/panels.h" @@ -48,15 +55,14 @@ enum ExportFormats { }; ExportDialog::ExportDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::ExportDialog) + QDialog(parent) { - ui->setupUi(this); + setup_ui(); - ui->rangeCombobox->setCurrentIndex(0); + rangeCombobox->setCurrentIndex(0); if (sequence->using_workarea) { - ui->rangeCombobox->setEnabled(sequence->using_workarea); - ui->rangeCombobox->setCurrentIndex(1); + rangeCombobox->setEnabled(sequence->using_workarea); + rangeCombobox->setCurrentIndex(1); } format_strings.resize(FORMAT_SIZE); @@ -83,27 +89,25 @@ ExportDialog::ExportDialog(QWidget *parent) : format_strings[FORMAT_WMV] = "Windows Media"; for (int i=0;iformatCombobox->addItem(format_strings[i]); + formatCombobox->addItem(format_strings[i]); } - ui->formatCombobox->setCurrentIndex(FORMAT_MPEG4); + formatCombobox->setCurrentIndex(FORMAT_MPEG4); - ui->widthSpinbox->setValue(sequence->width); - ui->heightSpinbox->setValue(sequence->height); - ui->samplingRateSpinbox->setValue(sequence->audio_frequency); - ui->framerateSpinbox->setValue(sequence->frame_rate); + widthSpinbox->setValue(sequence->width); + heightSpinbox->setValue(sequence->height); + samplingRateSpinbox->setValue(sequence->audio_frequency); + framerateSpinbox->setValue(sequence->frame_rate); } ExportDialog::~ExportDialog() -{ - delete ui; -} +{} -void ExportDialog::on_formatCombobox_currentIndexChanged(int index) +void ExportDialog::format_changed(int index) { format_vcodecs.clear(); format_acodecs.clear(); - ui->vcodecCombobox->clear(); - ui->acodecCombobox->clear(); + vcodecCombobox->clear(); + acodecCombobox->clear(); int default_vcodec = 0; int default_acodec = 0; @@ -241,7 +245,7 @@ void ExportDialog::on_formatCombobox_currentIndexChanged(int index) format_acodecs.append(AV_CODEC_ID_OPUS); format_acodecs.append(AV_CODEC_ID_VORBIS); - default_acodec = 1; + default_acodec = 1; break; case FORMAT_MOV: format_vcodecs.append(AV_CODEC_ID_QTRLE); @@ -288,60 +292,56 @@ void ExportDialog::on_formatCombobox_currentIndexChanged(int index) for (int i=0;ivcodecCombobox->addItem("NULL"); + vcodecCombobox->addItem("NULL"); } else { - ui->vcodecCombobox->addItem(codec_info->long_name); + vcodecCombobox->addItem(codec_info->long_name); } } for (int i=0;iacodecCombobox->addItem("NULL"); + acodecCombobox->addItem("NULL"); } else { - ui->acodecCombobox->addItem(codec_info->long_name); + acodecCombobox->addItem(codec_info->long_name); } } - ui->vcodecCombobox->setCurrentIndex(default_vcodec); - ui->acodecCombobox->setCurrentIndex(default_acodec); + vcodecCombobox->setCurrentIndex(default_vcodec); + acodecCombobox->setCurrentIndex(default_acodec); bool video_enabled = format_vcodecs.size() != 0; bool audio_enabled = format_acodecs.size() != 0; - ui->videoGroupbox->setChecked(video_enabled); - ui->audioGroupbox->setChecked(audio_enabled); - ui->videoGroupbox->setEnabled(video_enabled); - ui->audioGroupbox->setEnabled(audio_enabled); -} - -void ExportDialog::on_pushButton_2_clicked() { - close(); + videoGroupbox->setChecked(video_enabled); + audioGroupbox->setChecked(audio_enabled); + videoGroupbox->setEnabled(video_enabled); + audioGroupbox->setEnabled(audio_enabled); } void ExportDialog::render_thread_finished() { - if (ui->progressBar->value() < 100 && !cancelled) { - QMessageBox::critical(this, "Export Failed", "Export failed - " + export_error, QMessageBox::Ok); - } - prep_ui_for_render(false); - panel_sequence_viewer->viewer_widget->makeCurrent(); - panel_sequence_viewer->viewer_widget->initializeGL(); - update_ui(false); - if (ui->progressBar->value() == 100) close(); + if (progressBar->value() < 100 && !cancelled) { + QMessageBox::critical(this, "Export Failed", "Export failed - " + export_error, QMessageBox::Ok); + } + prep_ui_for_render(false); + panel_sequence_viewer->viewer_widget->makeCurrent(); + panel_sequence_viewer->viewer_widget->initializeGL(); + update_ui(false); + if (progressBar->value() == 100) accept(); } void ExportDialog::prep_ui_for_render(bool r) { - ui->pushButton->setEnabled(!r); - ui->pushButton_2->setEnabled(!r); - ui->renderCancel->setEnabled(r); + export_button->setEnabled(!r); + cancel_button->setEnabled(!r); + renderCancel->setEnabled(r); } -void ExportDialog::on_pushButton_clicked() { - if (ui->widthSpinbox->value()%2 == 1 || ui->heightSpinbox->value()%2 == 1) { +void ExportDialog::export_action() { + if (widthSpinbox->value()%2 == 1 || heightSpinbox->value()%2 == 1) { QMessageBox::critical(this, "Invalid dimensions", "Export width and height must both be even numbers/divisible by 2.", QMessageBox::Ok); return; } QString ext; - switch (ui->formatCombobox->currentIndex()) { + switch (formatCombobox->currentIndex()) { case FORMAT_3GPP: ext = "3gp"; break; @@ -366,57 +366,57 @@ void ExportDialog::on_pushButton_clicked() { case FORMAT_GIF: ext = "gif"; break; - case FORMAT_IMG: - switch (format_vcodecs.at(ui->vcodecCombobox->currentIndex())) { - case AV_CODEC_ID_BMP: - ext = "bmp"; - break; - case AV_CODEC_ID_MJPEG: - ext = "jpg"; - break; - case AV_CODEC_ID_JPEG2000: - ext = "jp2"; - break; - case AV_CODEC_ID_PSD: - ext = "psd"; - break; - case AV_CODEC_ID_PNG: - ext = "png"; - break; - case AV_CODEC_ID_TIFF: - ext = "tif"; - break; - default: + case FORMAT_IMG: + switch (format_vcodecs.at(vcodecCombobox->currentIndex())) { + case AV_CODEC_ID_BMP: + ext = "bmp"; + break; + case AV_CODEC_ID_MJPEG: + ext = "jpg"; + break; + case AV_CODEC_ID_JPEG2000: + ext = "jp2"; + break; + case AV_CODEC_ID_PSD: + ext = "psd"; + break; + case AV_CODEC_ID_PNG: + ext = "png"; + break; + case AV_CODEC_ID_TIFF: + ext = "tif"; + break; + default: dout << "[ERROR] Invalid codec selection for an image sequence"; - QMessageBox::critical(this, "Invalid codec", "Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers.", QMessageBox::Ok); - return; - } + QMessageBox::critical(this, "Invalid codec", "Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers.", QMessageBox::Ok); + return; + } break; case FORMAT_MP3: ext = "mp3"; break; case FORMAT_MPEG1: - if (ui->videoGroupbox->isChecked() && !ui->audioGroupbox->isChecked()) { + if (videoGroupbox->isChecked() && !audioGroupbox->isChecked()) { ext = "m1v"; - } else if (!ui->videoGroupbox->isChecked() && ui->audioGroupbox->isChecked()) { + } else if (!videoGroupbox->isChecked() && audioGroupbox->isChecked()) { ext = "m1a"; } else { ext = "mpg"; } break; case FORMAT_MPEG2: - if (ui->videoGroupbox->isChecked() && !ui->audioGroupbox->isChecked()) { + if (videoGroupbox->isChecked() && !audioGroupbox->isChecked()) { ext = "m2v"; - } else if (!ui->videoGroupbox->isChecked() && ui->audioGroupbox->isChecked()) { + } else if (!videoGroupbox->isChecked() && audioGroupbox->isChecked()) { ext = "m2a"; } else { ext = "mpg"; } break; case FORMAT_MPEG4: - if (ui->videoGroupbox->isChecked() && !ui->audioGroupbox->isChecked()) { + if (videoGroupbox->isChecked() && !audioGroupbox->isChecked()) { ext = "m4v"; - } else if (!ui->videoGroupbox->isChecked() && ui->audioGroupbox->isChecked()) { + } else if (!videoGroupbox->isChecked() && audioGroupbox->isChecked()) { ext = "m4a"; } else { ext = "mp4"; @@ -426,7 +426,7 @@ void ExportDialog::on_pushButton_clicked() { ext = "ts"; break; case FORMAT_MKV: - if (!ui->videoGroupbox->isChecked()) { + if (!videoGroupbox->isChecked()) { ext = "mka"; } else { ext = "mkv"; @@ -438,14 +438,14 @@ void ExportDialog::on_pushButton_clicked() { case FORMAT_MOV: ext = "mov"; break; - case FORMAT_WAV: - ext = "wav"; - break; + case FORMAT_WAV: + ext = "wav"; + break; case FORMAT_WEBM: ext = "webm"; break; case FORMAT_WMV: - if (ui->videoGroupbox->isChecked()) { + if (videoGroupbox->isChecked()) { ext = "wmv"; } else { ext = "wma"; @@ -453,66 +453,66 @@ void ExportDialog::on_pushButton_clicked() { break; default: dout << "[ERROR] Invalid format - this is a bug, please inform the developers"; - QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok); + QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok); return; } - QString filename = QFileDialog::getSaveFileName(this, "Export Media", "", format_strings[ui->formatCombobox->currentIndex()] + " (*." + ext + ")"); + QString filename = QFileDialog::getSaveFileName(this, "Export Media", "", format_strings[formatCombobox->currentIndex()] + " (*." + ext + ")"); if (!filename.isEmpty()) { - if (!filename.endsWith("." + ext, Qt::CaseInsensitive)) { - filename += "." + ext; - } + if (!filename.endsWith("." + ext, Qt::CaseInsensitive)) { + filename += "." + ext; + } - if (ui->formatCombobox->currentIndex() == FORMAT_IMG) { - int ext_location = filename.lastIndexOf('.'); - if (ext_location > filename.lastIndexOf('/')) { - filename.insert(ext_location, 'd'); - filename.insert(ext_location, '5'); - filename.insert(ext_location, '0'); - filename.insert(ext_location, '%'); - } - } + if (formatCombobox->currentIndex() == FORMAT_IMG) { + int ext_location = filename.lastIndexOf('.'); + if (ext_location > filename.lastIndexOf('/')) { + filename.insert(ext_location, 'd'); + filename.insert(ext_location, '5'); + filename.insert(ext_location, '0'); + filename.insert(ext_location, '%'); + } + } et = new ExportThread(); connect(et, SIGNAL(finished()), et, SLOT(deleteLater())); - connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished())); - connect(et, SIGNAL(progress_changed(int, qint64)), this, SLOT(update_progress_bar(int, qint64))); + connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished())); + connect(et, SIGNAL(progress_changed(int, qint64)), this, SLOT(update_progress_bar(int, qint64))); closeActiveClips(sequence, true); - mainWindow->autorecover_interval(); + mainWindow->autorecover_interval(); rendering = true; panel_sequence_viewer->viewer_widget->context()->doneCurrent(); panel_sequence_viewer->viewer_widget->context()->moveToThread(et); - prep_ui_for_render(true); + prep_ui_for_render(true); et->filename = filename; - et->video_enabled = ui->videoGroupbox->isChecked(); - if (et->video_enabled) { - et->video_codec = format_vcodecs.at(ui->vcodecCombobox->currentIndex()); - et->video_width = ui->widthSpinbox->value(); - et->video_height = ui->heightSpinbox->value(); - et->video_frame_rate = ui->framerateSpinbox->value(); - et->video_compression_type = ui->compressionTypeCombobox->currentData().toInt(); - et->video_bitrate = ui->videobitrateSpinbox->value(); - } - et->audio_enabled = ui->audioGroupbox->isChecked(); - if (et->audio_enabled) { - et->audio_codec = format_acodecs.at(ui->acodecCombobox->currentIndex()); - et->audio_sampling_rate = ui->samplingRateSpinbox->value(); - et->audio_bitrate = ui->audiobitrateSpinbox->value(); - } + et->video_enabled = videoGroupbox->isChecked(); + if (et->video_enabled) { + et->video_codec = format_vcodecs.at(vcodecCombobox->currentIndex()); + et->video_width = widthSpinbox->value(); + et->video_height = heightSpinbox->value(); + et->video_frame_rate = framerateSpinbox->value(); + et->video_compression_type = compressionTypeCombobox->currentData().toInt(); + et->video_bitrate = videobitrateSpinbox->value(); + } + et->audio_enabled = audioGroupbox->isChecked(); + if (et->audio_enabled) { + et->audio_codec = format_acodecs.at(acodecCombobox->currentIndex()); + et->audio_sampling_rate = samplingRateSpinbox->value(); + et->audio_bitrate = audiobitrateSpinbox->value(); + } - et->start_frame = 0; - et->end_frame = sequence->getEndFrame(); // entire sequence - if (ui->rangeCombobox->currentIndex() == 1) { - et->start_frame = qMax(sequence->workarea_in, et->start_frame); - et->end_frame = qMin(sequence->workarea_out, et->end_frame); - } + et->start_frame = 0; + et->end_frame = sequence->getEndFrame(); // entire sequence + if (rangeCombobox->currentIndex() == 1) { + et->start_frame = qMax(sequence->workarea_in, et->start_frame); + et->end_frame = qMin(sequence->workarea_out, et->end_frame); + } - et->ed = this; + et->ed = this; cancelled = false; et->start(); @@ -520,54 +520,207 @@ void ExportDialog::on_pushButton_clicked() { } void ExportDialog::update_progress_bar(int value, qint64 remaining_ms) { - // convert ms to H:MM:SS - int seconds = qFloor(remaining_ms*0.001)%60; - int minutes = qFloor(remaining_ms/60000)%60; - int hours = qFloor(remaining_ms/3600000); - ui->progressBar->setFormat("%p% (ETA: " + QString::number(hours) + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0') + ")"); + // convert ms to H:MM:SS + int seconds = qFloor(remaining_ms*0.001)%60; + int minutes = qFloor(remaining_ms/60000)%60; + int hours = qFloor(remaining_ms/3600000); + progressBar->setFormat("%p% (ETA: " + QString::number(hours) + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0') + ")"); - ui->progressBar->setValue(value); + progressBar->setValue(value); } -void ExportDialog::on_renderCancel_clicked() { - panel_sequence_viewer->viewer_widget->force_quit = true; +void ExportDialog::cancel_render() { + panel_sequence_viewer->viewer_widget->force_quit = true; et->continueEncode = false; - cancelled = true; + cancelled = true; } -void ExportDialog::on_vcodecCombobox_currentIndexChanged(int index) { - ui->compressionTypeCombobox->clear(); +void ExportDialog::vcodec_changed(int index) { + compressionTypeCombobox->clear(); if ((format_vcodecs.size() > 0 && format_vcodecs.at(index) == AV_CODEC_ID_H264)) { - ui->compressionTypeCombobox->setEnabled(true); - ui->compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)", COMPRESSION_TYPE_CFR); -// ui->compressionTypeCombobox->addItem("File size-based (Two-Pass)", COMPRESSION_TYPE_TARGETSIZE); -// ui->compressionTypeCombobox->addItem("Average bitrate (Two-Pass)", COMPRESSION_TYPE_TARGETBR); + compressionTypeCombobox->setEnabled(true); + compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)", COMPRESSION_TYPE_CFR); +// compressionTypeCombobox->addItem("File size-based (Two-Pass)", COMPRESSION_TYPE_TARGETSIZE); +// compressionTypeCombobox->addItem("Average bitrate (Two-Pass)", COMPRESSION_TYPE_TARGETBR); } else { - ui->compressionTypeCombobox->addItem("Constant Bitrate", COMPRESSION_TYPE_CBR); - ui->compressionTypeCombobox->setCurrentIndex(0); - ui->compressionTypeCombobox->setEnabled(false); + compressionTypeCombobox->addItem("Constant Bitrate", COMPRESSION_TYPE_CBR); + compressionTypeCombobox->setCurrentIndex(0); + compressionTypeCombobox->setEnabled(false); } } -void ExportDialog::on_compressionTypeCombobox_currentIndexChanged(int) { - ui->videobitrateSpinbox->setToolTip(""); - ui->videobitrateSpinbox->setMinimum(0); - ui->videobitrateSpinbox->setMaximum(99.99); - switch (ui->compressionTypeCombobox->currentData().toInt()) { +void ExportDialog::comp_type_changed(int) { + videobitrateSpinbox->setToolTip(""); + videobitrateSpinbox->setMinimum(0); + videobitrateSpinbox->setMaximum(99.99); + switch (compressionTypeCombobox->currentData().toInt()) { case COMPRESSION_TYPE_CBR: case COMPRESSION_TYPE_TARGETBR: - ui->videoBitrateLabel->setText("Bitrate (Mbps):"); - ui->videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence->height) - 4.5))); + videoBitrateLabel->setText("Bitrate (Mbps):"); + videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence->height) - 4.5))); break; case COMPRESSION_TYPE_CFR: - ui->videoBitrateLabel->setText("Quality (CRF):"); - ui->videobitrateSpinbox->setValue(36); - ui->videobitrateSpinbox->setMaximum(51); - ui->videobitrateSpinbox->setToolTip("Quality Factor:\n\n0 = lossless\n17-18 = visually lossless (compressed, but unnoticeable)\n23 = high quality\n51 = lowest quality possible"); + videoBitrateLabel->setText("Quality (CRF):"); + videobitrateSpinbox->setValue(36); + videobitrateSpinbox->setMaximum(51); + videobitrateSpinbox->setToolTip("Quality Factor:\n\n0 = lossless\n17-18 = visually lossless (compressed, but unnoticeable)\n23 = high quality\n51 = lowest quality possible"); break; case COMPRESSION_TYPE_TARGETSIZE: - ui->videoBitrateLabel->setText("Target File Size (MB):"); - ui->videobitrateSpinbox->setValue(100); + videoBitrateLabel->setText("Target File Size (MB):"); + videobitrateSpinbox->setValue(100); break; } } + +void ExportDialog::setup_ui() { + QVBoxLayout* verticalLayout = new QVBoxLayout(this); + + QHBoxLayout* horizontalLayout = new QHBoxLayout(); + + horizontalLayout->addWidget(new QLabel("Format:")); + + formatCombobox = new QComboBox(this); + + horizontalLayout->addWidget(formatCombobox); + + verticalLayout->addLayout(horizontalLayout); + + QHBoxLayout* horizontalLayout_4 = new QHBoxLayout(); + + horizontalLayout_4->addWidget(new QLabel("Range:")); + + rangeCombobox = new QComboBox(this); + rangeCombobox->addItem("Entire Sequence"); + rangeCombobox->addItem("In to Out"); + + horizontalLayout_4->addWidget(rangeCombobox); + + verticalLayout->addLayout(horizontalLayout_4); + + videoGroupbox = new QGroupBox(this); + videoGroupbox->setTitle("Video"); + videoGroupbox->setFlat(false); + videoGroupbox->setCheckable(true); + QGridLayout* gridLayout = new QGridLayout(videoGroupbox); + + gridLayout->addWidget(new QLabel("Compression Type:"), 4, 0, 1, 1); + + compressionTypeCombobox = new QComboBox(videoGroupbox); + compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)"); + compressionTypeCombobox->addItem("File size-based (Two-Pass)"); + + gridLayout->addWidget(compressionTypeCombobox, 4, 1, 1, 1); + + gridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + + vcodecCombobox = new QComboBox(videoGroupbox); + + gridLayout->addWidget(vcodecCombobox, 0, 1, 1, 1); + + gridLayout->addWidget(new QLabel("Height:"), 2, 0, 1, 1); + + gridLayout->addWidget(new QLabel("Width:"), 1, 0, 1, 1); + + heightSpinbox = new QSpinBox(videoGroupbox); + heightSpinbox->setMaximum(16777216); + + gridLayout->addWidget(heightSpinbox, 2, 1, 1, 1); + + widthSpinbox = new QSpinBox(videoGroupbox); + widthSpinbox->setMaximum(16777216); + + gridLayout->addWidget(widthSpinbox, 1, 1, 1, 1); + + videobitrateSpinbox = new QDoubleSpinBox(videoGroupbox); + videobitrateSpinbox->setMaximum(100); + videobitrateSpinbox->setValue(2); + + gridLayout->addWidget(videobitrateSpinbox, 5, 1, 1, 1); + + videoBitrateLabel = new QLabel(videoGroupbox); + + gridLayout->addWidget(videoBitrateLabel, 5, 0, 1, 1); + + gridLayout->addWidget(new QLabel("Frame Rate:"), 3, 0, 1, 1); + + framerateSpinbox = new QDoubleSpinBox(videoGroupbox); + framerateSpinbox->setMaximum(60); + framerateSpinbox->setValue(0); + + gridLayout->addWidget(framerateSpinbox, 3, 1, 1, 1); + + + verticalLayout->addWidget(videoGroupbox); + + audioGroupbox = new QGroupBox(this); + audioGroupbox->setTitle("Audio"); + audioGroupbox->setCheckable(true); + + QGridLayout* gridLayout_2 = new QGridLayout(audioGroupbox); + gridLayout_2->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + + acodecCombobox = new QComboBox(audioGroupbox); + + gridLayout_2->addWidget(acodecCombobox, 0, 1, 1, 1); + + samplingRateSpinbox = new QSpinBox(audioGroupbox); + samplingRateSpinbox->setMaximum(96000); + samplingRateSpinbox->setValue(0); + + gridLayout_2->addWidget(samplingRateSpinbox, 1, 1, 1, 1); + + gridLayout_2->addWidget(new QLabel("Sampling Rate:"), 1, 0, 1, 1); + + gridLayout_2->addWidget(new QLabel("Bitrate (Kbps/CBR):"), 3, 0, 1, 1); + + audiobitrateSpinbox = new QSpinBox(audioGroupbox); + audiobitrateSpinbox->setMaximum(320); + audiobitrateSpinbox->setValue(256); + + gridLayout_2->addWidget(audiobitrateSpinbox, 3, 1, 1, 1); + + + verticalLayout->addWidget(audioGroupbox); + + QHBoxLayout* horizontalLayout_3 = new QHBoxLayout(); + progressBar = new QProgressBar(this); + progressBar->setFormat("%p% (ETA: 0:00:00)"); + progressBar->setEnabled(false); + progressBar->setValue(0); + + horizontalLayout_3->addWidget(progressBar); + + renderCancel = new QPushButton(this); + renderCancel->setText("x"); + renderCancel->setEnabled(false); + renderCancel->setMaximumSize(QSize(20, 16777215)); + connect(renderCancel, SIGNAL(clicked(bool)), this, SLOT(cancel_render())); + + horizontalLayout_3->addWidget(renderCancel); + + + verticalLayout->addLayout(horizontalLayout_3); + + QHBoxLayout* horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->addStretch(); + + export_button = new QPushButton(this); + export_button->setText("Export"); + connect(export_button, SIGNAL(clicked(bool)), this, SLOT(export_action())); + + horizontalLayout_2->addWidget(export_button); + + cancel_button = new QPushButton(this); + cancel_button->setText("Cancel"); + connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(reject())); + + horizontalLayout_2->addWidget(cancel_button); + + horizontalLayout_2->addStretch(); + + verticalLayout->addLayout(horizontalLayout_2); + + connect(formatCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(format_changed(int))); + connect(compressionTypeCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(comp_type_changed(int))); + connect(vcodecCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(vcodec_changed(int))); +} diff --git a/dialogs/exportdialog.h b/dialogs/exportdialog.h index 07585b6f9..7e78d2a95 100644 --- a/dialogs/exportdialog.h +++ b/dialogs/exportdialog.h @@ -3,48 +3,60 @@ #include -namespace Ui { -class ExportDialog; -} - struct Sequence; class ExportThread; +class QComboBox; +class QSpinBox; +class QDoubleSpinBox; +class QLabel; +class QProgressBar; +class QGroupBox; class ExportDialog : public QDialog { Q_OBJECT public: explicit ExportDialog(QWidget *parent = 0); - ~ExportDialog(); - QString export_error; + ~ExportDialog(); + QString export_error; private slots: - void on_formatCombobox_currentIndexChanged(int index); - - void on_pushButton_2_clicked(); - - void on_pushButton_clicked(); - - void update_progress_bar(int value, qint64 remaining_ms); - - void on_renderCancel_clicked(); - - void render_thread_finished(); - - void on_vcodecCombobox_currentIndexChanged(int index); - - void on_compressionTypeCombobox_currentIndexChanged(int index); + void format_changed(int index); + void export_action(); + void update_progress_bar(int value, qint64 remaining_ms); + void cancel_render(); + void render_thread_finished(); + void vcodec_changed(int index); + void comp_type_changed(int index); private: - Ui::ExportDialog *ui; - QVector format_strings; QVector format_vcodecs; QVector format_acodecs; + void setup_ui(); - ExportThread* et; + ExportThread* et; void prep_ui_for_render(bool r); - bool cancelled; + bool cancelled; + + QComboBox* rangeCombobox; + QSpinBox* widthSpinbox; + QDoubleSpinBox* videobitrateSpinbox; + QLabel* videoBitrateLabel; + QDoubleSpinBox* framerateSpinbox; + QComboBox* vcodecCombobox; + QComboBox* acodecCombobox; + QSpinBox* samplingRateSpinbox; + QSpinBox* audiobitrateSpinbox; + QProgressBar* progressBar; + QComboBox* formatCombobox; + QSpinBox* heightSpinbox; + QPushButton* export_button; + QPushButton* cancel_button; + QPushButton* renderCancel; + QGroupBox* videoGroupbox; + QGroupBox* audioGroupbox; + QComboBox* compressionTypeCombobox; }; #endif // EXPORTDIALOG_H diff --git a/dialogs/exportdialog.ui b/dialogs/exportdialog.ui deleted file mode 100644 index 4a9207014..000000000 --- a/dialogs/exportdialog.ui +++ /dev/null @@ -1,317 +0,0 @@ - - - ExportDialog - - - - 0 - 0 - 443 - 562 - - - - Export - - - - - - - - Format: - - - - - - - - - - - - - - Range: - - - - - - - - Entire Sequence - - - - - In to Out - - - - - - - - - - Video - - - false - - - true - - - - - - Compression Type: - - - - - - - - Quality-based (Constant Rate Factor) - - - - - File size-based (Two-Pass) - - - - - - - - Codec: - - - - - - - - - - Height: - - - - - - - Width: - - - - - - - 16777216 - - - - - - - 16777216 - - - - - - - 100.000000000000000 - - - 2.000000000000000 - - - - - - - Bitrate (Mbps): - - - - - - - Frame Rate: - - - - - - - 60.000000000000000 - - - 0.000000000000000 - - - - - - - - - - Audio - - - true - - - - - - Codec: - - - - - - - - - - 96000 - - - 0 - - - - - - - Sampling Rate: - - - - - - - Bitrate (Kbps/CBR): - - - - - - - 320 - - - 256 - - - - - - - - - - - - false - - - 0 - - - %p% (ETA: 0:00:00) - - - - - - - false - - - - 20 - 16777215 - - - - x - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Export - - - - - - - Cancel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - formatCombobox - videoGroupbox - vcodecCombobox - widthSpinbox - heightSpinbox - framerateSpinbox - videobitrateSpinbox - audioGroupbox - acodecCombobox - samplingRateSpinbox - audiobitrateSpinbox - renderCancel - pushButton - pushButton_2 - - - - diff --git a/dialogs/loaddialog.cpp b/dialogs/loaddialog.cpp index 706b1193a..3751ebea9 100644 --- a/dialogs/loaddialog.cpp +++ b/dialogs/loaddialog.cpp @@ -14,39 +14,40 @@ #include "mainwindow.h" LoadDialog::LoadDialog(QWidget *parent, bool autorecovery) : QDialog(parent) { + setWindowTitle("Loading..."); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); - layout->addWidget(new QLabel("Loading '" + project_url.mid(project_url.lastIndexOf('/')+1) + "'...")); + layout->addWidget(new QLabel("Loading '" + project_url.mid(project_url.lastIndexOf('/')+1) + "'...")); bar = new QProgressBar(); - bar->setValue(0); + bar->setValue(0); layout->addWidget(bar); - cancel_button = new QPushButton("Cancel"); - connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(cancel())); + cancel_button = new QPushButton("Cancel"); + connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(cancel())); - hboxLayout = new QHBoxLayout(); + hboxLayout = new QHBoxLayout(); hboxLayout->addStretch(); hboxLayout->addWidget(cancel_button); hboxLayout->addStretch(); layout->addLayout(hboxLayout); - update(); + update(); - lt = new LoadThread(this, autorecovery); - QObject::connect(lt, SIGNAL(success()), this, SLOT(thread_done())); + lt = new LoadThread(this, autorecovery); + QObject::connect(lt, SIGNAL(success()), this, SLOT(thread_done())); QObject::connect(lt, SIGNAL(error()), this, SLOT(die())); - QObject::connect(lt, SIGNAL(report_progress(int)), bar, SLOT(setValue(int))); - lt->start(); + QObject::connect(lt, SIGNAL(report_progress(int)), bar, SLOT(setValue(int))); + lt->start(); } void LoadDialog::cancel() { - lt->cancel(); - lt->wait(); + lt->cancel(); + lt->wait(); die(); } @@ -56,5 +57,5 @@ void LoadDialog::die() { } void LoadDialog::thread_done() { - accept(); + accept(); } diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index b3fabd374..cfcd0678e 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -1,5 +1,4 @@ #include "newsequencedialog.h" -#include "ui_newsequencedialog.h" #include "panels/panels.h" #include "panels/project.h" @@ -8,82 +7,70 @@ #include "project/clip.h" #include "panels/timeline.h" #include "playback/playback.h" +#include "project/media.h" #include +#include +#include +#include +#include +#include +#include +#include +#include extern "C" { #include } -NewSequenceDialog::NewSequenceDialog(QWidget *parent) : +NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : QDialog(parent), - existing_sequence(NULL), - ui(new Ui::NewSequenceDialog) + existing_item(existing) { - ui->setupUi(this); + setup_ui(); - ui->frame_rate_combobox->addItem("10 FPS", 10.0); - ui->frame_rate_combobox->addItem("12.5 FPS", 12.5); - ui->frame_rate_combobox->addItem("15 FPS", 15.0); - ui->frame_rate_combobox->addItem("23.976 FPS", 23.976); - ui->frame_rate_combobox->addItem("24 FPS", 24.0); - ui->frame_rate_combobox->addItem("25 FPS", 25.0); - ui->frame_rate_combobox->addItem("29.97 FPS", 29.97); - ui->frame_rate_combobox->addItem("30 FPS", 30.0); - ui->frame_rate_combobox->addItem("50 FPS", 50.0); - ui->frame_rate_combobox->addItem("59.94 FPS", 59.94); - ui->frame_rate_combobox->addItem("60 FPS", 60.0); - ui->frame_rate_combobox->setCurrentIndex(6); + if (existing != NULL) { + existing_sequence = existing->to_sequence(); + setWindowTitle("Editing \"" + existing_sequence->name + "\""); - ui->audio_frequency_combobox->addItem("22050 Hz", 22050); - ui->audio_frequency_combobox->addItem("24000 Hz", 24000); - ui->audio_frequency_combobox->addItem("32000 Hz", 32000); - ui->audio_frequency_combobox->addItem("44100 Hz", 44100); - ui->audio_frequency_combobox->addItem("48000 Hz", 48000); - ui->audio_frequency_combobox->addItem("88200 Hz", 88200); - ui->audio_frequency_combobox->addItem("96000 Hz", 96000); - ui->audio_frequency_combobox->setCurrentIndex(4); -} - -NewSequenceDialog::~NewSequenceDialog() -{ - delete ui; -} - -void NewSequenceDialog::set_sequence_name(const QString& s) { - ui->lineEdit->setText(s); -} - -void NewSequenceDialog::showEvent(QShowEvent *) { - if (existing_sequence != NULL) { - ui->width_numeric->setValue(existing_sequence->width); - ui->height_numeric->setValue(existing_sequence->height); + width_numeric->setValue(existing_sequence->width); + height_numeric->setValue(existing_sequence->height); int comp_rate = qRound(existing_sequence->frame_rate*100); - for (int i=0;iframe_rate_combobox->count();i++) { - if (qRound(ui->frame_rate_combobox->itemData(i).toDouble()*100) == comp_rate) { - ui->frame_rate_combobox->setCurrentIndex(i); + for (int i=0;icount();i++) { + if (qRound(frame_rate_combobox->itemData(i).toDouble()*100) == comp_rate) { + frame_rate_combobox->setCurrentIndex(i); break; } } - ui->lineEdit->setText(existing_sequence->name); - for (int i=0;iaudio_frequency_combobox->count();i++) { - if (ui->audio_frequency_combobox->itemData(i) == existing_sequence->audio_frequency) { - ui->audio_frequency_combobox->setCurrentIndex(i); + lineEdit->setText(existing_sequence->name); + for (int i=0;icount();i++) { + if (audio_frequency_combobox->itemData(i) == existing_sequence->audio_frequency) { + audio_frequency_combobox->setCurrentIndex(i); break; } } + } else { + existing_sequence = NULL; + setWindowTitle("New Sequence"); } } -void NewSequenceDialog::on_buttonBox_accepted() { +NewSequenceDialog::~NewSequenceDialog() +{} + +void NewSequenceDialog::set_sequence_name(const QString& s) { + lineEdit->setText(s); +} + +void NewSequenceDialog::create() { if (existing_sequence == NULL) { Sequence* s = new Sequence(); - s->name = ui->lineEdit->text(); - s->width = ui->width_numeric->value(); - s->height = ui->height_numeric->value(); - s->frame_rate = ui->frame_rate_combobox->currentData().toDouble(); - s->audio_frequency = ui->audio_frequency_combobox->currentData().toInt(); + s->name = lineEdit->text(); + s->width = width_numeric->value(); + s->height = height_numeric->value(); + s->frame_rate = frame_rate_combobox->currentData().toDouble(); + s->audio_frequency = audio_frequency_combobox->currentData().toInt(); s->audio_layout = AV_CH_LAYOUT_STEREO; ComboAction* ca = new ComboAction(); @@ -92,14 +79,14 @@ void NewSequenceDialog::on_buttonBox_accepted() { } else { ComboAction* ca = new ComboAction(); - double multiplier = ui->frame_rate_combobox->currentData().toDouble() / existing_sequence->frame_rate; + double multiplier = frame_rate_combobox->currentData().toDouble() / existing_sequence->frame_rate; EditSequenceCommand* esc = new EditSequenceCommand(existing_item, existing_sequence); - esc->name = ui->lineEdit->text(); - esc->width = ui->width_numeric->value(); - esc->height = ui->height_numeric->value(); - esc->frame_rate = ui->frame_rate_combobox->currentData().toDouble(); - esc->audio_frequency = ui->audio_frequency_combobox->currentData().toInt(); + esc->name = lineEdit->text(); + esc->width = width_numeric->value(); + esc->height = height_numeric->value(); + esc->frame_rate = frame_rate_combobox->currentData().toDouble(); + esc->audio_frequency = audio_frequency_combobox->currentData().toInt(); esc->audio_layout = AV_CH_LAYOUT_STEREO; ca->append(esc); @@ -112,51 +99,183 @@ void NewSequenceDialog::on_buttonBox_accepted() { undo_stack.push(ca); } + + accept(); } -void NewSequenceDialog::on_comboBox_currentIndexChanged(int index) +void NewSequenceDialog::preset_changed(int index) { switch (index) { case 0: // FILM 4K - ui->width_numeric->setValue(4096); - ui->height_numeric->setValue(2160); - + width_numeric->setValue(4096); + height_numeric->setValue(2160); break; case 1: // TV 4K - ui->width_numeric->setValue(3840); - ui->height_numeric->setValue(2160); + width_numeric->setValue(3840); + height_numeric->setValue(2160); break; case 2: // 1080p - ui->width_numeric->setValue(1920); - ui->height_numeric->setValue(1080); + width_numeric->setValue(1920); + height_numeric->setValue(1080); break; case 3: // 720p - ui->width_numeric->setValue(1280); - ui->height_numeric->setValue(720); + width_numeric->setValue(1280); + height_numeric->setValue(720); break; case 4: // 480p - ui->width_numeric->setValue(640); - ui->height_numeric->setValue(480); + width_numeric->setValue(640); + height_numeric->setValue(480); break; case 5: // 360p - ui->width_numeric->setValue(640); - ui->height_numeric->setValue(360); + width_numeric->setValue(640); + height_numeric->setValue(360); break; case 6: // 240p - ui->width_numeric->setValue(320); - ui->height_numeric->setValue(240); + width_numeric->setValue(320); + height_numeric->setValue(240); break; case 7: // 144p - ui->width_numeric->setValue(192); - ui->height_numeric->setValue(144); + width_numeric->setValue(192); + height_numeric->setValue(144); break; case 8: // NTSC (480i) - ui->width_numeric->setValue(720); - ui->height_numeric->setValue(480); + width_numeric->setValue(720); + height_numeric->setValue(480); break; case 9: // PAL (576i) - ui->width_numeric->setValue(720); - ui->height_numeric->setValue(576); + width_numeric->setValue(720); + height_numeric->setValue(576); break; } } + +void NewSequenceDialog::setup_ui() { + QVBoxLayout* verticalLayout = new QVBoxLayout(this); + + QWidget* widget = new QWidget(this); + + QHBoxLayout* horizontalLayout_2 = new QHBoxLayout(widget); + horizontalLayout_2->setContentsMargins(0, 0, 0, 0); + + horizontalLayout_2->addWidget(new QLabel("Preset:")); + + preset_combobox = new QComboBox(widget); + + preset_combobox->addItem("Film 4K"); + preset_combobox->addItem("TV 4K (Ultra HD/2160p)"); + preset_combobox->addItem("1080p"); + preset_combobox->addItem("720p"); + preset_combobox->addItem("480p"); + preset_combobox->addItem("360p"); + preset_combobox->addItem("240p"); + preset_combobox->addItem("144p"); + preset_combobox->addItem("NTSC (480i)"); + preset_combobox->addItem("PAL (576i)"); + preset_combobox->addItem("Custom"); + preset_combobox->setCurrentIndex(2); + + horizontalLayout_2->addWidget(preset_combobox); + + verticalLayout->addWidget(widget); + + QGroupBox* groupBox = new QGroupBox(this); + groupBox->setTitle("Video"); + + QGridLayout* gridLayout = new QGridLayout(groupBox); + + height_numeric = new QSpinBox(groupBox); + height_numeric->setMaximum(9999); + height_numeric->setValue(1080); + + gridLayout->addWidget(height_numeric, 1, 2, 1, 2); + + width_numeric = new QSpinBox(groupBox); + width_numeric->setMaximum(9999); + width_numeric->setValue(1920); + + gridLayout->addWidget(width_numeric, 0, 2, 1, 2); + + gridLayout->addWidget(new QLabel("Width:"), 0, 0, 1, 1); + + gridLayout->addWidget(new QLabel("Pixel Aspect Ratio:"), 4, 0, 1, 1); + + gridLayout->addWidget(new QLabel("Interlacing:"), 6, 0, 1, 1); + + gridLayout->addWidget(new QLabel("Height:"), 1, 0, 1, 2); + + par_combobox = new QComboBox(groupBox); + par_combobox->addItem("Square Pixels (1.0)"); + + gridLayout->addWidget(par_combobox, 4, 2, 1, 2); + + interlacing_combobox = new QComboBox(groupBox); + interlacing_combobox->addItem("None (Progressive)"); + interlacing_combobox->addItem("Upper Field First"); + interlacing_combobox->addItem("Lower Field First"); + + gridLayout->addWidget(interlacing_combobox, 6, 2, 1, 2); + + frame_rate_combobox = new QComboBox(groupBox); + frame_rate_combobox->addItem("10 FPS", 10.0); + frame_rate_combobox->addItem("12.5 FPS", 12.5); + frame_rate_combobox->addItem("15 FPS", 15.0); + frame_rate_combobox->addItem("23.976 FPS", 23.976); + frame_rate_combobox->addItem("24 FPS", 24.0); + frame_rate_combobox->addItem("25 FPS", 25.0); + frame_rate_combobox->addItem("29.97 FPS", 29.97); + frame_rate_combobox->addItem("30 FPS", 30.0); + frame_rate_combobox->addItem("50 FPS", 50.0); + frame_rate_combobox->addItem("59.94 FPS", 59.94); + frame_rate_combobox->addItem("60 FPS", 60.0); + frame_rate_combobox->setCurrentIndex(6); + + gridLayout->addWidget(frame_rate_combobox, 2, 2, 1, 2); + + gridLayout->addWidget(new QLabel("Frame Rate:"), 2, 0, 1, 1); + + verticalLayout->addWidget(groupBox); + + QGroupBox* groupBox_2 = new QGroupBox(this); + groupBox_2->setTitle("Audio"); + + QGridLayout* gridLayout_2 = new QGridLayout(groupBox_2); + + gridLayout_2->addWidget(new QLabel("Sample Rate: "), 0, 0, 1, 1); + + audio_frequency_combobox = new QComboBox(groupBox_2); + audio_frequency_combobox->addItem("22050 Hz", 22050); + audio_frequency_combobox->addItem("24000 Hz", 24000); + audio_frequency_combobox->addItem("32000 Hz", 32000); + audio_frequency_combobox->addItem("44100 Hz", 44100); + audio_frequency_combobox->addItem("48000 Hz", 48000); + audio_frequency_combobox->addItem("88200 Hz", 88200); + audio_frequency_combobox->addItem("96000 Hz", 96000); + audio_frequency_combobox->setCurrentIndex(4); + + gridLayout_2->addWidget(audio_frequency_combobox, 0, 1, 1, 1); + + verticalLayout->addWidget(groupBox_2); + + QWidget* widget_2 = new QWidget(this); + QHBoxLayout* horizontalLayout = new QHBoxLayout(widget_2); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + horizontalLayout->addWidget(new QLabel("Name:")); + + lineEdit = new QLineEdit(widget_2); + + horizontalLayout->addWidget(lineEdit); + + verticalLayout->addWidget(widget_2); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(this); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + buttonBox->setCenterButtons(true); + + verticalLayout->addWidget(buttonBox); + + connect(preset_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(preset_changed(int))); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(create())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +} diff --git a/dialogs/newsequencedialog.h b/dialogs/newsequencedialog.h index d6b9b2a2d..1a5cf2042 100644 --- a/dialogs/newsequencedialog.h +++ b/dialogs/newsequencedialog.h @@ -5,32 +5,39 @@ class Project; class Media; +class QComboBox; +class QSpinBox; +class QLineEdit; struct Sequence; -namespace Ui { -class NewSequenceDialog; -} - class NewSequenceDialog : public QDialog { Q_OBJECT public: - explicit NewSequenceDialog(QWidget *parent = 0); + explicit NewSequenceDialog(QWidget *parent = 0, Media* existing = 0); ~NewSequenceDialog(); - Sequence* existing_sequence; - Media* existing_item; + void set_sequence_name(const QString& s); -protected: - void showEvent(QShowEvent *); - private slots: - void on_buttonBox_accepted(); - void on_comboBox_currentIndexChanged(int index); + void create(); + void preset_changed(int index); private: - Ui::NewSequenceDialog *ui; + Sequence* existing_sequence; + Media* existing_item; + + void setup_ui(); + + QComboBox* preset_combobox; + QSpinBox* height_numeric; + QSpinBox* width_numeric; + QComboBox* par_combobox; + QComboBox* interlacing_combobox; + QComboBox* frame_rate_combobox; + QComboBox* audio_frequency_combobox; + QLineEdit* lineEdit; }; #endif // NEWSEQUENCEDIALOG_H diff --git a/dialogs/newsequencedialog.ui b/dialogs/newsequencedialog.ui deleted file mode 100644 index 3a9663340..000000000 --- a/dialogs/newsequencedialog.ui +++ /dev/null @@ -1,370 +0,0 @@ - - - NewSequenceDialog - - - - 0 - 0 - 298 - 341 - - - - New Sequence - - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Preset: - - - - - - - 2 - - - - Film 4K - - - - - TV 4K (Ultra HD/2160p) - - - - - 1080p - - - - - 720p - - - - - 480p - - - - - 360p - - - - - 240p - - - - - 144p - - - - - NTSC (480i) - - - - - PAL (576i) - - - - - Custom - - - - - - - - - - - Video - - - - - - 9999 - - - 1080 - - - - - - - - 0 - 0 - - - - 9999 - - - 1920 - - - - - - - - 0 - 0 - - - - Width: - - - - - - - - 0 - 0 - - - - Pixel Aspect Ratio: - - - - - - - - 0 - 0 - - - - Interlacing: - - - - - - - Height: - - - - - - - - 0 - 0 - - - - - Square Pixels (1.0) - - - - - - - - - None (Progressive) - - - - - Upper Field First - - - - - Lower Field First - - - - - - - - - - - Frame Rate: - - - - - - - - - - - 0 - 0 - - - - Audio - - - - - - - 0 - 0 - - - - Sample Rate: - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Name: - - - - - - - Sequence 01 - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - true - - - - - - - comboBox - width_numeric - height_numeric - frame_rate_combobox - par_combobox - interlacing_combobox - audio_frequency_combobox - lineEdit - - - - - buttonBox - accepted() - NewSequenceDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - NewSequenceDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 81bd53211..3c2e4a3df 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -1,83 +1,174 @@ #include "preferencesdialog.h" -#include "ui_preferencesdialog.h" #include "io/config.h" #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -KeySequenceEditor::KeySequenceEditor(QAction* a) - : QKeySequenceEdit(0), action(a) { - setKeySequence(action->shortcut()); - connect(this, SIGNAL(editingFinished()), this, SLOT(set_action_shortcut())); +KeySequenceEditor::KeySequenceEditor(QWidget* parent, QAction* a) + : QKeySequenceEdit(parent), action(a) { + setKeySequence(action->shortcut()); + //connect(this, SIGNAL(editingFinished()), this, SLOT(set_action_shortcut())); } void KeySequenceEditor::set_action_shortcut() { - action->setShortcut(keySequence()); + action->setShortcut(keySequence()); } PreferencesDialog::PreferencesDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::PreferencesDialog) + QDialog(parent) { - ui->setupUi(this); + setWindowTitle("Preferences"); + setup_ui(); - ui->accurateSeekButton->setChecked(!config.fast_seeking); - ui->fastSeekButton->setChecked(config.fast_seeking); - ui->recordingComboBox->setCurrentIndex(config.recording_mode - 1); - ui->imgSeqFormatEdit->setText(config.img_seq_formats); + accurateSeekButton->setChecked(!config.fast_seeking); + fastSeekButton->setChecked(config.fast_seeking); + recordingComboBox->setCurrentIndex(config.recording_mode - 1); + imgSeqFormatEdit->setText(config.img_seq_formats); } -PreferencesDialog::~PreferencesDialog() { - delete ui; +PreferencesDialog::~PreferencesDialog() {} + +void PreferencesDialog::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent) { + QList actions = menu->actions(); + for (int i=0;iisSeparator()) { + QTreeWidgetItem* item = new QTreeWidgetItem(); + item->setText(0, a->text().replace("&", "")); + + parent->addChild(item); + + if (a->menu() != NULL) { + setup_kbd_shortcut_worker(a->menu(), item); + } else { + key_shortcut_items.append(item); + key_shortcut_actions.append(a); + } + } + } } void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { - ui->treeWidget->clear(); - QList menus = menubar->findChildren(); + QList menus = menubar->actions(); - // caching for parent-child pairing - QVector added_action_items; - QVector added_actions; + for (int i=0;imenu(); - for (int i=0;iparent() != menubar) { - for (int j=0;jmenu() == menu) { - item = added_action_items.at(j); - break; - } - } - } - if (menu->parent() == menubar || item == NULL) { - item = new QTreeWidgetItem(); - item->setText(0, menu->title().replace("&", "")); - ui->treeWidget->addTopLevelItem(item); - } - for (int j=0;jactions().size();j++) { - QAction* action = menu->actions().at(j); - if (!action->isSeparator()) { - QTreeWidgetItem* child = new QTreeWidgetItem(); - child->setText(0, action->text().replace("&", "")); - item->addChild(child); + QTreeWidgetItem* item = new QTreeWidgetItem(); + item->setText(0, menu->title().replace("&", "")); - added_actions.append(action); - added_action_items.append(child); - } - } - } - for (int i=0;imenu() == NULL) { - KeySequenceEditor* editor = new KeySequenceEditor(added_actions.at(i)); - ui->treeWidget->setItemWidget(added_action_items.at(i), 1, editor); - } - } + keyboard_tree->addTopLevelItem(item); + + setup_kbd_shortcut_worker(menu, item); + } + + for (int i=0;isetItemWidget(key_shortcut_items.at(i), 1, editor); + key_shortcut_fields.append(editor); + } } -void PreferencesDialog::on_buttonBox_accepted() { - config.recording_mode = ui->recordingComboBox->currentIndex() + 1; - config.img_seq_formats = ui->imgSeqFormatEdit->text(); - config.fast_seeking = ui->fastSeekButton->isChecked(); +void PreferencesDialog::save() { + config.recording_mode = recordingComboBox->currentIndex() + 1; + config.img_seq_formats = imgSeqFormatEdit->text(); + config.fast_seeking = fastSeekButton->isChecked(); + + // save keyboard shortcuts + for (int i=0;iset_action_shortcut(); + } + + accept(); +} + +void PreferencesDialog::setup_ui() { + QVBoxLayout* verticalLayout = new QVBoxLayout(this); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + QTabWidget* tabWidget = new QTabWidget(this); + tabWidget->setObjectName(QStringLiteral("tabWidget")); + + QTabWidget* tab = new QTabWidget(); + QGridLayout* gridLayout_2 = new QGridLayout(tab); + + gridLayout_2->setObjectName(QStringLiteral("gridLayout_2")); + + gridLayout_2->addWidget(new QLabel("Image sequence formats:"), 0, 0, 1, 1); + + imgSeqFormatEdit = new QLineEdit(tab); + + gridLayout_2->addWidget(imgSeqFormatEdit, 0, 1, 1, 1); + + gridLayout_2->addWidget(new QLabel("Audio Recording:"), 1, 0, 1, 1); + + recordingComboBox = new QComboBox(tab); + recordingComboBox->addItem("Mono"); + recordingComboBox->addItem("Stereo"); + recordingComboBox->setObjectName(QStringLiteral("recordingComboBox")); + + gridLayout_2->addWidget(recordingComboBox, 1, 1, 1, 1); + + tabWidget->addTab(tab, "General"); + QWidget* tab_2 = new QWidget(); + tabWidget->addTab(tab_2, "Behavior"); + QWidget* tab_4 = new QWidget(); + QVBoxLayout* verticalLayout_2 = new QVBoxLayout(tab_4); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); + QGroupBox* groupBox = new QGroupBox(tab_4); + groupBox->setTitle("Seeking"); + groupBox->setObjectName(QStringLiteral("groupBox")); + QVBoxLayout* verticalLayout_3 = new QVBoxLayout(groupBox); + verticalLayout_3->setObjectName(QStringLiteral("verticalLayout_3")); + accurateSeekButton = new QRadioButton(groupBox); + accurateSeekButton->setText("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)"); + accurateSeekButton->setObjectName(QStringLiteral("accurateSeekButton")); + + verticalLayout_3->addWidget(accurateSeekButton); + + fastSeekButton = new QRadioButton(groupBox); + fastSeekButton->setText("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)"); + fastSeekButton->setObjectName(QStringLiteral("fastSeekButton")); + + verticalLayout_3->addWidget(fastSeekButton); + + verticalLayout_2->addWidget(groupBox); + + tabWidget->addTab(tab_4, "Playback"); + QWidget* tab_3 = new QWidget(); + QHBoxLayout* horizontalLayout = new QHBoxLayout(tab_3); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + keyboard_tree = new QTreeWidget(); + QTreeWidgetItem* tree_header = keyboard_tree->headerItem(); + tree_header->setText(0, "Action"); + tree_header->setText(1, "Shortcut"); + horizontalLayout->addWidget(keyboard_tree); + + tabWidget->addTab(tab_3, "Keyboard"); + + verticalLayout->addWidget(tabWidget); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(this); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(save())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + tabWidget->setCurrentIndex(2); } diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 012f9b17a..b0560a247 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -4,36 +4,48 @@ #include #include class QMenuBar; +class QLineEdit; +class QComboBox; +class QRadioButton; +class QTreeWidget; +class QTreeWidgetItem; +class QMenu; -namespace Ui { -class PreferencesDialog; -} +class KeySequenceEditor : public QKeySequenceEdit { + Q_OBJECT +public: + KeySequenceEditor(QWidget *parent, QAction* a); + void set_action_shortcut(); +private: + QAction* action; +}; class PreferencesDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: - explicit PreferencesDialog(QWidget *parent = 0); - ~PreferencesDialog(); + explicit PreferencesDialog(QWidget *parent = 0); + ~PreferencesDialog(); - void setup_kbd_shortcuts(QMenuBar* menu); + void setup_kbd_shortcuts(QMenuBar* menu); private slots: - void on_buttonBox_accepted(); + void save(); private: - Ui::PreferencesDialog *ui; -}; + void setup_ui(); + void setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent); -class KeySequenceEditor : public QKeySequenceEdit { - Q_OBJECT -public: - KeySequenceEditor(QAction* a); -private slots: - void set_action_shortcut(); -private: - QAction* action; + QLineEdit* imgSeqFormatEdit; + QComboBox* recordingComboBox; + QRadioButton* accurateSeekButton; + QRadioButton* fastSeekButton; + QTreeWidget* keyboard_tree; + + QVector key_shortcut_actions; + QVector key_shortcut_items; + QVector key_shortcut_fields; }; #endif // PREFERENCESDIALOG_H diff --git a/dialogs/preferencesdialog.ui b/dialogs/preferencesdialog.ui deleted file mode 100644 index 814d3b4aa..000000000 --- a/dialogs/preferencesdialog.ui +++ /dev/null @@ -1,179 +0,0 @@ - - - PreferencesDialog - - - - 0 - 0 - 693 - 491 - - - - Dialog - - - - - - 2 - - - - General - - - - - - Image sequence formats: - - - - - - - - - - Audio Recording: - - - - - - - - Mono - - - - - Stereo - - - - - - - - - Behavior - - - - - Playback - - - - - - Seeking - - - - - - Accurate Seeking -Always show the correct frame (visual may pause briefly as correct frame is retrieved) - - - - - - - Fast Seeking -Seek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export) - - - - - - - - - - - Keyboard - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Action - - - - - Shortcut - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - PreferencesDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - PreferencesDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/mainwindow.cpp b/mainwindow.cpp index 59ea56faa..09a156eb0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,6 +12,7 @@ #include "ui/sourcetable.h" #include "ui/viewerwidget.h" #include "ui/sourceiconview.h" +#include "ui/timelineheader.h" #include "panels/panels.h" #include "panels/project.h" @@ -29,8 +30,6 @@ #include "playback/audio.h" #include "playback/playback.h" -#include "ui_timeline.h" - #include "debug.h" #include @@ -45,6 +44,9 @@ #include #include #include +#include +#include +#include MainWindow* mainWindow; @@ -273,8 +275,8 @@ void MainWindow::show_about() { void MainWindow::delete_slot() { - if (panel_timeline->ui->headers->hasFocus()) { - panel_timeline->ui->headers->delete_markers(); + if (panel_timeline->headers->hasFocus()) { + panel_timeline->headers->delete_markers(); } else if (panel_timeline->focused()) { panel_timeline->delete_selection(sequence->selections, false); } else if (panel_effect_controls->is_focused()) { @@ -649,41 +651,41 @@ void MainWindow::setup_menus() { pointer_tool_action = tools_menu->addAction("Pointer Tool", this, SLOT(menu_click_button()), QKeySequence("V")); pointer_tool_action->setCheckable(true); - pointer_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolArrowButton)); + pointer_tool_action->setData(reinterpret_cast(panel_timeline->toolArrowButton)); edit_tool_action = tools_menu->addAction("Edit Tool", this, SLOT(menu_click_button()), QKeySequence("X")); edit_tool_action->setCheckable(true); - edit_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolEditButton)); + edit_tool_action->setData(reinterpret_cast(panel_timeline->toolEditButton)); ripple_tool_action = tools_menu->addAction("Ripple Tool", this, SLOT(menu_click_button()), QKeySequence("B")); ripple_tool_action->setCheckable(true); - ripple_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolRippleButton)); + ripple_tool_action->setData(reinterpret_cast(panel_timeline->toolRippleButton)); razor_tool_action = tools_menu->addAction("Razor Tool", this, SLOT(menu_click_button()), QKeySequence("C")); razor_tool_action->setCheckable(true); - razor_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolRazorButton)); + razor_tool_action->setData(reinterpret_cast(panel_timeline->toolRazorButton)); slip_tool_action = tools_menu->addAction("Slip Tool", this, SLOT(menu_click_button()), QKeySequence("Y")); slip_tool_action->setCheckable(true); - slip_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolSlipButton)); + slip_tool_action->setData(reinterpret_cast(panel_timeline->toolSlipButton)); slide_tool_action = tools_menu->addAction("Slide Tool", this, SLOT(menu_click_button()), QKeySequence("U")); slide_tool_action->setCheckable(true); - slide_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolSlideButton)); + slide_tool_action->setData(reinterpret_cast(panel_timeline->toolSlideButton)); hand_tool_action = tools_menu->addAction("Hand Tool", this, SLOT(menu_click_button()), QKeySequence("H")); hand_tool_action->setCheckable(true); - hand_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolHandButton)); + hand_tool_action->setData(reinterpret_cast(panel_timeline->toolHandButton)); transition_tool_action = tools_menu->addAction("Transition Tool", this, SLOT(menu_click_button()), QKeySequence("T")); transition_tool_action->setCheckable(true); - transition_tool_action->setData(reinterpret_cast(panel_timeline->ui->toolTransitionButton)); + transition_tool_action->setData(reinterpret_cast(panel_timeline->toolTransitionButton)); tools_menu->addSeparator(); snap_toggle = tools_menu->addAction("Enable Snapping", this, SLOT(menu_click_button()), QKeySequence("S")); snap_toggle->setCheckable(true); - snap_toggle->setData(reinterpret_cast(panel_timeline->ui->snappingButton)); + snap_toggle->setData(reinterpret_cast(panel_timeline->snappingButton)); tools_menu->addSeparator(); diff --git a/olive.pro b/olive.pro index d59e863b5..1ab9f79e8 100644 --- a/olive.pro +++ b/olive.pro @@ -187,13 +187,7 @@ HEADERS += \ project/sourcescommon.h \ ui/keyframenavigator.h -FORMS += \ - panels/timeline.ui \ - dialogs/aboutdialog.ui \ - dialogs/newsequencedialog.ui \ - dialogs/exportdialog.ui \ - dialogs/preferencesdialog.ui \ - dialogs/demonotice.ui +FORMS += win32 { RC_FILE = icons/resources.rc @@ -223,8 +217,6 @@ unix:!mac:target.path = $$PREFIX/bin effects.files = $$PWD/effects/*.frag $$PWD/effects/*.xml $$PWD/effects/*.vert unix:!mac:effects.path = $$PREFIX/share/olive-editor/effects -INSTALLS += target effects - unix:!mac { metainfo.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.appdata.xml metainfo.path = $$PREFIX/share/metainfo @@ -248,5 +240,5 @@ unix:!mac { icon512.path = $$PREFIX/share/icons/hicolor/512x512/apps icon1024.files = $$PWD/packaging/linux/icons/1024x1024/org.olivevideoeditor.Olive.png icon1024.path = $$PREFIX/share/icons/hicolor/1024x1024/apps - INSTALLS += metainfo desktop mime icon16 icon32 icon48 icon64 icon128 icon256 icon512 icon1024 -} \ No newline at end of file + INSTALLS += target effects metainfo desktop mime icon16 icon32 icon48 icon64 icon128 icon256 icon512 icon1024 +} diff --git a/panels/project.cpp b/panels/project.cpp index 7a3f36510..5b8d24235 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -295,10 +295,7 @@ void Project::open_properties() { break; case MEDIA_TYPE_SEQUENCE: { - NewSequenceDialog nsd(this); - Sequence* s = item->to_sequence(); - nsd.existing_sequence = s; - nsd.existing_item = item; + NewSequenceDialog nsd(this, item); nsd.exec(); } break; diff --git a/panels/project.h b/panels/project.h index 6516ff39e..81a26c628 100644 --- a/panels/project.h +++ b/panels/project.h @@ -27,10 +27,6 @@ class SourcesCommon; #define LOAD_TYPE_VERSION 69 #define LOAD_TYPE_URL 70 -namespace Ui { -class Project; -} - extern QString autorecovery_filename; extern QString project_url; extern QStringList recent_projects; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index e768f6195..d0f1d171a 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -1,5 +1,4 @@ #include "timeline.h" -#include "ui_timeline.h" #include "panels/panels.h" #include "panels/project.h" @@ -19,6 +18,9 @@ #include "project/transition.h" #include "project/footage.h" #include "io/clipboard.h" +#include "ui/timelineheader.h" +#include "ui/resizablescrollbar.h" +#include "ui/audiomonitor.h" #include "debug.h" #include @@ -31,6 +33,9 @@ #include #include #include +#include +#include +#include long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate) { return qRound(((double)framenumber/source_frame_rate)*target_frame_rate); @@ -70,55 +75,39 @@ Timeline::Timeline(QWidget *parent) : transition_tool_post_clip(-1), hand_moving(false), block_repaints(false), - ui(new Ui::Timeline), last_frame(0), scroll(0) { + setup_ui(); + default_track_height = (QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT; - ui->setupUi(this); + headers->viewer = panel_sequence_viewer; - ui->headers->viewer = panel_sequence_viewer; + video_area->bottom_align = true; + video_area->scrollBar = videoScrollbar; + audio_area->scrollBar = audioScrollbar; - /* --- TEMPORARY --- - * I feel like the rolling edit tool is unnecessary, but just - * in case I change my mind, I'm leaving all the functionality - * intact and only hiding the UI to get to it. Still deciding - * on this one but the pointer tool literally does the same - * functionality. - */ - ui->toolRollingButton->setVisible(false); - ui->toolRollingButton->setEnabled(false); - /* --- */ + tool_buttons.append(toolArrowButton); + tool_buttons.append(toolEditButton); + tool_buttons.append(toolRippleButton); + tool_buttons.append(toolRazorButton); + tool_buttons.append(toolSlipButton); + tool_buttons.append(toolSlideButton); + tool_buttons.append(toolTransitionButton); + tool_buttons.append(toolHandButton); - ui->video_area->bottom_align = true; - ui->video_area->scrollBar = ui->videoScrollbar; - ui->audio_area->scrollBar = ui->audioScrollbar; + toolArrowButton->click(); - tool_buttons.append(ui->toolArrowButton); - tool_buttons.append(ui->toolEditButton); - tool_buttons.append(ui->toolRippleButton); - tool_buttons.append(ui->toolRazorButton); - tool_buttons.append(ui->toolSlipButton); - tool_buttons.append(ui->toolRollingButton); - tool_buttons.append(ui->toolSlideButton); - tool_buttons.append(ui->toolTransitionButton); - tool_buttons.append(ui->toolHandButton); - - ui->toolArrowButton->click(); - - connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(setScroll(int))); - connect(ui->videoScrollbar, SIGNAL(valueChanged(int)), ui->video_area, SLOT(setScroll(int))); - connect(ui->audioScrollbar, SIGNAL(valueChanged(int)), ui->audio_area, SLOT(setScroll(int))); - connect(ui->horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double))); + connect(horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(setScroll(int))); + connect(videoScrollbar, SIGNAL(valueChanged(int)), video_area, SLOT(setScroll(int))); + connect(audioScrollbar, SIGNAL(valueChanged(int)), audio_area, SLOT(setScroll(int))); + connect(horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double))); update_sequence(); } -Timeline::~Timeline() -{ - delete ui; -} +Timeline::~Timeline() {} void Timeline::previous_cut() { if (sequence->playhead > 0) { @@ -159,7 +148,7 @@ void Timeline::toggle_show_all() { showing_all = !showing_all; if (showing_all) { old_zoom = zoom; - set_zoom_value((double) (ui->timeline_area->width() - 200) / (double) sequence->getEndFrame()); + set_zoom_value((double) (timeline_area->width() - 200) / (double) sequence->getEndFrame()); } else { set_zoom_value(old_zoom); } @@ -398,12 +387,12 @@ void Timeline::update_sequence() { for (int i=0;isetEnabled(!null_sequence); } - ui->snappingButton->setEnabled(!null_sequence); - ui->pushButton_4->setEnabled(!null_sequence); - ui->pushButton_5->setEnabled(!null_sequence); - ui->recordButton->setEnabled(!null_sequence); - ui->addButton->setEnabled(!null_sequence); - ui->headers->setEnabled(!null_sequence); + snappingButton->setEnabled(!null_sequence); + zoomInButton->setEnabled(!null_sequence); + zoomOutButton->setEnabled(!null_sequence); + recordButton->setEnabled(!null_sequence); + addButton->setEnabled(!null_sequence); + headers->setEnabled(!null_sequence); if (null_sequence) { setWindowTitle("Timeline: "); @@ -418,7 +407,7 @@ int Timeline::get_snap_range() { } bool Timeline::focused() { - return (sequence != NULL && (ui->headers->hasFocus() || ui->video_area->hasFocus() || ui->audio_area->hasFocus())); + return (sequence != NULL && (headers->hasFocus() || video_area->hasFocus() || audio_area->hasFocus())); } void Timeline::repaint_timeline() { @@ -426,19 +415,19 @@ void Timeline::repaint_timeline() { bool draw = true; if (sequence != NULL - && !ui->horizontalScrollBar->isSliderDown() - && !ui->horizontalScrollBar->is_resizing() + && !horizontalScrollBar->isSliderDown() + && !horizontalScrollBar->is_resizing() && panel_sequence_viewer->playing && !zoom_just_changed) { // auto scroll if (config.autoscroll == AUTOSCROLL_PAGE_SCROLL) { int playhead_x = panel_timeline->getTimelineScreenPointFromFrame(sequence->playhead); - if (playhead_x < 0 || playhead_x > (ui->editAreas->width() - ui->videoScrollbar->width())) { - ui->horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, sequence->playhead)); + if (playhead_x < 0 || playhead_x > (editAreas->width() - videoScrollbar->width())) { + horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, sequence->playhead)); draw = false; } } else if (config.autoscroll == AUTOSCROLL_SMOOTH_SCROLL) { - if (center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead)) { + if (center_scroll_to_playhead(horizontalScrollBar, zoom, sequence->playhead)) { draw = false; } } @@ -447,15 +436,15 @@ void Timeline::repaint_timeline() { zoom_just_changed = false; if (draw) { - ui->headers->update(); - ui->video_area->update(); - ui->audio_area->update(); + headers->update(); + video_area->update(); + audio_area->update(); if (sequence != NULL) { set_sb_max(); if (last_frame != sequence->playhead) { - ui->audio_monitor->update(); + audio_monitor->update(); last_frame = sequence->playhead; } } @@ -573,13 +562,13 @@ void Timeline::delete_selection(QVector& selections, bool ripple_dele void Timeline::set_zoom_value(double v) { zoom = v; zoom_just_changed = true; - ui->headers->update_zoom(zoom); + headers->update_zoom(zoom); repaint_timeline(); // TODO find a way to gradually move towards target_scroll instead of just centering it? - if (!ui->horizontalScrollBar->is_resizing()) - center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead); + if (!horizontalScrollBar->is_resizing()) + center_scroll_to_playhead(horizontalScrollBar, zoom, sequence->playhead); } void Timeline::set_zoom(bool in) { @@ -602,13 +591,11 @@ QVector Timeline::get_tracks_of_linked_clips(int i) { return tracks; } -void Timeline::on_pushButton_4_clicked() -{ +void Timeline::zoom_in() { set_zoom(true); } -void Timeline::on_pushButton_5_clicked() -{ +void Timeline::zoom_out() { set_zoom(false); } @@ -623,7 +610,7 @@ bool Timeline::is_clip_selected(Clip* clip, bool containing) { return false; } -void Timeline::on_snappingButton_toggled(bool checked) { +void Timeline::snapping_clicked(bool checked) { snapping = checked; } @@ -1445,59 +1432,7 @@ int Timeline::getTimelineScreenPointFromFrame(long frame) { return getScreenPointFromFrame(zoom, frame) - scroll; } -void Timeline::on_toolArrowButton_clicked() { - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::ArrowCursor); - tool = TIMELINE_TOOL_POINTER; - creating = false; -} - -void Timeline::on_toolEditButton_clicked() { - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::IBeamCursor); - tool = TIMELINE_TOOL_EDIT; - creating = false; -} - -void Timeline::on_toolRippleButton_clicked() { - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::ArrowCursor); - tool = TIMELINE_TOOL_RIPPLE; - creating = false; -} - -void Timeline::on_toolRollingButton_clicked() { - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::ArrowCursor); - tool = TIMELINE_TOOL_ROLLING; - creating = false; -} - -void Timeline::on_toolRazorButton_clicked() -{ - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::IBeamCursor); - tool = TIMELINE_TOOL_RAZOR; - creating = false; -} - -void Timeline::on_toolSlipButton_clicked() -{ - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::ArrowCursor); - tool = TIMELINE_TOOL_SLIP; - creating = false; -} - -void Timeline::on_toolSlideButton_clicked() -{ - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::ArrowCursor); - tool = TIMELINE_TOOL_SLIDE; - creating = false; -} - -void Timeline::on_addButton_clicked() { +void Timeline::add_btn_click() { QMenu add_menu(this); QAction* titleMenuItem = new QAction(&add_menu); @@ -1527,23 +1462,23 @@ void Timeline::on_addButton_clicked() { noiseMenuItem->setData(ADD_OBJ_NOISE); add_menu.addAction(noiseMenuItem); - connect(&add_menu, SIGNAL(triggered(QAction*)), this, SLOT(addMenuItem(QAction*))); + connect(&add_menu, SIGNAL(triggered(QAction*)), this, SLOT(add_menu_item(QAction*))); add_menu.exec(QCursor::pos()); } -void Timeline::addMenuItem(QAction* action) { +void Timeline::add_menu_item(QAction* action) { creating = true; creating_object = action->data().toInt(); } void Timeline::setScroll(int s) { scroll = s; - ui->headers->set_scroll(s); + headers->set_scroll(s); repaint_timeline(); } -void Timeline::on_recordButton_clicked() { +void Timeline::record_btn_click() { if (project_url.isEmpty()) { QMessageBox::critical(this, "Unsaved Project", "You must save this project before you can record audio in it.", QMessageBox::Ok); } else { @@ -1552,7 +1487,7 @@ void Timeline::on_recordButton_clicked() { } } -void Timeline::on_toolTransitionButton_clicked() { +void Timeline::transition_tool_click() { creating = false; QMenu transition_menu(this); @@ -1579,7 +1514,7 @@ void Timeline::on_toolTransitionButton_clicked() { connect(&transition_menu, SIGNAL(triggered(QAction*)), this, SLOT(transition_menu_select(QAction*))); - ui->toolTransitionButton->setChecked(false); + toolTransitionButton->setChecked(false); transition_menu.exec(QCursor::pos()); } @@ -1594,9 +1529,9 @@ void Timeline::transition_menu_select(QAction* a) { } decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::CrossCursor); + timeline_area->setCursor(Qt::CrossCursor); tool = TIMELINE_TOOL_TRANSITION; - ui->toolTransitionButton->setChecked(true); + toolTransitionButton->setChecked(true); } void Timeline::resize_move(double z) { @@ -1604,7 +1539,242 @@ void Timeline::resize_move(double z) { } void Timeline::set_sb_max() { - ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequence->getEndFrame(), ui->editAreas->width() - getScreenPointFromFrame(zoom, 200)); + headers->set_scrollbar_max(horizontalScrollBar, sequence->getEndFrame(), editAreas->width() - getScreenPointFromFrame(zoom, 200)); +} + +void Timeline::setup_ui() { + QWidget* dockWidgetContents = new QWidget(); + + QHBoxLayout* horizontalLayout = new QHBoxLayout(dockWidgetContents); + horizontalLayout->setSpacing(0); + horizontalLayout->setContentsMargins(0, 0, 0, 0); + + QWidget* tool_buttons = new QWidget(dockWidgetContents); + tool_buttons->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); + + QVBoxLayout* tool_buttons_layout = new QVBoxLayout(tool_buttons); + tool_buttons_layout->setSpacing(4); + tool_buttons_layout->setContentsMargins(0, 0, 0, 0); + + toolArrowButton = new QPushButton(tool_buttons); + QIcon arrow_icon; + arrow_icon.addFile(QStringLiteral(":/icons/arrow.png"), QSize(), QIcon::Normal, QIcon::Off); + arrow_icon.addFile(QStringLiteral(":/icons/arrow-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); + toolArrowButton->setIcon(arrow_icon); + toolArrowButton->setCheckable(true); + toolArrowButton->setToolTip("Pointer Tool (V)"); + toolArrowButton->setProperty("tool", TIMELINE_TOOL_POINTER); + connect(toolArrowButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolArrowButton); + + toolEditButton = new QPushButton(tool_buttons); + QIcon icon1; + icon1.addFile(QStringLiteral(":/icons/beam.png"), QSize(), QIcon::Normal, QIcon::Off); + icon1.addFile(QStringLiteral(":/icons/beam-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); + toolEditButton->setIcon(icon1); + toolEditButton->setCheckable(true); + toolEditButton->setToolTip("Edit Tool (X)"); + toolEditButton->setProperty("tool", TIMELINE_TOOL_EDIT); + connect(toolEditButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolEditButton); + + toolRippleButton = new QPushButton(tool_buttons); + QIcon icon2; + icon2.addFile(QStringLiteral(":/icons/ripple.png"), QSize(), QIcon::Normal, QIcon::Off); + icon2.addFile(QStringLiteral(":/icons/ripple-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); + toolRippleButton->setIcon(icon2); + toolRippleButton->setCheckable(true); + toolRippleButton->setToolTip("Ripple Tool (B)"); + toolRippleButton->setProperty("tool", TIMELINE_TOOL_RIPPLE); + connect(toolRippleButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolRippleButton); + + toolRazorButton = new QPushButton(tool_buttons); + QIcon icon4; + icon4.addFile(QStringLiteral(":/icons/razor.png"), QSize(), QIcon::Normal, QIcon::Off); + icon4.addFile(QStringLiteral(":/icons/razor-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); + toolRazorButton->setIcon(icon4); + toolRazorButton->setCheckable(true); + toolRazorButton->setToolTip("Razor Tool (C)"); + toolRazorButton->setProperty("tool", TIMELINE_TOOL_RAZOR); + connect(toolRazorButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolRazorButton); + + toolSlipButton = new QPushButton(tool_buttons); + QIcon icon5; + icon5.addFile(QStringLiteral(":/icons/slip.png"), QSize(), QIcon::Normal, QIcon::On); + icon5.addFile(QStringLiteral(":/icons/slip-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + toolSlipButton->setIcon(icon5); + toolSlipButton->setCheckable(true); + toolSlipButton->setToolTip("Slip Tool (Y)"); + toolSlipButton->setProperty("tool", TIMELINE_TOOL_SLIP); + connect(toolSlipButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolSlipButton); + + toolSlideButton = new QPushButton(tool_buttons); + QIcon icon6; + icon6.addFile(QStringLiteral(":/icons/slide.png"), QSize(), QIcon::Normal, QIcon::On); + icon6.addFile(QStringLiteral(":/icons/slide-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + toolSlideButton->setIcon(icon6); + toolSlideButton->setCheckable(true); + toolSlideButton->setToolTip("Slide Tool (U)"); + toolSlideButton->setProperty("tool", TIMELINE_TOOL_SLIDE); + connect(toolSlideButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolSlideButton); + + toolHandButton = new QPushButton(tool_buttons); + QIcon icon7; + icon7.addFile(QStringLiteral(":/icons/hand.png"), QSize(), QIcon::Normal, QIcon::On); + icon7.addFile(QStringLiteral(":/icons/hand-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + toolHandButton->setIcon(icon7); + toolHandButton->setCheckable(true); + toolHandButton->setToolTip("Hand Tool (H)"); + toolHandButton->setProperty("tool", TIMELINE_TOOL_HAND); + connect(toolHandButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); + tool_buttons_layout->addWidget(toolHandButton); + + toolTransitionButton = new QPushButton(tool_buttons); + QIcon icon8; + icon8.addFile(QStringLiteral(":/icons/transition-tool.png"), QSize(), QIcon::Normal, QIcon::On); + icon8.addFile(QStringLiteral(":/icons/transition-tool-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + toolTransitionButton->setIcon(icon8); + toolTransitionButton->setCheckable(true); + toolTransitionButton->setToolTip("Transition Tool (T)"); + connect(toolTransitionButton, SIGNAL(clicked(bool)), this, SLOT(transition_tool_click())); + tool_buttons_layout->addWidget(toolTransitionButton); + + snappingButton = new QPushButton(tool_buttons); + QIcon icon9; + icon9.addFile(QStringLiteral(":/icons/magnet.png"), QSize(), QIcon::Normal, QIcon::On); + icon9.addFile(QStringLiteral(":/icons/magnet-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + snappingButton->setIcon(icon9); + snappingButton->setCheckable(true); + snappingButton->setChecked(true); + snappingButton->setToolTip("Snapping (S)"); + connect(snappingButton, SIGNAL(toggled(bool)), this, SLOT(snapping_clicked(bool))); + tool_buttons_layout->addWidget(snappingButton); + + zoomInButton = new QPushButton(tool_buttons); + QIcon icon10; + icon10.addFile(QStringLiteral(":/icons/zoomin.png"), QSize(), QIcon::Normal, QIcon::On); + icon10.addFile(QStringLiteral(":/icons/zoomin-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + zoomInButton->setIcon(icon10); + zoomInButton->setToolTip("Zoom In (=)"); + connect(zoomInButton, SIGNAL(clicked(bool)), this, SLOT(zoom_in())); + tool_buttons_layout->addWidget(zoomInButton); + + zoomOutButton = new QPushButton(tool_buttons); + QIcon icon11; + icon11.addFile(QStringLiteral(":/icons/zoomout.png"), QSize(), QIcon::Normal, QIcon::On); + icon11.addFile(QStringLiteral(":/icons/zoomout-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + zoomOutButton->setIcon(icon11); + zoomOutButton->setToolTip("Zoom Out (-)"); + connect(zoomOutButton, SIGNAL(clicked(bool)), this, SLOT(zoom_out())); + tool_buttons_layout->addWidget(zoomOutButton); + + recordButton = new QPushButton(tool_buttons); + QIcon icon12; + icon12.addFile(QStringLiteral(":/icons/record.png"), QSize(), QIcon::Normal, QIcon::On); + icon12.addFile(QStringLiteral(":/icons/record-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + recordButton->setIcon(icon12); + recordButton->setToolTip("Record audio"); + connect(recordButton, SIGNAL(clicked(bool)), this, SLOT(record_btn_click())); + + tool_buttons_layout->addWidget(recordButton); + + addButton = new QPushButton(tool_buttons); + QIcon icon13; + icon13.addFile(QStringLiteral(":/icons/add-button.png"), QSize(), QIcon::Normal, QIcon::On); + icon13.addFile(QStringLiteral(":/icons/add-button-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); + addButton->setIcon(icon13); + addButton->setToolTip("Add title, solid, bars, etc."); + connect(addButton, SIGNAL(clicked()), this, SLOT(add_btn_click())); + tool_buttons_layout->addWidget(addButton); + + tool_buttons_layout->addStretch(); + + horizontalLayout->addWidget(tool_buttons); + + timeline_area = new QWidget(dockWidgetContents); + QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum); + sizePolicy2.setHorizontalStretch(1); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(timeline_area->sizePolicy().hasHeightForWidth()); + timeline_area->setSizePolicy(sizePolicy2); + QVBoxLayout* timeline_area_layout = new QVBoxLayout(timeline_area); + timeline_area_layout->setSpacing(0); + timeline_area_layout->setContentsMargins(0, 0, 0, 0); + headers = new TimelineHeader(timeline_area); + + timeline_area_layout->addWidget(headers); + + editAreas = new QWidget(timeline_area); + QHBoxLayout* editAreaLayout = new QHBoxLayout(editAreas); + editAreaLayout->setSpacing(0); + editAreaLayout->setContentsMargins(0, 0, 0, 0); + QSplitter* splitter = new QSplitter(editAreas); + splitter->setOrientation(Qt::Vertical); + QWidget* videoContainer = new QWidget(splitter); + QHBoxLayout* videoContainerLayout = new QHBoxLayout(videoContainer); + videoContainerLayout->setSpacing(0); + videoContainerLayout->setObjectName(QStringLiteral("horizontalLayout_2")); + videoContainerLayout->setContentsMargins(0, 0, 0, 0); + video_area = new TimelineWidget(videoContainer); + video_area->setObjectName(QStringLiteral("video_area")); + video_area->setFocusPolicy(Qt::ClickFocus); + + videoContainerLayout->addWidget(video_area); + + videoScrollbar = new QScrollBar(videoContainer); + videoScrollbar->setObjectName(QStringLiteral("videoScrollbar")); + videoScrollbar->setMaximum(0); + videoScrollbar->setSingleStep(20); + videoScrollbar->setPageStep(1826); + videoScrollbar->setOrientation(Qt::Vertical); + + videoContainerLayout->addWidget(videoScrollbar); + + splitter->addWidget(videoContainer); + + QWidget* audioContainer = new QWidget(splitter); + QHBoxLayout* audioContainerLayout = new QHBoxLayout(audioContainer); + audioContainerLayout->setSpacing(0); + audioContainerLayout->setContentsMargins(0, 0, 0, 0); + audio_area = new TimelineWidget(audioContainer); + audio_area->setObjectName(QStringLiteral("audio_area")); + audio_area->setFocusPolicy(Qt::ClickFocus); + + audioContainerLayout->addWidget(audio_area); + + audioScrollbar = new QScrollBar(audioContainer); + audioScrollbar->setMaximum(0); + audioScrollbar->setOrientation(Qt::Vertical); + + audioContainerLayout->addWidget(audioScrollbar); + + splitter->addWidget(audioContainer); + + editAreaLayout->addWidget(splitter); + + timeline_area_layout->addWidget(editAreas); + + horizontalScrollBar = new ResizableScrollBar(timeline_area); + horizontalScrollBar->setObjectName(QStringLiteral("horizontalScrollBar")); + horizontalScrollBar->setMaximum(0); + horizontalScrollBar->setSingleStep(20); + horizontalScrollBar->setPageStep(1826); + horizontalScrollBar->setOrientation(Qt::Horizontal); + + timeline_area_layout->addWidget(horizontalScrollBar); + + horizontalLayout->addWidget(timeline_area); + + audio_monitor = new AudioMonitor(dockWidgetContents); + audio_monitor->setMinimumSize(QSize(50, 0)); + + horizontalLayout->addWidget(audio_monitor); + + setWidget(dockWidgetContents); } void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions) { @@ -1625,9 +1795,20 @@ void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int } } -void Timeline::on_toolHandButton_clicked() { - decheck_tool_buttons(sender()); - ui->timeline_area->setCursor(Qt::OpenHandCursor); - tool = TIMELINE_TOOL_HAND; +void Timeline::set_tool() { + QPushButton* button = static_cast(sender()); + decheck_tool_buttons(button); + tool = button->property("tool").toInt(); creating = false; + switch (tool) { + case TIMELINE_TOOL_EDIT: + case TIMELINE_TOOL_RAZOR: + timeline_area->setCursor(Qt::IBeamCursor); + break; + case TIMELINE_TOOL_HAND: + timeline_area->setCursor(Qt::OpenHandCursor); + break; + default: + timeline_area->setCursor(Qt::ArrowCursor); + } } diff --git a/panels/timeline.h b/panels/timeline.h index 0caf38d8b..3f1a79bc2 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -24,6 +24,11 @@ class ComboAction; class Effect; class Media; class Transition; +class TimelineHeader; +class TimelineWidget; +class ResizableScrollBar; +class AudioMonitor; +class QScrollBar; struct EffectMeta; struct Sequence; struct Clip; @@ -63,10 +68,6 @@ struct Ghost { Transition* transition; }; -namespace Ui { -class Timeline; -} - class Timeline : public QDockWidget { Q_OBJECT @@ -188,7 +189,19 @@ public: bool block_repaints; - Ui::Timeline *ui; + TimelineHeader* headers; + AudioMonitor* audio_monitor; + ResizableScrollBar* horizontalScrollBar; + + QPushButton* toolArrowButton; + QPushButton* toolEditButton; + QPushButton* toolRippleButton; + QPushButton* toolRazorButton; + QPushButton* toolSlipButton; + QPushButton* toolSlideButton; + QPushButton* toolHandButton; + QPushButton* toolTransitionButton; + QPushButton* snappingButton; void resizeEvent(QResizeEvent *event); public slots: @@ -199,42 +212,17 @@ public slots: void split_at_playhead(); private slots: - - void on_pushButton_4_clicked(); - - void on_pushButton_5_clicked(); - - void on_snappingButton_toggled(bool checked); - - void on_toolSlideButton_clicked(); - - void on_toolArrowButton_clicked(); - - void on_toolEditButton_clicked(); - - void on_toolRippleButton_clicked(); - - void on_toolRollingButton_clicked(); - - void on_toolRazorButton_clicked(); - - void on_toolSlipButton_clicked(); - - void on_addButton_clicked(); - - void addMenuItem(QAction*); - + void zoom_in(); + void zoom_out(); + void snapping_clicked(bool checked); + void add_btn_click(); + void add_menu_item(QAction*); void setScroll(int); - - void on_recordButton_clicked(); - - void on_toolTransitionButton_clicked(); - + void record_btn_click(); + void transition_tool_click(); void transition_menu_select(QAction*); - void resize_move(double d); - - void on_toolHandButton_clicked(); + void set_tool(); private: void set_zoom_value(double v); @@ -245,7 +233,20 @@ private: int scroll; void set_sb_max(); + void setup_ui(); + int default_track_height; + + QWidget* timeline_area; + TimelineWidget* video_area; + TimelineWidget* audio_area; + QWidget* editAreas; + QScrollBar* videoScrollbar; + QScrollBar* audioScrollbar; + QPushButton* zoomInButton; + QPushButton* zoomOutButton; + QPushButton* recordButton; + QPushButton* addButton; }; #endif // TIMELINE_H diff --git a/panels/timeline.ui b/panels/timeline.ui deleted file mode 100644 index 7cf0a5ce7..000000000 --- a/panels/timeline.ui +++ /dev/null @@ -1,538 +0,0 @@ - - - Timeline - - - - 0 - 0 - 901 - 592 - - - - - 0 - 0 - - - - Timeline - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 4 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Pointer Tool (V) - - - - - - - :/icons/arrow.png - :/icons/arrow-disabled.png:/icons/arrow.png - - - true - - - - - - - Edit Tool (X) - - - - - - - :/icons/beam.png - :/icons/beam-disabled.png:/icons/beam.png - - - true - - - - - - - Ripple Tool (B) - - - - - - - :/icons/ripple.png - :/icons/ripple-disabled.png:/icons/ripple.png - - - true - - - - - - - Rolling Tool (N) - - - - - - - :/icons/rolling.png - :/icons/rolling-disabled.png:/icons/rolling.png - - - true - - - - - - - Razor Tool (C) - - - - - - - :/icons/razor.png - :/icons/razor-disabled.png:/icons/razor.png - - - true - - - - - - - Slip Tool (Y) - - - - - - - :/icons/slip.png - :/icons/slip-disabled.png - - - - true - - - - - - - Slide Tool (U) - - - - - - - :/icons/slide.png - :/icons/slide-disabled.png - - - - true - - - - - - - Hand Tool (H) - - - - - - - :/icons/hand.png - :/icons/hand-disabled.png - - - - true - - - - - - - Transition Tool (T) - - - - - - - :/icons/transition-tool.png - :/icons/transition-tool-disabled.png - - - - true - - - - - - - - - - - :/icons/magnet.png - :/icons/magnet-disabled.png - - - - true - - - true - - - - - - - Zoom In (=) - - - - - - - :/icons/zoomin.png - :/icons/zoomin-disabled.png - - - - - - - - Zoom Out (-) - - - - - - - :/icons/zoomout.png - :/icons/zoomout-disabled.png - - - - - - - - Record audio - - - - :/icons/record.png - :/icons/record-disabled.png - - - - - - - - Add title, solid, bars, etc. - - - - - - - :/icons/add-button.png - :/icons/add-button-disabled.png - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 1 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::ClickFocus - - - - - - - 0 - - - 20 - - - 1826 - - - Qt::Vertical - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::ClickFocus - - - - - - - 0 - - - 20 - - - 1826 - - - Qt::Vertical - - - - - - - - - - - - - - 0 - - - 20 - - - 1826 - - - Qt::Horizontal - - - - - - - - - - - 50 - 0 - - - - - - - - - - TimelineHeader - QWidget -
ui/timelineheader.h
- 1 -
- - TimelineWidget - QWidget -
ui/timelinewidget.h
- 1 -
- - AudioMonitor - QWidget -
ui/audiomonitor.h
- 1 -
- - ResizableScrollBar - QScrollBar -
ui/resizablescrollbar.h
-
-
- - - - -
diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 0430ab2d6..f86c3655c 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -11,11 +11,12 @@ #include "project/media.h" #include "project/undo.h" #include "ui/audiomonitor.h" -#include "ui_timeline.h" #include "playback/playback.h" #include "ui/viewerwidget.h" #include "ui/viewercontainer.h" #include "ui/labelslider.h" +#include "ui/timelineheader.h" +#include "ui/resizablescrollbar.h" #include "debug.h" #define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2 @@ -31,6 +32,8 @@ extern "C" { #include #include #include +#include +#include Viewer::Viewer(QWidget *parent) : QDockWidget(parent), @@ -466,7 +469,6 @@ void Viewer::setup_ui() { horizontalScrollBar->setOrientation(Qt::Horizontal); layout->addWidget(horizontalScrollBar); - QWidget* lower_controls = new QWidget(contents); QHBoxLayout* lower_control_layout = new QHBoxLayout(lower_controls); @@ -492,6 +494,7 @@ void Viewer::setup_ui() { goToStartIcon.addFile(QStringLiteral(":/icons/prev.png"), QSize(), QIcon::Normal, QIcon::Off); goToStartIcon.addFile(QStringLiteral(":/icons/prev-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); btnSkipToStart->setIcon(goToStartIcon); + connect(btnSkipToStart, SIGNAL(clicked(bool)), this, SLOT(go_to_start())); playback_control_layout->addWidget(btnSkipToStart); btnRewind = new QPushButton(playback_controls); @@ -499,6 +502,7 @@ void Viewer::setup_ui() { rewindIcon.addFile(QStringLiteral(":/icons/rew.png"), QSize(), QIcon::Normal, QIcon::Off); rewindIcon.addFile(QStringLiteral(":/icons/rew-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); btnRewind->setIcon(rewindIcon); + connect(btnRewind, SIGNAL(clicked(bool)), this, SLOT(previous_frame())); playback_control_layout->addWidget(btnRewind); btnPlay = new QPushButton(playback_controls); @@ -506,6 +510,7 @@ void Viewer::setup_ui() { playIcon.addFile(QStringLiteral(":/icons/play.png"), QSize(), QIcon::Normal, QIcon::Off); playIcon.addFile(QStringLiteral(":/icons/play-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); btnPlay->setIcon(playIcon); + connect(btnPlay, SIGNAL(clicked(bool)), this, SLOT(toggle_play())); playback_control_layout->addWidget(btnPlay); btnFastForward = new QPushButton(playback_controls); @@ -513,6 +518,7 @@ void Viewer::setup_ui() { ffIcon.addFile(QStringLiteral(":/icons/ff.png"), QSize(), QIcon::Normal, QIcon::On); ffIcon.addFile(QStringLiteral(":/icons/ff-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); btnFastForward->setIcon(ffIcon); + connect(btnFastForward, SIGNAL(clicked(bool)), this, SLOT(next_frame())); playback_control_layout->addWidget(btnFastForward); btnSkipToEnd = new QPushButton(playback_controls); @@ -520,6 +526,7 @@ void Viewer::setup_ui() { nextIcon.addFile(QStringLiteral(":/icons/next.png"), QSize(), QIcon::Normal, QIcon::Off); nextIcon.addFile(QStringLiteral(":/icons/next-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); btnSkipToEnd->setIcon(nextIcon); + connect(btnSkipToEnd, SIGNAL(clicked(bool)), this, SLOT(go_to_end())); playback_control_layout->addWidget(btnSkipToEnd); lower_control_layout->addWidget(playback_controls); diff --git a/panels/viewer.h b/panels/viewer.h index 78edcd099..d46ba94c4 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -42,14 +42,9 @@ public: void set_zoom(bool in); // playback functions - void go_to_start(); - void previous_frame(); - void next_frame(); void seek(long p); - void toggle_play(); void play(); void pause(); - void go_to_end(); bool playing; long playhead_start; qint64 start_msecs; @@ -75,6 +70,11 @@ public: public slots: void play_wake(); + void go_to_start(); + void previous_frame(); + void toggle_play(); + void next_frame(); + void go_to_end(); private slots: void on_btnSkipToStart_clicked(); diff --git a/playback/audio.cpp b/playback/audio.cpp index 8d04cedce..e5e90601e 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -7,9 +7,10 @@ #include "panels/panels.h" #include "panels/timeline.h" #include "panels/viewer.h" -#include "ui_timeline.h" +#include "ui/audiomonitor.h" #include "debug.h" +#include #include #include #include @@ -43,49 +44,49 @@ bool is_audio_device_set() { void init_audio() { stop_audio(); - QAudioFormat audio_format; - audio_format.setSampleRate(config.audio_rate); - audio_format.setChannelCount(2); - audio_format.setSampleSize(16); - audio_format.setCodec("audio/pcm"); - audio_format.setByteOrder(QAudioFormat::LittleEndian); - audio_format.setSampleType(QAudioFormat::SignedInt); + QAudioFormat audio_format; + audio_format.setSampleRate(config.audio_rate); + audio_format.setChannelCount(2); + audio_format.setSampleSize(16); + audio_format.setCodec("audio/pcm"); + audio_format.setByteOrder(QAudioFormat::LittleEndian); + audio_format.setSampleType(QAudioFormat::SignedInt); - QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); - QList devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); - dout << "[INFO] Found the following audio devices:"; - for (int i=0;i 0) { - dout << "[WARNING] Default audio returned NULL, attempting to use first device found..."; - info = devs.at(0); - } - dout << "[INFO] Using audio device" << info.deviceName(); + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + QList devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + dout << "[INFO] Found the following audio devices:"; + for (int i=0;i 0) { + dout << "[WARNING] Default audio returned NULL, attempting to use first device found..."; + info = devs.at(0); + } + dout << "[INFO] Using audio device" << info.deviceName(); - if (!info.isFormatSupported(audio_format)) { - qWarning() << "[WARNING] Audio format is not supported by backend, using nearest"; - audio_format = info.nearestFormat(audio_format); - } + if (!info.isFormatSupported(audio_format)) { + qWarning() << "[WARNING] Audio format is not supported by backend, using nearest"; + audio_format = info.nearestFormat(audio_format); + } - audio_output = new QAudioOutput(info, audio_format); - audio_output->moveToThread(QApplication::instance()->thread()); - audio_output->setNotifyInterval(5); + audio_output = new QAudioOutput(info, audio_format); + audio_output->moveToThread(QApplication::instance()->thread()); + audio_output->setNotifyInterval(5); - // connect - audio_io_device = audio_output->start(); - if (audio_io_device == NULL) { - dout << "[WARNING] Received NULL audio device. No compatible audio output was found."; - } else { - audio_device_set = true; + // connect + audio_io_device = audio_output->start(); + if (audio_io_device == NULL) { + dout << "[WARNING] Received NULL audio device. No compatible audio output was found."; + } else { + audio_device_set = true; - // start sender thread - audio_thread = new AudioSenderThread(); - QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver())); - audio_thread->start(QThread::TimeCriticalPriority); + // start sender thread + audio_thread = new AudioSenderThread(); + QObject::connect(audio_output, SIGNAL(notify()), audio_thread, SLOT(notifyReceiver())); + audio_thread->start(QThread::TimeCriticalPriority); - clear_audio_ibuffer(); - } + clear_audio_ibuffer(); + } } void stop_audio() { @@ -100,12 +101,12 @@ void stop_audio() { void clear_audio_ibuffer() { memset(audio_ibuffer, 0, audio_ibuffer_size); - audio_ibuffer_read = 0; + audio_ibuffer_read = 0; } int get_buffer_offset_from_frame(double framerate, long frame) { if (frame >= audio_ibuffer_frame) { - return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*audio_output->format().sampleRate())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); + return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*audio_output->format().sampleRate())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); } else { dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame"; return 0; @@ -135,7 +136,7 @@ void AudioSenderThread::run() { cond.wait(&lock); if (close) { break; - } else if (panel_sequence_viewer->playing || panel_footage_viewer->playing || audio_scrub) { + } else if (panel_sequence_viewer->playing || panel_footage_viewer->playing || audio_scrub) { int written_bytes = 0; int adjusted_read_index = audio_ibuffer_read%audio_ibuffer_size; @@ -147,7 +148,7 @@ void AudioSenderThread::run() { written_bytes += send_audio_to_output(0, audio_ibuffer_size); } - audio_scrub = false; + audio_scrub = false; } } lock.unlock(); @@ -163,26 +164,26 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) { // TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT Sequence* s = NULL; /*if (panel_footage_viewer->playing) { - s = panel_footage_viewer->seq; + s = panel_footage_viewer->seq; }*/ - if (panel_sequence_viewer->playing) { - s = panel_sequence_viewer->seq; - } - if (s != NULL) { - if (panel_timeline->ui->audio_monitor->sample_cache_offset == -1) { - panel_timeline->ui->audio_monitor->sample_cache_offset = s->playhead; + if (panel_sequence_viewer->playing) { + s = panel_sequence_viewer->seq; + } + if (s != NULL) { + if (panel_timeline->audio_monitor->sample_cache_offset == -1) { + panel_timeline->audio_monitor->sample_cache_offset = s->playhead; } - int channel_count = av_get_channel_layout_nb_channels(s->audio_layout); - long sample_cache_playhead = panel_timeline->ui->audio_monitor->sample_cache_offset + (panel_timeline->ui->audio_monitor->sample_cache.size()/channel_count); + int channel_count = av_get_channel_layout_nb_channels(s->audio_layout); + long sample_cache_playhead = panel_timeline->audio_monitor->sample_cache_offset + (panel_timeline->audio_monitor->sample_cache.size()/channel_count); int next_buffer_offset, buffer_offset_adjusted, i; - int buffer_offset = get_buffer_offset_from_frame(s->frame_rate, sample_cache_playhead); + int buffer_offset = get_buffer_offset_from_frame(s->frame_rate, sample_cache_playhead); if (samples.size() != channel_count) samples.resize(channel_count); samples.fill(0); // TODO: I don't like this, but i'm not sure if there's a smarter way to do it while (buffer_offset < audio_ibuffer_limit) { sample_cache_playhead++; - next_buffer_offset = qMin(get_buffer_offset_from_frame(s->frame_rate, sample_cache_playhead), audio_ibuffer_limit); + next_buffer_offset = qMin(get_buffer_offset_from_frame(s->frame_rate, sample_cache_playhead), audio_ibuffer_limit); while (buffer_offset < next_buffer_offset) { for (i=0;iui->audio_monitor->sample_cache.append(samples); + panel_timeline->audio_monitor->sample_cache.append(samples); buffer_offset = next_buffer_offset; } } diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 2d5cfbe9c..e82332395 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -14,11 +14,11 @@ #include "panels/effectcontrols.h" #include "panels/viewer.h" #include "project/undo.h" -#include "ui_timeline.h" #include "mainwindow.h" #include "ui/viewerwidget.h" #include "dialogs/stabilizerdialog.h" #include "project/media.h" +#include "ui/resizablescrollbar.h" #include "debug.h" #include "project/effect.h" @@ -361,7 +361,7 @@ void TimelineWidget::wheelEvent(QWheelEvent *event) { if (config.scroll_zooms != shift) { panel_timeline->set_zoom(in); } else { - QScrollBar* bar = alt ? scrollBar : panel_timeline->ui->horizontalScrollBar; + QScrollBar* bar = alt ? scrollBar : panel_timeline->horizontalScrollBar; int step = bar->singleStep(); if (in) step = -step; @@ -1638,7 +1638,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } else if (panel_timeline->hand_moving) { panel_timeline->block_repaints = true; - panel_timeline->ui->horizontalScrollBar->setValue(panel_timeline->ui->horizontalScrollBar->value() + panel_timeline->drag_x_start - event->pos().x()); + panel_timeline->horizontalScrollBar->setValue(panel_timeline->horizontalScrollBar->value() + panel_timeline->drag_x_start - event->pos().x()); scrollBar->setValue(scrollBar->value() + panel_timeline->drag_y_start - event->pos().y()); panel_timeline->block_repaints = false; diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index f84c27b6f..a501fbfec 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -11,7 +11,6 @@ #include "playback/playback.h" #include "playback/audio.h" #include "project/footage.h" -#include "ui_timeline.h" #include "playback/cacher.h" #include "io/config.h" #include "debug.h" @@ -21,6 +20,7 @@ #include "project/media.h" #include "ui/viewercontainer.h" #include "io/avtogl.h" +#include "ui/timelinewidget.h" #include #include @@ -36,6 +36,7 @@ #include #include #include +#include extern "C" { #include @@ -47,40 +48,40 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent), default_fbo(NULL), waveform(false), - dragging(false), - selected_gizmo(NULL), - waveform_zoom(1.0), - waveform_scroll(0) + dragging(false), + selected_gizmo(NULL), + waveform_zoom(1.0), + waveform_scroll(0) { - setMouseTracking(true); + setMouseTracking(true); setFocusPolicy(Qt::ClickFocus); QSurfaceFormat format; format.setDepthBufferSize(24); setFormat(format); - // error handler - retries after 50ms if we couldn't get the entire image - retry_timer.setInterval(50); + // error handler - retries after 50ms if we couldn't get the entire image + retry_timer.setInterval(50); connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry())); setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu())); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu())); } void ViewerWidget::delete_function() { - // destroy all textures as well + // destroy all textures as well if (viewer->seq != NULL) { - makeCurrent(); - closeActiveClips(viewer->seq, true); - doneCurrent(); - } + makeCurrent(); + closeActiveClips(viewer->seq, true); + doneCurrent(); + } } void ViewerWidget::set_waveform_scroll(int s) { - if (waveform) { - waveform_scroll = s; - update(); - } + if (waveform) { + waveform_scroll = s; + update(); + } } void ViewerWidget::show_context_menu() { @@ -89,47 +90,47 @@ void ViewerWidget::show_context_menu() { QAction* save_frame_as_image = menu.addAction("Save Frame as Image..."); connect(save_frame_as_image, SIGNAL(triggered(bool)), this, SLOT(save_frame())); - QAction* show_fullscreen_action = menu.addAction("Show Fullscreen"); - connect(show_fullscreen_action, SIGNAL(triggered()), this, SLOT(show_fullscreen())); + QAction* show_fullscreen_action = menu.addAction("Show Fullscreen"); + connect(show_fullscreen_action, SIGNAL(triggered()), this, SLOT(show_fullscreen())); - QMenu zoom_menu("Zoom"); - QAction* fit_zoom = zoom_menu.addAction("Fit"); - connect(fit_zoom, SIGNAL(triggered(bool)), this, SLOT(set_fit_zoom())); - zoom_menu.addAction("10%")->setData(0.1); - zoom_menu.addAction("25%")->setData(0.25); - zoom_menu.addAction("50%")->setData(0.5); - zoom_menu.addAction("75%")->setData(0.75); - zoom_menu.addAction("100%")->setData(1.0); - zoom_menu.addAction("150%")->setData(1.5); - zoom_menu.addAction("200%")->setData(2.0); - zoom_menu.addAction("400%")->setData(4.0); - QAction* custom_zoom = zoom_menu.addAction("Custom"); - connect(custom_zoom, SIGNAL(triggered(bool)), this, SLOT(set_custom_zoom())); - connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*))); - menu.addMenu(&zoom_menu); + QMenu zoom_menu("Zoom"); + QAction* fit_zoom = zoom_menu.addAction("Fit"); + connect(fit_zoom, SIGNAL(triggered(bool)), this, SLOT(set_fit_zoom())); + zoom_menu.addAction("10%")->setData(0.1); + zoom_menu.addAction("25%")->setData(0.25); + zoom_menu.addAction("50%")->setData(0.5); + zoom_menu.addAction("75%")->setData(0.75); + zoom_menu.addAction("100%")->setData(1.0); + zoom_menu.addAction("150%")->setData(1.5); + zoom_menu.addAction("200%")->setData(2.0); + zoom_menu.addAction("400%")->setData(4.0); + QAction* custom_zoom = zoom_menu.addAction("Custom"); + connect(custom_zoom, SIGNAL(triggered(bool)), this, SLOT(set_custom_zoom())); + connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*))); + menu.addMenu(&zoom_menu); menu.exec(QCursor::pos()); } void ViewerWidget::save_frame() { - QFileDialog fd(this); - fd.setAcceptMode(QFileDialog::AcceptSave); - fd.setFileMode(QFileDialog::AnyFile); - fd.setWindowTitle("Save Frame"); - fd.setNameFilter("Portable Network Graphic (*.png);;JPEG (*.jpg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)"); + QFileDialog fd(this); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setFileMode(QFileDialog::AnyFile); + fd.setWindowTitle("Save Frame"); + fd.setNameFilter("Portable Network Graphic (*.png);;JPEG (*.jpg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)"); - if (fd.exec()) { - QString fn = fd.selectedFiles().at(0); - QString selected_ext = fd.selectedNameFilter().mid(fd.selectedNameFilter().indexOf(QRegExp("\\*.[a-z][a-z][a-z]")) + 1, 4); - if (!fn.endsWith(selected_ext, Qt::CaseInsensitive)) { - fn += selected_ext; - } + if (fd.exec()) { + QString fn = fd.selectedFiles().at(0); + QString selected_ext = fd.selectedNameFilter().mid(fd.selectedNameFilter().indexOf(QRegExp("\\*.[a-z][a-z][a-z]")) + 1, 4); + if (!fn.endsWith(selected_ext, Qt::CaseInsensitive)) { + fn += selected_ext; + } QOpenGLFramebufferObject fbo(viewer->seq->width, viewer->seq->height, QOpenGLFramebufferObject::CombinedDepthStencil, GL_TEXTURE_RECTANGLE); rendering = true; fbo.bind(); - default_fbo = &fbo; + default_fbo = &fbo; paintGL(); @@ -138,37 +139,37 @@ void ViewerWidget::save_frame() { img.save(fn); fbo.release(); - default_fbo = NULL; + default_fbo = NULL; rendering = false; - } + } } void ViewerWidget::show_fullscreen() { - showFullScreen(); + showFullScreen(); } void ViewerWidget::set_fit_zoom() { - container->fit = true; - container->adjust(); + container->fit = true; + container->adjust(); } void ViewerWidget::set_custom_zoom() { - bool ok; - double d = QInputDialog::getDouble(this, "Viewer Zoom", "Set Custom Zoom Value:", container->zoom*100, 0, 2147483647, 2, &ok); - if (ok) { - container->fit = false; - container->zoom = d*0.01; - container->adjust(); - } + bool ok; + double d = QInputDialog::getDouble(this, "Viewer Zoom", "Set Custom Zoom Value:", container->zoom*100, 0, 2147483647, 2, &ok); + if (ok) { + container->fit = false; + container->zoom = d*0.01; + container->adjust(); + } } void ViewerWidget::set_menu_zoom(QAction* action) { - const QVariant& data = action->data(); - if (!data.isNull()) { - container->fit = false; - container->zoom = data.toDouble(); - container->adjust(); - } + const QVariant& data = action->data(); + if (!data.isNull()) { + container->fit = false; + container->zoom = data.toDouble(); + container->adjust(); + } } void ViewerWidget::retry() { @@ -176,11 +177,11 @@ void ViewerWidget::retry() { } void ViewerWidget::initializeGL() { - initializeOpenGLFunctions(); + initializeOpenGLFunctions(); - connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(delete_function()), Qt::DirectConnection); + connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(delete_function()), Qt::DirectConnection); - retry_timer.start(); + retry_timer.start(); } //void ViewerWidget::resizeGL(int w, int h) @@ -195,210 +196,210 @@ void ViewerWidget::paintEvent(QPaintEvent *e) { } void ViewerWidget::seek_from_click(int x) { - viewer->seek(getFrameFromScreenPoint(waveform_zoom, x+waveform_scroll)); + viewer->seek(getFrameFromScreenPoint(waveform_zoom, x+waveform_scroll)); } EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) { - if (gizmos != NULL) { - double multiplier = (double) viewer->seq->width / (double) width(); - QPoint mouse_pos(qRound(x*multiplier), qRound(y*multiplier)); - int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier); - int target_size = 2 * qRound(GIZMO_TARGET_SIZE * multiplier); - for (int i=0;igizmo_count();i++) { - EffectGizmo* g = gizmos->gizmo(i); + if (gizmos != NULL) { + double multiplier = (double) viewer->seq->width / (double) width(); + QPoint mouse_pos(qRound(x*multiplier), qRound(y*multiplier)); + int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier); + int target_size = 2 * qRound(GIZMO_TARGET_SIZE * multiplier); + for (int i=0;igizmo_count();i++) { + EffectGizmo* g = gizmos->gizmo(i); - switch (g->get_type()) { - case GIZMO_TYPE_DOT: - if (mouse_pos.x() > g->screen_pos[0].x() - dot_size - && mouse_pos.y() > g->screen_pos[0].y() - dot_size - && mouse_pos.x() < g->screen_pos[0].x() + dot_size - && mouse_pos.y() < g->screen_pos[0].y() + dot_size) { - return g; - } - break; - case GIZMO_TYPE_POLY: - if (QPolygon(g->screen_pos).containsPoint(mouse_pos, Qt::OddEvenFill)) { - return g; - } - break; - case GIZMO_TYPE_TARGET: - if (mouse_pos.x() > g->screen_pos[0].x() - target_size - && mouse_pos.y() > g->screen_pos[0].y() - target_size - && mouse_pos.x() < g->screen_pos[0].x() + target_size - && mouse_pos.y() < g->screen_pos[0].y() + target_size) { - return g; - } - break; - } + switch (g->get_type()) { + case GIZMO_TYPE_DOT: + if (mouse_pos.x() > g->screen_pos[0].x() - dot_size + && mouse_pos.y() > g->screen_pos[0].y() - dot_size + && mouse_pos.x() < g->screen_pos[0].x() + dot_size + && mouse_pos.y() < g->screen_pos[0].y() + dot_size) { + return g; + } + break; + case GIZMO_TYPE_POLY: + if (QPolygon(g->screen_pos).containsPoint(mouse_pos, Qt::OddEvenFill)) { + return g; + } + break; + case GIZMO_TYPE_TARGET: + if (mouse_pos.x() > g->screen_pos[0].x() - target_size + && mouse_pos.y() > g->screen_pos[0].y() - target_size + && mouse_pos.x() < g->screen_pos[0].x() + target_size + && mouse_pos.y() < g->screen_pos[0].y() + target_size) { + return g; + } + break; + } - } - } - return NULL; + } + } + return NULL; } void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) { - if (selected_gizmo != NULL) { - double multiplier = (double) viewer->seq->width / (double) width(); + if (selected_gizmo != NULL) { + double multiplier = (double) viewer->seq->width / (double) width(); - int x_movement = (event->pos().x() - drag_start_x)*multiplier; - int y_movement = (event->pos().y() - drag_start_y)*multiplier; + int x_movement = (event->pos().x() - drag_start_x)*multiplier; + int y_movement = (event->pos().y() - drag_start_y)*multiplier; - gizmos->gizmo_move(selected_gizmo, x_movement, y_movement, get_timecode(gizmos->parent_clip, gizmos->parent_clip->sequence->playhead), done); + gizmos->gizmo_move(selected_gizmo, x_movement, y_movement, get_timecode(gizmos->parent_clip, gizmos->parent_clip->sequence->playhead), done); - gizmo_x_mvmt += x_movement; - gizmo_y_mvmt += y_movement; + gizmo_x_mvmt += x_movement; + gizmo_y_mvmt += y_movement; - drag_start_x = event->pos().x(); - drag_start_y = event->pos().y(); + drag_start_x = event->pos().x(); + drag_start_y = event->pos().y(); - gizmos->field_changed(); - } + gizmos->field_changed(); + } } void ViewerWidget::mousePressEvent(QMouseEvent* event) { - if (waveform) { - seek_from_click(event->x()); - } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { - container->dragScrollPress(event->pos()); - } else { - drag_start_x = event->pos().x(); - drag_start_y = event->pos().y(); + if (waveform) { + seek_from_click(event->x()); + } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { + container->dragScrollPress(event->pos()); + } else { + drag_start_x = event->pos().x(); + drag_start_y = event->pos().y(); - gizmo_x_mvmt = 0; - gizmo_y_mvmt = 0; + gizmo_x_mvmt = 0; + gizmo_y_mvmt = 0; - selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); + selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (selected_gizmo != NULL) { - selected_gizmo->set_previous_value(); - } - } - dragging = true; + if (selected_gizmo != NULL) { + selected_gizmo->set_previous_value(); + } + } + dragging = true; } void ViewerWidget::mouseMoveEvent(QMouseEvent* event) { - unsetCursor(); - if (panel_timeline->tool == TIMELINE_TOOL_HAND) { - setCursor(Qt::OpenHandCursor); - } - if (dragging) { + unsetCursor(); + if (panel_timeline->tool == TIMELINE_TOOL_HAND) { + setCursor(Qt::OpenHandCursor); + } + if (dragging) { if (waveform) { seek_from_click(event->x()); - } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { - container->dragScrollMove(event->pos()); - } else if (gizmos == NULL) { + } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { + container->dragScrollMove(event->pos()); + } else if (gizmos == NULL) { QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; - mimeData->setText("h"); // QMimeData will fail without some kind of data + mimeData->setText("h"); // QMimeData will fail without some kind of data drag->setMimeData(mimeData); drag->exec(); - dragging = false; - } else { - move_gizmos(event, false); - } - } else { - EffectGizmo* g = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (g != NULL) { - if (g->get_cursor() > -1) { - setCursor(static_cast(g->get_cursor())); - } - } - } + dragging = false; + } else { + move_gizmos(event, false); + } + } else { + EffectGizmo* g = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); + if (g != NULL) { + if (g->get_cursor() > -1) { + setCursor(static_cast(g->get_cursor())); + } + } + } } void ViewerWidget::mouseReleaseEvent(QMouseEvent *event) { - if (dragging) move_gizmos(event, true); - dragging = false; + if (dragging) move_gizmos(event, true); + dragging = false; } void ViewerWidget::drawTitleSafeArea() { - double halfWidth = 0.5; - double halfHeight = 0.5; - double viewportAr = (double) width() / (double) height(); - double halfAr = viewportAr*0.5; + double halfWidth = 0.5; + double halfHeight = 0.5; + double viewportAr = (double) width() / (double) height(); + double halfAr = viewportAr*0.5; - if (config.use_custom_title_safe_ratio && config.custom_title_safe_ratio > 0) { - if (config.custom_title_safe_ratio > viewportAr) { - halfHeight = (config.custom_title_safe_ratio/viewportAr)*0.5; - } else { - halfWidth = (viewportAr/config.custom_title_safe_ratio)*0.5; - } - } + if (config.use_custom_title_safe_ratio && config.custom_title_safe_ratio > 0) { + if (config.custom_title_safe_ratio > viewportAr) { + halfHeight = (config.custom_title_safe_ratio/viewportAr)*0.5; + } else { + halfWidth = (viewportAr/config.custom_title_safe_ratio)*0.5; + } + } - glLoadIdentity(); - glOrtho(-halfWidth, halfWidth, halfHeight, -halfHeight, 0, 1); + glLoadIdentity(); + glOrtho(-halfWidth, halfWidth, halfHeight, -halfHeight, 0, 1); glColor4f(0.66f, 0.66f, 0.66f, 1.0f); - glBegin(GL_LINES); + glBegin(GL_LINES); - // action safe rectangle - glVertex2d(-0.45, -0.45); - glVertex2d(0.45, -0.45); - glVertex2d(0.45, -0.45); - glVertex2d(0.45, 0.45); - glVertex2d(0.45, 0.45); - glVertex2d(-0.45, 0.45); - glVertex2d(-0.45, 0.45); - glVertex2d(-0.45, -0.45); + // action safe rectangle + glVertex2d(-0.45, -0.45); + glVertex2d(0.45, -0.45); + glVertex2d(0.45, -0.45); + glVertex2d(0.45, 0.45); + glVertex2d(0.45, 0.45); + glVertex2d(-0.45, 0.45); + glVertex2d(-0.45, 0.45); + glVertex2d(-0.45, -0.45); - // title safe rectangle - glVertex2d(-0.4, -0.4); - glVertex2d(0.4, -0.4); - glVertex2d(0.4, -0.4); - glVertex2d(0.4, 0.4); - glVertex2d(0.4, 0.4); - glVertex2d(-0.4, 0.4); - glVertex2d(-0.4, 0.4); - glVertex2d(-0.4, -0.4); + // title safe rectangle + glVertex2d(-0.4, -0.4); + glVertex2d(0.4, -0.4); + glVertex2d(0.4, -0.4); + glVertex2d(0.4, 0.4); + glVertex2d(0.4, 0.4); + glVertex2d(-0.4, 0.4); + glVertex2d(-0.4, 0.4); + glVertex2d(-0.4, -0.4); - // horizontal centers - glVertex2d(-0.45, 0); - glVertex2d(-0.375, 0); - glVertex2d(0.45, 0); - glVertex2d(0.375, 0); + // horizontal centers + glVertex2d(-0.45, 0); + glVertex2d(-0.375, 0); + glVertex2d(0.45, 0); + glVertex2d(0.375, 0); - // vertical centers - glVertex2d(0, -0.45); - glVertex2d(0, -0.375); - glVertex2d(0, 0.45); - glVertex2d(0, 0.375); + // vertical centers + glVertex2d(0, -0.45); + glVertex2d(0, -0.375); + glVertex2d(0, 0.45); + glVertex2d(0, 0.375); - glEnd(); + glEnd(); - // center cross - glLoadIdentity(); - glOrtho(-halfAr, halfAr, 0.5, -0.5, -1, 1); + // center cross + glLoadIdentity(); + glOrtho(-halfAr, halfAr, 0.5, -0.5, -1, 1); - glBegin(GL_LINES); + glBegin(GL_LINES); - glVertex2d(-0.05, 0); - glVertex2d(0.05, 0); - glVertex2d(0, -0.05); - glVertex2d(0, 0.05); + glVertex2d(-0.05, 0); + glVertex2d(0.05, 0); + glVertex2d(0, -0.05); + glVertex2d(0, 0.05); - glEnd(); + glEnd(); } GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) { - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, 1, 0, 1, -1, 1); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, 1, 0, 1, -1, 1); - fbo->bind(); + fbo->bind(); - if (clear) glClear(GL_COLOR_BUFFER_BIT); + if (clear) glClear(GL_COLOR_BUFFER_BIT); - // get current blend mode - GLint src_rgb, src_alpha, dst_rgb, dst_alpha; - glGetIntegerv(GL_BLEND_SRC_RGB, &src_rgb); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &src_alpha); - glGetIntegerv(GL_BLEND_DST_RGB, &dst_rgb); - glGetIntegerv(GL_BLEND_DST_ALPHA, &dst_alpha); + // get current blend mode + GLint src_rgb, src_alpha, dst_rgb, dst_alpha; + glGetIntegerv(GL_BLEND_SRC_RGB, &src_rgb); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &src_alpha); + glGetIntegerv(GL_BLEND_DST_RGB, &dst_rgb); + glGetIntegerv(GL_BLEND_DST_ALPHA, &dst_alpha); - GL_DEFAULT_BLEND + GL_DEFAULT_BLEND - glBindTexture(GL_TEXTURE_2D, texture); - glBegin(GL_QUADS); + glBindTexture(GL_TEXTURE_2D, texture); + glBegin(GL_QUADS); glTexCoord2f(0, 0); // top left glVertex2f(0, 0); // top left glTexCoord2f(1, 0); // top right @@ -408,14 +409,14 @@ GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bo glTexCoord2f(0, 1); // bottom left glVertex2f(0, 1); // bottom left glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_2D, 0); fbo->release(); - // restore previous blendFunc - glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); + // restore previous blendFunc + glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); - if (default_fbo != NULL) default_fbo->bind(); + if (default_fbo != NULL) default_fbo->bind(); glPopMatrix(); return fbo->texture(); @@ -424,27 +425,27 @@ GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bo void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTextureCoords& coords, GLuint& composite_texture, bool& fbo_switcher, int data) { if (e->is_enabled()) { if (e->enable_coords) { - e->process_coords(timecode, coords, data); + e->process_coords(timecode, coords, data); } if (e->enable_shader || e->enable_superimpose) { - e->startEffect(); - if (e->enable_shader) { - e->process_shader(timecode, coords); - composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true); - fbo_switcher = !fbo_switcher; - } - if (e->enable_superimpose) { - GLuint superimpose_texture = e->process_superimpose(timecode); - if (superimpose_texture == 0) { - dout << "[WARNING] Superimpose texture was NULL, retrying..."; - texture_failed = true; - } else { - composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); - } - } - e->endEffect(); + e->startEffect(); + if (e->enable_shader) { + e->process_shader(timecode, coords); + composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true); + fbo_switcher = !fbo_switcher; + } + if (e->enable_superimpose) { + GLuint superimpose_texture = e->process_superimpose(timecode); + if (superimpose_texture == 0) { + dout << "[WARNING] Superimpose texture was NULL, retrying..."; + texture_failed = true; + } else { + composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); + } + } + e->endEffect(); } - } + } } int motion_blur_prog = 0; @@ -456,8 +457,8 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) if (!nests.isEmpty()) { for (int i=0;imedia->to_sequence(); - playhead += nests.at(i)->clip_in - nests.at(i)->get_timeline_in_with_transition(); + s = nests.at(i)->media->to_sequence(); + playhead += nests.at(i)->clip_in - nests.at(i)->get_timeline_in_with_transition(); playhead = refactor_frame_number(playhead, nests.at(i)->sequence->frame_rate, s->frame_rate); } @@ -470,45 +471,45 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) int audio_track_count = 0; - QVector current_clips; + QVector current_clips; - for (int i=0;iclips.size();i++) { + for (int i=0;iclips.size();i++) { Clip* c = s->clips.at(i); - // if clip starts within one second and/or hasn't finished yet + // if clip starts within one second and/or hasn't finished yet if (c != NULL) { if (!(!nests.isEmpty() && !same_sign(c->track, nests.last()->track))) { bool clip_is_active = false; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { - Footage* m = c->media->to_footage(); - if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) { - if (m->ready) { - FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); - if (ms != NULL && is_clip_active(c, playhead)) { - // if thread is already working, we don't want to touch this, - // but we also don't want to hang the UI thread - if (!c->open) { - open_clip(c, !rendering); - } - clip_is_active = true; - if (c->track >= 0) audio_track_count++; - } else if (c->open) { - close_clip(c); - } - } else { - //dout << "[WARNING] Media '" + m->name + "' was not ready, retrying..."; - texture_failed = true; - } - } - } else { - if (is_clip_active(c, playhead)) { - if (!c->open) open_clip(c, !rendering); - clip_is_active = true; - } else if (c->open) { - close_clip(c); - } - } + if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + Footage* m = c->media->to_footage(); + if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) { + if (m->ready) { + FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); + if (ms != NULL && is_clip_active(c, playhead)) { + // if thread is already working, we don't want to touch this, + // but we also don't want to hang the UI thread + if (!c->open) { + open_clip(c, !rendering); + } + clip_is_active = true; + if (c->track >= 0) audio_track_count++; + } else if (c->open) { + close_clip(c); + } + } else { + //dout << "[WARNING] Media '" + m->name + "' was not ready, retrying..."; + texture_failed = true; + } + } + } else { + if (is_clip_active(c, playhead)) { + if (!c->open) open_clip(c, !rendering); + clip_is_active = true; + } else if (c->open) { + close_clip(c); + } + } if (clip_is_active) { bool added = false; for (int j=0;j& nests, bool render_audio) int half_height = s->height/2; if (rendering || !nests.isEmpty()) half_height = -half_height; // invert vertical - glPushMatrix(); - glLoadIdentity(); - glOrtho(-half_width, half_width, half_height, -half_height, -1, 10); + glPushMatrix(); + glLoadIdentity(); + glOrtho(-half_width, half_width, half_height, -half_height, -1, 10); - for (int i=0;imedia != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { + if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { dout << "[WARNING] Tried to display clip" << i << "but it's closed"; - texture_failed = true; - } else { + texture_failed = true; + } else { if (c->track < 0) { GLuint textureID = 0; int video_width = c->getWidth(); int video_height = c->getHeight(); - if (c->media != NULL) { - switch (c->media->get_type()) { - case MEDIA_TYPE_FOOTAGE: - // set up opengl texture - if (c->texture == NULL) { - c->texture = new QOpenGLTexture(QOpenGLTexture::Target2D); - c->texture->setSize(c->stream->codecpar->width, c->stream->codecpar->height); + if (c->media != NULL) { + switch (c->media->get_type()) { + case MEDIA_TYPE_FOOTAGE: + // set up opengl texture + if (c->texture == NULL) { + c->texture = new QOpenGLTexture(QOpenGLTexture::Target2D); + c->texture->setSize(c->stream->codecpar->width, c->stream->codecpar->height); c->texture->setFormat(get_gl_tex_fmt_from_av(c->pix_fmt)); - c->texture->setMipLevels(c->texture->maximumMipLevels()); - c->texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear); + c->texture->setMipLevels(c->texture->maximumMipLevels()); + c->texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear); c->texture->allocateStorage(get_gl_pix_fmt_from_av(c->pix_fmt), QOpenGLTexture::UInt8); - } - get_clip_frame(c, playhead); - textureID = c->texture->textureId(); - break; - case MEDIA_TYPE_SEQUENCE: - textureID = -1; - break; - } - } + } + get_clip_frame(c, playhead); + textureID = c->texture->textureId(); + break; + case MEDIA_TYPE_SEQUENCE: + textureID = -1; + break; + } + } - if (textureID == 0 && c->media != NULL) { + if (textureID == 0 && c->media != NULL) { dout << "[WARNING] Texture hasn't been created yet"; texture_failed = true; - } else if (playhead >= c->get_timeline_in_with_transition()) { + } else if (playhead >= c->get_timeline_in_with_transition()) { glPushMatrix(); // start preparing cache @@ -595,84 +596,84 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glViewport(0, 0, video_width, video_height); - GLuint composite_texture; + GLuint composite_texture; - if (c->media == NULL) { - c->fbo[fbo_switcher]->bind(); - glClear(GL_COLOR_BUFFER_BIT); - c->fbo[fbo_switcher]->release(); + if (c->media == NULL) { + c->fbo[fbo_switcher]->bind(); + glClear(GL_COLOR_BUFFER_BIT); + c->fbo[fbo_switcher]->release(); composite_texture = c->fbo[fbo_switcher]->texture(); } else { - // for nested sequences - if (c->media->get_type()== MEDIA_TYPE_SEQUENCE) { - nests.append(c); - textureID = compose_sequence(nests, render_audio); - nests.removeLast(); - fbo_switcher = true; - } + // for nested sequences + if (c->media->get_type()== MEDIA_TYPE_SEQUENCE) { + nests.append(c); + textureID = compose_sequence(nests, render_audio); + nests.removeLast(); + fbo_switcher = true; + } - composite_texture = draw_clip(c->fbo[fbo_switcher], textureID, true); + composite_texture = draw_clip(c->fbo[fbo_switcher], textureID, true); } - fbo_switcher = !fbo_switcher; + fbo_switcher = !fbo_switcher; - // set up default coords - GLTextureCoords coords; - coords.grid_size = 1; + // set up default coords + GLTextureCoords coords; + coords.grid_size = 1; coords.vertexTopLeftX = coords.vertexBottomLeftX = -video_width/2; coords.vertexTopLeftY = coords.vertexTopRightY = -video_height/2; coords.vertexTopRightX = coords.vertexBottomRightX = video_width/2; - coords.vertexBottomLeftY = coords.vertexBottomRightY = video_height/2; - coords.vertexBottomLeftZ = coords.vertexBottomRightZ = coords.vertexTopLeftZ = coords.vertexTopRightZ = 1; - coords.textureTopLeftY = coords.textureTopRightY = coords.textureTopLeftX = coords.textureBottomLeftX = 0.0; + coords.vertexBottomLeftY = coords.vertexBottomRightY = video_height/2; + coords.vertexBottomLeftZ = coords.vertexBottomRightZ = coords.vertexTopLeftZ = coords.vertexTopRightZ = 1; + coords.textureTopLeftY = coords.textureTopRightY = coords.textureTopLeftX = coords.textureBottomLeftX = 0.0; coords.textureBottomLeftY = coords.textureBottomRightY = coords.textureTopRightX = coords.textureBottomRightX = 1.0; - coords.textureTopLeftQ = coords.textureTopRightQ = coords.textureTopLeftQ = coords.textureBottomLeftQ = 1; + coords.textureTopLeftQ = coords.textureTopRightQ = coords.textureTopLeftQ = coords.textureBottomLeftQ = 1; - // set up autoscale - if (c->autoscale && (video_width != s->width && video_height != s->height)) { - float width_multiplier = (float) s->width / (float) video_width; - float height_multiplier = (float) s->height / (float) video_height; - float scale_multiplier = qMin(width_multiplier, height_multiplier); + // set up autoscale + if (c->autoscale && (video_width != s->width && video_height != s->height)) { + float width_multiplier = (float) s->width / (float) video_width; + float height_multiplier = (float) s->height / (float) video_height; + float scale_multiplier = qMin(width_multiplier, height_multiplier); glScalef(scale_multiplier, scale_multiplier, 1); } // EFFECT CODE START - double timecode = get_timecode(c, playhead); + double timecode = get_timecode(c, playhead); - Effect* first_gizmo_effect = NULL; - Effect* selected_effect = NULL; + Effect* first_gizmo_effect = NULL; + Effect* selected_effect = NULL; for (int j=0;jeffects.size();j++) { - Effect* e = c->effects.at(j); - process_effect(c, e, timecode, coords, composite_texture, fbo_switcher, TA_NO_TRANSITION); + Effect* e = c->effects.at(j); + process_effect(c, e, timecode, coords, composite_texture, fbo_switcher, TA_NO_TRANSITION); - if (e->are_gizmos_enabled()) { - if (first_gizmo_effect == NULL) first_gizmo_effect = e; - if (e->container->selected) selected_effect = e; - } + if (e->are_gizmos_enabled()) { + if (first_gizmo_effect == NULL) first_gizmo_effect = e; + if (e->container->selected) selected_effect = e; + } } - if (!rendering) { - if (selected_effect != NULL) { - gizmos = selected_effect; - } else if (panel_timeline->is_clip_selected(c, true)) { - gizmos = first_gizmo_effect; - } - } - - if (c->get_opening_transition() != NULL) { - int transition_progress = playhead - c->get_timeline_in_with_transition(); - if (transition_progress < c->get_opening_transition()->get_length()) { - process_effect(c, c->get_opening_transition(), (double)transition_progress/(double)c->get_opening_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_OPENING_TRANSITION); + if (!rendering) { + if (selected_effect != NULL) { + gizmos = selected_effect; + } else if (panel_timeline->is_clip_selected(c, true)) { + gizmos = first_gizmo_effect; } - } + } - if (c->get_closing_transition() != NULL) { - int transition_progress = playhead - (c->get_timeline_out_with_transition() - c->get_closing_transition()->get_length()); - if (transition_progress >= 0 && transition_progress < c->get_closing_transition()->get_length()) { - process_effect(c, c->get_closing_transition(), (double)transition_progress/(double)c->get_closing_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_CLOSING_TRANSITION); + if (c->get_opening_transition() != NULL) { + int transition_progress = playhead - c->get_timeline_in_with_transition(); + if (transition_progress < c->get_opening_transition()->get_length()) { + process_effect(c, c->get_opening_transition(), (double)transition_progress/(double)c->get_opening_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_OPENING_TRANSITION); } - } + } + + if (c->get_closing_transition() != NULL) { + int transition_progress = playhead - (c->get_timeline_out_with_transition() - c->get_closing_transition()->get_length()); + if (transition_progress >= 0 && transition_progress < c->get_closing_transition()->get_length()) { + process_effect(c, c->get_closing_transition(), (double)transition_progress/(double)c->get_closing_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_CLOSING_TRANSITION); + } + } // EFFECT CODE END if (!nests.isEmpty()) { @@ -681,13 +682,13 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } else if (rendering) { glViewport(0, 0, s->width, s->height); } else { - int widget_width = width(); - int widget_height = height(); + int widget_width = width(); + int widget_height = height(); - widget_width *= QApplication::desktop()->devicePixelRatio(); - widget_height *= QApplication::desktop()->devicePixelRatio(); + widget_width *= QApplication::desktop()->devicePixelRatio(); + widget_height *= QApplication::desktop()->devicePixelRatio(); - glViewport(0, 0, widget_width, widget_height); + glViewport(0, 0, widget_width, widget_height); } glBindTexture(GL_TEXTURE_2D, composite_texture); @@ -695,62 +696,62 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glBegin(GL_QUADS); + glBegin(GL_QUADS); if (coords.grid_size <= 1) { - float z = 0.0f; + float z = 0.0f; - glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left - glVertex3f(coords.vertexTopLeftX, coords.vertexTopLeftY, z); // top left - glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right - glVertex3f(coords.vertexTopRightX, coords.vertexTopRightY, z); // top right - glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right - glVertex3f(coords.vertexBottomRightX, coords.vertexBottomRightY, z); // bottom right - glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left - glVertex3f(coords.vertexBottomLeftX, coords.vertexBottomLeftY, z); // bottom left + glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left + glVertex3f(coords.vertexTopLeftX, coords.vertexTopLeftY, z); // top left + glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right + glVertex3f(coords.vertexTopRightX, coords.vertexTopRightY, z); // top right + glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right + glVertex3f(coords.vertexBottomRightX, coords.vertexBottomRightY, z); // bottom right + glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left + glVertex3f(coords.vertexBottomLeftX, coords.vertexBottomLeftY, z); // bottom left } else { - float rows = coords.grid_size; - float cols = coords.grid_size; + float rows = coords.grid_size; + float cols = coords.grid_size; - for (float k=0;kgizmo_draw(timecode, coords); // set correct gizmo coords - gizmos->gizmo_world_to_screen(); + if (gizmos != NULL && !drawn_gizmos) { + gizmos->gizmo_draw(timecode, coords); // set correct gizmo coords + gizmos->gizmo_world_to_screen(); - drawn_gizmos = true; - } + drawn_gizmos = true; + } if (!nests.isEmpty()) { nests.last()->fbo[0]->release(); @@ -759,32 +760,32 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glPopMatrix(); - /*GLfloat motion_blur_frac = (GLfloat) motion_blur_prog / (GLfloat) motion_blur_lim; - if (motion_blur_prog == 0) { - glAccum(GL_LOAD, motion_blur_frac); - } else { - glAccum(GL_ACCUM, motion_blur_frac); - } - motion_blur_prog++;*/ + /*GLfloat motion_blur_frac = (GLfloat) motion_blur_prog / (GLfloat) motion_blur_lim; + if (motion_blur_prog == 0) { + glAccum(GL_LOAD, motion_blur_frac); + } else { + glAccum(GL_ACCUM, motion_blur_frac); + } + motion_blur_prog++;*/ } - } else { - if (render_audio || (config.enable_audio_scrubbing && audio_scrub)) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { - nests.append(c); - compose_sequence(nests, render_audio); - nests.removeLast(); - } else { - if (c->lock.tryLock()) { - // clip is not caching, start caching audio - cache_clip(c, playhead, c->audio_reset, !render_audio, nests); - c->lock.unlock(); - } - } + } else { + if (render_audio || (config.enable_audio_scrubbing && audio_scrub)) { + if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { + nests.append(c); + compose_sequence(nests, render_audio); + nests.removeLast(); + } else { + if (c->lock.tryLock()) { + // clip is not caching, start caching audio + cache_clip(c, playhead, c->audio_reset, !render_audio, nests); + c->lock.unlock(); + } + } } // visually update all the keyframe values if (c->sequence == viewer->seq) { // only if you can currently see them - double ts = (playhead - c->get_timeline_in_with_transition() + c->get_clip_in_with_transition())/s->frame_rate; + double ts = (playhead - c->get_timeline_in_with_transition() + c->get_clip_in_with_transition())/s->frame_rate; for (int i=0;ieffects.size();i++) { Effect* e = c->effects.at(i); for (int j=0;jrow_count();j++) { @@ -796,7 +797,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } } } - } + } } if (audio_track_count == 0) { @@ -814,136 +815,136 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } void ViewerWidget::paintGL() { - drawn_gizmos = false; - force_quit = false; - if (viewer->seq != NULL) { - gizmos = NULL; + drawn_gizmos = false; + force_quit = false; + if (viewer->seq != NULL) { + gizmos = NULL; - bool render_audio = (viewer->playing || rendering); - bool loop = false; - do { - loop = false; + bool render_audio = (viewer->playing || rendering); + bool loop = false; + do { + loop = false; - glClearColor(0, 0, 0, 1); - glMatrixMode(GL_MODELVIEW); - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glEnable(GL_DEPTH); + glClearColor(0, 0, 0, 1); + glMatrixMode(GL_MODELVIEW); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glEnable(GL_DEPTH); - texture_failed = false; + texture_failed = false; - if (!rendering) retry_timer.stop(); + if (!rendering) retry_timer.stop(); - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); - // compose video preview - glClearColor(0, 0, 0, 0); + // compose video preview + glClearColor(0, 0, 0, 0); - QVector nests; + QVector nests; - compose_sequence(nests, render_audio); + compose_sequence(nests, render_audio); - if (waveform) { - QPainter p(this); - if (viewer->seq->using_workarea) { - int in_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->workarea_in) - waveform_scroll; - int out_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->workarea_out) - waveform_scroll; + if (waveform) { + QPainter p(this); + if (viewer->seq->using_workarea) { + int in_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->workarea_in) - waveform_scroll; + int out_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->workarea_out) - waveform_scroll; - p.fillRect(QRect(in_x, 0, out_x - in_x, height()), QColor(255, 255, 255, 64)); - p.setPen(Qt::white); - p.drawLine(in_x, 0, in_x, height()); - p.drawLine(out_x, 0, out_x, height()); - } - QRect wr = rect(); - wr.setX(wr.x() - waveform_scroll); + p.fillRect(QRect(in_x, 0, out_x - in_x, height()), QColor(255, 255, 255, 64)); + p.setPen(Qt::white); + p.drawLine(in_x, 0, in_x, height()); + p.drawLine(out_x, 0, out_x, height()); + } + QRect wr = rect(); + wr.setX(wr.x() - waveform_scroll); - p.setPen(Qt::green); - draw_waveform(waveform_clip, waveform_ms, waveform_clip->timeline_out, &p, wr, waveform_scroll, width()+waveform_scroll, waveform_zoom); - p.setPen(Qt::red); - int playhead_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->playhead) - waveform_scroll; - p.drawLine(playhead_x, 0, playhead_x, height()); - } + p.setPen(Qt::green); + draw_waveform(waveform_clip, waveform_ms, waveform_clip->timeline_out, &p, wr, waveform_scroll, width()+waveform_scroll, waveform_zoom); + p.setPen(Qt::red); + int playhead_x = getScreenPointFromFrame(waveform_zoom, viewer->seq->playhead) - waveform_scroll; + p.drawLine(playhead_x, 0, playhead_x, height()); + } - if (force_quit) break; - if (texture_failed) { - if (rendering) { - dout << "[INFO] Texture failed - looping"; - loop = true; - } else { - retry_timer.start(); - } - } + if (force_quit) break; + if (texture_failed) { + if (rendering) { + dout << "[INFO] Texture failed - looping"; + loop = true; + } else { + retry_timer.start(); + } + } - if (config.show_title_safe_area && !rendering) { - drawTitleSafeArea(); - } + if (config.show_title_safe_area && !rendering) { + drawTitleSafeArea(); + } - if (gizmos != NULL && drawn_gizmos) { - float color[4]; - glGetFloatv(GL_CURRENT_COLOR, color); + if (gizmos != NULL && drawn_gizmos) { + float color[4]; + glGetFloatv(GL_CURRENT_COLOR, color); - float dot_size = GIZMO_DOT_SIZE / width() * viewer->seq->width; - float target_size = GIZMO_TARGET_SIZE / width() * viewer->seq->width; + float dot_size = GIZMO_DOT_SIZE / width() * viewer->seq->width; + float target_size = GIZMO_TARGET_SIZE / width() * viewer->seq->width; - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, viewer->seq->width, viewer->seq->height, 0, -1, 10); - float gizmo_z = 0.0f; - for (int j=0;jgizmo_count();j++) { - EffectGizmo* g = gizmos->gizmo(j); - glColor4f(g->color.redF(), g->color.greenF(), g->color.blueF(), 1.0); - switch (g->get_type()) { - case GIZMO_TYPE_DOT: // draw dot - glBegin(GL_QUADS); - glVertex3f(g->screen_pos[0].x()-dot_size, g->screen_pos[0].y()-dot_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+dot_size, g->screen_pos[0].y()-dot_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+dot_size, g->screen_pos[0].y()+dot_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()-dot_size, g->screen_pos[0].y()+dot_size, gizmo_z); - glEnd(); - break; - case GIZMO_TYPE_POLY: // draw lines - glBegin(GL_LINES); - for (int k=1;kget_point_count();k++) { - glVertex3f(g->screen_pos[k-1].x(), g->screen_pos[k-1].y(), gizmo_z); - glVertex3f(g->screen_pos[k].x(), g->screen_pos[k].y(), gizmo_z); - } - glVertex3f(g->screen_pos[g->get_point_count()-1].x(), g->screen_pos[g->get_point_count()-1].y(), gizmo_z); - glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y(), gizmo_z); - glEnd(); - break; - case GIZMO_TYPE_TARGET: // draw target - glBegin(GL_LINES); - glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()-target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()-target_size, gizmo_z); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, viewer->seq->width, viewer->seq->height, 0, -1, 10); + float gizmo_z = 0.0f; + for (int j=0;jgizmo_count();j++) { + EffectGizmo* g = gizmos->gizmo(j); + glColor4f(g->color.redF(), g->color.greenF(), g->color.blueF(), 1.0); + switch (g->get_type()) { + case GIZMO_TYPE_DOT: // draw dot + glBegin(GL_QUADS); + glVertex3f(g->screen_pos[0].x()-dot_size, g->screen_pos[0].y()-dot_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+dot_size, g->screen_pos[0].y()-dot_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+dot_size, g->screen_pos[0].y()+dot_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()-dot_size, g->screen_pos[0].y()+dot_size, gizmo_z); + glEnd(); + break; + case GIZMO_TYPE_POLY: // draw lines + glBegin(GL_LINES); + for (int k=1;kget_point_count();k++) { + glVertex3f(g->screen_pos[k-1].x(), g->screen_pos[k-1].y(), gizmo_z); + glVertex3f(g->screen_pos[k].x(), g->screen_pos[k].y(), gizmo_z); + } + glVertex3f(g->screen_pos[g->get_point_count()-1].x(), g->screen_pos[g->get_point_count()-1].y(), gizmo_z); + glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y(), gizmo_z); + glEnd(); + break; + case GIZMO_TYPE_TARGET: // draw target + glBegin(GL_LINES); + glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()-target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()-target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()-target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()+target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()-target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()+target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()+target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()+target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y()+target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()+target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()+target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()-target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()+target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y()-target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y(), gizmo_z); - glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y(), gizmo_z); + glVertex3f(g->screen_pos[0].x()-target_size, g->screen_pos[0].y(), gizmo_z); + glVertex3f(g->screen_pos[0].x()+target_size, g->screen_pos[0].y(), gizmo_z); - glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y()-target_size, gizmo_z); - glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y()+target_size, gizmo_z); - glEnd(); - break; - } - } - glPopMatrix(); + glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y()-target_size, gizmo_z); + glVertex3f(g->screen_pos[0].x(), g->screen_pos[0].y()+target_size, gizmo_z); + glEnd(); + break; + } + } + glPopMatrix(); - glColor4f(color[0], color[1], color[2], color[3]); + glColor4f(color[0], color[1], color[2], color[3]); - drawn_gizmos = true; - } + drawn_gizmos = true; + } - glDisable(GL_DEPTH); - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - } while (loop); - } + glDisable(GL_DEPTH); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + } while (loop); + } }