began transition rewrite
This commit is contained in:
@@ -29,8 +29,8 @@ CrossDissolveTransition::CrossDissolveTransition(ClipPtr c, ClipPtr s, const Eff
|
||||
}
|
||||
|
||||
void CrossDissolveTransition::process_coords(double progress, GLTextureCoords& coords, int data) {
|
||||
if (!(data == TA_CLOSING_TRANSITION && secondary_clip != nullptr)) {
|
||||
if (data == TA_CLOSING_TRANSITION) progress = 1.0 - progress;
|
||||
if (!(data == kTransitionClosing && secondary_clip != nullptr)) {
|
||||
if (data == kTransitionClosing) progress = 1.0 - progress;
|
||||
coords.opacity *= progress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ void ExponentialFadeTransition::process_audio(double timecode_start, double time
|
||||
break;
|
||||
}*/
|
||||
switch (type) {
|
||||
case TA_OPENING_TRANSITION:
|
||||
case kTransitionOpening:
|
||||
samp *= qPow(timecode_start + (interval * i), 2);
|
||||
break;
|
||||
case TA_CLOSING_TRANSITION:
|
||||
case kTransitionClosing:
|
||||
samp *= qPow(1 - (timecode_start + (interval * i)), 2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ void LinearFadeTransition::process_audio(double timecode_start, double timecode_
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
switch (type) {
|
||||
case TA_OPENING_TRANSITION:
|
||||
case kTransitionOpening:
|
||||
samp *= timecode_start + (interval * i);
|
||||
break;
|
||||
case TA_CLOSING_TRANSITION:
|
||||
case kTransitionClosing:
|
||||
samp *= 1 - (timecode_start + (interval * i));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ void LogarithmicFadeTransition::process_audio(double timecode_start, double time
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
switch (type) {
|
||||
case TA_OPENING_TRANSITION:
|
||||
case kTransitionOpening:
|
||||
samp *= qSqrt(timecode_start + (interval * i));
|
||||
break;
|
||||
case TA_CLOSING_TRANSITION:
|
||||
case kTransitionClosing:
|
||||
samp *= qSqrt(1 - (timecode_start + (interval * i)));
|
||||
break;
|
||||
}
|
||||
|
||||
+16
-8
@@ -80,11 +80,11 @@ void LoadThread::load_effect(QXmlStreamReader& stream, ClipPtr c) {
|
||||
|
||||
int type;
|
||||
if (tag == "opening") {
|
||||
type = TA_OPENING_TRANSITION;
|
||||
type = kTransitionOpening;
|
||||
} else if (tag == "closing") {
|
||||
type = TA_CLOSING_TRANSITION;
|
||||
type = kTransitionClosing;
|
||||
} else {
|
||||
type = TA_NO_TRANSITION;
|
||||
type = kTransitionNone;
|
||||
}
|
||||
|
||||
emit start_create_effect_ui(&stream, c, type, &effect_name, meta, effect_length, effect_enabled);
|
||||
@@ -391,11 +391,11 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
} else if (attr.name() == "track") {
|
||||
c->track = attr.value().toInt();
|
||||
} else if (attr.name() == "r") {
|
||||
c->color_r = attr.value().toInt();
|
||||
c->color_r = quint8(attr.value().toInt());
|
||||
} else if (attr.name() == "g") {
|
||||
c->color_g = attr.value().toInt();
|
||||
c->color_g = quint8(attr.value().toInt());
|
||||
} else if (attr.name() == "b") {
|
||||
c->color_b = attr.value().toInt();
|
||||
c->color_b = quint8(attr.value().toInt());
|
||||
} else if (attr.name() == "autoscale") {
|
||||
c->autoscale = (attr.value() == "1");
|
||||
} else if (attr.name() == "media") {
|
||||
@@ -409,10 +409,12 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
c->maintain_audio_pitch = (attr.value() == "1");
|
||||
} else if (attr.name() == "reverse") {
|
||||
c->reverse = (attr.value() == "1");
|
||||
/*
|
||||
} else if (attr.name() == "opening") {
|
||||
c->opening_transition = attr.value().toInt();
|
||||
} else if (attr.name() == "closing") {
|
||||
c->closing_transition = attr.value().toInt();
|
||||
*/
|
||||
} else if (attr.name() == "sequence") {
|
||||
media_type = MEDIA_TYPE_SEQUENCE;
|
||||
|
||||
@@ -514,6 +516,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// re-link clips to transitions
|
||||
if (correct_clip->opening_transition > -1) {
|
||||
for (int j=0;j<transition_data.size();j++) {
|
||||
@@ -552,6 +555,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
waitCond.wait(&mutex);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Media* m = panel_project->create_sequence_internal(nullptr, s, false, parent);
|
||||
@@ -792,7 +796,7 @@ void LoadThread::create_effect_ui(
|
||||
mutex.lock();
|
||||
|
||||
if (cancelled) return;
|
||||
if (type == TA_NO_TRANSITION) {
|
||||
if (type == kTransitionNone) {
|
||||
if (meta == nullptr) {
|
||||
// create void effect
|
||||
EffectPtr ve(new VoidEffect(c, *effect_name));
|
||||
@@ -807,17 +811,19 @@ void LoadThread::create_effect_ui(
|
||||
c->effects.append(e);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
int transition_index = create_transition(c, nullptr, meta);
|
||||
TransitionPtr t = c->sequence->transitions.at(transition_index);
|
||||
if (effect_length > -1) t->set_length(effect_length);
|
||||
t->set_enabled(effect_enabled);
|
||||
t->load(*stream);
|
||||
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
if (type == kTransitionOpening) {
|
||||
c->opening_transition = transition_index;
|
||||
} else {
|
||||
c->closing_transition = transition_index;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
mutex.unlock();
|
||||
@@ -829,10 +835,12 @@ void LoadThread::create_dual_transition(const TransitionData* td, ClipPtr primar
|
||||
// lock mutex - ensures the load thread is suspended while this happens
|
||||
mutex.lock();
|
||||
|
||||
/*
|
||||
int transition_index = create_transition(primary, secondary, meta);
|
||||
primary->sequence->transitions.at(transition_index)->set_length(td->length);
|
||||
if (td->otc != nullptr) td->otc->opening_transition = transition_index;
|
||||
if (td->ctc != nullptr) td->ctc->closing_transition = transition_index;
|
||||
*/
|
||||
|
||||
mutex.unlock();
|
||||
|
||||
|
||||
+465
-477
File diff suppressed because it is too large
Load Diff
+22
-22
@@ -29,34 +29,34 @@
|
||||
#include "project/media.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libswresample/swresample.h>
|
||||
}
|
||||
|
||||
class PreviewGenerator : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreviewGenerator(Media*, FootagePtr, bool);
|
||||
void run();
|
||||
void cancel();
|
||||
PreviewGenerator(Media*, FootagePtr, bool);
|
||||
void run();
|
||||
void cancel();
|
||||
private:
|
||||
void parse_media();
|
||||
bool retrieve_preview(const QString &hash);
|
||||
void generate_waveform();
|
||||
void finalize_media();
|
||||
AVFormatContext* fmt_ctx;
|
||||
Media* media;
|
||||
FootagePtr footage;
|
||||
bool retrieve_duration;
|
||||
bool contains_still_image;
|
||||
bool replace;
|
||||
bool cancelled;
|
||||
QDir data_dir;
|
||||
QString get_thumbnail_path(const QString &hash, const FootageStream &ms);
|
||||
QString get_waveform_path(const QString& hash, const FootageStream &ms);
|
||||
void parse_media();
|
||||
bool retrieve_preview(const QString &hash);
|
||||
void generate_waveform();
|
||||
void finalize_media();
|
||||
AVFormatContext* fmt_ctx;
|
||||
Media* media;
|
||||
FootagePtr footage;
|
||||
bool retrieve_duration;
|
||||
bool contains_still_image;
|
||||
bool replace;
|
||||
bool cancelled;
|
||||
QDir data_dir;
|
||||
QString get_thumbnail_path(const QString &hash, const FootageStream &ms);
|
||||
QString get_waveform_path(const QString& hash, const FootageStream &ms);
|
||||
};
|
||||
|
||||
#endif // PREVIEWGENERATOR_H
|
||||
|
||||
@@ -29,107 +29,114 @@
|
||||
#include "io/config.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
olive::Global = std::unique_ptr<OliveGlobal>(new OliveGlobal);
|
||||
olive::Global = std::unique_ptr<OliveGlobal>(new OliveGlobal);
|
||||
|
||||
bool launch_fullscreen = false;
|
||||
QString load_proj;
|
||||
bool launch_fullscreen = false;
|
||||
QString load_proj;
|
||||
|
||||
bool use_internal_logger = true;
|
||||
bool use_internal_logger = true;
|
||||
|
||||
if (argc > 1) {
|
||||
for (int i=1;i<argc;i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
|
||||
if (argc > 1) {
|
||||
for (int i=1;i<argc;i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) {
|
||||
#ifndef GITHASH
|
||||
qWarning() << "No Git commit information found";
|
||||
qWarning() << "No Git commit information found";
|
||||
#endif
|
||||
printf("%s\n", olive::AppName.toUtf8().constData());
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
|
||||
printf("Usage: %s [options] [filename]\n\n"
|
||||
"[filename] is the file to open on startup.\n\n"
|
||||
"Options:\n"
|
||||
"\t-v, --version\t\tShow version information\n"
|
||||
"\t-h, --help\t\tShow this help\n"
|
||||
"\t-f, --fullscreen\tStart in full screen mode\n"
|
||||
"\t--disable-shaders\tDisable OpenGL shaders (for debugging)\n"
|
||||
"\t--no-debug\t\tDisable internal debug log and output directly to console\n"
|
||||
"\t--disable-blend-modes\tDisable shader-based blending for older GPUs\n"
|
||||
"\t--translation <file>\tSet an external language file to use\n"
|
||||
"\n"
|
||||
"Environment Variables:\n"
|
||||
"\tOLIVE_EFFECTS_PATH\tSpecify a path to search for GLSL shader effects\n"
|
||||
"\tFREI0R_PATH\t\tSpecify a path to search for Frei0r effects\n"
|
||||
"\tOLIVE_LANG_PATH\t\tSpecify a path to search for translation files\n"
|
||||
"\n", argv[0]);
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {
|
||||
launch_fullscreen = true;
|
||||
} else if (!strcmp(argv[i], "--disable-shaders")) {
|
||||
olive::CurrentRuntimeConfig.shaders_are_enabled = false;
|
||||
} else if (!strcmp(argv[i], "--no-debug")) {
|
||||
use_internal_logger = false;
|
||||
} else if (!strcmp(argv[i], "--disable-blend-modes")) {
|
||||
olive::CurrentRuntimeConfig.disable_blending = true;
|
||||
} else if (!strcmp(argv[i], "--translation")) {
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
// load translation file
|
||||
olive::CurrentRuntimeConfig.external_translation_file = argv[i + 1];
|
||||
printf("%s\n", olive::AppName.toUtf8().constData());
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
|
||||
printf("Usage: %s [options] [filename]\n\n"
|
||||
"[filename] is the file to open on startup.\n\n"
|
||||
"Options:\n"
|
||||
"\t-v, --version\t\tShow version information\n"
|
||||
"\t-h, --help\t\tShow this help\n"
|
||||
"\t-f, --fullscreen\tStart in full screen mode\n"
|
||||
"\t--disable-shaders\tDisable OpenGL shaders (for debugging)\n"
|
||||
"\t--no-debug\t\tDisable internal debug log and output directly to console\n"
|
||||
"\t--disable-blend-modes\tDisable shader-based blending for older GPUs\n"
|
||||
"\t--translation <file>\tSet an external language file to use\n"
|
||||
"\n"
|
||||
"Environment Variables:\n"
|
||||
"\tOLIVE_EFFECTS_PATH\tSpecify a path to search for GLSL shader effects\n"
|
||||
"\tFREI0R_PATH\t\tSpecify a path to search for Frei0r effects\n"
|
||||
"\tOLIVE_LANG_PATH\t\tSpecify a path to search for translation files\n"
|
||||
"\n", argv[0]);
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "--fullscreen") || !strcmp(argv[i], "-f")) {
|
||||
launch_fullscreen = true;
|
||||
} else if (!strcmp(argv[i], "--disable-shaders")) {
|
||||
olive::CurrentRuntimeConfig.shaders_are_enabled = false;
|
||||
} else if (!strcmp(argv[i], "--no-debug")) {
|
||||
use_internal_logger = false;
|
||||
} else if (!strcmp(argv[i], "--disable-blend-modes")) {
|
||||
olive::CurrentRuntimeConfig.disable_blending = true;
|
||||
} else if (!strcmp(argv[i], "--translation")) {
|
||||
if (i + 1 < argc && argv[i + 1][0] != '-') {
|
||||
// load translation file
|
||||
olive::CurrentRuntimeConfig.external_translation_file = argv[i + 1];
|
||||
|
||||
i++;
|
||||
} else {
|
||||
printf("[ERROR] No translation file specified\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
printf("[ERROR] Unknown argument '%s'\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
} else if (load_proj.isEmpty()) {
|
||||
load_proj = argv[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (use_internal_logger) {
|
||||
qInstallMessageHandler(debug_message_handler);
|
||||
i++;
|
||||
} else {
|
||||
printf("[ERROR] No translation file specified\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
printf("[ERROR] Unknown argument '%s'\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
} else if (load_proj.isEmpty()) {
|
||||
load_proj = argv[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize ffmpeg subsystem
|
||||
// (these have been deprecated in FFmpeg 4, but are still necessary for FFmpeg 3)
|
||||
av_register_all();
|
||||
avfilter_register_all();
|
||||
if (use_internal_logger) {
|
||||
qInstallMessageHandler(debug_message_handler);
|
||||
}
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
// Initialize ffmpeg subsystem
|
||||
// (these have been deprecated in FFmpeg 4, but are still necessary for FFmpeg 3)
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
|
||||
av_register_all();
|
||||
#endif
|
||||
|
||||
QApplication a(argc, argv);
|
||||
a.setWindowIcon(QIcon(":/icons/olive64.png"));
|
||||
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(7, 14, 100)
|
||||
avfilter_register_all();
|
||||
#endif
|
||||
|
||||
olive::media_icon_service = std::unique_ptr<MediaIconService>(new MediaIconService());
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
|
||||
QCoreApplication::setOrganizationName("olivevideoeditor.org");
|
||||
QCoreApplication::setOrganizationDomain("olivevideoeditor.org");
|
||||
QCoreApplication::setApplicationName("Olive");
|
||||
QGuiApplication::setDesktopFileName("org.olivevideoeditor.Olive");
|
||||
QApplication a(argc, argv);
|
||||
a.setWindowIcon(QIcon(":/icons/olive64.png"));
|
||||
|
||||
MainWindow w(nullptr);
|
||||
// start media icon service (uses QPixmaps which require a QGuiApplication to have been created)
|
||||
olive::media_icon_service = std::unique_ptr<MediaIconService>(new MediaIconService());
|
||||
|
||||
// connect main window's first paint to global's init finished function
|
||||
QObject::connect(&w, SIGNAL(finished_first_paint()), olive::Global.get(), SLOT(finished_initialize()));
|
||||
// set app name data
|
||||
QCoreApplication::setOrganizationName("olivevideoeditor.org");
|
||||
QCoreApplication::setOrganizationDomain("olivevideoeditor.org");
|
||||
QCoreApplication::setApplicationName("Olive");
|
||||
QGuiApplication::setDesktopFileName("org.olivevideoeditor.Olive");
|
||||
|
||||
if (!load_proj.isEmpty()) {
|
||||
olive::Global->load_project_on_launch(load_proj);
|
||||
}
|
||||
if (launch_fullscreen) {
|
||||
w.showFullScreen();
|
||||
} else {
|
||||
w.showMaximized();
|
||||
}
|
||||
MainWindow w(nullptr);
|
||||
|
||||
return a.exec();
|
||||
// connect main window's first paint to global's init finished function
|
||||
QObject::connect(&w, SIGNAL(finished_first_paint()), olive::Global.get(), SLOT(finished_initialize()));
|
||||
|
||||
if (!load_proj.isEmpty()) {
|
||||
olive::Global->load_project_on_launch(load_proj);
|
||||
}
|
||||
if (launch_fullscreen) {
|
||||
w.showFullScreen();
|
||||
} else {
|
||||
w.showMaximized();
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
+394
-394
@@ -52,567 +52,567 @@
|
||||
#include "debug.h"
|
||||
|
||||
EffectControls::EffectControls(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
multiple(false),
|
||||
zoom(1),
|
||||
panel_name(tr("Effects: ")),
|
||||
mode(TA_NO_TRANSITION)
|
||||
QDockWidget(parent),
|
||||
multiple(false),
|
||||
zoom(1),
|
||||
panel_name(tr("Effects: ")),
|
||||
mode(kTransitionNone)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
setup_ui();
|
||||
setup_ui();
|
||||
|
||||
clear_effects(false);
|
||||
headers->viewer = panel_sequence_viewer;
|
||||
headers->snapping = false;
|
||||
clear_effects(false);
|
||||
headers->viewer = panel_sequence_viewer;
|
||||
headers->snapping = false;
|
||||
|
||||
effects_area->parent_widget = scrollArea;
|
||||
effects_area->keyframe_area = keyframeView;
|
||||
effects_area->header = headers;
|
||||
keyframeView->header = headers;
|
||||
effects_area->parent_widget = scrollArea;
|
||||
effects_area->keyframe_area = keyframeView;
|
||||
effects_area->header = headers;
|
||||
keyframeView->header = headers;
|
||||
|
||||
lblMultipleClipsSelected->setVisible(false);
|
||||
lblMultipleClipsSelected->setVisible(false);
|
||||
|
||||
connect(keyframeView, SIGNAL(wheel_event_signal(QWheelEvent*)), effects_area, SLOT(receive_wheel_event(QWheelEvent*)));
|
||||
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), headers, SLOT(set_scroll(int)));
|
||||
connect(horizontalScrollBar, SIGNAL(resize_move(double)), keyframeView, SLOT(resize_move(double)));
|
||||
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_x_scroll(int)));
|
||||
connect(verticalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_y_scroll(int)));
|
||||
connect(verticalScrollBar, SIGNAL(valueChanged(int)), scrollArea->verticalScrollBar(), SLOT(setValue(int)));
|
||||
connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar, SLOT(setValue(int)));
|
||||
connect(keyframeView, SIGNAL(wheel_event_signal(QWheelEvent*)), effects_area, SLOT(receive_wheel_event(QWheelEvent*)));
|
||||
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), headers, SLOT(set_scroll(int)));
|
||||
connect(horizontalScrollBar, SIGNAL(resize_move(double)), keyframeView, SLOT(resize_move(double)));
|
||||
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_x_scroll(int)));
|
||||
connect(verticalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_y_scroll(int)));
|
||||
connect(verticalScrollBar, SIGNAL(valueChanged(int)), scrollArea->verticalScrollBar(), SLOT(setValue(int)));
|
||||
connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar, SLOT(setValue(int)));
|
||||
}
|
||||
|
||||
EffectControls::~EffectControls() {}
|
||||
|
||||
int EffectControls::get_mode() {
|
||||
return mode;
|
||||
return mode;
|
||||
}
|
||||
|
||||
bool EffectControls::keyframe_focus() {
|
||||
return headers->hasFocus() || keyframeView->hasFocus();
|
||||
return headers->hasFocus() || keyframeView->hasFocus();
|
||||
}
|
||||
|
||||
void EffectControls::set_zoom(bool in) {
|
||||
zoom *= (in) ? 2 : 0.5;
|
||||
update_keyframes();
|
||||
zoom *= (in) ? 2 : 0.5;
|
||||
update_keyframes();
|
||||
}
|
||||
|
||||
void EffectControls::menu_select(QAction* q) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) {
|
||||
const EffectMeta* meta = reinterpret_cast<const EffectMeta*>(q->data().value<quintptr>());
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
if (c->get_opening_transition() == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_OPENING_TRANSITION, 30));
|
||||
}
|
||||
if (c->get_closing_transition() == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_CLOSING_TRANSITION, 30));
|
||||
}
|
||||
} else {
|
||||
ca->append(new AddEffectCommand(c, nullptr, meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
olive::UndoStack.push(ca);
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
update_ui(true);
|
||||
} else {
|
||||
reload_clips();
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
}
|
||||
ComboAction* ca = new ComboAction();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) {
|
||||
const EffectMeta* meta = reinterpret_cast<const EffectMeta*>(q->data().value<quintptr>());
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
if (c->opening_transition == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, kTransitionOpening, 30));
|
||||
}
|
||||
if (c->closing_transition == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, kTransitionClosing, 30));
|
||||
}
|
||||
} else {
|
||||
ca->append(new AddEffectCommand(c, nullptr, meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
olive::UndoStack.push(ca);
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
update_ui(true);
|
||||
} else {
|
||||
reload_clips();
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::update_keyframes() {
|
||||
headers->update_zoom(zoom);
|
||||
keyframeView->update();
|
||||
headers->update_zoom(zoom);
|
||||
keyframeView->update();
|
||||
}
|
||||
|
||||
void EffectControls::delete_selected_keyframes() {
|
||||
keyframeView->delete_selected_keyframes();
|
||||
keyframeView->delete_selected_keyframes();
|
||||
}
|
||||
|
||||
void EffectControls::copy(bool del) {
|
||||
if (mode == TA_NO_TRANSITION) {
|
||||
bool cleared = false;
|
||||
if (mode == kTransitionNone) {
|
||||
bool cleared = false;
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : nullptr;
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
if (!cleared) {
|
||||
clear_clipboard();
|
||||
cleared = true;
|
||||
clipboard_type = CLIPBOARD_TYPE_EFFECT;
|
||||
}
|
||||
ComboAction* ca = new ComboAction();
|
||||
EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : nullptr;
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
if (!cleared) {
|
||||
clear_clipboard();
|
||||
cleared = true;
|
||||
clipboard_type = CLIPBOARD_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
clipboard.append(EffectPtr(effect->copy(nullptr)));
|
||||
clipboard.append(EffectPtr(effect->copy(nullptr)));
|
||||
|
||||
if (del_com != nullptr) {
|
||||
del_com->clips.append(c);
|
||||
del_com->fx.append(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (del_com != nullptr) {
|
||||
if (del_com->clips.size() > 0) {
|
||||
ca->append(del_com);
|
||||
} else {
|
||||
delete del_com;
|
||||
}
|
||||
}
|
||||
olive::UndoStack.push(ca);
|
||||
}
|
||||
if (del_com != nullptr) {
|
||||
del_com->clips.append(c);
|
||||
del_com->fx.append(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (del_com != nullptr) {
|
||||
if (del_com->clips.size() > 0) {
|
||||
ca->append(del_com);
|
||||
} else {
|
||||
delete del_com;
|
||||
}
|
||||
}
|
||||
olive::UndoStack.push(ca);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::scroll_to_frame(long frame) {
|
||||
scroll_to_frame_internal(horizontalScrollBar, frame, zoom, keyframeView->width());
|
||||
scroll_to_frame_internal(horizontalScrollBar, frame, zoom, keyframeView->width());
|
||||
}
|
||||
|
||||
void EffectControls::add_effect_paste_action(QMenu *menu) {
|
||||
QAction* paste_action = menu->addAction(tr("&Paste"), panel_timeline, SLOT(paste(bool)));
|
||||
paste_action->setEnabled(clipboard.size() > 0 && clipboard_type == CLIPBOARD_TYPE_EFFECT);
|
||||
QAction* paste_action = menu->addAction(tr("&Paste"), panel_timeline, SLOT(paste(bool)));
|
||||
paste_action->setEnabled(clipboard.size() > 0 && clipboard_type == CLIPBOARD_TYPE_EFFECT);
|
||||
}
|
||||
|
||||
void EffectControls::cut() {
|
||||
copy(true);
|
||||
copy(true);
|
||||
}
|
||||
|
||||
void EffectControls::show_effect_menu(int type, int subtype) {
|
||||
effect_menu_type = type;
|
||||
effect_menu_subtype = subtype;
|
||||
effect_menu_type = type;
|
||||
effect_menu_subtype = subtype;
|
||||
|
||||
effects_loaded.lock();
|
||||
effects_loaded.lock();
|
||||
|
||||
QMenu effects_menu(this);
|
||||
effects_menu.setToolTipsVisible(true);
|
||||
QMenu effects_menu(this);
|
||||
effects_menu.setToolTipsVisible(true);
|
||||
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
const EffectMeta& em = effects.at(i);
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
const EffectMeta& em = effects.at(i);
|
||||
|
||||
if (em.type == type && em.subtype == subtype) {
|
||||
QAction* action = new QAction(&effects_menu);
|
||||
action->setText(em.name);
|
||||
action->setData(reinterpret_cast<quintptr>(&em));
|
||||
if (!em.tooltip.isEmpty()) {
|
||||
action->setToolTip(em.tooltip);
|
||||
if (em.type == type && em.subtype == subtype) {
|
||||
QAction* action = new QAction(&effects_menu);
|
||||
action->setText(em.name);
|
||||
action->setData(reinterpret_cast<quintptr>(&em));
|
||||
if (!em.tooltip.isEmpty()) {
|
||||
action->setToolTip(em.tooltip);
|
||||
}
|
||||
|
||||
QMenu* parent = &effects_menu;
|
||||
if (!em.category.isEmpty()) {
|
||||
bool found = false;
|
||||
for (int j=0;j<effects_menu.actions().size();j++) {
|
||||
QAction* action = effects_menu.actions().at(j);
|
||||
if (action->menu() != nullptr) {
|
||||
if (action->menu()->title() == em.category) {
|
||||
parent = action->menu();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
QMenu* parent = &effects_menu;
|
||||
if (!em.category.isEmpty()) {
|
||||
bool found = false;
|
||||
for (int j=0;j<effects_menu.actions().size();j++) {
|
||||
QAction* action = effects_menu.actions().at(j);
|
||||
if (action->menu() != nullptr) {
|
||||
if (action->menu()->title() == em.category) {
|
||||
parent = action->menu();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
parent = new QMenu(&effects_menu);
|
||||
parent->setToolTipsVisible(true);
|
||||
parent->setTitle(em.category);
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<effects_menu.actions().size();i++) {
|
||||
QAction* comp_action = effects_menu.actions().at(i);
|
||||
if (comp_action->text() > em.category) {
|
||||
effects_menu.insertMenu(comp_action, parent);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) effects_menu.addMenu(parent);
|
||||
}
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<parent->actions().size();i++) {
|
||||
QAction* comp_action = parent->actions().at(i);
|
||||
if (comp_action->text() > action->text()) {
|
||||
parent->insertAction(comp_action, action);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) parent->addAction(action);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
parent = new QMenu(&effects_menu);
|
||||
parent->setToolTipsVisible(true);
|
||||
parent->setTitle(em.category);
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<effects_menu.actions().size();i++) {
|
||||
QAction* comp_action = effects_menu.actions().at(i);
|
||||
if (comp_action->text() > em.category) {
|
||||
effects_menu.insertMenu(comp_action, parent);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) effects_menu.addMenu(parent);
|
||||
}
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<parent->actions().size();i++) {
|
||||
QAction* comp_action = parent->actions().at(i);
|
||||
if (comp_action->text() > action->text()) {
|
||||
parent->insertAction(comp_action, action);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) parent->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
effects_loaded.unlock();
|
||||
effects_loaded.unlock();
|
||||
|
||||
connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));
|
||||
effects_menu.exec(QCursor::pos());
|
||||
connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));
|
||||
effects_menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void EffectControls::clear_effects(bool clear_cache) {
|
||||
// clear existing clips
|
||||
deselect_all_effects(nullptr);
|
||||
// clear existing clips
|
||||
deselect_all_effects(nullptr);
|
||||
|
||||
// clear graph editor
|
||||
if (panel_graph_editor != nullptr) panel_graph_editor->set_row(nullptr);
|
||||
// clear graph editor
|
||||
if (panel_graph_editor != nullptr) panel_graph_editor->set_row(nullptr);
|
||||
|
||||
QVBoxLayout* video_layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
|
||||
QVBoxLayout* audio_layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
|
||||
QLayoutItem* item;
|
||||
while ((item = video_layout->takeAt(0))) {
|
||||
item->widget()->setParent(nullptr);
|
||||
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
}
|
||||
while ((item = audio_layout->takeAt(0))) {
|
||||
item->widget()->setParent(nullptr);
|
||||
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
}
|
||||
lblMultipleClipsSelected->setVisible(false);
|
||||
vcontainer->setVisible(false);
|
||||
acontainer->setVisible(false);
|
||||
headers->setVisible(false);
|
||||
keyframeView->setEnabled(false);
|
||||
if (clear_cache) selected_clips.clear();
|
||||
setWindowTitle(panel_name + "(none)");
|
||||
QVBoxLayout* video_layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
|
||||
QVBoxLayout* audio_layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
|
||||
QLayoutItem* item;
|
||||
while ((item = video_layout->takeAt(0))) {
|
||||
item->widget()->setParent(nullptr);
|
||||
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
}
|
||||
while ((item = audio_layout->takeAt(0))) {
|
||||
item->widget()->setParent(nullptr);
|
||||
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
}
|
||||
lblMultipleClipsSelected->setVisible(false);
|
||||
vcontainer->setVisible(false);
|
||||
acontainer->setVisible(false);
|
||||
headers->setVisible(false);
|
||||
keyframeView->setEnabled(false);
|
||||
if (clear_cache) selected_clips.clear();
|
||||
setWindowTitle(panel_name + "(none)");
|
||||
}
|
||||
|
||||
void EffectControls::deselect_all_effects(QWidget* sender) {
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
if (c->effects.at(j)->container != sender) {
|
||||
c->effects.at(j)->container->header_click(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_sequence_viewer->viewer_widget->update();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
if (c->effects.at(j)->container != sender) {
|
||||
c->effects.at(j)->container->header_click(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_sequence_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void EffectControls::open_effect(QVBoxLayout* layout, EffectPtr e) {
|
||||
CollapsibleWidget* container = e->container;
|
||||
layout->addWidget(container);
|
||||
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
CollapsibleWidget* container = e->container;
|
||||
layout->addWidget(container);
|
||||
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
|
||||
}
|
||||
|
||||
void EffectControls::setup_ui() {
|
||||
QWidget* contents = new QWidget(this);
|
||||
QWidget* contents = new QWidget(this);
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout(contents);
|
||||
hlayout->setSpacing(0);
|
||||
hlayout->setMargin(0);
|
||||
QHBoxLayout* hlayout = new QHBoxLayout(contents);
|
||||
hlayout->setSpacing(0);
|
||||
hlayout->setMargin(0);
|
||||
|
||||
QSplitter* splitter = new QSplitter();
|
||||
splitter->setOrientation(Qt::Horizontal);
|
||||
splitter->setChildrenCollapsible(false);
|
||||
QSplitter* splitter = new QSplitter();
|
||||
splitter->setOrientation(Qt::Horizontal);
|
||||
splitter->setChildrenCollapsible(false);
|
||||
|
||||
scrollArea = new QScrollArea();
|
||||
scrollArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
scrollArea->setFrameShape(QFrame::NoFrame);
|
||||
scrollArea->setFrameShadow(QFrame::Plain);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea = new QScrollArea();
|
||||
scrollArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
scrollArea->setFrameShape(QFrame::NoFrame);
|
||||
scrollArea->setFrameShadow(QFrame::Plain);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
|
||||
QWidget* scrollAreaWidgetContents = new QWidget();
|
||||
QWidget* scrollAreaWidgetContents = new QWidget();
|
||||
|
||||
QHBoxLayout* scrollAreaLayout = new QHBoxLayout(scrollAreaWidgetContents);
|
||||
scrollAreaLayout->setSpacing(0);
|
||||
scrollAreaLayout->setMargin(0);
|
||||
QHBoxLayout* scrollAreaLayout = new QHBoxLayout(scrollAreaWidgetContents);
|
||||
scrollAreaLayout->setSpacing(0);
|
||||
scrollAreaLayout->setMargin(0);
|
||||
|
||||
effects_area = new EffectsArea();
|
||||
effects_area->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(effects_area, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(effects_area_context_menu()));
|
||||
effects_area = new EffectsArea();
|
||||
effects_area->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(effects_area, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(effects_area_context_menu()));
|
||||
|
||||
QVBoxLayout* effects_area_layout = new QVBoxLayout(effects_area);
|
||||
effects_area_layout->setSpacing(0);
|
||||
effects_area_layout->setMargin(0);
|
||||
QVBoxLayout* effects_area_layout = new QVBoxLayout(effects_area);
|
||||
effects_area_layout->setSpacing(0);
|
||||
effects_area_layout->setMargin(0);
|
||||
|
||||
vcontainer = new QWidget();
|
||||
QVBoxLayout* vcontainerLayout = new QVBoxLayout(vcontainer);
|
||||
vcontainerLayout->setSpacing(0);
|
||||
vcontainerLayout->setMargin(0);
|
||||
vcontainer = new QWidget();
|
||||
QVBoxLayout* vcontainerLayout = new QVBoxLayout(vcontainer);
|
||||
vcontainerLayout->setSpacing(0);
|
||||
vcontainerLayout->setMargin(0);
|
||||
|
||||
QWidget* veHeader = new QWidget();
|
||||
veHeader->setObjectName(QStringLiteral("veHeader"));
|
||||
veHeader->setStyleSheet(QLatin1String("#veHeader { background: rgba(0, 0, 0, 0.25); }"));
|
||||
QWidget* veHeader = new QWidget();
|
||||
veHeader->setObjectName(QStringLiteral("veHeader"));
|
||||
veHeader->setStyleSheet(QLatin1String("#veHeader { background: rgba(0, 0, 0, 0.25); }"));
|
||||
|
||||
QHBoxLayout* veHeaderLayout = new QHBoxLayout(veHeader);
|
||||
veHeaderLayout->setSpacing(0);
|
||||
veHeaderLayout->setMargin(0);
|
||||
QHBoxLayout* veHeaderLayout = new QHBoxLayout(veHeader);
|
||||
veHeaderLayout->setSpacing(0);
|
||||
veHeaderLayout->setMargin(0);
|
||||
|
||||
QPushButton* btnAddVideoEffect = new QPushButton();
|
||||
btnAddVideoEffect->setIcon(QIcon(":/icons/add-effect.png"));
|
||||
btnAddVideoEffect->setToolTip(tr("Add Video Effect"));
|
||||
veHeaderLayout->addWidget(btnAddVideoEffect);
|
||||
connect(btnAddVideoEffect, SIGNAL(clicked(bool)), this, SLOT(video_effect_click()));
|
||||
QPushButton* btnAddVideoEffect = new QPushButton();
|
||||
btnAddVideoEffect->setIcon(QIcon(":/icons/add-effect.png"));
|
||||
btnAddVideoEffect->setToolTip(tr("Add Video Effect"));
|
||||
veHeaderLayout->addWidget(btnAddVideoEffect);
|
||||
connect(btnAddVideoEffect, SIGNAL(clicked(bool)), this, SLOT(video_effect_click()));
|
||||
|
||||
veHeaderLayout->addStretch();
|
||||
veHeaderLayout->addStretch();
|
||||
|
||||
QLabel* lblVideoEffects = new QLabel();
|
||||
QFont font;
|
||||
font.setPointSize(9);
|
||||
lblVideoEffects->setFont(font);
|
||||
lblVideoEffects->setAlignment(Qt::AlignCenter);
|
||||
lblVideoEffects->setText(tr("VIDEO EFFECTS"));
|
||||
veHeaderLayout->addWidget(lblVideoEffects);
|
||||
QLabel* lblVideoEffects = new QLabel();
|
||||
QFont font;
|
||||
font.setPointSize(9);
|
||||
lblVideoEffects->setFont(font);
|
||||
lblVideoEffects->setAlignment(Qt::AlignCenter);
|
||||
lblVideoEffects->setText(tr("VIDEO EFFECTS"));
|
||||
veHeaderLayout->addWidget(lblVideoEffects);
|
||||
|
||||
veHeaderLayout->addStretch();
|
||||
veHeaderLayout->addStretch();
|
||||
|
||||
QPushButton* btnAddVideoTransition = new QPushButton();
|
||||
btnAddVideoTransition->setIcon(QIcon(":/icons/add-transition.png"));
|
||||
btnAddVideoTransition->setToolTip(tr("Add Video Transition"));
|
||||
connect(btnAddVideoTransition, SIGNAL(clicked(bool)), this, SLOT(video_transition_click()));
|
||||
veHeaderLayout->addWidget(btnAddVideoTransition);
|
||||
QPushButton* btnAddVideoTransition = new QPushButton();
|
||||
btnAddVideoTransition->setIcon(QIcon(":/icons/add-transition.png"));
|
||||
btnAddVideoTransition->setToolTip(tr("Add Video Transition"));
|
||||
connect(btnAddVideoTransition, SIGNAL(clicked(bool)), this, SLOT(video_transition_click()));
|
||||
veHeaderLayout->addWidget(btnAddVideoTransition);
|
||||
|
||||
vcontainerLayout->addWidget(veHeader);
|
||||
vcontainerLayout->addWidget(veHeader);
|
||||
|
||||
video_effect_area = new QWidget();
|
||||
QVBoxLayout* veAreaLayout = new QVBoxLayout(video_effect_area);
|
||||
veAreaLayout->setSpacing(0);
|
||||
veAreaLayout->setMargin(0);
|
||||
video_effect_area = new QWidget();
|
||||
QVBoxLayout* veAreaLayout = new QVBoxLayout(video_effect_area);
|
||||
veAreaLayout->setSpacing(0);
|
||||
veAreaLayout->setMargin(0);
|
||||
|
||||
vcontainerLayout->addWidget(video_effect_area);
|
||||
vcontainerLayout->addWidget(video_effect_area);
|
||||
|
||||
effects_area_layout->addWidget(vcontainer);
|
||||
effects_area_layout->addWidget(vcontainer);
|
||||
|
||||
acontainer = new QWidget();
|
||||
QVBoxLayout* acontainerLayout = new QVBoxLayout(acontainer);
|
||||
acontainerLayout->setSpacing(0);
|
||||
acontainerLayout->setMargin(0);
|
||||
QWidget* aeHeader = new QWidget();
|
||||
aeHeader->setObjectName(QStringLiteral("aeHeader"));
|
||||
aeHeader->setStyleSheet(QLatin1String("#aeHeader { background: rgba(0, 0, 0, 0.25); }"));
|
||||
acontainer = new QWidget();
|
||||
QVBoxLayout* acontainerLayout = new QVBoxLayout(acontainer);
|
||||
acontainerLayout->setSpacing(0);
|
||||
acontainerLayout->setMargin(0);
|
||||
QWidget* aeHeader = new QWidget();
|
||||
aeHeader->setObjectName(QStringLiteral("aeHeader"));
|
||||
aeHeader->setStyleSheet(QLatin1String("#aeHeader { background: rgba(0, 0, 0, 0.25); }"));
|
||||
|
||||
QHBoxLayout* aeHeaderLayout = new QHBoxLayout(aeHeader);
|
||||
aeHeaderLayout->setSpacing(0);
|
||||
aeHeaderLayout->setMargin(0);
|
||||
QHBoxLayout* aeHeaderLayout = new QHBoxLayout(aeHeader);
|
||||
aeHeaderLayout->setSpacing(0);
|
||||
aeHeaderLayout->setMargin(0);
|
||||
|
||||
QPushButton* btnAddAudioEffect = new QPushButton();
|
||||
btnAddAudioEffect->setIcon(QIcon(":/icons/add-effect.png"));
|
||||
btnAddAudioEffect->setToolTip(tr("Add Audio Effect"));
|
||||
connect(btnAddAudioEffect, SIGNAL(clicked(bool)), this, SLOT(audio_effect_click()));
|
||||
aeHeaderLayout->addWidget(btnAddAudioEffect);
|
||||
QPushButton* btnAddAudioEffect = new QPushButton();
|
||||
btnAddAudioEffect->setIcon(QIcon(":/icons/add-effect.png"));
|
||||
btnAddAudioEffect->setToolTip(tr("Add Audio Effect"));
|
||||
connect(btnAddAudioEffect, SIGNAL(clicked(bool)), this, SLOT(audio_effect_click()));
|
||||
aeHeaderLayout->addWidget(btnAddAudioEffect);
|
||||
|
||||
aeHeaderLayout->addStretch();
|
||||
aeHeaderLayout->addStretch();
|
||||
|
||||
QLabel* lblAudioEffects = new QLabel();
|
||||
lblAudioEffects->setFont(font);
|
||||
lblAudioEffects->setAlignment(Qt::AlignCenter);
|
||||
lblAudioEffects->setText(tr("AUDIO EFFECTS"));
|
||||
aeHeaderLayout->addWidget(lblAudioEffects);
|
||||
QLabel* lblAudioEffects = new QLabel();
|
||||
lblAudioEffects->setFont(font);
|
||||
lblAudioEffects->setAlignment(Qt::AlignCenter);
|
||||
lblAudioEffects->setText(tr("AUDIO EFFECTS"));
|
||||
aeHeaderLayout->addWidget(lblAudioEffects);
|
||||
|
||||
aeHeaderLayout->addStretch();
|
||||
aeHeaderLayout->addStretch();
|
||||
|
||||
QPushButton* btnAddAudioTransition = new QPushButton();
|
||||
btnAddAudioTransition->setIcon(QIcon(":/icons/add-transition.png"));
|
||||
btnAddAudioTransition->setToolTip(tr("Add Audio Transition"));
|
||||
connect(btnAddAudioTransition, SIGNAL(clicked(bool)), this, SLOT(audio_transition_click()));
|
||||
aeHeaderLayout->addWidget(btnAddAudioTransition);
|
||||
QPushButton* btnAddAudioTransition = new QPushButton();
|
||||
btnAddAudioTransition->setIcon(QIcon(":/icons/add-transition.png"));
|
||||
btnAddAudioTransition->setToolTip(tr("Add Audio Transition"));
|
||||
connect(btnAddAudioTransition, SIGNAL(clicked(bool)), this, SLOT(audio_transition_click()));
|
||||
aeHeaderLayout->addWidget(btnAddAudioTransition);
|
||||
|
||||
acontainerLayout->addWidget(aeHeader);
|
||||
acontainerLayout->addWidget(aeHeader);
|
||||
|
||||
audio_effect_area = new QWidget();
|
||||
QVBoxLayout* aeAreaLayout = new QVBoxLayout(audio_effect_area);
|
||||
aeAreaLayout->setSpacing(0);
|
||||
aeAreaLayout->setMargin(0);
|
||||
audio_effect_area = new QWidget();
|
||||
QVBoxLayout* aeAreaLayout = new QVBoxLayout(audio_effect_area);
|
||||
aeAreaLayout->setSpacing(0);
|
||||
aeAreaLayout->setMargin(0);
|
||||
|
||||
acontainerLayout->addWidget(audio_effect_area);
|
||||
acontainerLayout->addWidget(audio_effect_area);
|
||||
|
||||
effects_area_layout->addWidget(acontainer);
|
||||
effects_area_layout->addWidget(acontainer);
|
||||
|
||||
lblMultipleClipsSelected = new QLabel();
|
||||
lblMultipleClipsSelected->setAlignment(Qt::AlignCenter);
|
||||
lblMultipleClipsSelected->setText(tr("(Multiple clips selected)"));
|
||||
effects_area_layout->addWidget(lblMultipleClipsSelected);
|
||||
lblMultipleClipsSelected = new QLabel();
|
||||
lblMultipleClipsSelected->setAlignment(Qt::AlignCenter);
|
||||
lblMultipleClipsSelected->setText(tr("(Multiple clips selected)"));
|
||||
effects_area_layout->addWidget(lblMultipleClipsSelected);
|
||||
|
||||
effects_area_layout->addStretch();
|
||||
effects_area_layout->addStretch();
|
||||
|
||||
scrollAreaLayout->addWidget(effects_area);
|
||||
scrollAreaLayout->addWidget(effects_area);
|
||||
|
||||
scrollArea->setWidget(scrollAreaWidgetContents);
|
||||
splitter->addWidget(scrollArea);
|
||||
scrollArea->setWidget(scrollAreaWidgetContents);
|
||||
splitter->addWidget(scrollArea);
|
||||
|
||||
QWidget* keyframeArea = new QWidget();
|
||||
QWidget* keyframeArea = new QWidget();
|
||||
|
||||
QSizePolicy keyframe_sp;
|
||||
keyframe_sp.setHorizontalPolicy(QSizePolicy::Minimum);
|
||||
keyframe_sp.setVerticalPolicy(QSizePolicy::Preferred);
|
||||
keyframe_sp.setHorizontalStretch(1);
|
||||
keyframeArea->setSizePolicy(keyframe_sp);
|
||||
QSizePolicy keyframe_sp;
|
||||
keyframe_sp.setHorizontalPolicy(QSizePolicy::Minimum);
|
||||
keyframe_sp.setVerticalPolicy(QSizePolicy::Preferred);
|
||||
keyframe_sp.setHorizontalStretch(1);
|
||||
keyframeArea->setSizePolicy(keyframe_sp);
|
||||
|
||||
QVBoxLayout* keyframeAreaLayout = new QVBoxLayout(keyframeArea);
|
||||
keyframeAreaLayout->setSpacing(0);
|
||||
keyframeAreaLayout->setMargin(0);
|
||||
QVBoxLayout* keyframeAreaLayout = new QVBoxLayout(keyframeArea);
|
||||
keyframeAreaLayout->setSpacing(0);
|
||||
keyframeAreaLayout->setMargin(0);
|
||||
|
||||
headers = new TimelineHeader();
|
||||
keyframeAreaLayout->addWidget(headers);
|
||||
headers = new TimelineHeader();
|
||||
keyframeAreaLayout->addWidget(headers);
|
||||
|
||||
QWidget* keyframeCenterWidget = new QWidget();
|
||||
QWidget* keyframeCenterWidget = new QWidget();
|
||||
|
||||
QHBoxLayout* keyframeCenterLayout = new QHBoxLayout(keyframeCenterWidget);
|
||||
keyframeCenterLayout->setSpacing(0);
|
||||
keyframeCenterLayout->setMargin(0);
|
||||
QHBoxLayout* keyframeCenterLayout = new QHBoxLayout(keyframeCenterWidget);
|
||||
keyframeCenterLayout->setSpacing(0);
|
||||
keyframeCenterLayout->setMargin(0);
|
||||
|
||||
keyframeView = new KeyframeView();
|
||||
keyframeView = new KeyframeView();
|
||||
|
||||
keyframeCenterLayout->addWidget(keyframeView);
|
||||
keyframeCenterLayout->addWidget(keyframeView);
|
||||
|
||||
verticalScrollBar = new QScrollBar();
|
||||
verticalScrollBar->setOrientation(Qt::Vertical);
|
||||
verticalScrollBar = new QScrollBar();
|
||||
verticalScrollBar->setOrientation(Qt::Vertical);
|
||||
|
||||
keyframeCenterLayout->addWidget(verticalScrollBar);
|
||||
keyframeCenterLayout->addWidget(verticalScrollBar);
|
||||
|
||||
|
||||
keyframeAreaLayout->addWidget(keyframeCenterWidget);
|
||||
keyframeAreaLayout->addWidget(keyframeCenterWidget);
|
||||
|
||||
horizontalScrollBar = new ResizableScrollBar();
|
||||
horizontalScrollBar->setOrientation(Qt::Horizontal);
|
||||
horizontalScrollBar = new ResizableScrollBar();
|
||||
horizontalScrollBar->setOrientation(Qt::Horizontal);
|
||||
|
||||
keyframeAreaLayout->addWidget(horizontalScrollBar);
|
||||
keyframeAreaLayout->addWidget(horizontalScrollBar);
|
||||
|
||||
splitter->addWidget(keyframeArea);
|
||||
splitter->addWidget(keyframeArea);
|
||||
|
||||
hlayout->addWidget(splitter);
|
||||
hlayout->addWidget(splitter);
|
||||
|
||||
setWidget(contents);
|
||||
setWidget(contents);
|
||||
}
|
||||
|
||||
void EffectControls::update_scrollbar() {
|
||||
verticalScrollBar->setMaximum(qMax(0, effects_area->height() - keyframeView->height() - headers->height()));
|
||||
verticalScrollBar->setPageStep(verticalScrollBar->height());
|
||||
verticalScrollBar->setMaximum(qMax(0, effects_area->height() - keyframeView->height() - headers->height()));
|
||||
verticalScrollBar->setPageStep(verticalScrollBar->height());
|
||||
}
|
||||
|
||||
void EffectControls::queue_post_update() {
|
||||
keyframeView->update();
|
||||
update_scrollbar();
|
||||
keyframeView->update();
|
||||
update_scrollbar();
|
||||
}
|
||||
|
||||
void EffectControls::effects_area_context_menu() {
|
||||
QMenu menu(this);
|
||||
QMenu menu(this);
|
||||
|
||||
add_effect_paste_action(&menu);
|
||||
add_effect_paste_action(&menu);
|
||||
|
||||
menu.exec(QCursor::pos());
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void EffectControls::load_effects() {
|
||||
lblMultipleClipsSelected->setVisible(multiple);
|
||||
lblMultipleClipsSelected->setVisible(multiple);
|
||||
|
||||
if (!multiple) {
|
||||
// load in new clips
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
QVBoxLayout* layout;
|
||||
if (c->track < 0) {
|
||||
vcontainer->setVisible(true);
|
||||
layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
|
||||
} else {
|
||||
acontainer->setVisible(true);
|
||||
layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
|
||||
}
|
||||
if (mode == TA_NO_TRANSITION) {
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
open_effect(layout, c->effects.at(j));
|
||||
}
|
||||
} else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != nullptr) {
|
||||
open_effect(layout, c->get_opening_transition());
|
||||
} else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != nullptr) {
|
||||
open_effect(layout, c->get_closing_transition());
|
||||
}
|
||||
}
|
||||
if (selected_clips.size() > 0) {
|
||||
setWindowTitle(panel_name + olive::ActiveSequence->clips.at(selected_clips.at(0))->name);
|
||||
keyframeView->setEnabled(true);
|
||||
headers->setVisible(true);
|
||||
if (!multiple) {
|
||||
// load in new clips
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
QVBoxLayout* layout;
|
||||
if (c->track < 0) {
|
||||
vcontainer->setVisible(true);
|
||||
layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
|
||||
} else {
|
||||
acontainer->setVisible(true);
|
||||
layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
|
||||
}
|
||||
if (mode == kTransitionNone) {
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
open_effect(layout, c->effects.at(j));
|
||||
}
|
||||
} else if (mode == kTransitionOpening && c->opening_transition != nullptr) {
|
||||
open_effect(layout, c->opening_transition);
|
||||
} else if (mode == kTransitionClosing && c->closing_transition != nullptr) {
|
||||
open_effect(layout, c->closing_transition);
|
||||
}
|
||||
}
|
||||
if (selected_clips.size() > 0) {
|
||||
setWindowTitle(panel_name + olive::ActiveSequence->clips.at(selected_clips.at(0))->name);
|
||||
keyframeView->setEnabled(true);
|
||||
headers->setVisible(true);
|
||||
|
||||
QTimer::singleShot(50, this, SLOT(queue_post_update()));
|
||||
}
|
||||
}
|
||||
QTimer::singleShot(50, this, SLOT(queue_post_update()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::delete_effects() {
|
||||
// load in new clips
|
||||
if (mode == TA_NO_TRANSITION) {
|
||||
EffectDeleteCommand* command = new EffectDeleteCommand();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
command->clips.append(c);
|
||||
command->fx.append(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
olive::UndoStack.push(command);
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
} else {
|
||||
delete command;
|
||||
}
|
||||
}
|
||||
// load in new clips
|
||||
if (mode == kTransitionNone) {
|
||||
EffectDeleteCommand* command = new EffectDeleteCommand();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
command->clips.append(c);
|
||||
command->fx.append(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
olive::UndoStack.push(command);
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
} else {
|
||||
delete command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::reload_clips() {
|
||||
clear_effects(false);
|
||||
load_effects();
|
||||
clear_effects(false);
|
||||
load_effects();
|
||||
}
|
||||
|
||||
void EffectControls::set_clips(QVector<int>& clips, int m) {
|
||||
clear_effects(true);
|
||||
clear_effects(true);
|
||||
|
||||
// replace clip vector
|
||||
selected_clips = clips;
|
||||
mode = m;
|
||||
// replace clip vector
|
||||
selected_clips = clips;
|
||||
mode = m;
|
||||
|
||||
load_effects();
|
||||
load_effects();
|
||||
}
|
||||
|
||||
void EffectControls::video_effect_click() {
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_VIDEO);
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_VIDEO);
|
||||
}
|
||||
|
||||
void EffectControls::audio_effect_click() {
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_AUDIO);
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_AUDIO);
|
||||
}
|
||||
|
||||
void EffectControls::video_transition_click() {
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_VIDEO);
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_VIDEO);
|
||||
}
|
||||
|
||||
void EffectControls::audio_transition_click() {
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_AUDIO);
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_AUDIO);
|
||||
}
|
||||
|
||||
void EffectControls::resizeEvent(QResizeEvent*) {
|
||||
update_scrollbar();
|
||||
update_scrollbar();
|
||||
}
|
||||
|
||||
bool EffectControls::is_focused() {
|
||||
if (this->hasFocus()) return true;
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
if (c != nullptr) {
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
if (c->effects.at(j)->container->is_focused()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Tried to check focus of a nullptr clip";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (this->hasFocus()) return true;
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
if (c != nullptr) {
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
if (c->effects.at(j)->container->is_focused()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Tried to check focus of a nullptr clip";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
EffectsArea::EffectsArea(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
QWidget(parent)
|
||||
{}
|
||||
|
||||
void EffectsArea::receive_wheel_event(QWheelEvent *e) {
|
||||
QApplication::sendEvent(this, e);
|
||||
QApplication::sendEvent(this, e);
|
||||
}
|
||||
|
||||
+6
-6
@@ -47,7 +47,7 @@ void update_effect_controls() {
|
||||
int vclip = -1;
|
||||
int aclip = -1;
|
||||
QVector<int> selected_clips;
|
||||
int mode = TA_NO_TRANSITION;
|
||||
int mode = kTransitionNone;
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr clip = olive::ActiveSequence->clips.at(i);
|
||||
@@ -56,11 +56,11 @@ void update_effect_controls() {
|
||||
const Selection& s = olive::ActiveSequence->selections.at(j);
|
||||
bool add = true;
|
||||
if (clip->timeline_in >= s.in && clip->timeline_out <= s.out && clip->track == s.track) {
|
||||
mode = TA_NO_TRANSITION;
|
||||
} else if (selection_contains_transition(s, clip, TA_OPENING_TRANSITION)) {
|
||||
mode = TA_OPENING_TRANSITION;
|
||||
} else if (selection_contains_transition(s, clip, TA_CLOSING_TRANSITION)) {
|
||||
mode = TA_CLOSING_TRANSITION;
|
||||
mode = kTransitionNone;
|
||||
} else if (selection_contains_transition(s, clip, kTransitionOpening)) {
|
||||
mode = kTransitionOpening;
|
||||
} else if (selection_contains_transition(s, clip, kTransitionClosing)) {
|
||||
mode = kTransitionClosing;
|
||||
} else {
|
||||
add = false;
|
||||
}
|
||||
|
||||
@@ -1081,6 +1081,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only,
|
||||
stream.writeAttribute("workareaIn", QString::number(s->workarea_in));
|
||||
stream.writeAttribute("workareaOut", QString::number(s->workarea_out));
|
||||
|
||||
/*
|
||||
for (int j=0;j<s->transitions.size();j++) {
|
||||
TransitionPtr t = s->transitions.at(j);
|
||||
if (t != nullptr) {
|
||||
@@ -1091,6 +1092,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only,
|
||||
stream.writeEndElement(); // transition
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (int j=0;j<s->clips.size();j++) {
|
||||
const ClipPtr& c = s->clips.at(j);
|
||||
@@ -1103,8 +1105,10 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only,
|
||||
stream.writeAttribute("in", QString::number(c->timeline_in));
|
||||
stream.writeAttribute("out", QString::number(c->timeline_out));
|
||||
stream.writeAttribute("track", QString::number(c->track));
|
||||
/*
|
||||
stream.writeAttribute("opening", QString::number(c->opening_transition));
|
||||
stream.writeAttribute("closing", QString::number(c->closing_transition));
|
||||
*/
|
||||
|
||||
stream.writeAttribute("r", QString::number(c->color_r));
|
||||
stream.writeAttribute("g", QString::number(c->color_g));
|
||||
|
||||
+17
-19
@@ -371,11 +371,11 @@ void Timeline::add_transition() {
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
int transition_to_add = (c->track < 0) ? TRANSITION_INTERNAL_CROSSDISSOLVE : TRANSITION_INTERNAL_LINEARFADE;
|
||||
if (c->get_opening_transition() == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(transition_to_add, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30));
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(transition_to_add, EFFECT_TYPE_TRANSITION), kTransitionOpening, 30));
|
||||
adding = true;
|
||||
}
|
||||
if (c->get_closing_transition() == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(transition_to_add, EFFECT_TYPE_TRANSITION), TA_CLOSING_TRANSITION, 30));
|
||||
ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(transition_to_add, EFFECT_TYPE_TRANSITION), kTransitionClosing, 30));
|
||||
adding = true;
|
||||
}
|
||||
}
|
||||
@@ -843,19 +843,17 @@ ClipPtr Timeline::split_clip(ComboAction* ca, bool transitions, int p, long fram
|
||||
// }
|
||||
|
||||
if (pre->get_opening_transition()->get_true_length() > new_clip_length) {
|
||||
ca->append(new ModifyTransitionCommand(pre, TA_OPENING_TRANSITION, new_clip_length));
|
||||
}
|
||||
|
||||
post->sequence->hard_delete_transition(post, TA_OPENING_TRANSITION);
|
||||
ca->append(new ModifyTransitionCommand(pre->get_opening_transition(), new_clip_length));
|
||||
}
|
||||
}
|
||||
if (pre->get_closing_transition() != nullptr) {
|
||||
if (splitting_closing_dual_transition) {
|
||||
// just move closing transition to post clip
|
||||
|
||||
// WORKAROUND
|
||||
ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(pre->closing_transition));
|
||||
} else {
|
||||
ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(pre->closing_transition));
|
||||
|
||||
if (post->get_closing_transition() != nullptr) {
|
||||
if (pre->get_closing_transition()->secondary_clip == nullptr) {
|
||||
@@ -964,7 +962,7 @@ void Timeline::clean_up_selections(QVector<Selection>& areas) {
|
||||
}
|
||||
|
||||
bool selection_contains_transition(const Selection& s, ClipPtr c, int type) {
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
if (type == kTransitionOpening) {
|
||||
return c->get_opening_transition() != nullptr
|
||||
&& s.out == c->timeline_in + c->get_opening_transition()->get_true_length()
|
||||
&& ((c->get_opening_transition()->secondary_clip == nullptr && s.in == c->timeline_in)
|
||||
@@ -989,12 +987,12 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
for (int j=0;j<olive::ActiveSequence->clips.size();j++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(j);
|
||||
if (c != nullptr && c->track == s.track && !c->undeletable) {
|
||||
if (selection_contains_transition(s, c, TA_OPENING_TRANSITION)) {
|
||||
if (selection_contains_transition(s, c, kTransitionOpening)) {
|
||||
// delete opening transition
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
} else if (selection_contains_transition(s, c, TA_CLOSING_TRANSITION)) {
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else if (selection_contains_transition(s, c, kTransitionClosing)) {
|
||||
// delete closing transition
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else if (c->timeline_in >= s.in && c->timeline_out <= s.out) {
|
||||
// clips falls entirely within deletion area
|
||||
ca->append(new DeleteClipAction(olive::ActiveSequence, j));
|
||||
@@ -1012,9 +1010,9 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
|
||||
if (c->get_closing_transition() != nullptr) {
|
||||
if (s.in < c->timeline_out - c->get_closing_transition()->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, c->get_closing_transition()->get_true_length() - (c->timeline_out - s.in)));
|
||||
ca->append(new ModifyTransitionCommand(c->closing_transition, c->get_closing_transition()->get_true_length() - (c->timeline_out - s.in)));
|
||||
}
|
||||
}
|
||||
} else if (c->timeline_in < s.out && c->timeline_out > s.out) {
|
||||
@@ -1023,9 +1021,9 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
|
||||
if (c->get_opening_transition() != nullptr) {
|
||||
if (s.out > c->timeline_in + c->get_opening_transition()->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, c->get_opening_transition()->get_true_length() - (s.out - c->timeline_in)));
|
||||
ca->append(new ModifyTransitionCommand(c->opening_transition, c->get_opening_transition()->get_true_length() - (s.out - c->timeline_in)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2070,13 +2068,13 @@ void move_clip(ComboAction* ca, ClipPtr c, long iin, long iout, long iclip_in, i
|
||||
if (c->get_opening_transition() != nullptr && c->get_opening_transition()->secondary_clip != nullptr && c->get_opening_transition()->secondary_clip->timeline_out != iin) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&c->get_opening_transition()->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, TA_CLOSING_TRANSITION, 0));
|
||||
ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, kTransitionClosing, 0));
|
||||
}
|
||||
|
||||
if (c->get_closing_transition() != nullptr && c->get_closing_transition()->secondary_clip != nullptr && c->get_closing_transition()->parent_clip->timeline_in != iout) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&c->get_closing_transition()->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, TA_CLOSING_TRANSITION, 0));
|
||||
ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, kTransitionClosing, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ void apply_audio_effects(ClipPtr c, double timecode_start, AVFrame* frame, int n
|
||||
double adjustment = transition_end - transition_start;
|
||||
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
|
||||
double adjusted_range_end = (timecode_end - transition_start) / adjustment;
|
||||
c->get_opening_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_OPENING_TRANSITION);
|
||||
c->get_opening_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, kTransitionOpening);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ void apply_audio_effects(ClipPtr c, double timecode_start, AVFrame* frame, int n
|
||||
double adjustment = transition_end - transition_start;
|
||||
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
|
||||
double adjusted_range_end = (timecode_end - transition_start) / adjustment;
|
||||
c->get_closing_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, TA_CLOSING_TRANSITION);
|
||||
c->get_closing_transition()->process_audio(adjusted_range_start, adjusted_range_end, frame->data[0], nb_bytes, kTransitionClosing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+219
-232
@@ -35,312 +35,299 @@
|
||||
#include "debug.h"
|
||||
|
||||
Clip::Clip(SequencePtr s) :
|
||||
sequence(s),
|
||||
enabled(true),
|
||||
clip_in(0),
|
||||
timeline_in(0),
|
||||
timeline_out(0),
|
||||
track(0),
|
||||
media(nullptr),
|
||||
speed(1.0),
|
||||
reverse(false),
|
||||
maintain_audio_pitch(false),
|
||||
autoscale(olive::CurrentConfig.autoscale_by_default),
|
||||
opening_transition(-1),
|
||||
closing_transition(-1),
|
||||
undeletable(false),
|
||||
replaced(false),
|
||||
ignore_reverse(false),
|
||||
use_existing_frame(false),
|
||||
filter_graph(nullptr),
|
||||
fbo(nullptr),
|
||||
opts(nullptr)
|
||||
sequence(s),
|
||||
enabled(true),
|
||||
clip_in(0),
|
||||
timeline_in(0),
|
||||
timeline_out(0),
|
||||
track(0),
|
||||
media(nullptr),
|
||||
speed(1.0),
|
||||
reverse(false),
|
||||
maintain_audio_pitch(false),
|
||||
autoscale(olive::CurrentConfig.autoscale_by_default),
|
||||
opening_transition(nullptr),
|
||||
closing_transition(nullptr),
|
||||
undeletable(false),
|
||||
replaced(false),
|
||||
ignore_reverse(false),
|
||||
use_existing_frame(false),
|
||||
filter_graph(nullptr),
|
||||
fbo(nullptr),
|
||||
opts(nullptr)
|
||||
{
|
||||
pkt = av_packet_alloc();
|
||||
reset();
|
||||
pkt = av_packet_alloc();
|
||||
reset();
|
||||
}
|
||||
|
||||
ClipPtr Clip::copy(SequencePtr s, bool duplicate_transitions) {
|
||||
ClipPtr copy(new Clip(s));
|
||||
ClipPtr copy(new Clip(s));
|
||||
|
||||
copy->enabled = enabled;
|
||||
copy->name = QString(name);
|
||||
copy->clip_in = clip_in;
|
||||
copy->timeline_in = timeline_in;
|
||||
copy->timeline_out = timeline_out;
|
||||
copy->track = track;
|
||||
copy->color_r = color_r;
|
||||
copy->color_g = color_g;
|
||||
copy->color_b = color_b;
|
||||
copy->media = media;
|
||||
copy->media_stream = media_stream;
|
||||
copy->autoscale = autoscale;
|
||||
copy->speed = speed;
|
||||
copy->maintain_audio_pitch = maintain_audio_pitch;
|
||||
copy->reverse = reverse;
|
||||
copy->enabled = enabled;
|
||||
copy->name = QString(name);
|
||||
copy->clip_in = clip_in;
|
||||
copy->timeline_in = timeline_in;
|
||||
copy->timeline_out = timeline_out;
|
||||
copy->track = track;
|
||||
copy->color_r = color_r;
|
||||
copy->color_g = color_g;
|
||||
copy->color_b = color_b;
|
||||
copy->media = media;
|
||||
copy->media_stream = media_stream;
|
||||
copy->autoscale = autoscale;
|
||||
copy->speed = speed;
|
||||
copy->maintain_audio_pitch = maintain_audio_pitch;
|
||||
copy->reverse = reverse;
|
||||
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
copy->effects.append(effects.at(i)->copy(copy));
|
||||
}
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
copy->effects.append(effects.at(i)->copy(copy));
|
||||
}
|
||||
|
||||
copy->cached_fr = (this->sequence == nullptr) ? cached_fr : this->sequence->frame_rate;
|
||||
copy->cached_fr = (this->sequence == nullptr) ? cached_fr : this->sequence->frame_rate;
|
||||
|
||||
if (duplicate_transitions) {
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip == nullptr) copy->opening_transition = get_opening_transition()->copy(copy, nullptr);
|
||||
if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip == nullptr) copy->closing_transition = get_closing_transition()->copy(copy, nullptr);
|
||||
}
|
||||
if (duplicate_transitions) {
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip == nullptr) {
|
||||
copy->opening_transition = get_opening_transition()->copy(copy, nullptr);
|
||||
}
|
||||
if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip == nullptr) {
|
||||
copy->closing_transition = get_closing_transition()->copy(copy, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
copy->recalculateMaxLength();
|
||||
copy->recalculateMaxLength();
|
||||
|
||||
return copy;
|
||||
return copy;
|
||||
}
|
||||
|
||||
void Clip::reset() {
|
||||
audio_just_reset = false;
|
||||
open = false;
|
||||
finished_opening = false;
|
||||
pkt_written = false;
|
||||
audio_reset = false;
|
||||
frame_sample_index = -1;
|
||||
audio_buffer_write = false;
|
||||
texture_frame = -1;
|
||||
formatCtx = nullptr;
|
||||
stream = nullptr;
|
||||
codec = nullptr;
|
||||
codecCtx = nullptr;
|
||||
texture = nullptr;
|
||||
last_invalid_ts = -1;
|
||||
audio_just_reset = false;
|
||||
open = false;
|
||||
finished_opening = false;
|
||||
pkt_written = false;
|
||||
audio_reset = false;
|
||||
frame_sample_index = -1;
|
||||
audio_buffer_write = false;
|
||||
texture_frame = -1;
|
||||
formatCtx = nullptr;
|
||||
stream = nullptr;
|
||||
codec = nullptr;
|
||||
codecCtx = nullptr;
|
||||
texture = nullptr;
|
||||
last_invalid_ts = -1;
|
||||
}
|
||||
|
||||
void Clip::reset_audio() {
|
||||
if (media == nullptr || media->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
audio_reset = true;
|
||||
frame_sample_index = -1;
|
||||
audio_buffer_write = 0;
|
||||
} else if (media->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
SequencePtr nested_sequence = media->to_sequence();
|
||||
for (int i=0;i<nested_sequence->clips.size();i++) {
|
||||
ClipPtr c = nested_sequence->clips.at(i);
|
||||
if (c != nullptr) c->reset_audio();
|
||||
}
|
||||
}
|
||||
if (media == nullptr || media->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
audio_reset = true;
|
||||
frame_sample_index = -1;
|
||||
audio_buffer_write = 0;
|
||||
} else if (media->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
SequencePtr nested_sequence = media->to_sequence();
|
||||
for (int i=0;i<nested_sequence->clips.size();i++) {
|
||||
ClipPtr c = nested_sequence->clips.at(i);
|
||||
if (c != nullptr) c->reset_audio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Clip::refresh() {
|
||||
// validates media if it was replaced
|
||||
if (replaced && media != nullptr && media->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
FootagePtr m = media->to_footage();
|
||||
// validates media if it was replaced
|
||||
if (replaced && media != nullptr && media->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
FootagePtr m = media->to_footage();
|
||||
|
||||
if (track < 0 && m->video_tracks.size() > 0) {
|
||||
media_stream = m->video_tracks.at(0).file_index;
|
||||
} else if (track >= 0 && m->audio_tracks.size() > 0) {
|
||||
media_stream = m->audio_tracks.at(0).file_index;
|
||||
}
|
||||
}
|
||||
replaced = false;
|
||||
if (track < 0 && m->video_tracks.size() > 0) {
|
||||
media_stream = m->video_tracks.at(0).file_index;
|
||||
} else if (track >= 0 && m->audio_tracks.size() > 0) {
|
||||
media_stream = m->audio_tracks.at(0).file_index;
|
||||
}
|
||||
}
|
||||
replaced = false;
|
||||
|
||||
// reinitializes all effects... just in case
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
effects.at(i)->refresh();
|
||||
}
|
||||
// reinitializes all effects... just in case
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
effects.at(i)->refresh();
|
||||
}
|
||||
|
||||
recalculateMaxLength();
|
||||
recalculateMaxLength();
|
||||
}
|
||||
|
||||
void Clip::queue_clear() {
|
||||
while (queue.size() > 0) {
|
||||
av_frame_free(&queue.first());
|
||||
queue.removeFirst();
|
||||
}
|
||||
while (queue.size() > 0) {
|
||||
av_frame_free(&queue.first());
|
||||
queue.removeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
void Clip::queue_remove_earliest() {
|
||||
int earliest_frame = 0;
|
||||
for (int i=1;i<queue.size();i++) {
|
||||
// TODO/NOTE: this will not work on sped up AND reversed video
|
||||
if (queue.at(i)->pts < queue.at(earliest_frame)->pts) {
|
||||
earliest_frame = i;
|
||||
}
|
||||
}
|
||||
av_frame_free(&queue[earliest_frame]);
|
||||
queue.removeAt(earliest_frame);
|
||||
int earliest_frame = 0;
|
||||
for (int i=1;i<queue.size();i++) {
|
||||
// TODO/NOTE: this will not work on sped up AND reversed video
|
||||
if (queue.at(i)->pts < queue.at(earliest_frame)->pts) {
|
||||
earliest_frame = i;
|
||||
}
|
||||
}
|
||||
av_frame_free(&queue[earliest_frame]);
|
||||
queue.removeAt(earliest_frame);
|
||||
}
|
||||
|
||||
QVector<Marker> &Clip::get_markers() {
|
||||
if (media != nullptr) {
|
||||
return media->get_markers();
|
||||
}
|
||||
return markers;
|
||||
if (media != nullptr) {
|
||||
return media->get_markers();
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
TransitionPtr Clip::get_opening_transition() {
|
||||
if (opening_transition > -1) {
|
||||
if (this->sequence == nullptr) {
|
||||
return clipboard_transitions.at(opening_transition);
|
||||
} else {
|
||||
return this->sequence->transitions.at(opening_transition);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return opening_transition;
|
||||
}
|
||||
|
||||
TransitionPtr Clip::get_closing_transition() {
|
||||
if (closing_transition > -1) {
|
||||
if (this->sequence == nullptr) {
|
||||
return clipboard_transitions.at(closing_transition);
|
||||
} else {
|
||||
return this->sequence->transitions.at(closing_transition);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return closing_transition;
|
||||
}
|
||||
|
||||
Clip::~Clip() {
|
||||
if (open) {
|
||||
close_clip(ClipPtr(this), true);
|
||||
}
|
||||
if (open) {
|
||||
close_clip(ClipPtr(this), true);
|
||||
}
|
||||
|
||||
if (opening_transition != -1) this->sequence->hard_delete_transition(ClipPtr(this), TA_OPENING_TRANSITION);
|
||||
if (closing_transition != -1) this->sequence->hard_delete_transition(ClipPtr(this), TA_CLOSING_TRANSITION);
|
||||
|
||||
effects.clear();
|
||||
av_packet_free(&pkt);
|
||||
effects.clear();
|
||||
av_packet_free(&pkt);
|
||||
}
|
||||
|
||||
long Clip::get_clip_in_with_transition() {
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) {
|
||||
// we must be the secondary clip, so return (timeline in - length)
|
||||
return clip_in - get_opening_transition()->get_true_length();
|
||||
}
|
||||
return clip_in;
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) {
|
||||
// we must be the secondary clip, so return (timeline in - length)
|
||||
return clip_in - get_opening_transition()->get_true_length();
|
||||
}
|
||||
return clip_in;
|
||||
}
|
||||
|
||||
long Clip::get_timeline_in_with_transition() {
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) {
|
||||
// we must be the secondary clip, so return (timeline in - length)
|
||||
return timeline_in - get_opening_transition()->get_true_length();
|
||||
}
|
||||
return timeline_in;
|
||||
if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) {
|
||||
// we must be the secondary clip, so return (timeline in - length)
|
||||
return timeline_in - get_opening_transition()->get_true_length();
|
||||
}
|
||||
return timeline_in;
|
||||
}
|
||||
|
||||
long Clip::get_timeline_out_with_transition() {
|
||||
if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip != nullptr) {
|
||||
// we must be the primary clip, so return (timeline out + length2)
|
||||
return timeline_out + get_closing_transition()->get_true_length();
|
||||
} else {
|
||||
return timeline_out;
|
||||
}
|
||||
if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip != nullptr) {
|
||||
// we must be the primary clip, so return (timeline out + length2)
|
||||
return timeline_out + get_closing_transition()->get_true_length();
|
||||
} else {
|
||||
return timeline_out;
|
||||
}
|
||||
}
|
||||
|
||||
// timeline functions
|
||||
long Clip::getLength() {
|
||||
return timeline_out - timeline_in;
|
||||
return timeline_out - timeline_in;
|
||||
}
|
||||
|
||||
double Clip::getMediaFrameRate() {
|
||||
Q_ASSERT(track < 0);
|
||||
if (media != nullptr) {
|
||||
double rate = media->get_frame_rate(media_stream);
|
||||
if (!qIsNaN(rate)) return rate;
|
||||
}
|
||||
if (sequence != nullptr) return sequence->frame_rate;
|
||||
return qSNaN();
|
||||
Q_ASSERT(track < 0);
|
||||
if (media != nullptr) {
|
||||
double rate = media->get_frame_rate(media_stream);
|
||||
if (!qIsNaN(rate)) return rate;
|
||||
}
|
||||
if (sequence != nullptr) return sequence->frame_rate;
|
||||
return qSNaN();
|
||||
}
|
||||
|
||||
void Clip::recalculateMaxLength() {
|
||||
if (this->sequence != nullptr) {
|
||||
double fr = this->sequence->frame_rate;
|
||||
if (this->sequence != nullptr) {
|
||||
double fr = this->sequence->frame_rate;
|
||||
|
||||
fr /= speed;
|
||||
fr /= speed;
|
||||
|
||||
calculated_length = LONG_MAX;
|
||||
calculated_length = LONG_MAX;
|
||||
|
||||
if (media != nullptr) {
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
FootagePtr m = media->to_footage();
|
||||
const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr && ms->infinite_length) {
|
||||
calculated_length = LONG_MAX;
|
||||
} else {
|
||||
calculated_length = m->get_length_in_frames(fr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
calculated_length = refactor_frame_number(s->getEndFrame(), s->frame_rate, fr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (media != nullptr) {
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
FootagePtr m = media->to_footage();
|
||||
const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr && ms->infinite_length) {
|
||||
calculated_length = LONG_MAX;
|
||||
} else {
|
||||
calculated_length = m->get_length_in_frames(fr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
calculated_length = refactor_frame_number(s->getEndFrame(), s->frame_rate, fr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long Clip::getMaximumLength() {
|
||||
return calculated_length;
|
||||
return calculated_length;
|
||||
}
|
||||
|
||||
int Clip::getWidth() {
|
||||
if (media == nullptr && sequence != nullptr) return sequence->width;
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr) return ms->video_width;
|
||||
if (sequence != nullptr) return sequence->width;
|
||||
break;
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
return s->width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
if (media == nullptr && sequence != nullptr) return sequence->width;
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr) return ms->video_width;
|
||||
if (sequence != nullptr) return sequence->width;
|
||||
break;
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
return s->width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Clip::getHeight() {
|
||||
if (media == nullptr && sequence != nullptr) return sequence->height;
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr) return ms->video_height;
|
||||
if (sequence != nullptr) return sequence->height;
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
return s->height;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
if (media == nullptr && sequence != nullptr) return sequence->height;
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
|
||||
if (ms != nullptr) return ms->video_height;
|
||||
if (sequence != nullptr) return sequence->height;
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
SequencePtr s = media->to_sequence();
|
||||
return s->height;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points) {
|
||||
if (change_timeline_points) {
|
||||
move_clip(ca, ClipPtr(this),
|
||||
qRound((double) timeline_in * multiplier),
|
||||
qRound((double) timeline_out * multiplier),
|
||||
qRound((double) clip_in * multiplier),
|
||||
track);
|
||||
}
|
||||
if (change_timeline_points) {
|
||||
move_clip(ca, ClipPtr(this),
|
||||
qRound((double) timeline_in * multiplier),
|
||||
qRound((double) timeline_out * multiplier),
|
||||
qRound((double) clip_in * multiplier),
|
||||
track);
|
||||
}
|
||||
|
||||
// move keyframes
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
EffectPtr e = effects.at(i);
|
||||
for (int j=0;j<e->row_count();j++) {
|
||||
EffectRow* r = e->row(j);
|
||||
for (int l=0;l<r->fieldCount();l++) {
|
||||
EffectField* f = r->field(l);
|
||||
for (int k=0;k<f->keyframes.size();k++) {
|
||||
ca->append(new SetLong(&f->keyframes[k].time, f->keyframes[k].time, f->keyframes[k].time * multiplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// move keyframes
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
EffectPtr e = effects.at(i);
|
||||
for (int j=0;j<e->row_count();j++) {
|
||||
EffectRow* r = e->row(j);
|
||||
for (int l=0;l<r->fieldCount();l++) {
|
||||
EffectField* f = r->field(l);
|
||||
for (int k=0;k<f->keyframes.size();k++) {
|
||||
ca->append(new SetLong(&f->keyframes[k].time, f->keyframes[k].time, f->keyframes[k].time * multiplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+94
-94
@@ -38,8 +38,8 @@
|
||||
#include "marker.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavfilter/avfilter.h>
|
||||
}
|
||||
|
||||
using ClipPtr = std::shared_ptr<Clip>;
|
||||
@@ -49,109 +49,109 @@ using SequencePtr = std::shared_ptr<Sequence>;
|
||||
|
||||
class Clip {
|
||||
public:
|
||||
Clip(SequencePtr s);
|
||||
~Clip();
|
||||
ClipPtr copy(SequencePtr s, bool duplicate_transitions = true);
|
||||
void reset_audio();
|
||||
void reset();
|
||||
void refresh();
|
||||
long get_clip_in_with_transition();
|
||||
long get_timeline_in_with_transition();
|
||||
long get_timeline_out_with_transition();
|
||||
long getLength();
|
||||
double getMediaFrameRate();
|
||||
long getMaximumLength();
|
||||
void recalculateMaxLength();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
void refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points);
|
||||
SequencePtr sequence;
|
||||
Clip(SequencePtr s);
|
||||
~Clip();
|
||||
ClipPtr copy(SequencePtr s, bool duplicate_transitions = true);
|
||||
void reset_audio();
|
||||
void reset();
|
||||
void refresh();
|
||||
long get_clip_in_with_transition();
|
||||
long get_timeline_in_with_transition();
|
||||
long get_timeline_out_with_transition();
|
||||
long getLength();
|
||||
double getMediaFrameRate();
|
||||
long getMaximumLength();
|
||||
void recalculateMaxLength();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
void refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points);
|
||||
SequencePtr sequence;
|
||||
|
||||
// queue functions
|
||||
void queue_clear();
|
||||
void queue_remove_earliest();
|
||||
// queue functions
|
||||
void queue_clear();
|
||||
void queue_remove_earliest();
|
||||
|
||||
// timeline variables (should be copied in copy())
|
||||
bool enabled;
|
||||
long clip_in;
|
||||
long timeline_in;
|
||||
long timeline_out;
|
||||
int track;
|
||||
QString name;
|
||||
quint8 color_r;
|
||||
quint8 color_g;
|
||||
quint8 color_b;
|
||||
Media* media;
|
||||
int media_stream;
|
||||
double speed;
|
||||
double cached_fr;
|
||||
bool reverse;
|
||||
bool maintain_audio_pitch;
|
||||
bool autoscale;
|
||||
// timeline variables (should be copied in copy())
|
||||
bool enabled;
|
||||
long clip_in;
|
||||
long timeline_in;
|
||||
long timeline_out;
|
||||
int track;
|
||||
QString name;
|
||||
quint8 color_r;
|
||||
quint8 color_g;
|
||||
quint8 color_b;
|
||||
Media* media;
|
||||
int media_stream;
|
||||
double speed;
|
||||
double cached_fr;
|
||||
bool reverse;
|
||||
bool maintain_audio_pitch;
|
||||
bool autoscale;
|
||||
|
||||
// markers
|
||||
QVector<Marker>& get_markers();
|
||||
// markers
|
||||
QVector<Marker>& get_markers();
|
||||
|
||||
// other variables (should be deep copied/duplicated in copy())
|
||||
QList<EffectPtr> effects;
|
||||
QVector<int> linked;
|
||||
int opening_transition;
|
||||
TransitionPtr get_opening_transition();
|
||||
int closing_transition;
|
||||
TransitionPtr get_closing_transition();
|
||||
// other variables (should be deep copied/duplicated in copy())
|
||||
QList<EffectPtr> effects;
|
||||
QVector<int> linked;
|
||||
TransitionPtr opening_transition;
|
||||
TransitionPtr get_opening_transition();
|
||||
TransitionPtr closing_transition;
|
||||
TransitionPtr get_closing_transition();
|
||||
|
||||
// media handling
|
||||
AVFormatContext* formatCtx;
|
||||
AVStream* stream;
|
||||
AVCodec* codec;
|
||||
AVCodecContext* codecCtx;
|
||||
AVPacket* pkt;
|
||||
AVFrame* frame;
|
||||
AVDictionary* opts;
|
||||
long calculated_length;
|
||||
// media handling
|
||||
AVFormatContext* formatCtx;
|
||||
AVStream* stream;
|
||||
AVCodec* codec;
|
||||
AVCodecContext* codecCtx;
|
||||
AVPacket* pkt;
|
||||
AVFrame* frame;
|
||||
AVDictionary* opts;
|
||||
long calculated_length;
|
||||
|
||||
// temporary variables
|
||||
int load_id;
|
||||
bool undeletable;
|
||||
bool reached_end;
|
||||
bool pkt_written;
|
||||
bool open;
|
||||
bool finished_opening;
|
||||
bool replaced;
|
||||
bool ignore_reverse;
|
||||
int pix_fmt;
|
||||
// temporary variables
|
||||
int load_id;
|
||||
bool undeletable;
|
||||
bool reached_end;
|
||||
bool pkt_written;
|
||||
bool open;
|
||||
bool finished_opening;
|
||||
bool replaced;
|
||||
bool ignore_reverse;
|
||||
int pix_fmt;
|
||||
|
||||
// caching functions
|
||||
bool use_existing_frame;
|
||||
bool multithreaded;
|
||||
Cacher* cacher;
|
||||
QWaitCondition can_cache;
|
||||
int max_queue_size;
|
||||
QVector<AVFrame*> queue;
|
||||
QMutex queue_lock;
|
||||
QMutex lock;
|
||||
QMutex open_lock;
|
||||
int64_t last_invalid_ts;
|
||||
// caching functions
|
||||
bool use_existing_frame;
|
||||
bool multithreaded;
|
||||
Cacher* cacher;
|
||||
QWaitCondition can_cache;
|
||||
int max_queue_size;
|
||||
QVector<AVFrame*> queue;
|
||||
QMutex queue_lock;
|
||||
QMutex lock;
|
||||
QMutex open_lock;
|
||||
int64_t last_invalid_ts;
|
||||
|
||||
// converters/filters
|
||||
AVFilterGraph* filter_graph;
|
||||
AVFilterContext* buffersink_ctx;
|
||||
AVFilterContext* buffersrc_ctx;
|
||||
// converters/filters
|
||||
AVFilterGraph* filter_graph;
|
||||
AVFilterContext* buffersink_ctx;
|
||||
AVFilterContext* buffersrc_ctx;
|
||||
|
||||
// video playback variables
|
||||
QOpenGLFramebufferObject** fbo;
|
||||
QOpenGLTexture* texture;
|
||||
long texture_frame;
|
||||
// video playback variables
|
||||
QOpenGLFramebufferObject** fbo;
|
||||
QOpenGLTexture* texture;
|
||||
long texture_frame;
|
||||
|
||||
// audio playback variables
|
||||
int64_t reverse_target;
|
||||
int frame_sample_index;
|
||||
qint64 audio_buffer_write;
|
||||
bool audio_reset;
|
||||
bool audio_just_reset;
|
||||
long audio_target_frame;
|
||||
// audio playback variables
|
||||
int64_t reverse_target;
|
||||
int frame_sample_index;
|
||||
qint64 audio_buffer_write;
|
||||
bool audio_reset;
|
||||
bool audio_just_reset;
|
||||
long audio_target_frame;
|
||||
private:
|
||||
QVector<Marker> markers;
|
||||
QVector<Marker> markers;
|
||||
};
|
||||
|
||||
#endif // CLIP_H
|
||||
|
||||
@@ -67,42 +67,6 @@ long Sequence::getEndFrame() {
|
||||
return end;
|
||||
}
|
||||
|
||||
void Sequence::hard_delete_transition(ClipPtr c, int type) {
|
||||
int transition_index = (type == TA_OPENING_TRANSITION) ? c->opening_transition : c->closing_transition;
|
||||
if (transition_index > -1) {
|
||||
bool del = true;
|
||||
|
||||
TransitionPtr t = transitions.at(transition_index);
|
||||
if (t->secondary_clip != nullptr) {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
ClipPtr comp = clips.at(i);
|
||||
if (comp != nullptr
|
||||
&& c != comp
|
||||
&& (c->opening_transition == transition_index
|
||||
|| c->closing_transition == transition_index)) {
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
// convert to closing transition
|
||||
t->parent_clip = t->secondary_clip;
|
||||
}
|
||||
|
||||
del = false;
|
||||
t->secondary_clip = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (del) {
|
||||
transitions[transition_index].reset();
|
||||
}
|
||||
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
c->opening_transition = -1;
|
||||
} else {
|
||||
c->closing_transition = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) {
|
||||
int vt = 0;
|
||||
int at = 0;
|
||||
|
||||
+1
-3
@@ -35,8 +35,7 @@ public:
|
||||
SequencePtr copy();
|
||||
QString name;
|
||||
void getTrackLimits(int* video_tracks, int* audio_tracks);
|
||||
long getEndFrame();
|
||||
void hard_delete_transition(ClipPtr c, int type);
|
||||
long getEndFrame();
|
||||
int width;
|
||||
int height;
|
||||
double frame_rate;
|
||||
@@ -56,7 +55,6 @@ public:
|
||||
|
||||
QVector<Marker> markers;
|
||||
QVector<ClipPtr> clips;
|
||||
QVector<TransitionPtr> transitions;
|
||||
};
|
||||
|
||||
using SequencePtr = std::shared_ptr<Sequence>;
|
||||
|
||||
+67
-49
@@ -42,74 +42,92 @@
|
||||
#include <QCoreApplication>
|
||||
|
||||
Transition::Transition(ClipPtr c, ClipPtr s, const EffectMeta* em) :
|
||||
Effect(c, em), secondary_clip(s),
|
||||
length(30)
|
||||
Effect(c, em), secondary_clip(s),
|
||||
length(30)
|
||||
{
|
||||
length_field = add_row(tr("Length"), false)->add_field(EFFECT_FIELD_DOUBLE, "length");
|
||||
connect(length_field, SIGNAL(changed()), this, SLOT(set_length_from_slider()));
|
||||
length_field->set_double_default_value(30);
|
||||
length_field->set_double_minimum_value(0);
|
||||
length_field = add_row(tr("Length"), false)->add_field(EFFECT_FIELD_DOUBLE, "length");
|
||||
connect(length_field, SIGNAL(changed()), this, SLOT(set_length_from_slider()));
|
||||
length_field->set_double_default_value(30);
|
||||
length_field->set_double_minimum_value(0);
|
||||
|
||||
LabelSlider* length_ui_ele = static_cast<LabelSlider*>(length_field->ui_element);
|
||||
length_ui_ele->set_display_type(LABELSLIDER_FRAMENUMBER);
|
||||
length_ui_ele->set_frame_rate(parent_clip->sequence == nullptr ? parent_clip->cached_fr : parent_clip->sequence->frame_rate);
|
||||
LabelSlider* length_ui_ele = static_cast<LabelSlider*>(length_field->ui_element);
|
||||
length_ui_ele->set_display_type(LABELSLIDER_FRAMENUMBER);
|
||||
length_ui_ele->set_frame_rate(parent_clip->sequence == nullptr ? parent_clip->cached_fr : parent_clip->sequence->frame_rate);
|
||||
}
|
||||
|
||||
int Transition::copy(ClipPtr c, ClipPtr s) {
|
||||
return create_transition(c, s, meta, length);
|
||||
TransitionPtr Transition::copy(ClipPtr c, ClipPtr s) {
|
||||
return create_transition(c, s, meta, length);
|
||||
}
|
||||
|
||||
void Transition::set_length(long l) {
|
||||
length = l;
|
||||
length_field->set_double_value(l);
|
||||
length = l;
|
||||
length_field->set_double_value(l);
|
||||
}
|
||||
|
||||
long Transition::get_true_length() {
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
|
||||
long Transition::get_length() {
|
||||
if (secondary_clip != nullptr) {
|
||||
return length * 2;
|
||||
}
|
||||
return length;
|
||||
if (secondary_clip != nullptr) {
|
||||
return length * 2;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
ClipPtr Transition::get_opened_clip() {
|
||||
if (parent_clip->opening_transition.get() == this) {
|
||||
return parent_clip;
|
||||
} else if (secondary_clip != nullptr && secondary_clip->opening_transition.get() == this) {
|
||||
return secondary_clip;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClipPtr Transition::get_closed_clip() {
|
||||
if (parent_clip->closing_transition.get() == this) {
|
||||
return parent_clip;
|
||||
} else if (secondary_clip != nullptr && secondary_clip->closing_transition.get() == this) {
|
||||
return secondary_clip;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Transition::set_length_from_slider() {
|
||||
set_length(length_field->get_double_value(0));
|
||||
update_ui(false);
|
||||
set_length(length_field->get_double_value(0));
|
||||
update_ui(false);
|
||||
}
|
||||
|
||||
TransitionPtr get_transition_from_meta(ClipPtr c, ClipPtr s, const EffectMeta* em) {
|
||||
if (!em->filename.isEmpty()) {
|
||||
// load effect from file
|
||||
return TransitionPtr(new Transition(c, s, em));
|
||||
} else if (em->internal >= 0 && em->internal < TRANSITION_INTERNAL_COUNT) {
|
||||
// must be an internal effect
|
||||
switch (em->internal) {
|
||||
case TRANSITION_INTERNAL_CROSSDISSOLVE: return TransitionPtr(new CrossDissolveTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_LINEARFADE: return TransitionPtr(new LinearFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_EXPONENTIALFADE: return TransitionPtr(new ExponentialFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_LOGARITHMICFADE: return TransitionPtr(new LogarithmicFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_CUBE: return TransitionPtr(new CubeTransition(c, s, em));
|
||||
}
|
||||
} else {
|
||||
qCritical() << "Invalid transition data";
|
||||
QMessageBox::critical(olive::MainWindow,
|
||||
QCoreApplication::translate("transition", "Invalid transition"),
|
||||
QCoreApplication::translate("transition", "No candidate for transition '%1'. This transition may be corrupt. Try reinstalling it or Olive.").arg(em->name)
|
||||
);
|
||||
}
|
||||
return nullptr;
|
||||
if (!em->filename.isEmpty()) {
|
||||
// load effect from file
|
||||
return TransitionPtr(new Transition(c, s, em));
|
||||
} else if (em->internal >= 0 && em->internal < TRANSITION_INTERNAL_COUNT) {
|
||||
// must be an internal effect
|
||||
switch (em->internal) {
|
||||
case TRANSITION_INTERNAL_CROSSDISSOLVE: return TransitionPtr(new CrossDissolveTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_LINEARFADE: return TransitionPtr(new LinearFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_EXPONENTIALFADE: return TransitionPtr(new ExponentialFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_LOGARITHMICFADE: return TransitionPtr(new LogarithmicFadeTransition(c, s, em));
|
||||
case TRANSITION_INTERNAL_CUBE: return TransitionPtr(new CubeTransition(c, s, em));
|
||||
}
|
||||
} else {
|
||||
qCritical() << "Invalid transition data";
|
||||
QMessageBox::critical(olive::MainWindow,
|
||||
QCoreApplication::translate("transition", "Invalid transition"),
|
||||
QCoreApplication::translate("transition", "No candidate for transition '%1'. This transition may be corrupt. Try reinstalling it or Olive.").arg(em->name)
|
||||
);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int create_transition(ClipPtr c, ClipPtr s, const EffectMeta* em, long length) {
|
||||
TransitionPtr t(get_transition_from_meta(c, s, em));
|
||||
if (t != nullptr) {
|
||||
if (length >= 0) t->set_length(length);
|
||||
QVector<TransitionPtr>& transition_list = (c->sequence == nullptr) ? clipboard_transitions : c->sequence->transitions;
|
||||
transition_list.append(t);
|
||||
return transition_list.size() - 1;
|
||||
}
|
||||
return -1;
|
||||
TransitionPtr create_transition(ClipPtr c, ClipPtr s, const EffectMeta* em, long length) {
|
||||
TransitionPtr t(get_transition_from_meta(c, s, em));
|
||||
if (t != nullptr) {
|
||||
if (length > 0) {
|
||||
t->set_length(length);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
+37
-27
@@ -23,35 +23,45 @@
|
||||
|
||||
#include "effect.h"
|
||||
|
||||
#define TA_NO_TRANSITION 0
|
||||
#define TA_OPENING_TRANSITION 1
|
||||
#define TA_CLOSING_TRANSITION 2
|
||||
|
||||
#define TRANSITION_INTERNAL_CROSSDISSOLVE 0
|
||||
#define TRANSITION_INTERNAL_LINEARFADE 1
|
||||
#define TRANSITION_INTERNAL_EXPONENTIALFADE 2
|
||||
#define TRANSITION_INTERNAL_LOGARITHMICFADE 3
|
||||
#define TRANSITION_INTERNAL_CUBE 4
|
||||
#define TRANSITION_INTERNAL_COUNT 5
|
||||
|
||||
int create_transition(ClipPtr c, ClipPtr s, const EffectMeta* em, long length = -1);
|
||||
|
||||
class Transition : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Transition(ClipPtr c, ClipPtr s, const EffectMeta* em);
|
||||
int copy(ClipPtr c, ClipPtr s);
|
||||
ClipPtr secondary_clip;
|
||||
void set_length(long l);
|
||||
long get_true_length();
|
||||
long get_length();
|
||||
private slots:
|
||||
void set_length_from_slider();
|
||||
private:
|
||||
long length; // used only for transitions
|
||||
EffectField* length_field;
|
||||
enum TransitionType {
|
||||
kTransitionNone,
|
||||
kTransitionOpening,
|
||||
kTransitionClosing
|
||||
};
|
||||
|
||||
enum TransitionInternal {
|
||||
TRANSITION_INTERNAL_CROSSDISSOLVE,
|
||||
TRANSITION_INTERNAL_LINEARFADE,
|
||||
TRANSITION_INTERNAL_EXPONENTIALFADE,
|
||||
TRANSITION_INTERNAL_LOGARITHMICFADE,
|
||||
TRANSITION_INTERNAL_CUBE,
|
||||
TRANSITION_INTERNAL_COUNT
|
||||
};
|
||||
|
||||
class Transition;
|
||||
using TransitionPtr = std::shared_ptr<Transition>;
|
||||
|
||||
TransitionPtr get_transition_from_meta(ClipPtr c, ClipPtr s, const EffectMeta* em);
|
||||
|
||||
TransitionPtr create_transition(ClipPtr c, ClipPtr s, const EffectMeta* em, long length = 0);
|
||||
|
||||
class Transition : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Transition(ClipPtr c, ClipPtr s, const EffectMeta* em);
|
||||
virtual TransitionPtr copy(ClipPtr c, ClipPtr s);
|
||||
ClipPtr secondary_clip;
|
||||
void set_length(long l);
|
||||
long get_true_length();
|
||||
long get_length();
|
||||
|
||||
ClipPtr get_opened_clip();
|
||||
ClipPtr get_closed_clip();
|
||||
private slots:
|
||||
void set_length_from_slider();
|
||||
private:
|
||||
long length; // used only for transitions
|
||||
EffectField* length_field;
|
||||
};
|
||||
|
||||
#endif // TRANSITION_H
|
||||
|
||||
+616
-651
File diff suppressed because it is too large
Load Diff
+331
-335
@@ -36,594 +36,590 @@
|
||||
#include <QModelIndex>
|
||||
|
||||
namespace olive {
|
||||
extern QUndoStack UndoStack;
|
||||
extern QUndoStack UndoStack;
|
||||
}
|
||||
|
||||
class OliveAction : public QUndoCommand {
|
||||
public:
|
||||
OliveAction(bool iset_window_modified = true);
|
||||
virtual ~OliveAction() override;
|
||||
OliveAction(bool iset_window_modified = true);
|
||||
virtual ~OliveAction() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
virtual void redo() override;
|
||||
|
||||
virtual void doUndo() = 0;
|
||||
virtual void doRedo() = 0;
|
||||
virtual void doUndo() = 0;
|
||||
virtual void doRedo() = 0;
|
||||
private:
|
||||
/**
|
||||
/**
|
||||
* @brief Setting whether to change the windowModified state of MainWindow
|
||||
*/
|
||||
bool set_window_modified;
|
||||
bool set_window_modified;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Cache previous window modified value to return to if the user undoes this action
|
||||
*/
|
||||
bool old_window_modified;
|
||||
bool old_window_modified;
|
||||
};
|
||||
|
||||
class MoveClipAction : public OliveAction {
|
||||
public:
|
||||
MoveClipAction(ClipPtr c, long iin, long iout, long iclip_in, int itrack, bool irelative);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
MoveClipAction(ClipPtr c, long iin, long iout, long iclip_in, int itrack, bool irelative);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
ClipPtr clip;
|
||||
ClipPtr clip;
|
||||
|
||||
long old_in;
|
||||
long old_out;
|
||||
long old_clip_in;
|
||||
int old_track;
|
||||
long old_in;
|
||||
long old_out;
|
||||
long old_clip_in;
|
||||
int old_track;
|
||||
|
||||
long new_in;
|
||||
long new_out;
|
||||
long new_clip_in;
|
||||
int new_track;
|
||||
long new_in;
|
||||
long new_out;
|
||||
long new_clip_in;
|
||||
int new_track;
|
||||
|
||||
bool relative;
|
||||
bool relative;
|
||||
};
|
||||
|
||||
class RippleAction : public OliveAction {
|
||||
public:
|
||||
RippleAction(SequencePtr is, long ipoint, long ilength, const QVector<int>& iignore);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
RippleAction(SequencePtr is, long ipoint, long ilength, const QVector<int>& iignore);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr s;
|
||||
long point;
|
||||
long length;
|
||||
QVector<int> ignore;
|
||||
ComboAction* ca;
|
||||
SequencePtr s;
|
||||
long point;
|
||||
long length;
|
||||
QVector<int> ignore;
|
||||
ComboAction* ca;
|
||||
};
|
||||
|
||||
class DeleteClipAction : public OliveAction {
|
||||
public:
|
||||
DeleteClipAction(SequencePtr s, int clip);
|
||||
virtual ~DeleteClipAction() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
DeleteClipAction(SequencePtr s, int clip);
|
||||
virtual ~DeleteClipAction() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr seq;
|
||||
ClipPtr ref;
|
||||
int index;
|
||||
SequencePtr seq;
|
||||
ClipPtr ref;
|
||||
int index;
|
||||
|
||||
int opening_transition;
|
||||
int closing_transition;
|
||||
int opening_transition;
|
||||
int closing_transition;
|
||||
|
||||
QVector<int> linkClipIndex;
|
||||
QVector<int> linkLinkIndex;
|
||||
QVector<int> linkClipIndex;
|
||||
QVector<int> linkLinkIndex;
|
||||
};
|
||||
|
||||
class ChangeSequenceAction : public OliveAction {
|
||||
public:
|
||||
ChangeSequenceAction(SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
ChangeSequenceAction(SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr old_sequence;
|
||||
SequencePtr new_sequence;
|
||||
SequencePtr old_sequence;
|
||||
SequencePtr new_sequence;
|
||||
};
|
||||
|
||||
class AddEffectCommand : public OliveAction {
|
||||
public:
|
||||
AddEffectCommand(ClipPtr c, EffectPtr e, const EffectMeta* m, int insert_pos = -1);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
AddEffectCommand(ClipPtr c, EffectPtr e, const EffectMeta* m, int insert_pos = -1);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
ClipPtr clip;
|
||||
const EffectMeta* meta;
|
||||
EffectPtr ref;
|
||||
int pos;
|
||||
bool done;
|
||||
ClipPtr clip;
|
||||
const EffectMeta* meta;
|
||||
EffectPtr ref;
|
||||
int pos;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class AddTransitionCommand : public OliveAction {
|
||||
public:
|
||||
AddTransitionCommand(ClipPtr c, ClipPtr s, TransitionPtr copy, const EffectMeta* itransition, int itype, int ilength);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
AddTransitionCommand(ClipPtr c, ClipPtr s, TransitionPtr copy, const EffectMeta* itransition, int itype, int ilength);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
ClipPtr clip;
|
||||
ClipPtr secondary;
|
||||
TransitionPtr transition_to_copy;
|
||||
const EffectMeta* transition;
|
||||
int type;
|
||||
int length;
|
||||
int old_ptransition;
|
||||
int old_stransition;
|
||||
ClipPtr primary;
|
||||
ClipPtr secondary;
|
||||
TransitionPtr transition_to_copy;
|
||||
const EffectMeta* transition_meta_;
|
||||
int type;
|
||||
int length;
|
||||
TransitionPtr old_ptransition;
|
||||
TransitionPtr old_stransition;
|
||||
};
|
||||
|
||||
class ModifyTransitionCommand : public OliveAction {
|
||||
public:
|
||||
ModifyTransitionCommand(ClipPtr c, int itype, long ilength);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
ModifyTransitionCommand(TransitionPtr t, long ilength);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
ClipPtr clip;
|
||||
int type;
|
||||
long new_length;
|
||||
long old_length;
|
||||
TransitionPtr transition_ref_;
|
||||
long new_length_;
|
||||
long old_length_;
|
||||
};
|
||||
|
||||
class DeleteTransitionCommand : public OliveAction {
|
||||
public:
|
||||
DeleteTransitionCommand(SequencePtr s, int transition_index);
|
||||
virtual ~DeleteTransitionCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
DeleteTransitionCommand(TransitionPtr t);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr seq;
|
||||
int index;
|
||||
TransitionPtr transition;
|
||||
ClipPtr otc;
|
||||
ClipPtr ctc;
|
||||
TransitionPtr transition_ref_;
|
||||
ClipPtr opened_clip_;
|
||||
ClipPtr closed_clip_;
|
||||
};
|
||||
|
||||
class SetTimelineInOutCommand : public OliveAction {
|
||||
public:
|
||||
SetTimelineInOutCommand(SequencePtr s, bool enabled, long in, long out);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetTimelineInOutCommand(SequencePtr s, bool enabled, long in, long out);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr seq;
|
||||
SequencePtr seq;
|
||||
|
||||
bool old_enabled;
|
||||
long old_in;
|
||||
long old_out;
|
||||
bool old_enabled;
|
||||
long old_in;
|
||||
long old_out;
|
||||
|
||||
bool new_enabled;
|
||||
long new_in;
|
||||
long new_out;
|
||||
bool new_enabled;
|
||||
long new_in;
|
||||
long new_out;
|
||||
};
|
||||
|
||||
class NewSequenceCommand : public OliveAction {
|
||||
public:
|
||||
NewSequenceCommand(Media* s, Media* iparent);
|
||||
virtual ~NewSequenceCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
NewSequenceCommand(Media* s, Media* iparent);
|
||||
virtual ~NewSequenceCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* seq;
|
||||
Media* parent;
|
||||
bool done;
|
||||
Media* seq;
|
||||
Media* parent;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class AddMediaCommand : public OliveAction {
|
||||
public:
|
||||
AddMediaCommand(Media* iitem, Media* iparent);
|
||||
virtual ~AddMediaCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
AddMediaCommand(Media* iitem, Media* iparent);
|
||||
virtual ~AddMediaCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* item;
|
||||
Media* parent;
|
||||
bool done;
|
||||
Media* item;
|
||||
Media* parent;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class DeleteMediaCommand : public OliveAction {
|
||||
public:
|
||||
DeleteMediaCommand(Media *i);
|
||||
virtual ~DeleteMediaCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
DeleteMediaCommand(Media *i);
|
||||
virtual ~DeleteMediaCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* item;
|
||||
Media* parent;
|
||||
bool done;
|
||||
Media* item;
|
||||
Media* parent;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class AddClipCommand : public OliveAction {
|
||||
public:
|
||||
AddClipCommand(SequencePtr s, QVector<ClipPtr>& add);
|
||||
virtual ~AddClipCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
AddClipCommand(SequencePtr s, QVector<ClipPtr>& add);
|
||||
virtual ~AddClipCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
SequencePtr seq;
|
||||
QVector<ClipPtr> clips;
|
||||
QVector<ClipPtr> undone_clips;
|
||||
SequencePtr seq;
|
||||
QVector<ClipPtr> clips;
|
||||
QVector<ClipPtr> undone_clips;
|
||||
};
|
||||
|
||||
class LinkCommand : public OliveAction {
|
||||
public:
|
||||
LinkCommand();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SequencePtr s;
|
||||
QVector<int> clips;
|
||||
bool link;
|
||||
LinkCommand();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SequencePtr s;
|
||||
QVector<int> clips;
|
||||
bool link;
|
||||
private:
|
||||
QVector< QVector<int> > old_links;
|
||||
QVector< QVector<int> > old_links;
|
||||
};
|
||||
|
||||
class CheckboxCommand : public OliveAction {
|
||||
public:
|
||||
CheckboxCommand(QCheckBox* b);
|
||||
virtual ~CheckboxCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
CheckboxCommand(QCheckBox* b);
|
||||
virtual ~CheckboxCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QCheckBox* box;
|
||||
bool checked;
|
||||
bool done;
|
||||
QCheckBox* box;
|
||||
bool checked;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class ReplaceMediaCommand : public OliveAction {
|
||||
public:
|
||||
ReplaceMediaCommand(Media*, QString);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
ReplaceMediaCommand(Media*, QString);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media *item;
|
||||
QString old_filename;
|
||||
QString new_filename;
|
||||
void replace(QString& filename);
|
||||
Media *item;
|
||||
QString old_filename;
|
||||
QString new_filename;
|
||||
void replace(QString& filename);
|
||||
};
|
||||
|
||||
class ReplaceClipMediaCommand : public OliveAction {
|
||||
public:
|
||||
ReplaceClipMediaCommand(Media *, Media *, bool);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
ReplaceClipMediaCommand(Media *, Media *, bool);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
private:
|
||||
Media* old_media;
|
||||
Media* new_media;
|
||||
bool preserve_clip_ins;
|
||||
QVector<int> old_clip_ins;
|
||||
void replace(bool undo);
|
||||
Media* old_media;
|
||||
Media* new_media;
|
||||
bool preserve_clip_ins;
|
||||
QVector<int> old_clip_ins;
|
||||
void replace(bool undo);
|
||||
};
|
||||
|
||||
class EffectDeleteCommand : public OliveAction {
|
||||
public:
|
||||
EffectDeleteCommand();
|
||||
virtual ~EffectDeleteCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
QVector<int> fx;
|
||||
EffectDeleteCommand();
|
||||
virtual ~EffectDeleteCommand() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
QVector<int> fx;
|
||||
private:
|
||||
bool done;
|
||||
QVector<EffectPtr> deleted_objects;
|
||||
bool done;
|
||||
QVector<EffectPtr> deleted_objects;
|
||||
};
|
||||
|
||||
class MediaMove : public OliveAction {
|
||||
public:
|
||||
MediaMove();
|
||||
QVector<Media*> items;
|
||||
Media* to;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
MediaMove();
|
||||
QVector<Media*> items;
|
||||
Media* to;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QVector<Media*> froms;
|
||||
QVector<Media*> froms;
|
||||
};
|
||||
|
||||
class MediaRename : public OliveAction {
|
||||
public:
|
||||
MediaRename(Media* iitem, QString to);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
MediaRename(Media* iitem, QString to);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* item;
|
||||
QString from;
|
||||
QString to;
|
||||
Media* item;
|
||||
QString from;
|
||||
QString to;
|
||||
};
|
||||
|
||||
class KeyframeDelete : public OliveAction {
|
||||
public:
|
||||
KeyframeDelete(EffectField* ifield, int iindex);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
KeyframeDelete(EffectField* ifield, int iindex);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectField* field;
|
||||
int index;
|
||||
bool done;
|
||||
EffectKeyframe deleted_key;
|
||||
EffectField* field;
|
||||
int index;
|
||||
bool done;
|
||||
EffectKeyframe deleted_key;
|
||||
};
|
||||
|
||||
// a more modern version of the above, could probably replace it
|
||||
// assumes the keyframe already exists
|
||||
class KeyframeFieldSet : public OliveAction {
|
||||
public:
|
||||
KeyframeFieldSet(EffectField* ifield, int ii);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
KeyframeFieldSet(EffectField* ifield, int ii);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectField* field;
|
||||
int index;
|
||||
EffectKeyframe key;
|
||||
bool done;
|
||||
EffectField* field;
|
||||
int index;
|
||||
EffectKeyframe key;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class EffectFieldUndo : public OliveAction {
|
||||
public:
|
||||
EffectFieldUndo(EffectField* field);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
EffectFieldUndo(EffectField* field);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectField* field;
|
||||
QVariant old_val;
|
||||
QVariant new_val;
|
||||
bool done;
|
||||
EffectField* field;
|
||||
QVariant old_val;
|
||||
QVariant new_val;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class SetAutoscaleAction : public OliveAction {
|
||||
public:
|
||||
SetAutoscaleAction();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
SetAutoscaleAction();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<ClipPtr> clips;
|
||||
};
|
||||
|
||||
class AddMarkerAction : public OliveAction {
|
||||
public:
|
||||
AddMarkerAction(QVector<Marker>* m, long t, QString n);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
AddMarkerAction(QVector<Marker>* m, long t, QString n);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QVector<Marker>* active_array;
|
||||
long time;
|
||||
QString name;
|
||||
QString old_name;
|
||||
int index;
|
||||
QVector<Marker>* active_array;
|
||||
long time;
|
||||
QString name;
|
||||
QString old_name;
|
||||
int index;
|
||||
};
|
||||
|
||||
class MoveMarkerAction : public OliveAction {
|
||||
public:
|
||||
MoveMarkerAction(Marker* m, long o, long n);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
MoveMarkerAction(Marker* m, long o, long n);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Marker* marker;
|
||||
long old_time;
|
||||
long new_time;
|
||||
Marker* marker;
|
||||
long old_time;
|
||||
long new_time;
|
||||
};
|
||||
|
||||
class DeleteMarkerAction : public OliveAction {
|
||||
public:
|
||||
DeleteMarkerAction(QVector<Marker>* m);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<int> markers;
|
||||
DeleteMarkerAction(QVector<Marker>* m);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<int> markers;
|
||||
private:
|
||||
QVector<Marker>* active_array;
|
||||
QVector<Marker> copies;
|
||||
bool sorted;
|
||||
QVector<Marker>* active_array;
|
||||
QVector<Marker> copies;
|
||||
bool sorted;
|
||||
};
|
||||
|
||||
class SetSpeedAction : public OliveAction {
|
||||
public:
|
||||
SetSpeedAction(ClipPtr c, double speed);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetSpeedAction(ClipPtr c, double speed);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
ClipPtr clip;
|
||||
double old_speed;
|
||||
double new_speed;
|
||||
ClipPtr clip;
|
||||
double old_speed;
|
||||
double new_speed;
|
||||
};
|
||||
|
||||
class SetBool : public OliveAction {
|
||||
public:
|
||||
SetBool(bool* b, bool setting);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetBool(bool* b, bool setting);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
bool* boolean;
|
||||
bool old_setting;
|
||||
bool new_setting;
|
||||
bool* boolean;
|
||||
bool old_setting;
|
||||
bool new_setting;
|
||||
};
|
||||
|
||||
class SetSelectionsCommand : public OliveAction {
|
||||
public:
|
||||
SetSelectionsCommand(SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<Selection> old_data;
|
||||
QVector<Selection> new_data;
|
||||
SetSelectionsCommand(SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
QVector<Selection> old_data;
|
||||
QVector<Selection> new_data;
|
||||
private:
|
||||
SequencePtr seq;
|
||||
bool done;
|
||||
SequencePtr seq;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class EditSequenceCommand : public OliveAction {
|
||||
public:
|
||||
EditSequenceCommand(Media *i, SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
void update();
|
||||
EditSequenceCommand(Media *i, SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
void update();
|
||||
|
||||
QString name;
|
||||
int width;
|
||||
int height;
|
||||
double frame_rate;
|
||||
int audio_frequency;
|
||||
int audio_layout;
|
||||
QString name;
|
||||
int width;
|
||||
int height;
|
||||
double frame_rate;
|
||||
int audio_frequency;
|
||||
int audio_layout;
|
||||
private:
|
||||
Media* item;
|
||||
SequencePtr seq;
|
||||
Media* item;
|
||||
SequencePtr seq;
|
||||
|
||||
QString old_name;
|
||||
int old_width;
|
||||
int old_height;
|
||||
double old_frame_rate;
|
||||
int old_audio_frequency;
|
||||
int old_audio_layout;
|
||||
QString old_name;
|
||||
int old_width;
|
||||
int old_height;
|
||||
double old_frame_rate;
|
||||
int old_audio_frequency;
|
||||
int old_audio_layout;
|
||||
};
|
||||
|
||||
class SetInt : public OliveAction {
|
||||
public:
|
||||
SetInt(int* pointer, int new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetInt(int* pointer, int new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
int* p;
|
||||
int oldval;
|
||||
int newval;
|
||||
int* p;
|
||||
int oldval;
|
||||
int newval;
|
||||
};
|
||||
|
||||
class SetLong : public OliveAction {
|
||||
public:
|
||||
SetLong(long* pointer, long old_value, long new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetLong(long* pointer, long old_value, long new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
long* p;
|
||||
long oldval;
|
||||
long newval;
|
||||
long* p;
|
||||
long oldval;
|
||||
long newval;
|
||||
};
|
||||
|
||||
class SetDouble : public OliveAction {
|
||||
public:
|
||||
SetDouble(double* pointer, double old_value, double new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetDouble(double* pointer, double old_value, double new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
double* p;
|
||||
double oldval;
|
||||
double newval;
|
||||
double* p;
|
||||
double oldval;
|
||||
double newval;
|
||||
};
|
||||
|
||||
class SetString : public OliveAction {
|
||||
public:
|
||||
SetString(QString* pointer, QString new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetString(QString* pointer, QString new_value);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QString* p;
|
||||
QString oldval;
|
||||
QString newval;
|
||||
QString* p;
|
||||
QString oldval;
|
||||
QString newval;
|
||||
};
|
||||
|
||||
class CloseAllClipsCommand : public OliveAction {
|
||||
public:
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
};
|
||||
|
||||
class UpdateFootageTooltip : public OliveAction {
|
||||
public:
|
||||
UpdateFootageTooltip(Media* i);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
UpdateFootageTooltip(Media* i);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* item;
|
||||
Media* item;
|
||||
};
|
||||
|
||||
class MoveEffectCommand : public OliveAction {
|
||||
public:
|
||||
MoveEffectCommand();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
ClipPtr clip;
|
||||
int from;
|
||||
int to;
|
||||
MoveEffectCommand();
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
ClipPtr clip;
|
||||
int from;
|
||||
int to;
|
||||
};
|
||||
|
||||
class RemoveClipsFromClipboard : public OliveAction {
|
||||
public:
|
||||
RemoveClipsFromClipboard(int index);
|
||||
virtual ~RemoveClipsFromClipboard() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
RemoveClipsFromClipboard(int index);
|
||||
virtual ~RemoveClipsFromClipboard() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
int pos;
|
||||
ClipPtr clip;
|
||||
bool done;
|
||||
int pos;
|
||||
ClipPtr clip;
|
||||
bool done;
|
||||
};
|
||||
|
||||
class RenameClipCommand : public OliveAction {
|
||||
public:
|
||||
RenameClipCommand();
|
||||
QVector<ClipPtr> clips;
|
||||
QString new_name;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
RenameClipCommand();
|
||||
QVector<ClipPtr> clips;
|
||||
QString new_name;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QVector<QString> old_names;
|
||||
QVector<QString> old_names;
|
||||
};
|
||||
|
||||
class SetPointer : public OliveAction {
|
||||
public:
|
||||
SetPointer(void** pointer, void* data);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetPointer(void** pointer, void* data);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
bool old_changed;
|
||||
void** p;
|
||||
void* new_data;
|
||||
void* old_data;
|
||||
bool old_changed;
|
||||
void** p;
|
||||
void* new_data;
|
||||
void* old_data;
|
||||
};
|
||||
|
||||
class ReloadEffectsCommand : public OliveAction {
|
||||
public:
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
};
|
||||
|
||||
class SetQVariant : public OliveAction {
|
||||
public:
|
||||
SetQVariant(QVariant* itarget, const QVariant& iold, const QVariant& inew);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetQVariant(QVariant* itarget, const QVariant& iold, const QVariant& inew);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
QVariant* target;
|
||||
QVariant old_val;
|
||||
QVariant new_val;
|
||||
QVariant* target;
|
||||
QVariant old_val;
|
||||
QVariant new_val;
|
||||
};
|
||||
|
||||
class SetKeyframing : public OliveAction {
|
||||
public:
|
||||
SetKeyframing(EffectRow* irow, bool ib);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetKeyframing(EffectRow* irow, bool ib);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectRow* row;
|
||||
bool b;
|
||||
EffectRow* row;
|
||||
bool b;
|
||||
};
|
||||
|
||||
class RefreshClips : public OliveAction {
|
||||
public:
|
||||
RefreshClips(Media* m);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
RefreshClips(Media* m);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Media* media;
|
||||
Media* media;
|
||||
};
|
||||
|
||||
class UpdateViewer : public OliveAction {
|
||||
public:
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
};
|
||||
|
||||
class SetEffectData : public OliveAction {
|
||||
public:
|
||||
SetEffectData(EffectPtr e, const QByteArray &s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
SetEffectData(EffectPtr e, const QByteArray &s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectPtr effect;
|
||||
QByteArray data;
|
||||
QByteArray old_data;
|
||||
EffectPtr effect;
|
||||
QByteArray data;
|
||||
QByteArray old_data;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
@@ -401,7 +401,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
// run through all of the clip's effects
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr e = c->effects.at(j);
|
||||
process_effect(c, e, timecode, coords, textureID, fbo_switcher, params.texture_failed, TA_NO_TRANSITION);
|
||||
process_effect(c, e, timecode, coords, textureID, fbo_switcher, params.texture_failed, kTransitionNone);
|
||||
|
||||
// retrieve gizmo data from effect
|
||||
if (e->are_gizmos_enabled()) {
|
||||
@@ -421,7 +421,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
if (c->get_opening_transition() != nullptr) {
|
||||
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, textureID, fbo_switcher, params.texture_failed, TA_OPENING_TRANSITION);
|
||||
process_effect(c, c->get_opening_transition(), double(transition_progress)/double(c->get_opening_transition()->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionOpening);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
if (c->get_closing_transition() != nullptr) {
|
||||
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, textureID, fbo_switcher, params.texture_failed, TA_CLOSING_TRANSITION);
|
||||
process_effect(c, c->get_closing_transition(), double(transition_progress)/double(c->get_closing_transition()->get_length()), coords, textureID, fbo_switcher, params.texture_failed, kTransitionClosing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+53
-53
@@ -656,7 +656,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
panel_timeline->deselect_area(link->timeline_in, link->timeline_out, link->track);
|
||||
}
|
||||
}
|
||||
} else if (panel_timeline->tool == TIMELINE_TOOL_POINTER && panel_timeline->transition_select != TA_NO_TRANSITION) {
|
||||
} else if (panel_timeline->tool == TIMELINE_TOOL_POINTER && panel_timeline->transition_select != kTransitionNone) {
|
||||
panel_timeline->deselect_area(clip->timeline_in, clip->timeline_out, clip->track);
|
||||
|
||||
for (int i=0;i<clip->linked.size();i++) {
|
||||
@@ -667,11 +667,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
Selection s;
|
||||
s.track = clip->track;
|
||||
|
||||
if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != nullptr) {
|
||||
if (panel_timeline->transition_select == kTransitionOpening && clip->get_opening_transition() != nullptr) {
|
||||
s.in = clip->timeline_in;
|
||||
if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length();
|
||||
s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length();
|
||||
} else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != nullptr) {
|
||||
} else if (panel_timeline->transition_select == kTransitionClosing && clip->get_closing_transition() != nullptr) {
|
||||
s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length();
|
||||
s.out = clip->timeline_out;
|
||||
if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length();
|
||||
@@ -690,12 +690,12 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
s.out = clip->timeline_out;
|
||||
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_POINTER) {
|
||||
if (panel_timeline->transition_select == TA_OPENING_TRANSITION) {
|
||||
if (panel_timeline->transition_select == kTransitionOpening) {
|
||||
s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length();
|
||||
if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length();
|
||||
}
|
||||
|
||||
if (panel_timeline->transition_select == TA_CLOSING_TRANSITION) {
|
||||
if (panel_timeline->transition_select == kTransitionClosing) {
|
||||
s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length();
|
||||
if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length();
|
||||
}
|
||||
@@ -709,7 +709,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
}
|
||||
|
||||
// if alt is not down, select links
|
||||
if (!alt && panel_timeline->transition_select == TA_NO_TRANSITION) {
|
||||
if (!alt && panel_timeline->transition_select == kTransitionNone) {
|
||||
for (int i=0;i<clip->linked.size();i++) {
|
||||
ClipPtr link = olive::ActiveSequence->clips.at(clip->linked.at(i));
|
||||
if (!is_clip_selected(link, true)) {
|
||||
@@ -767,26 +767,26 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
|
||||
void make_room_for_transition(ComboAction* ca, ClipPtr c, int type, long transition_start, long transition_end, bool delete_old_transitions) {
|
||||
// make room for transition
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
if (type == kTransitionOpening) {
|
||||
if (delete_old_transitions && c->get_opening_transition() != nullptr) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
}
|
||||
if (c->get_closing_transition() != nullptr) {
|
||||
if (transition_end >= c->timeline_out) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else if (transition_end > c->timeline_out - c->get_closing_transition()->get_true_length()) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, c->timeline_out - transition_end));
|
||||
ca->append(new ModifyTransitionCommand(c->closing_transition, c->timeline_out - transition_end));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (delete_old_transitions && c->get_closing_transition() != nullptr) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
}
|
||||
if (c->get_opening_transition() != nullptr) {
|
||||
if (transition_start <= c->timeline_in) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else if (transition_start < c->timeline_in + c->get_opening_transition()->get_true_length()) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, transition_start - c->timeline_in));
|
||||
ca->append(new ModifyTransitionCommand(c->opening_transition, transition_start - c->timeline_in));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1022,9 +1022,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
max_open_length -= c->get_closing_transition()->get_true_length();
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else if (c->get_opening_transition()->get_true_length() > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, max_open_length));
|
||||
ca->append(new ModifyTransitionCommand(c->opening_transition, max_open_length));
|
||||
}
|
||||
}
|
||||
if (c->get_closing_transition() != nullptr) {
|
||||
@@ -1033,16 +1033,16 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
max_open_length -= c->get_opening_transition()->get_true_length();
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition));
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else if (c->get_closing_transition()->get_true_length() > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, max_open_length));
|
||||
ca->append(new ModifyTransitionCommand(c->closing_transition, max_open_length));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bool is_opening_transition = (g.transition == c->get_opening_transition());
|
||||
long new_transition_length = g.out - g.in;
|
||||
if (g.transition->secondary_clip != nullptr) new_transition_length >>= 1;
|
||||
ca->append(new ModifyTransitionCommand(c, is_opening_transition ? TA_OPENING_TRANSITION : TA_CLOSING_TRANSITION, new_transition_length));
|
||||
ca->append(new ModifyTransitionCommand(is_opening_transition ? c->opening_transition : c->closing_transition, new_transition_length));
|
||||
|
||||
long clip_length = c->getLength();
|
||||
|
||||
@@ -1059,7 +1059,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
clip_length -= (g.in - g.old_in);
|
||||
}
|
||||
|
||||
make_room_for_transition(ca, c, TA_OPENING_TRANSITION, g.in, g.out, false);
|
||||
make_room_for_transition(ca, c, kTransitionOpening, g.in, g.out, false);
|
||||
} else {
|
||||
if (g.out != g.old_out) {
|
||||
// if transition is going to make the clip bigger, make the clip bigger
|
||||
@@ -1067,7 +1067,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
clip_length += (g.out - g.old_out);
|
||||
}
|
||||
|
||||
make_room_for_transition(ca, c, TA_CLOSING_TRANSITION, g.in, g.out, false);
|
||||
make_room_for_transition(ca, c, kTransitionClosing, g.in, g.out, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
|
||||
if (panel_timeline->transition_tool_post_clip > -1) {
|
||||
post = olive::ActiveSequence->clips.at(panel_timeline->transition_tool_post_clip);
|
||||
int opposite_type = (panel_timeline->transition_tool_type == TA_OPENING_TRANSITION) ? TA_CLOSING_TRANSITION : TA_OPENING_TRANSITION;
|
||||
int opposite_type = (panel_timeline->transition_tool_type == kTransitionOpening) ? kTransitionClosing : kTransitionOpening;
|
||||
make_room_for_transition(
|
||||
ca,
|
||||
post,
|
||||
@@ -1099,7 +1099,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
true
|
||||
);
|
||||
|
||||
if (panel_timeline->transition_tool_type == TA_CLOSING_TRANSITION) {
|
||||
if (panel_timeline->transition_tool_type == kTransitionClosing) {
|
||||
// swap
|
||||
ClipPtr temp = pre;
|
||||
pre = post;
|
||||
@@ -1136,7 +1136,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
}
|
||||
|
||||
if (panel_timeline->transition_tool_post_clip > -1) {
|
||||
ca->append(new AddTransitionCommand(pre, post, nullptr, panel_timeline->transition_tool_meta, TA_OPENING_TRANSITION, transition_end - pre->timeline_in));
|
||||
ca->append(new AddTransitionCommand(pre, post, nullptr, panel_timeline->transition_tool_meta, kTransitionOpening, transition_end - pre->timeline_in));
|
||||
} else {
|
||||
ca->append(new AddTransitionCommand(pre, nullptr, nullptr, panel_timeline->transition_tool_meta, panel_timeline->transition_tool_type, transition_end - transition_start));
|
||||
}
|
||||
@@ -1241,7 +1241,7 @@ void TimelineWidget::init_ghosts() {
|
||||
void validate_transitions(ClipPtr c, int transition_type, long& frame_diff) {
|
||||
long validator;
|
||||
|
||||
if (transition_type == TA_OPENING_TRANSITION) {
|
||||
if (transition_type == kTransitionOpening) {
|
||||
// prevent from going below 0 on the timeline
|
||||
validator = c->timeline_in + frame_diff;
|
||||
if (validator < 0) frame_diff -= validator;
|
||||
@@ -1274,7 +1274,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
|
||||
int mouse_track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
long frame_diff = (lock_frame) ? 0 : panel_timeline->getTimelineFrameFromScreenPoint(mouse_pos.x()) - panel_timeline->drag_frame_start;
|
||||
int track_diff = ((effective_tool == TIMELINE_TOOL_SLIDE || panel_timeline->transition_select != TA_NO_TRANSITION) && !panel_timeline->importing) ? 0 : mouse_track - panel_timeline->drag_track_start;
|
||||
int track_diff = ((effective_tool == TIMELINE_TOOL_SLIDE || panel_timeline->transition_select != kTransitionNone) && !panel_timeline->importing) ? 0 : mouse_track - panel_timeline->drag_track_start;
|
||||
long validator;
|
||||
long earliest_in_point = LONG_MAX;
|
||||
|
||||
@@ -1389,12 +1389,12 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
frame_diff += g.transition->get_true_length();
|
||||
}
|
||||
|
||||
validate_transitions(otc, TA_OPENING_TRANSITION, frame_diff);
|
||||
validate_transitions(ctc, TA_CLOSING_TRANSITION, frame_diff);
|
||||
validate_transitions(otc, kTransitionOpening, frame_diff);
|
||||
validate_transitions(ctc, kTransitionClosing, frame_diff);
|
||||
|
||||
frame_diff = -frame_diff;
|
||||
validate_transitions(otc, TA_OPENING_TRANSITION, frame_diff);
|
||||
validate_transitions(ctc, TA_CLOSING_TRANSITION, frame_diff);
|
||||
validate_transitions(otc, kTransitionOpening, frame_diff);
|
||||
validate_transitions(ctc, kTransitionClosing, frame_diff);
|
||||
frame_diff = -frame_diff;
|
||||
|
||||
if (g.trim_in) {
|
||||
@@ -1484,7 +1484,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
ClipPtr otc = c; // open transition clip
|
||||
ClipPtr ctc = olive::ActiveSequence->clips.at(panel_timeline->transition_tool_post_clip); // close transition clip
|
||||
|
||||
if (panel_timeline->transition_tool_type == TA_CLOSING_TRANSITION) {
|
||||
if (panel_timeline->transition_tool_type == kTransitionClosing) {
|
||||
// swap
|
||||
ClipPtr temp = otc;
|
||||
otc = ctc;
|
||||
@@ -1492,13 +1492,13 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
}
|
||||
|
||||
// always gets a positive frame_diff
|
||||
validate_transitions(otc, TA_OPENING_TRANSITION, frame_diff);
|
||||
validate_transitions(ctc, TA_CLOSING_TRANSITION, frame_diff);
|
||||
validate_transitions(otc, kTransitionOpening, frame_diff);
|
||||
validate_transitions(ctc, kTransitionClosing, frame_diff);
|
||||
|
||||
// always gets a negative frame_diff
|
||||
frame_diff = -frame_diff;
|
||||
validate_transitions(otc, TA_OPENING_TRANSITION, frame_diff);
|
||||
validate_transitions(ctc, TA_CLOSING_TRANSITION, frame_diff);
|
||||
validate_transitions(otc, kTransitionOpening, frame_diff);
|
||||
validate_transitions(ctc, kTransitionClosing, frame_diff);
|
||||
frame_diff = -frame_diff;
|
||||
}
|
||||
}
|
||||
@@ -1566,7 +1566,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
if (panel_timeline->transition_tool_post_clip > -1) {
|
||||
g.in = g.old_in - frame_diff;
|
||||
g.out = g.old_out + frame_diff;
|
||||
} else if (panel_timeline->transition_tool_type == TA_OPENING_TRANSITION) {
|
||||
} else if (panel_timeline->transition_tool_type == kTransitionOpening) {
|
||||
g.out = g.old_out + frame_diff;
|
||||
} else {
|
||||
g.in = g.old_in + frame_diff;
|
||||
@@ -1750,11 +1750,11 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
for (int j=0;j<olive::ActiveSequence->selections.size();j++) {
|
||||
const Selection& s = olive::ActiveSequence->selections.at(j);
|
||||
if (s.track == c->track) {
|
||||
if (selection_contains_transition(s, c, TA_OPENING_TRANSITION)) {
|
||||
if (selection_contains_transition(s, c, kTransitionOpening)) {
|
||||
g.transition = c->get_opening_transition();
|
||||
add = true;
|
||||
break;
|
||||
} else if (selection_contains_transition(s, c, TA_CLOSING_TRANSITION)) {
|
||||
} else if (selection_contains_transition(s, c, kTransitionClosing)) {
|
||||
g.transition = c->get_closing_transition();
|
||||
add = true;
|
||||
break;
|
||||
@@ -2049,7 +2049,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
int max_track = INT_MIN;
|
||||
|
||||
// we default to selecting no transition, but set this accordingly if the cursor is on a transition
|
||||
panel_timeline->transition_select = TA_NO_TRANSITION;
|
||||
panel_timeline->transition_select = kTransitionNone;
|
||||
|
||||
// set currently trimming clip to -1 (aka null)
|
||||
panel_timeline->trim_target = -1;
|
||||
@@ -2081,12 +2081,12 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (c->get_opening_transition() != nullptr
|
||||
&& panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->get_true_length()) {
|
||||
|
||||
panel_timeline->transition_select = TA_OPENING_TRANSITION;
|
||||
panel_timeline->transition_select = kTransitionOpening;
|
||||
|
||||
} else if (c->get_closing_transition() != nullptr
|
||||
&& panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->get_true_length()) {
|
||||
|
||||
panel_timeline->transition_select = TA_CLOSING_TRANSITION;
|
||||
panel_timeline->transition_select = kTransitionClosing;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2145,7 +2145,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (nc < closeness) {
|
||||
panel_timeline->trim_target = i;
|
||||
panel_timeline->trim_in_point = false;
|
||||
panel_timeline->transition_select = TA_OPENING_TRANSITION;
|
||||
panel_timeline->transition_select = kTransitionOpening;
|
||||
closeness = nc;
|
||||
found = true;
|
||||
}
|
||||
@@ -2166,7 +2166,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (nc < closeness) {
|
||||
panel_timeline->trim_target = i;
|
||||
panel_timeline->trim_in_point = true;
|
||||
panel_timeline->transition_select = TA_CLOSING_TRANSITION;
|
||||
panel_timeline->transition_select = kTransitionClosing;
|
||||
closeness = nc;
|
||||
found = true;
|
||||
}
|
||||
@@ -2234,7 +2234,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
|
||||
Ghost g;
|
||||
|
||||
g.in = g.old_in = g.out = g.old_out = (panel_timeline->transition_tool_type == TA_OPENING_TRANSITION) ? c->timeline_in : c->timeline_out;
|
||||
g.in = g.old_in = g.out = g.old_out = (panel_timeline->transition_tool_type == kTransitionOpening) ? c->timeline_in : c->timeline_out;
|
||||
g.track = c->track;
|
||||
g.clip = panel_timeline->transition_tool_pre_clip;
|
||||
g.media_stream = panel_timeline->transition_tool_type;
|
||||
@@ -2254,9 +2254,9 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
long between_range = getFrameFromScreenPoint(panel_timeline->zoom, TRANSITION_BETWEEN_RANGE) + 1;
|
||||
|
||||
if (panel_timeline->cursor_frame > halfway) {
|
||||
panel_timeline->transition_tool_type = TA_CLOSING_TRANSITION;
|
||||
panel_timeline->transition_tool_type = kTransitionClosing;
|
||||
} else {
|
||||
panel_timeline->transition_tool_type = TA_OPENING_TRANSITION;
|
||||
panel_timeline->transition_tool_type = kTransitionOpening;
|
||||
}
|
||||
|
||||
panel_timeline->transition_tool_post_clip = -1;
|
||||
@@ -2334,14 +2334,14 @@ void draw_waveform(ClipPtr clip, const FootageStream* ms, long media_length, QPa
|
||||
}
|
||||
|
||||
void draw_transition(QPainter& p, ClipPtr c, const QRect& clip_rect, QRect& text_rect, int transition_type) {
|
||||
TransitionPtr t = (transition_type == TA_OPENING_TRANSITION) ? c->get_opening_transition() : c->get_closing_transition();
|
||||
TransitionPtr t = (transition_type == kTransitionOpening) ? c->get_opening_transition() : c->get_closing_transition();
|
||||
if (t != nullptr) {
|
||||
QColor transition_color(255, 0, 0, 16);
|
||||
int transition_width = getScreenPointFromFrame(panel_timeline->zoom, t->get_true_length());
|
||||
int transition_height = clip_rect.height();
|
||||
int tr_y = clip_rect.y();
|
||||
int tr_x = 0;
|
||||
if (transition_type == TA_OPENING_TRANSITION) {
|
||||
if (transition_type == kTransitionOpening) {
|
||||
tr_x = clip_rect.x();
|
||||
text_rect.setX(text_rect.x()+transition_width);
|
||||
} else {
|
||||
@@ -2356,13 +2356,13 @@ void draw_transition(QPainter& p, ClipPtr c, const QRect& clip_rect, QRect& text
|
||||
|
||||
p.setPen(QColor(0, 0, 0, 96));
|
||||
if (t->secondary_clip == nullptr) {
|
||||
if (transition_type == TA_OPENING_TRANSITION) {
|
||||
if (transition_type == kTransitionOpening) {
|
||||
p.drawLine(transition_rect.bottomLeft(), transition_rect.topRight());
|
||||
} else {
|
||||
p.drawLine(transition_rect.topLeft(), transition_rect.bottomRight());
|
||||
}
|
||||
} else {
|
||||
if (transition_type == TA_OPENING_TRANSITION) {
|
||||
if (transition_type == kTransitionOpening) {
|
||||
p.drawLine(QPoint(transition_rect.left(), transition_rect.center().y()), transition_rect.topRight());
|
||||
p.drawLine(QPoint(transition_rect.left(), transition_rect.center().y()), transition_rect.bottomRight());
|
||||
draw_text = false;
|
||||
@@ -2577,8 +2577,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
// draw clip transitions
|
||||
draw_transition(p, clip, clip_rect, text_rect, TA_OPENING_TRANSITION);
|
||||
draw_transition(p, clip, clip_rect, text_rect, TA_CLOSING_TRANSITION);
|
||||
draw_transition(p, clip, clip_rect, text_rect, kTransitionOpening);
|
||||
draw_transition(p, clip, clip_rect, text_rect, kTransitionClosing);
|
||||
|
||||
// top left bevel
|
||||
p.setPen(Qt::white);
|
||||
@@ -2617,10 +2617,10 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
int type = panel_timeline->transition_tool_type;
|
||||
if (panel_timeline->transition_tool_post_clip == i) {
|
||||
// invert transition type
|
||||
type = (type == TA_CLOSING_TRANSITION) ? TA_OPENING_TRANSITION : TA_CLOSING_TRANSITION;
|
||||
type = (type == kTransitionClosing) ? kTransitionOpening : kTransitionClosing;
|
||||
}
|
||||
QRect transition_tool_rect = clip_rect;
|
||||
if (type == TA_CLOSING_TRANSITION) {
|
||||
if (type == kTransitionClosing) {
|
||||
if (panel_timeline->transition_tool_post_clip > -1) {
|
||||
transition_tool_rect.setLeft(transition_tool_rect.right() - TRANSITION_BETWEEN_RANGE);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user