updated and merged sweeping timeline behavior fixes

This commit is contained in:
itsmattkc
2018-12-31 01:59:30 +11:00
63 changed files with 7867 additions and 9088 deletions
+153 -143
View File
@@ -10,6 +10,7 @@
#include "project/sequence.h"
#include "panels/timeline.h"
#include "project/media.h"
#include "io/clipboard.h"
#include "undo.h"
extern "C" {
@@ -17,69 +18,70 @@ extern "C" {
}
Clip::Clip(Sequence* s) :
sequence(s),
enabled(true),
clip_in(0),
timeline_in(0),
timeline_out(0),
track(0),
media(NULL),
speed(1.0),
reverse(false),
maintain_audio_pitch(false),
autoscale(config.autoscale_by_default),
opening_transition(-1),
closing_transition(-1),
undeletable(false),
replaced(false),
ignore_reverse(false),
use_existing_frame(false),
sequence(s),
enabled(true),
clip_in(0),
timeline_in(0),
timeline_out(0),
track(0),
media(NULL),
speed(1.0),
reverse(false),
maintain_audio_pitch(false),
autoscale(config.autoscale_by_default),
opening_transition(-1),
closing_transition(-1),
undeletable(false),
replaced(false),
ignore_reverse(false),
use_existing_frame(false),
filter_graph(NULL),
fbo(NULL),
opts(NULL)
fbo(NULL),
opts(NULL)
{
pkt = av_packet_alloc();
reset();
reset();
}
Clip* Clip::copy(Sequence* s) {
Clip* copy = new Clip(s);
Clip* 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->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->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));
}
// TODO make a replacemennt for this somehow
if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip == NULL) copy->opening_transition = get_opening_transition()->copy(copy, NULL);
if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip == NULL) copy->closing_transition = get_closing_transition()->copy(copy, NULL);
copy->cached_fr = (this->sequence == NULL) ? cached_fr : this->sequence->frame_rate;
if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip == NULL) copy->opening_transition = get_opening_transition()->copy(copy, NULL);
if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip == NULL) copy->closing_transition = get_closing_transition()->copy(copy, NULL);
copy->recalculateMaxLength();
return copy;
return copy;
}
void Clip::reset() {
audio_just_reset = false;
open = false;
finished_opening = false;
audio_just_reset = false;
open = false;
finished_opening = false;
pkt_written = false;
audio_reset = false;
audio_reset = false;
frame_sample_index = -1;
audio_buffer_write = false;
texture_frame = -1;
@@ -88,42 +90,42 @@ void Clip::reset() {
codec = NULL;
codecCtx = NULL;
texture = NULL;
last_invalid_ts = -1;
last_invalid_ts = -1;
}
void Clip::reset_audio() {
if (media == NULL || 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) {
Sequence* nested_sequence = media->to_sequence();
for (int i=0;i<nested_sequence->clips.size();i++) {
Clip* c = nested_sequence->clips.at(i);
if (c != NULL) c->reset_audio();
}
}
if (media == NULL || 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) {
Sequence* nested_sequence = media->to_sequence();
for (int i=0;i<nested_sequence->clips.size();i++) {
Clip* c = nested_sequence->clips.at(i);
if (c != NULL) c->reset_audio();
}
}
}
void Clip::refresh() {
// validates media if it was replaced
if (replaced && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) {
Footage* m = media->to_footage();
if (replaced && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) {
Footage* 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;
}
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++) {
// reinitializes all effects... just in case
for (int i=0;i<effects.size();i++) {
effects.at(i)->refresh();
}
recalculateMaxLength();
recalculateMaxLength();
}
void Clip::queue_clear() {
@@ -142,79 +144,87 @@ void Clip::queue_remove_earliest() {
}
}
av_frame_free(&queue[earliest_frame]);
queue.removeAt(earliest_frame);
queue.removeAt(earliest_frame);
}
Transition* Clip::get_opening_transition() {
if (opening_transition > -1) {
return this->sequence->transitions.at(opening_transition);
}
return NULL;
if (opening_transition > -1) {
if (this->sequence == NULL) {
return clipboard_transitions.at(opening_transition);
} else {
return this->sequence->transitions.at(opening_transition);
}
}
return NULL;
}
Transition* Clip::get_closing_transition() {
if (closing_transition > -1) {
return this->sequence->transitions.at(closing_transition);
}
return NULL;
if (closing_transition > -1) {
if (this->sequence == NULL) {
return clipboard_transitions.at(closing_transition);
} else {
return this->sequence->transitions.at(closing_transition);
}
}
return NULL;
}
Clip::~Clip() {
if (open) {
if (open) {
close_clip(this);
// make sure clip has closed before clip is destroyed
if (multithreaded && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) {
cacher->wait();
}
}
// make sure clip has closed before clip is destroyed
if (multithreaded && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) {
cacher->wait();
}
}
if (opening_transition != -1) this->sequence->hard_delete_transition(this, TA_OPENING_TRANSITION);
if (closing_transition != -1) this->sequence->hard_delete_transition(this, TA_CLOSING_TRANSITION);
if (opening_transition != -1) this->sequence->hard_delete_transition(this, TA_OPENING_TRANSITION);
if (closing_transition != -1) this->sequence->hard_delete_transition(this, TA_CLOSING_TRANSITION);
for (int i=0;i<effects.size();i++) {
delete effects.at(i);
}
for (int i=0;i<effects.size();i++) {
delete effects.at(i);
}
av_packet_free(&pkt);
}
long Clip::get_clip_in_with_transition() {
if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) {
// 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() != NULL && get_opening_transition()->secondary_clip != NULL) {
// 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() != NULL && get_opening_transition()->secondary_clip != NULL) {
// 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() != NULL && get_opening_transition()->secondary_clip != NULL) {
// 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() != NULL && get_closing_transition()->secondary_clip != NULL) {
// 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() != NULL && get_closing_transition()->secondary_clip != NULL) {
// 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 != NULL) {
double rate = media->get_frame_rate(media_stream);
if (!qIsNaN(rate)) return rate;
}
if (sequence != NULL) return sequence->frame_rate;
Q_ASSERT(track < 0);
if (media != NULL) {
double rate = media->get_frame_rate(media_stream);
if (!qIsNaN(rate)) return rate;
}
if (sequence != NULL) return sequence->frame_rate;
return qSNaN();
}
@@ -224,29 +234,29 @@ void Clip::recalculateMaxLength() {
fr /= speed;
calculated_length = LONG_MAX;
calculated_length = LONG_MAX;
if (media != NULL) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* m = media->to_footage();
FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL && ms->infinite_length) {
calculated_length = LONG_MAX;
} else {
calculated_length = m->get_length_in_frames(fr);
}
}
break;
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media->to_sequence();
calculated_length = refactor_frame_number(s->getEndFrame(), s->frame_rate, fr);
}
break;
}
}
if (media != NULL) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* m = media->to_footage();
FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL && ms->infinite_length) {
calculated_length = LONG_MAX;
} else {
calculated_length = m->get_length_in_frames(fr);
}
}
break;
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media->to_sequence();
calculated_length = refactor_frame_number(s->getEndFrame(), s->frame_rate, fr);
}
break;
}
}
}
}
@@ -256,16 +266,16 @@ long Clip::getMaximumLength() {
int Clip::getWidth() {
if (media == NULL && sequence != NULL) return sequence->width;
switch (media->get_type()) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL) return ms->video_width;
if (sequence != NULL) return sequence->width;
if (sequence != NULL) return sequence->width;
}
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media->to_sequence();
Sequence* s = media->to_sequence();
return s->width;
}
}
@@ -274,16 +284,16 @@ int Clip::getWidth() {
int Clip::getHeight() {
if (media == NULL && sequence != NULL) return sequence->height;
switch (media->get_type()) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream);
if (ms != NULL) return ms->video_height;
if (sequence != NULL) return sequence->height;
if (sequence != NULL) return sequence->height;
}
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media->to_sequence();
Sequence* s = media->to_sequence();
return s->height;
}
}
@@ -292,11 +302,11 @@ int Clip::getHeight() {
void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points) {
if (change_timeline_points) {
move_clip(ca, this,
qRound((double) timeline_in * multiplier),
qRound((double) timeline_out * multiplier),
qRound((double) clip_in * multiplier),
track);
move_clip(ca, this,
qRound((double) timeline_in * multiplier),
qRound((double) timeline_out * multiplier),
qRound((double) clip_in * multiplier),
track);
}
for (int i=0;i<effects.size();i++) {
+100 -96
View File
@@ -7,172 +7,176 @@
#include "debug.h"
ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(NULL) {
root_item = new Media(0);
root_item->root = true;
root_item = new Media(0);
root_item->root = true;
}
ProjectModel::~ProjectModel() {
destroy_root();
ProjectModel::~ProjectModel() {
destroy_root();
}
void ProjectModel::destroy_root() {
if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function();
if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function();
if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function();
if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function();
if (root_item != NULL) {
delete root_item;
}
if (root_item != NULL) {
delete root_item;
}
}
void ProjectModel::clear() {
beginResetModel();
destroy_root();
root_item = new Media(0);
root_item->root = true;
endResetModel();
beginResetModel();
destroy_root();
root_item = new Media(0);
root_item->root = true;
endResetModel();
}
Media *ProjectModel::get_root() {
return root_item;
return root_item;
}
QVariant ProjectModel::data(const QModelIndex &index, int role) const {
if (!index.isValid())
return QVariant();
if (!index.isValid())
return QVariant();
return static_cast<Media*>(index.internalPointer())->data(index.column(), role);
return static_cast<Media*>(index.internalPointer())->data(index.column(), role);
}
Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const {
if (!index.isValid())
return Qt::ItemIsDropEnabled;
if (!index.isValid())
return Qt::ItemIsDropEnabled;
return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable;
}
QVariant ProjectModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return root_item->data(section, role);
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return root_item->data(section, role);
return QVariant();
return QVariant();
}
QModelIndex ProjectModel::index(int row, int column, const QModelIndex &parent) const {
if (!hasIndex(row, column, parent))
return QModelIndex();
if (!hasIndex(row, column, parent))
return QModelIndex();
Media *parentItem;
Media *parentItem;
if (!parent.isValid())
parentItem = root_item;
else
parentItem = static_cast<Media*>(parent.internalPointer());
if (!parent.isValid())
parentItem = root_item;
else
parentItem = static_cast<Media*>(parent.internalPointer());
Media *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
Media *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}
QModelIndex ProjectModel::create_index(int arow, int acolumn, void* aid) {
return createIndex(arow, acolumn, aid);
}
QModelIndex ProjectModel::parent(const QModelIndex &index) const {
if (!index.isValid())
return QModelIndex();
if (!index.isValid())
return QModelIndex();
Media *childItem = static_cast<Media*>(index.internalPointer());
Media *parentItem = childItem->parentItem();
Media *childItem = static_cast<Media*>(index.internalPointer());
Media *parentItem = childItem->parentItem();
if (parentItem == root_item)
return QModelIndex();
if (parentItem == root_item)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
return createIndex(parentItem->row(), 0, parentItem);
}
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int role) {
if (role != Qt::EditRole)
return false;
if (role != Qt::EditRole)
return false;
Media *item = static_cast<Media*>(index.internalPointer());
bool result = item->setData(index.column(), value);
Media *item = static_cast<Media*>(index.internalPointer());
bool result = item->setData(index.column(), value);
if (result)
emit dataChanged(index, index);
if (result)
emit dataChanged(index, index);
return result;
return result;
}
int ProjectModel::rowCount(const QModelIndex &parent) const {
Media *parentItem;
if (parent.column() > 0)
return 0;
Media *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid()) {
parentItem = root_item;
} else {
parentItem = static_cast<Media*>(parent.internalPointer());
}
if (!parent.isValid()) {
parentItem = root_item;
} else {
parentItem = static_cast<Media*>(parent.internalPointer());
}
return parentItem->childCount();
return parentItem->childCount();
}
int ProjectModel::columnCount(const QModelIndex &parent) const {
if (parent.isValid())
return static_cast<Media*>(parent.internalPointer())->columnCount();
else
return root_item->columnCount();
if (parent.isValid())
return static_cast<Media*>(parent.internalPointer())->columnCount();
else
return root_item->columnCount();
}
Media *ProjectModel::getItem(const QModelIndex &index) const {
if (index.isValid()) {
Media *item = static_cast<Media*>(index.internalPointer());
if (item)
return item;
}
return root_item;
if (index.isValid()) {
Media *item = static_cast<Media*>(index.internalPointer());
if (item)
return item;
}
return root_item;
}
void ProjectModel::set_icon(Media* m, const QIcon &ico) {
QModelIndex index = createIndex(m->row(), 0, m);
m->set_icon(ico);
emit dataChanged(index, index);
QModelIndex index = createIndex(m->row(), 0, m);
m->set_icon(ico);
emit dataChanged(index, index);
}
void ProjectModel::appendChild(Media *parent, Media *child) {
if (parent == NULL) parent = root_item;
beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount());
parent->appendChild(child);
endInsertRows();
if (parent == NULL) parent = root_item;
beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount());
parent->appendChild(child);
endInsertRows();
}
void ProjectModel::moveChild(Media *child, Media *to) {
if (to == NULL) to = root_item;
Media* from = child->parentItem();
beginMoveRows(
from == root_item ? QModelIndex() : createIndex(from->row(), 0, from),
child->row(),
child->row(),
to == root_item ? QModelIndex() : createIndex(to->row(), 0, to),
to->childCount()
);
from->removeChild(child->row());
to->appendChild(child);
endMoveRows();
if (to == NULL) to = root_item;
Media* from = child->parentItem();
beginMoveRows(
from == root_item ? QModelIndex() : createIndex(from->row(), 0, from),
child->row(),
child->row(),
to == root_item ? QModelIndex() : createIndex(to->row(), 0, to),
to->childCount()
);
from->removeChild(child->row());
to->appendChild(child);
endMoveRows();
}
void ProjectModel::removeChild(Media* parent, Media* m) {
if (parent == NULL) parent = root_item;
beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row());
parent->removeChild(m->row());
endRemoveRows();
if (parent == NULL) parent = root_item;
beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row());
parent->removeChild(m->row());
endRemoveRows();
}
Media* ProjectModel::child(int i, Media* parent) {
if (parent == NULL) parent = root_item;
return parent->child(i);
if (parent == NULL) parent = root_item;
return parent->child(i);
}
int ProjectModel::childCount(Media *parent) {
if (parent == NULL) parent = root_item;
return parent->childCount();
if (parent == NULL) parent = root_item;
return parent->childCount();
}
+25 -24
View File
@@ -7,35 +7,36 @@ class Media;
class ProjectModel : public QAbstractItemModel
{
Q_OBJECT
Q_OBJECT
public:
ProjectModel(QObject* parent = 0);
~ProjectModel() override;
ProjectModel(QObject* parent = 0);
~ProjectModel() override;
void destroy_root();
void clear();
Media* get_root();
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Media *getItem(const QModelIndex &index) const;
void destroy_root();
void clear();
Media* get_root();
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex create_index(int arow, int acolumn, void *aid);
QModelIndex parent(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Media *getItem(const QModelIndex &index) const;
void appendChild(Media* parent, Media* child);
void moveChild(Media *child, Media *to);
void removeChild(Media *parent, Media* m);
Media *child(int i, Media* parent = NULL);
int childCount(Media* parent = NULL);
void set_icon(Media* m, const QIcon &ico);
void appendChild(Media* parent, Media* child);
void moveChild(Media *child, Media *to);
void removeChild(Media *parent, Media* m);
Media *child(int i, Media* parent = NULL);
int childCount(Media* parent = NULL);
void set_icon(Media* m, const QIcon &ico);
private:
Media* root_item;
Media* root_item;
};
#endif // PROJECTMODEL_H
+76 -68
View File
@@ -7,94 +7,102 @@
Sequence::Sequence() :
playhead(0),
using_workarea(false),
workarea_in(0),
workarea_out(0),
wrapper_sequence(false)
using_workarea(false),
workarea_in(0),
workarea_out(0),
wrapper_sequence(false)
{
}
Sequence::~Sequence() {
// dealloc all clips
for (int i=0;i<clips.size();i++) {
delete clips.at(i);
}
// dealloc all clips
for (int i=0;i<clips.size();i++) {
delete clips.at(i);
}
}
Sequence* Sequence::copy() {
Sequence* s = new Sequence();
s->name = name + " (copy)";
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
s->audio_frequency = audio_frequency;
s->audio_layout = audio_layout;
s->clips.resize(clips.size());
for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i);
if (c == NULL) {
s->clips[i] = NULL;
} else {
Clip* copy = c->copy(s);
copy->linked = c->linked;
s->clips[i] = copy;
}
}
return s;
Sequence* s = new Sequence();
s->name = name + " (copy)";
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
s->audio_frequency = audio_frequency;
s->audio_layout = audio_layout;
s->clips.resize(clips.size());
for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i);
if (c == NULL) {
s->clips[i] = NULL;
} else {
Clip* copy = c->copy(s);
copy->linked = c->linked;
s->clips[i] = copy;
}
}
return s;
}
long Sequence::getEndFrame() {
long end = 0;
for (int j=0;j<clips.size();j++) {
Clip* c = clips.at(j);
if (c != NULL && c->timeline_out > end) {
end = c->timeline_out;
}
}
return end;
long end = 0;
for (int j=0;j<clips.size();j++) {
Clip* c = clips.at(j);
if (c != NULL && c->timeline_out > end) {
end = c->timeline_out;
}
}
return end;
}
void Sequence::hard_delete_transition(Clip *c, int type) {
int transition_index = (type == TA_OPENING_TRANSITION) ? c->opening_transition : c->closing_transition;
if (transition_index > -1) {
bool del = true;
for (int i=0;i<clips.size();i++) {
Clip* cc = clips.at(i);
if (cc != NULL
&& c != cc
&& (cc->opening_transition == transition_index
|| cc->closing_transition == transition_index)) {
// another clip is using this, don't delete just yet
del = false;
break;
}
}
int transition_index = (type == TA_OPENING_TRANSITION) ? c->opening_transition : c->closing_transition;
if (transition_index > -1) {
bool del = true;
if (del) {
delete transitions.at(transition_index);
transitions[transition_index] = NULL;
}
Transition* t = transitions.at(transition_index);
if (t->secondary_clip != NULL) {
for (int i=0;i<clips.size();i++) {
Clip* comp = clips.at(i);
if (comp != NULL
&& 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;
}
if (type == TA_OPENING_TRANSITION) {
c->opening_transition = -1;
} else {
c->closing_transition = -1;
}
}
del = false;
t->secondary_clip = NULL;
}
}
}
if (del) {
delete transitions.at(transition_index);
transitions[transition_index] = NULL;
}
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;
for (int j=0;j<clips.size();j++) {
Clip* c = clips.at(j);
if (c != NULL) {
if (c->track < 0 && c->track < vt) { // video clip
vt = c->track;
} else if (c->track > at) {
at = c->track;
}
}
for (int j=0;j<clips.size();j++) {
Clip* c = clips.at(j);
if (c != NULL) {
if (c->track < 0 && c->track < vt) { // video clip
vt = c->track;
} else if (c->track > at) {
at = c->track;
}
}
}
if (video_tracks != NULL) *video_tracks = vt;
if (audio_tracks != NULL) *audio_tracks = at;
+14 -13
View File
@@ -8,35 +8,36 @@
struct Clip;
class Transition;
class Media;
struct Sequence {
Sequence();
~Sequence();
Sequence* copy();
QString name;
void getTrackLimits(int* video_tracks, int* audio_tracks);
Sequence* copy();
QString name;
void getTrackLimits(int* video_tracks, int* audio_tracks);
long getEndFrame();
void hard_delete_transition(Clip *c, int type);
void hard_delete_transition(Clip *c, int type);
int width;
int height;
double frame_rate;
double frame_rate;
int audio_frequency;
int audio_layout;
int audio_layout;
QVector<Selection> selections;
long playhead;
bool using_workarea;
long workarea_in;
long workarea_out;
bool using_workarea;
long workarea_in;
long workarea_out;
bool wrapper_sequence;
bool wrapper_sequence;
int save_id;
int save_id;
QVector<Marker> markers;
QVector<Marker> markers;
QVector<Clip*> clips;
QVector<Transition*> transitions;
QVector<Transition*> transitions;
};
// static variable for the currently active sequence
+199 -199
View File
@@ -18,263 +18,263 @@
#include <QDesktopServices>
SourcesCommon::SourcesCommon(Project* parent) :
project_parent(parent),
editing_item(NULL)
project_parent(parent),
editing_item(NULL)
{
rename_timer.setInterval(1000);
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
rename_timer.setInterval(1000);
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
}
void SourcesCommon::create_seq_from_selected() {
if (!selected_items.isEmpty()) {
QVector<Media*> media_list;
for (int i=0;i<selected_items.size();i++) {
media_list.append(project_parent->item_to_media(selected_items.at(i)));
}
if (!selected_items.isEmpty()) {
QVector<Media*> media_list;
for (int i=0;i<selected_items.size();i++) {
media_list.append(project_parent->item_to_media(selected_items.at(i)));
}
ComboAction* ca = new ComboAction();
Sequence* s = create_sequence_from_media(media_list);
ComboAction* ca = new ComboAction();
Sequence* s = create_sequence_from_media(media_list);
// add clips to it
panel_timeline->create_ghosts_from_media(s, 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s);
// add clips to it
panel_timeline->create_ghosts_from_media(s, 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s);
project_parent->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
}
project_parent->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
}
}
void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& items) {
QMenu menu(parent);
QMenu menu(parent);
selected_items = items;
selected_items = items;
QAction* import_action = menu.addAction("Import...");
QObject::connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog()));
QAction* import_action = menu.addAction("Import...");
QObject::connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog()));
QAction* new_folder_action = menu.addAction("New Folder...");
QObject::connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionFolder_triggered()));
QMenu* new_menu = menu.addMenu("New");
mainWindow->make_new_menu(new_menu);
if (items.size() > 0) {
Media* m = project_parent->item_to_media(items.at(0));
if (items.size() > 0) {
Media* m = project_parent->item_to_media(items.at(0));
if (items.size() == 1) {
// replace footage
int type = m->get_type();
if (type == MEDIA_TYPE_FOOTAGE) {
QAction* replace_action = menu.addAction("Replace/Relink Media");
QObject::connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file()));
if (items.size() == 1) {
// replace footage
int type = m->get_type();
if (type == MEDIA_TYPE_FOOTAGE) {
QAction* replace_action = menu.addAction("Replace/Relink Media");
QObject::connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file()));
#if defined(Q_OS_WIN)
QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer");
QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer");
#elif defined(Q_OS_MAC)
QAction* reveal_in_explorer = menu.addAction("Reveal in Finder");
QAction* reveal_in_explorer = menu.addAction("Reveal in Finder");
#else
QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager");
QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager");
#endif
QObject::connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser()));
}
if (type != MEDIA_TYPE_FOLDER) {
QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media");
QObject::connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media()));
}
}
QObject::connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser()));
}
if (type != MEDIA_TYPE_FOLDER) {
QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media");
QObject::connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media()));
}
}
// duplicate item
bool all_sequences = true;
bool all_footage = true;
for (int i=0;i<items.size();i++) {
if (m->get_type() != MEDIA_TYPE_SEQUENCE) {
all_sequences = false;
}
if (m->get_type() != MEDIA_TYPE_FOOTAGE) {
all_footage = false;
}
}
// duplicate item
bool all_sequences = true;
bool all_footage = true;
for (int i=0;i<items.size();i++) {
if (m->get_type() != MEDIA_TYPE_SEQUENCE) {
all_sequences = false;
}
if (m->get_type() != MEDIA_TYPE_FOOTAGE) {
all_footage = false;
}
}
// create sequence from
QAction* create_seq_from = menu.addAction("Create Sequence With This Media");
QObject::connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected()));
// create sequence from
QAction* create_seq_from = menu.addAction("Create Sequence With This Media");
QObject::connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected()));
// ONLY sequences are selected
if (all_sequences) {
// ONLY sequences are selected
QAction* duplicate_action = menu.addAction("Duplicate");
QObject::connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected()));
}
// ONLY sequences are selected
if (all_sequences) {
// ONLY sequences are selected
QAction* duplicate_action = menu.addAction("Duplicate");
QObject::connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected()));
}
// ONLY footage is selected
if (all_footage) {
QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media");
QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media()));
}
// ONLY footage is selected
if (all_footage) {
QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media");
QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media()));
}
// delete media
QAction* delete_action = menu.addAction("Delete");
QObject::connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media()));
// delete media
QAction* delete_action = menu.addAction("Delete");
QObject::connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media()));
if (items.size() == 1) {
QAction* properties_action = menu.addAction("Properties...");
QObject::connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties()));
}
}
if (items.size() == 1) {
QAction* properties_action = menu.addAction("Properties...");
QObject::connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties()));
}
}
menu.addSeparator();
menu.addSeparator();
QAction* tree_view_action = menu.addAction("Tree View");
connect(tree_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_tree_view()));
QAction* tree_view_action = menu.addAction("Tree View");
connect(tree_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_tree_view()));
QAction* icon_view_action = menu.addAction("Icon View");
connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view()));
QAction* icon_view_action = menu.addAction("Icon View");
connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view()));
menu.exec(QCursor::pos());
menu.exec(QCursor::pos());
}
void SourcesCommon::mousePressEvent(QMouseEvent *) {
stop_rename_timer();
stop_rename_timer();
}
void SourcesCommon::item_click(Media *m, const QModelIndex& index) {
if (editing_item == m) {
rename_timer.start();
} else {
editing_item = m;
editing_index = index;
}
if (editing_item == m) {
rename_timer.start();
} else {
editing_item = m;
editing_index = index;
}
}
void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *e, const QModelIndexList& selected_items) {
stop_rename_timer();
if (selected_items.size() == 0) {
project_parent->import_dialog();
} else if (selected_items.size() == 1) {
Media* item = project_parent->item_to_media(selected_items.at(0));
switch (item->get_type()) {
case MEDIA_TYPE_FOOTAGE:
panel_footage_viewer->set_media(item);
panel_footage_viewer->setFocus();
break;
case MEDIA_TYPE_SEQUENCE:
undo_stack.push(new ChangeSequenceAction(item->to_sequence()));
break;
}
}
stop_rename_timer();
if (selected_items.size() == 0) {
project_parent->import_dialog();
} else if (selected_items.size() == 1) {
Media* item = project_parent->item_to_media(selected_items.at(0));
switch (item->get_type()) {
case MEDIA_TYPE_FOOTAGE:
panel_footage_viewer->set_media(item);
panel_footage_viewer->setFocus();
break;
case MEDIA_TYPE_SEQUENCE:
undo_stack.push(new ChangeSequenceAction(item->to_sequence()));
break;
}
}
}
void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIndex& drop_item, const QModelIndexList& items) {
const QMimeData* mimeData = event->mimeData();
Media* m = project_parent->item_to_media(drop_item);
if (mimeData->hasUrls()) {
// drag files in from outside
QList<QUrl> urls = mimeData->urls();
if (!urls.isEmpty()) {
QStringList paths;
for (int i=0;i<urls.size();i++) {
paths.append(urls.at(i).toLocalFile());
}
bool replace = false;
if (urls.size() == 1
&& drop_item.isValid()
&& m->get_type() == MEDIA_TYPE_FOOTAGE
&& !QFileInfo(paths.at(0)).isDir()
&& config.drop_on_media_to_replace
&& QMessageBox::question(parent, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
if (drop_item.isValid()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
parent = drop_item;
} else {
parent = drop_item.parent();
}
}
project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
} else {
event->ignore();
const QMimeData* mimeData = event->mimeData();
Media* m = project_parent->item_to_media(drop_item);
if (mimeData->hasUrls()) {
// drag files in from outside
QList<QUrl> urls = mimeData->urls();
if (!urls.isEmpty()) {
QStringList paths;
for (int i=0;i<urls.size();i++) {
paths.append(urls.at(i).toLocalFile());
}
bool replace = false;
if (urls.size() == 1
&& drop_item.isValid()
&& m->get_type() == MEDIA_TYPE_FOOTAGE
&& !QFileInfo(paths.at(0)).isDir()
&& config.drop_on_media_to_replace
&& QMessageBox::question(parent, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
if (drop_item.isValid()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
parent = drop_item;
} else {
parent = drop_item.parent();
}
}
project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
} else {
event->ignore();
// dragging files within project
// if we dragged to the root OR dragged to a folder
if (!drop_item.isValid() || (drop_item.isValid() && m->get_type() == MEDIA_TYPE_FOLDER)) {
QVector<Media*> move_items;
for (int i=0;i<items.size();i++) {
const QModelIndex& item = items.at(i);
const QModelIndex& parent = item.parent();
Media* s = project_parent->item_to_media(item);
if (parent != drop_item && item != drop_item) {
bool ignore = false;
if (parent.isValid()) {
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
QModelIndex par = parent;
while (par.isValid() && !ignore) {
for (int j=0;j<items.size();j++) {
if (par == items.at(j)) {
ignore = true;
break;
}
}
par = par.parent();
}
}
if (!ignore) {
move_items.append(s);
}
}
}
if (move_items.size() > 0) {
MediaMove* mm = new MediaMove();
mm->to = m;
mm->items = move_items;
undo_stack.push(mm);
}
}
}
// dragging files within project
// if we dragged to the root OR dragged to a folder
if (!drop_item.isValid() || (drop_item.isValid() && m->get_type() == MEDIA_TYPE_FOLDER)) {
QVector<Media*> move_items;
for (int i=0;i<items.size();i++) {
const QModelIndex& item = items.at(i);
const QModelIndex& parent = item.parent();
Media* s = project_parent->item_to_media(item);
if (parent != drop_item && item != drop_item) {
bool ignore = false;
if (parent.isValid()) {
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
QModelIndex par = parent;
while (par.isValid() && !ignore) {
for (int j=0;j<items.size();j++) {
if (par == items.at(j)) {
ignore = true;
break;
}
}
par = par.parent();
}
}
if (!ignore) {
move_items.append(s);
}
}
}
if (move_items.size() > 0) {
MediaMove* mm = new MediaMove();
mm->to = m;
mm->items = move_items;
undo_stack.push(mm);
}
}
}
}
void SourcesCommon::reveal_in_browser() {
Media* media = project_parent->item_to_media(selected_items.at(0));
Footage* m = media->to_footage();
Media* media = project_parent->item_to_media(selected_items.at(0));
Footage* m = media->to_footage();
#if defined(Q_OS_WIN)
QStringList args;
args << "/select," << QDir::toNativeSeparators(m->url);
QProcess::startDetached("explorer", args);
QStringList args;
args << "/select," << QDir::toNativeSeparators(m->url);
QProcess::startDetached("explorer", args);
#elif defined(Q_OS_MAC)
QStringList args;
args << "-e";
args << "tell application \"Finder\"";
args << "-e";
args << "activate";
args << "-e";
args << "select POSIX file \""+m->url+"\"";
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
QStringList args;
args << "-e";
args << "tell application \"Finder\"";
args << "-e";
args << "activate";
args << "-e";
args << "select POSIX file \""+m->url+"\"";
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
#else
QDesktopServices::openUrl(QUrl::fromLocalFile(m->url.left(m->url.lastIndexOf('/'))));
QDesktopServices::openUrl(QUrl::fromLocalFile(m->url.left(m->url.lastIndexOf('/'))));
#endif
}
void SourcesCommon::stop_rename_timer() {
rename_timer.stop();
rename_timer.stop();
}
void SourcesCommon::rename_interval() {
stop_rename_timer();
if (view->hasFocus() && editing_item != NULL) {
view->edit(editing_index);
}
stop_rename_timer();
if (view->hasFocus() && editing_item != NULL) {
view->edit(editing_index);
}
}
void SourcesCommon::item_renamed(Media* item) {
if (editing_item == item) {
MediaRename* mr = new MediaRename(item, "idk");
undo_stack.push(mr);
editing_item = NULL;
}
if (editing_item == item) {
MediaRename* mr = new MediaRename(item, "idk");
undo_stack.push(mr);
editing_item = NULL;
}
}
+47 -45
View File
@@ -5,6 +5,8 @@
#include "sequence.h"
#include "debug.h"
#include "io/clipboard.h"
#include "effects/internal/crossdissolvetransition.h"
#include "effects/internal/linearfadetransition.h"
#include "effects/internal/exponentialfadetransition.h"
@@ -19,71 +21,71 @@
#include <QMessageBox>
Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) :
Effect(c, em), secondary_clip(s),
length(30)
Effect(c, em), secondary_clip(s),
length(30)
{
length_field = add_row("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("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->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 == NULL ? parent_clip->cached_fr : parent_clip->sequence->frame_rate);
}
int Transition::copy(Clip *c, Clip* s) {
int copy_index = create_transition(c, s, meta);
c->sequence->transitions.at(copy_index)->length = length;
return copy_index;
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 != NULL) {
return length * 2;
}
return length;
if (secondary_clip != NULL) {
return length * 2;
}
return length;
}
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);
}
Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) {
if (!em->filename.isEmpty()) {
// load effect from file
return 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 new CrossDissolveTransition(c, s, em);
case TRANSITION_INTERNAL_LINEARFADE: return new LinearFadeTransition(c, s, em);
case TRANSITION_INTERNAL_EXPONENTIALFADE: return new ExponentialFadeTransition(c, s, em);
case TRANSITION_INTERNAL_LOGARITHMICFADE: return new LogarithmicFadeTransition(c, s, em);
case TRANSITION_INTERNAL_CUBE: return new CubeTransition(c, s, em);
}
} else {
dout << "[ERROR] Invalid transition data";
QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive.");
}
return NULL;
if (!em->filename.isEmpty()) {
// load effect from file
return 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 new CrossDissolveTransition(c, s, em);
case TRANSITION_INTERNAL_LINEARFADE: return new LinearFadeTransition(c, s, em);
case TRANSITION_INTERNAL_EXPONENTIALFADE: return new ExponentialFadeTransition(c, s, em);
case TRANSITION_INTERNAL_LOGARITHMICFADE: return new LogarithmicFadeTransition(c, s, em);
case TRANSITION_INTERNAL_CUBE: return new CubeTransition(c, s, em);
}
} else {
dout << "[ERROR] Invalid transition data";
QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive.");
}
return NULL;
}
int create_transition(Clip* c, Clip* s, const EffectMeta* em) {
Transition* t = get_transition_from_meta(c, s, em);
if (t != NULL) {
c->sequence->transitions.append(t);
return c->sequence->transitions.size() - 1;
}
return -1;
int create_transition(Clip* c, Clip* s, const EffectMeta* em, long length) {
Transition* t = get_transition_from_meta(c, s, em);
if (length >= 0) t->set_length(length);
if (t != NULL) {
QVector<Transition*>& transition_list = (c->sequence == NULL) ? clipboard_transitions : c->sequence->transitions;
transition_list.append(t);
return transition_list.size() - 1;
}
return -1;
}
+11 -11
View File
@@ -14,22 +14,22 @@
#define TRANSITION_INTERNAL_CUBE 4
#define TRANSITION_INTERNAL_COUNT 5
int create_transition(Clip* c, Clip* s, const EffectMeta* em);
int create_transition(Clip* c, Clip* s, const EffectMeta* em, long length = -1);
class Transition : public Effect {
Q_OBJECT
Q_OBJECT
public:
Transition(Clip* c, Clip* s, const EffectMeta* em);
int copy(Clip* c, Clip* s);
Clip* secondary_clip;
void set_length(long l);
long get_true_length();
long get_length();
Transition(Clip* c, Clip* s, const EffectMeta* em);
int copy(Clip* c, Clip* s);
Clip* secondary_clip;
void set_length(long l);
long get_true_length();
long get_length();
private slots:
void set_length_from_slider();
void set_length_from_slider();
private:
long length; // used only for transitions
EffectField* length_field;
long length; // used only for transitions
EffectField* length_field;
};
#endif // TRANSITION_H
+353 -321
View File
File diff suppressed because it is too large Load Diff
+181 -177
View File
@@ -28,48 +28,66 @@ extern QUndoStack undo_stack;
class ComboAction : public QUndoCommand {
public:
ComboAction();
~ComboAction();
void undo();
void redo();
void append(QUndoCommand* u);
ComboAction();
~ComboAction();
void undo();
void redo();
void append(QUndoCommand* u);
void appendPost(QUndoCommand* u);
private:
QVector<QUndoCommand*> commands;
QVector<QUndoCommand*> commands;
QVector<QUndoCommand*> post_commands;
};
class MoveClipAction : public QUndoCommand {
public:
MoveClipAction(Clip* c, long iin, long iout, long iclip_in, int itrack);
void undo();
void redo();
MoveClipAction(Clip* c, long iin, long iout, long iclip_in, int itrack, bool irelative);
void undo();
void redo();
private:
Clip* clip;
Clip* 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 old_project_changed;
};
class RippleAction : public QUndoCommand {
public:
RippleAction(Sequence *is, long ipoint, long ilength, const QVector<int>& iignore);
void undo();
void redo();
private:
Sequence *s;
long point;
long length;
QVector<int> ignore;
ComboAction* ca;
};
class DeleteClipAction : public QUndoCommand {
public:
DeleteClipAction(Sequence* s, int clip);
~DeleteClipAction();
void undo();
void redo();
DeleteClipAction(Sequence* s, int clip);
~DeleteClipAction();
void undo();
void redo();
private:
Sequence* seq;
Clip* ref;
int index;
Sequence* seq;
Clip* ref;
int index;
int opening_transition;
int closing_transition;
QVector<int> linkClipIndex;
QVector<int> linkLinkIndex;
@@ -79,207 +97,193 @@ private:
class ChangeSequenceAction : public QUndoCommand {
public:
ChangeSequenceAction(Sequence* s);
void undo();
void redo();
ChangeSequenceAction(Sequence* s);
void undo();
void redo();
private:
Sequence* old_sequence;
Sequence* new_sequence;
Sequence* old_sequence;
Sequence* new_sequence;
};
class AddEffectCommand : public QUndoCommand {
public:
AddEffectCommand(Clip* c, Effect *e, const EffectMeta* m, int insert_pos = -1);
~AddEffectCommand();
void undo();
void redo();
AddEffectCommand(Clip* c, Effect *e, const EffectMeta* m, int insert_pos = -1);
~AddEffectCommand();
void undo();
void redo();
private:
Clip* clip;
Clip* clip;
const EffectMeta* meta;
Effect* ref;
int pos;
bool done;
Effect* ref;
int pos;
bool done;
bool old_project_changed;
};
class AddTransitionCommand : public QUndoCommand {
public:
AddTransitionCommand(Clip* c, Clip* s, Transition *copy, const EffectMeta* itransition, int itype, int ilength);
void undo();
void redo();
AddTransitionCommand(Clip* c, Clip* s, Transition *copy, const EffectMeta* itransition, int itype, int ilength);
void undo();
void redo();
private:
Clip* clip;
Clip* secondary;
Transition* transition_to_copy;
Clip* clip;
Clip* secondary;
Transition* transition_to_copy;
const EffectMeta* transition;
int type;
int length;
int type;
int length;
bool old_project_changed;
int old_ptransition;
int old_stransition;
int old_ptransition;
int old_stransition;
};
class ModifyTransitionCommand : public QUndoCommand {
public:
ModifyTransitionCommand(Clip* c, int itype, long ilength);
void undo();
void redo();
ModifyTransitionCommand(Clip* c, int itype, long ilength);
void undo();
void redo();
private:
Clip* clip;
int type;
long new_length;
long old_length;
Clip* clip;
int type;
long new_length;
long old_length;
bool old_project_changed;
};
class DeleteTransitionCommand : public QUndoCommand {
public:
DeleteTransitionCommand(Sequence* s, int transition_index);
~DeleteTransitionCommand();
void undo();
void redo();
DeleteTransitionCommand(Sequence* s, int transition_index);
~DeleteTransitionCommand();
void undo();
void redo();
private:
Sequence* seq;
int index;
Transition* transition;
Clip* otc;
Clip* ctc;
Sequence* seq;
int index;
Transition* transition;
Clip* otc;
Clip* ctc;
bool old_project_changed;
};
class SetTimelineInOutCommand : public QUndoCommand {
public:
SetTimelineInOutCommand(Sequence* s, bool enabled, long in, long out);
void undo();
void redo();
SetTimelineInOutCommand(Sequence* s, bool enabled, long in, long out);
void undo();
void redo();
private:
Sequence* seq;
Sequence* 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;
bool old_project_changed;
};
class NewSequenceCommand : public QUndoCommand {
public:
NewSequenceCommand(Media *s, Media* iparent);
~NewSequenceCommand();
void undo();
void redo();
NewSequenceCommand(Media *s, Media* iparent);
~NewSequenceCommand();
void undo();
void redo();
private:
Media* seq;
Media* parent;
bool done;
Media* seq;
Media* parent;
bool done;
bool old_project_changed;
};
class AddMediaCommand : public QUndoCommand {
public:
AddMediaCommand(Media* iitem, Media* iparent);
~AddMediaCommand();
void undo();
void redo();
AddMediaCommand(Media* iitem, Media* iparent);
~AddMediaCommand();
void undo();
void redo();
private:
Media* item;
Media* parent;
bool done;
Media* item;
Media* parent;
bool done;
bool old_project_changed;
};
class DeleteMediaCommand : public QUndoCommand {
public:
DeleteMediaCommand(Media *i);
~DeleteMediaCommand();
void undo();
void redo();
DeleteMediaCommand(Media *i);
~DeleteMediaCommand();
void undo();
void redo();
private:
Media* item;
Media* parent;
Media* item;
Media* parent;
bool old_project_changed;
bool done;
};
class RippleCommand : public QUndoCommand {
public:
RippleCommand(Sequence* s, long ipoint, long ilength);
QVector<Clip*> ignore;
void undo();
void redo();
private:
Sequence* seq;
long point;
long length;
QVector<Clip*> rippled;
bool old_project_changed;
};
class AddClipCommand : public QUndoCommand {
public:
AddClipCommand(Sequence* s, QVector<Clip*>& add);
~AddClipCommand();
void undo();
void redo();
AddClipCommand(Sequence* s, QVector<Clip*>& add);
~AddClipCommand();
void undo();
void redo();
private:
Sequence* seq;
QVector<Clip*> clips;
Sequence* seq;
QVector<Clip*> clips;
QVector<Clip*> undone_clips;
bool old_project_changed;
};
class LinkCommand : public QUndoCommand {
public:
LinkCommand();
void undo();
LinkCommand();
void undo();
void redo();
Sequence* s;
QVector<int> clips;
bool link;
bool link;
private:
QVector< QVector<int> > old_links;
QVector< QVector<int> > old_links;
bool old_project_changed;
};
class CheckboxCommand : public QUndoCommand {
public:
CheckboxCommand(QCheckBox* b);
~CheckboxCommand();
void undo();
void redo();
CheckboxCommand(QCheckBox* b);
~CheckboxCommand();
void undo();
void redo();
private:
QCheckBox* box;
bool checked;
bool done;
QCheckBox* box;
bool checked;
bool done;
bool old_project_changed;
};
class ReplaceMediaCommand : public QUndoCommand {
public:
ReplaceMediaCommand(Media*, QString);
ReplaceMediaCommand(Media*, QString);
void undo();
void redo();
private:
Media *item;
Media *item;
QString old_filename;
QString new_filename;
bool old_project_changed;
bool old_project_changed;
void replace(QString& filename);
};
class ReplaceClipMediaCommand : public QUndoCommand {
public:
ReplaceClipMediaCommand(Media *, Media *, bool);
ReplaceClipMediaCommand(Media *, Media *, bool);
void undo();
void redo();
QVector<Clip*> clips;
private:
Media* old_media;
Media* new_media;
Media* old_media;
Media* new_media;
bool preserve_clip_ins;
bool old_project_changed;
QVector<int> old_clip_ins;
@@ -302,26 +306,26 @@ private:
class MediaMove : public QUndoCommand {
public:
MediaMove();
QVector<Media*> items;
Media* to;
MediaMove();
QVector<Media*> items;
Media* to;
void undo();
void redo();
private:
QVector<Media*> froms;
QVector<Media*> froms;
bool old_project_changed;
};
class MediaRename : public QUndoCommand {
public:
MediaRename(Media* iitem, QString to);
void undo();
void redo();
MediaRename(Media* iitem, QString to);
void undo();
void redo();
private:
bool old_project_changed;
Media* item;
QString from;
QString to;
bool old_project_changed;
Media* item;
QString from;
QString to;
};
class KeyframeMove : public QUndoCommand {
@@ -386,9 +390,9 @@ private:
class SetAutoscaleAction : public QUndoCommand {
public:
SetAutoscaleAction();
void undo();
void redo();
QVector<Clip*> clips;
void undo();
void redo();
QVector<Clip*> clips;
private:
bool old_project_changed;
};
@@ -458,14 +462,14 @@ private:
class SetSelectionsCommand : public QUndoCommand {
public:
SetSelectionsCommand(Sequence *s);
void undo();
void redo();
QVector<Selection> old_data;
QVector<Selection> new_data;
SetSelectionsCommand(Sequence *s);
void undo();
void redo();
QVector<Selection> old_data;
QVector<Selection> new_data;
private:
Sequence* seq;
bool done;
Sequence* seq;
bool done;
bool old_project_changed;
};
@@ -483,7 +487,7 @@ private:
class EditSequenceCommand : public QUndoCommand {
public:
EditSequenceCommand(Media *i, Sequence* s);
EditSequenceCommand(Media *i, Sequence* s);
void undo();
void redo();
void update();
@@ -495,7 +499,7 @@ public:
int audio_frequency;
int audio_layout;
private:
Media* item;
Media* item;
Sequence* seq;
bool old_project_changed;
@@ -509,25 +513,25 @@ private:
class SetInt : public QUndoCommand {
public:
SetInt(int* pointer, int new_value);
void undo();
void redo();
SetInt(int* pointer, int new_value);
void undo();
void redo();
private:
int* p;
int oldval;
int newval;
int* p;
int oldval;
int newval;
bool old_project_changed;
};
class SetString : public QUndoCommand {
public:
SetString(QString* pointer, QString new_value);
void undo();
void redo();
SetString(QString* pointer, QString new_value);
void undo();
void redo();
private:
QString* p;
QString oldval;
QString newval;
QString* p;
QString oldval;
QString newval;
bool old_project_changed;
};
@@ -539,11 +543,11 @@ public:
class UpdateFootageTooltip : public QUndoCommand {
public:
UpdateFootageTooltip(Media* i);
UpdateFootageTooltip(Media* i);
void undo();
void redo();
private:
Media* item;
Media* item;
};
class MoveEffectCommand : public QUndoCommand {
@@ -585,20 +589,20 @@ private:
class SetPointer : public QUndoCommand {
public:
SetPointer(void** pointer, void* data);
void undo();
void redo();
SetPointer(void** pointer, void* data);
void undo();
void redo();
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 QUndoCommand {
public:
void undo();
void redo();
void undo();
void redo();
};
#endif // UNDO_H