separated effect from UI

This commit is contained in:
itsmattkc
2019-03-12 22:49:01 +11:00
parent 0b090ddc21
commit 5b03af5e5a
58 changed files with 1166 additions and 1071 deletions
+19 -9
View File
@@ -38,7 +38,7 @@
const int kRGBAComponentCount = 4;
Clip::Clip(SequencePtr s) :
Clip::Clip(Sequence* s) :
sequence(s),
cacher(this)
{
@@ -62,7 +62,7 @@ Clip::Clip(SequencePtr s) :
reset();
}
ClipPtr Clip::copy(SequencePtr s) {
ClipPtr Clip::copy(Sequence* s) {
ClipPtr copy = std::make_shared<Clip>(s);
copy->set_enabled(enabled());
@@ -197,7 +197,7 @@ void Clip::reset_audio() {
cacher.ResetAudio();
}
if (media() != nullptr && media()->get_type() == MEDIA_TYPE_SEQUENCE) {
SequencePtr nested_sequence = media()->to_sequence();
Sequence* 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();
@@ -208,7 +208,7 @@ void Clip::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();
Footage* m = media()->to_footage();
if (track() < 0 && m->video_tracks.size() > 0) {
set_media(media(), m->video_tracks.at(0).file_index);
@@ -231,6 +231,16 @@ QVector<Marker> &Clip::get_markers() {
return markers;
}
int Clip::IndexOfEffect(Effect *e)
{
for (int i=0;i<effects.size();i++) {
if (effects.at(i).get() == e) {
return i;
}
}
return -1;
}
Clip::~Clip() {
if (IsOpen()) {
Close(true);
@@ -371,7 +381,7 @@ long Clip::media_length() {
switch (media_->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootagePtr m = media_->to_footage();
Footage* m = media_->to_footage();
const FootageStream* ms = m->get_stream_from_file_index(track_ < 0, media_stream_index());
if (ms != nullptr && ms->infinite_length) {
return LONG_MAX;
@@ -381,7 +391,7 @@ long Clip::media_length() {
}
case MEDIA_TYPE_SEQUENCE:
{
SequencePtr s = media_->to_sequence();
Sequence* s = media_->to_sequence();
return rescale_frame_number(s->getEndFrame(), s->frame_rate, fr);
}
}
@@ -402,7 +412,7 @@ int Clip::media_width() {
}
case MEDIA_TYPE_SEQUENCE:
{
SequencePtr s = media_->to_sequence();
Sequence* s = media_->to_sequence();
return s->width;
}
}
@@ -421,7 +431,7 @@ int Clip::media_height() {
break;
case MEDIA_TYPE_SEQUENCE:
{
SequencePtr s = media_->to_sequence();
Sequence* s = media_->to_sequence();
return s->height;
}
}
@@ -575,7 +585,7 @@ bool Clip::Retrieve()
for (int i=0;i<effects.size();i++) {
Effect* e = effects.at(i).get();
if ((e->Flags() & Effect::ImageFlag) && e->is_enabled()) {
if ((e->Flags() & Effect::ImageFlag) && e->IsEnabled()) {
if (data_buffer_1 == frame->data[0]) {
data_buffer_1 = new uint8_t[frame_size];
data_buffer_2 = new uint8_t[frame_size];
+5 -5
View File
@@ -51,13 +51,12 @@ struct ClipSpeed {
using ClipPtr = std::shared_ptr<Clip>;
class Sequence;
using SequencePtr = std::shared_ptr<Sequence>;
class Clip : public std::enable_shared_from_this<Clip> {
class Clip {
public:
Clip(SequencePtr s);
Clip(Sequence *s);
~Clip();
ClipPtr copy(SequencePtr s);
ClipPtr copy(Sequence *s);
bool IsActiveAt(long timecode);
@@ -121,12 +120,13 @@ public:
long length();
void refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points);
SequencePtr sequence;
Sequence* sequence;
// markers
QVector<Marker>& get_markers();
// other variables (should be deep copied/duplicated in copy())
int IndexOfEffect(Effect* e);
QList<EffectPtr> effects;
QVector<int> linked;
TransitionPtr opening_transition;
+65 -123
View File
@@ -73,32 +73,32 @@ EffectPtr Effect::Create(Clip* c, const EffectMeta* em) {
if (em->internal >= 0 && em->internal < EFFECT_INTERNAL_COUNT) {
// must be an internal effect
switch (em->internal) {
case EFFECT_INTERNAL_TRANSFORM: return std::make_shared<TransformEffect>(c, em);
case EFFECT_INTERNAL_TEXT: return std::make_shared<TextEffect>(c, em);
case EFFECT_INTERNAL_TIMECODE: return std::make_shared<TimecodeEffect>(c, em);
case EFFECT_INTERNAL_SOLID: return std::make_shared<SolidEffect>(c, em);
case EFFECT_INTERNAL_NOISE: return std::make_shared<AudioNoiseEffect>(c, em);
case EFFECT_INTERNAL_VOLUME: return std::make_shared<VolumeEffect>(c, em);
case EFFECT_INTERNAL_PAN: return std::make_shared<PanEffect>(c, em);
case EFFECT_INTERNAL_TONE: return std::make_shared<ToneEffect>(c, em);
case EFFECT_INTERNAL_SHAKE: return std::make_shared<ShakeEffect>(c, em);
case EFFECT_INTERNAL_CORNERPIN: return std::make_shared<CornerPinEffect>(c, em);
case EFFECT_INTERNAL_FILLLEFTRIGHT: return std::make_shared<FillLeftRightEffect>(c, em);
case EFFECT_INTERNAL_TRANSFORM: return std::make_shared<TransformEffect>(c, em);
case EFFECT_INTERNAL_TEXT: return std::make_shared<TextEffect>(c, em);
case EFFECT_INTERNAL_TIMECODE: return std::make_shared<TimecodeEffect>(c, em);
case EFFECT_INTERNAL_SOLID: return std::make_shared<SolidEffect>(c, em);
case EFFECT_INTERNAL_NOISE: return std::make_shared<AudioNoiseEffect>(c, em);
case EFFECT_INTERNAL_VOLUME: return std::make_shared<VolumeEffect>(c, em);
case EFFECT_INTERNAL_PAN: return std::make_shared<PanEffect>(c, em);
case EFFECT_INTERNAL_TONE: return std::make_shared<ToneEffect>(c, em);
case EFFECT_INTERNAL_SHAKE: return std::make_shared<ShakeEffect>(c, em);
case EFFECT_INTERNAL_CORNERPIN: return std::make_shared<CornerPinEffect>(c, em);
case EFFECT_INTERNAL_FILLLEFTRIGHT: return std::make_shared<FillLeftRightEffect>(c, em);
#ifndef NOVST
case EFFECT_INTERNAL_VST: return std::make_shared<VSTHost>(c, em);
case EFFECT_INTERNAL_VST: return std::make_shared<VSTHost>(c, em);
#endif
#ifndef NOFREI0R
case EFFECT_INTERNAL_FREI0R: return std::make_shared<Frei0rEffect>(c, em);
case EFFECT_INTERNAL_FREI0R: return std::make_shared<Frei0rEffect>(c, em);
#endif
}
} else if (!em->filename.isEmpty()) {
// load effect from file
return std::make_shared<Effect>(c, em);
return std::make_shared<Effect>(c, em);
} else {
qCritical() << "Invalid effect data";
QMessageBox::critical(olive::MainWindow,
QCoreApplication::translate("Effect", "Invalid effect"),
QCoreApplication::translate("Effect", "No candidate for effect '%1'. This effect may be corrupt. Try reinstalling it or Olive.").arg(em->name));
QMessageBox::critical(olive::MainWindow,
QCoreApplication::translate("Effect", "Invalid effect"),
QCoreApplication::translate("Effect", "No candidate for effect '%1'. This effect may be corrupt. Try reinstalling it or Olive.").arg(em->name));
}
return nullptr;
}
@@ -123,19 +123,9 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
bound(false),
iterations(1)
{
// set up base UI
container = new CollapsibleWidget();
connect(container->enabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed()));
ui = new QWidget(container);
ui_layout = new QGridLayout(ui);
ui_layout->setSpacing(4);
container->setContents(ui);
connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&)));
if (em != nullptr) {
// set up UI from effect file
container->setText(em->name);
name = em->name;
if (!em->filename.isEmpty() && em->internal == -1) {
QFile effect_file(em->filename);
@@ -353,12 +343,12 @@ Effect::~Effect() {
if (isOpen) {
close();
}
}
delete container;
for (int i=0;i<gizmos.size();i++) {
delete gizmos.at(i);
}
void Effect::AddRow(EffectRow *row)
{
row->setParent(this);
rows.append(row);
}
void Effect::copy_field_keyframes(EffectPtr e) {
@@ -388,7 +378,7 @@ int Effect::row_count() {
}
EffectGizmo *Effect::add_gizmo(int type) {
EffectGizmo* gizmo = new EffectGizmo(type);
EffectGizmo* gizmo = new EffectGizmo(this, type);
gizmos.append(gizmo);
return gizmo;
}
@@ -408,83 +398,45 @@ void Effect::field_changed() {
panel_graph_editor->update_panel();
}
void Effect::show_context_menu(const QPoint& pos) {
if (meta->type == EFFECT_TYPE_EFFECT) {
QMenu menu(olive::MainWindow);
int index = get_index_in_clip();
menu.addAction(tr("Cu&t"), panel_effect_controls, SLOT(cut()));
menu.addAction(tr("&Copy"), panel_effect_controls, SLOT(copy(bool)));
panel_effect_controls->add_effect_paste_action(&menu);
menu.addSeparator();
if (index > 0) {
menu.addAction(tr("Move &Up"), this, SLOT(move_up()));
}
if (index < parent_clip->effects.size() - 1) {
menu.addAction(tr("Move &Down"), this, SLOT(move_down()));
}
menu.addSeparator();
menu.addAction(tr("D&elete"), this, SLOT(delete_self()));
menu.addSeparator();
menu.addAction(tr("Load Settings From File"), this, SLOT(load_from_file()));
menu.addAction(tr("Save Settings to File"), this, SLOT(save_to_file()));
menu.exec(container->title_bar->mapToGlobal(pos));
}
}
void Effect::delete_self() {
EffectDeleteCommand* command = new EffectDeleteCommand();
command->clips.append(parent_clip);
command->fx.append(get_index_in_clip());
olive::UndoStack.push(command);
olive::UndoStack.push(new EffectDeleteCommand(this));
update_ui(true);
}
void Effect::move_up() {
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = get_index_in_clip();
command->from = parent_clip->IndexOfEffect(this);
command->to = command->from - 1;
olive::UndoStack.push(command);
panel_effect_controls->reload_clips();
panel_effect_controls->Reload();
panel_sequence_viewer->viewer_widget->frame_update();
}
void Effect::move_down() {
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = get_index_in_clip();
command->from = parent_clip->IndexOfEffect(this);
command->to = command->from + 1;
olive::UndoStack.push(command);
panel_effect_controls->reload_clips();
panel_effect_controls->Reload();
panel_sequence_viewer->viewer_widget->frame_update();
}
void Effect::save_to_file() {
// save effect settings to file
QString file = QFileDialog::getSaveFileName(olive::MainWindow,
tr("Save Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
QString file = QFileDialog::getSaveFileName(olive::MainWindow,
tr("Save Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
// if the user picked a file
if (!file.isEmpty()) {
// ensure file ends with .xml extension
if (!file.endsWith(".xml", Qt::CaseInsensitive)) {
file.append(".xml");
}
// ensure file ends with .xml extension
if (!file.endsWith(".xml", Qt::CaseInsensitive)) {
file.append(".xml");
}
QFile file_handle(file);
if (file_handle.open(QFile::WriteOnly)) {
@@ -493,36 +445,36 @@ void Effect::save_to_file() {
file_handle.close();
} else {
QMessageBox::critical(olive::MainWindow,
tr("Save Settings Failed"),
tr("Failed to open \"%1\" for writing.").arg(file),
QMessageBox::Ok);
QMessageBox::critical(olive::MainWindow,
tr("Save Settings Failed"),
tr("Failed to open \"%1\" for writing.").arg(file),
QMessageBox::Ok);
}
}
}
void Effect::load_from_file() {
// load effect settings from file
QString file = QFileDialog::getOpenFileName(olive::MainWindow,
tr("Load Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
QString file = QFileDialog::getOpenFileName(olive::MainWindow,
tr("Load Effect Settings"),
QString(),
tr("Effect XML Settings %1").arg("(*.xml)"));
// if the user picked a file
if (!file.isEmpty()) {
QFile file_handle(file);
if (file_handle.open(QFile::ReadOnly)) {
olive::UndoStack.push(new SetEffectData(EffectPtr(this), file_handle.readAll()));
olive::UndoStack.push(new SetEffectData(EffectPtr(this), file_handle.readAll()));
file_handle.close();
update_ui(false);
} else {
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("Failed to open \"%1\" for reading.").arg(file),
QMessageBox::Ok);
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("Failed to open \"%1\" for reading.").arg(file),
QMessageBox::Ok);
}
}
}
@@ -537,23 +489,13 @@ void Effect::SetAlwaysUpdate(bool b)
enable_always_update_ = b;
}
int Effect::get_index_in_clip() {
if (parent_clip != nullptr) {
for (int i=0;i<parent_clip->effects.size();i++) {
if (parent_clip->effects.at(i).get() == this) {
return i;
}
}
}
return -1;
bool Effect::IsEnabled() {
return enabled_;
}
bool Effect::is_enabled() {
return container->enabled_check->isChecked();
}
void Effect::set_enabled(bool b) {
container->enabled_check->setChecked(b);
void Effect::SetEnabled(bool b) {
enabled_ = b;
emit EnabledChanged(b);
}
void Effect::load(QXmlStreamReader& stream) {
@@ -649,7 +591,7 @@ void Effect::custom_load(QXmlStreamReader &) {}
void Effect::save(QXmlStreamWriter& stream) {
stream.writeAttribute("name", meta->category + "/" + meta->name);
stream.writeAttribute("enabled", QString::number(is_enabled()));
stream.writeAttribute("enabled", QString::number(IsEnabled()));
for (int i=0;i<rows.size();i++) {
EffectRow* row = rows.at(i);
@@ -710,10 +652,10 @@ void Effect::load_from_string(const QByteArray &s) {
// pass off to standard loading function
load(stream);
} else {
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("This settings file doesn't match this effect."),
QMessageBox::Ok);
QMessageBox::critical(olive::MainWindow,
tr("Load Settings Failed"),
tr("This settings file doesn't match this effect."),
QMessageBox::Ok);
}
break;
}
@@ -862,8 +804,8 @@ void Effect::setIterations(int i) {
void Effect::process_image(double, uint8_t *, uint8_t *, int){}
EffectPtr Effect::copy(Clip *c) {
EffectPtr copy = Effect::Create(c, meta);
copy->set_enabled(is_enabled());
EffectPtr copy = Effect::Create(c, meta);
copy->SetEnabled(IsEnabled());
copy_field_keyframes(copy);
return copy;
}
@@ -894,7 +836,7 @@ void Effect::process_shader(double timecode, GLTextureCoords&, int iteration) {
GLfloat(color_field->GetColorAt(timecode).redF()),
GLfloat(color_field->GetColorAt(timecode).greenF()),
GLfloat(color_field->GetColorAt(timecode).blueF())
);
);
}
break;
case EffectField::EFFECT_FIELD_BOOL:
@@ -904,7 +846,7 @@ void Effect::process_shader(double timecode, GLTextureCoords&, int iteration) {
glslProgram->setUniformValue(field->id().toUtf8().constData(), field->GetValueAt(timecode).toInt());
break;
// can you even send a string to a uniform value?
// can you even send a string to a uniform value?
case EffectField::EFFECT_FIELD_STRING:
case EffectField::EFFECT_FIELD_FONT:
case EffectField::EFFECT_FIELD_FILE:
@@ -1105,7 +1047,7 @@ const EffectMeta* get_meta_from_name(const QString& input) {
for (int j=0;j<effects.size();j++) {
if (effects.at(j).name == name
&& (effects.at(j).category == category
|| category.isEmpty())) {
|| category.isEmpty())) {
return &effects.at(j);
}
}
+9 -17
View File
@@ -139,11 +139,13 @@ class Effect : public QObject {
public:
Effect(Clip *c, const EffectMeta* em);
~Effect();
Clip* parent_clip;
const EffectMeta* meta;
int id;
QString name;
CollapsibleWidget* container;
void AddRow(EffectRow* row);
EffectRow* row(int i);
int row_count();
@@ -152,8 +154,8 @@ public:
EffectGizmo* gizmo(int i);
int gizmo_count();
bool is_enabled();
void set_enabled(bool b);
bool IsEnabled();
void SetEnabled(bool b);
virtual void refresh();
@@ -213,8 +215,9 @@ public:
static const EffectMeta* GetInternalMeta(int internal_id, int type);
public slots:
void field_changed();
signals:
void EnabledChanged(bool);
private slots:
void show_context_menu(const QPoint&);
void delete_self();
void move_up();
void move_down();
@@ -234,17 +237,14 @@ protected:
void SetAlwaysUpdate(bool b);
private:
// superimpose effect
QString script;
bool isOpen;
QVector<EffectRow*> rows;
QVector<EffectGizmo*> gizmos;
QGridLayout* ui_layout;
QWidget* ui;
bool bound;
int iterations;
bool enabled_;
int flags_;
// enable effect to update constantly
@@ -255,15 +255,7 @@ private:
bool valueHasChanged(double timecode);
QVector<QVariant> cachedValues;
void delete_texture();
int get_index_in_clip();
void validate_meta_path();
};
class EffectInit : public QThread {
public:
EffectInit();
protected:
void run();
};
#endif // EFFECT_H
+5
View File
@@ -54,6 +54,11 @@ QString DoubleField::ConvertValueToString(const QVariant &v)
return QString::number(v.toDouble());
}
//QWidget *DoubleField::CreateWidget()
//{
//}
void DoubleField::ValueHasBeenSet()
{
value_set_ = true;
+2
View File
@@ -34,6 +34,8 @@ public:
virtual QVariant ConvertStringToValue(const QString& s);
virtual QString ConvertValueToString(const QVariant& v);
//virtual QWidget* CreateWidget() override;
private:
double min_;
double max_;
+5
View File
@@ -151,6 +151,11 @@ QString EffectField::ConvertValueToString(const QVariant &v)
return v.toString();
}
QWidget *EffectField::CreateWidget()
{
return new QLabel(tr("(Invalid field)"));
}
QVariant EffectField::GetValueAt(double timecode)
{
Q_ASSERT(!keyframes.isEmpty());
+2
View File
@@ -61,6 +61,8 @@ public:
virtual QVariant ConvertStringToValue(const QString& s);
virtual QString ConvertValueToString(const QVariant& v);
virtual QWidget* CreateWidget();
double GetValidKeyframeHandlePosition(int key, bool post);
bool IsEnabled();
+3 -1
View File
@@ -22,8 +22,10 @@
#include "ui/labelslider.h"
#include "effectfields/doublefield.h"
#include "project/effect.h"
EffectGizmo::EffectGizmo(int type) :
EffectGizmo::EffectGizmo(Effect *parent, int type) :
QObject(parent),
x_field1(nullptr),
x_field_multi1(1.0),
y_field1(nullptr),
+5 -3
View File
@@ -30,6 +30,7 @@ enum GizmoType {
#define GIZMO_DOT_SIZE 2.5
#define GIZMO_TARGET_SIZE 5.0
#include <QObject>
#include <QString>
#include <QRect>
#include <QPoint>
@@ -37,11 +38,12 @@ enum GizmoType {
#include <QColor>
class DoubleField;
class Effect;
class EffectGizmo
{
class EffectGizmo : public QObject {
Q_OBJECT
public:
EffectGizmo(int type);
EffectGizmo(Effect* parent, int type);
QVector<QPoint> world_pos;
QVector<QPoint> screen_pos;
+8
View File
@@ -22,7 +22,15 @@
#define EFFECTLOADERS_H
#include <QList>
#include <QThread>
void init_effects();
class EffectInit : public QThread {
public:
EffectInit();
protected:
void run();
};
#endif // EFFECTLOADERS_H
+2
View File
@@ -44,6 +44,8 @@ EffectRow::EffectRow(Effect *parent, const QString &n, bool savable, bool keyfra
savable_(savable)
{
Q_ASSERT(parent != nullptr);
parent->AddRow(this);
}
void EffectRow::AddField(EffectField *field)
+62 -62
View File
@@ -32,96 +32,96 @@
#include <QCoreApplication>
void draw_marker(QPainter &p, int x, int y, int bottom, bool selected) {
const QPoint points[5] = {
QPoint(x, bottom),
QPoint(x + MARKER_SIZE, bottom - MARKER_SIZE),
QPoint(x + MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, bottom - MARKER_SIZE)
};
p.setPen(Qt::black);
if (selected) {
p.setBrush(QColor(208, 255, 208));
} else {
p.setBrush(QColor(128, 224, 128));
}
p.drawPolygon(points, 5);
const QPoint points[5] = {
QPoint(x, bottom),
QPoint(x + MARKER_SIZE, bottom - MARKER_SIZE),
QPoint(x + MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, y),
QPoint(x - MARKER_SIZE, bottom - MARKER_SIZE)
};
p.setPen(Qt::black);
if (selected) {
p.setBrush(QColor(208, 255, 208));
} else {
p.setBrush(QColor(128, 224, 128));
}
p.drawPolygon(points, 5);
}
void set_marker_internal(SequencePtr seq, const QVector<int>& clips) {
// if clips is empty, the marker is being added to the sequence
void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
// if clips is empty, the marker is being added to the sequence
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
bool add_marker = !olive::CurrentConfig.set_name_with_marker;
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
bool add_marker = !olive::CurrentConfig.set_name_with_marker;
QString marker_name;
QString marker_name;
// if (config.set_name_with_marker) is false (set above), ask for a marker name
if (!add_marker) {
// if (config.set_name_with_marker) is false (set above), ask for a marker name
if (!add_marker) {
QInputDialog d(olive::MainWindow);
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
d.setLabelText(clips.size() > 0
? QCoreApplication::translate("Marker", "Set clip marker name:")
: QCoreApplication::translate("Marker", "Set sequence marker name:"));
d.setInputMode(QInputDialog::TextInput);
add_marker = (d.exec() == QDialog::Accepted);
marker_name = d.textValue();
}
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
d.setLabelText(clips.size() > 0
? QCoreApplication::translate("Marker", "Set clip marker name:")
: QCoreApplication::translate("Marker", "Set sequence marker name:"));
d.setInputMode(QInputDialog::TextInput);
add_marker = (d.exec() == QDialog::Accepted);
marker_name = d.textValue();
}
// if we've decided to add a marker
if (add_marker) {
// if we've decided to add a marker
if (add_marker) {
ComboAction* ca = new ComboAction();
ComboAction* ca = new ComboAction();
if (clips.size() > 0) {
if (clips.size() > 0) {
// add a marker action for each clip
foreach (int i, clips) {
// add a marker action for each clip
foreach (int i, clips) {
ClipPtr c = seq->clips.at(i);
ca->append(new AddMarkerAction(&c->get_markers(),
ca->append(new AddMarkerAction(&c->get_markers(),
seq->playhead - c->timeline_in() + c->clip_in(),
marker_name));
}
marker_name));
}
} else {
} else {
// if no clips are selected, we're adding a marker to the sequence
// if no clips are selected, we're adding a marker to the sequence
// kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is attached to
if (seq == panel_footage_viewer->seq) {
// kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is attached to
if (seq == panel_footage_viewer->seq.get()) {
// get correct marker reference from footage viewer
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
// get correct marker reference from footage viewer
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
} else if (seq == panel_sequence_viewer->seq) {
} else if (seq == panel_sequence_viewer->seq.get()) {
// get correct marker reference from sequence viewer
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
// get correct marker reference from sequence viewer
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
} else {
} else {
// fallback to using markers from sequence provided
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
// fallback to using markers from sequence provided
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
}
}
}
}
// push action
// push action
olive::UndoStack.push(ca);
// redraw UI for new markers
update_ui(false);
panel_footage_viewer->update_viewer();
// redraw UI for new markers
update_ui(false);
panel_footage_viewer->update_viewer();
}
}
}
void set_marker_internal(SequencePtr seq) {
// create empty clip array
QVector<int> clips;
void set_marker_internal(Sequence *seq) {
// create empty clip array
QVector<int> clips;
set_marker_internal(seq, clips);
set_marker_internal(seq, clips);
}
+2 -2
View File
@@ -37,7 +37,7 @@ struct Marker {
void draw_marker(QPainter& p, int x, int y, int bottom, bool selected);
void set_marker_internal(SequencePtr seq, const QVector<int>& clips);
void set_marker_internal(SequencePtr seq);
void set_marker_internal(Sequence *seq, const QVector<int>& clips);
void set_marker_internal(Sequence* seq);
#endif // MARKER_H
+15 -13
View File
@@ -73,12 +73,12 @@ Media::~Media() {
}
}
FootagePtr Media::to_footage() {
return std::static_pointer_cast<Footage>(object);
Footage* Media::to_footage() {
return static_cast<Footage*>(object.get());
}
SequencePtr Media::to_sequence() {
return std::static_pointer_cast<Sequence>(object);
Sequence* Media::to_sequence() {
return static_cast<Sequence*>(object.get());
}
void Media::set_footage(FootagePtr f) {
@@ -90,7 +90,9 @@ void Media::set_sequence(SequencePtr s) {
set_icon(olive::icon::MediaSequence);
type = MEDIA_TYPE_SEQUENCE;
object = VoidPtr(s);
if (s != nullptr) update_tooltip();
if (s != nullptr) {
update_tooltip();
}
}
void Media::set_folder() {
@@ -119,7 +121,7 @@ void Media::update_tooltip(const QString& error) {
switch (type) {
case MEDIA_TYPE_FOOTAGE:
{
FootagePtr f = to_footage();
Footage* f = to_footage();
tooltip = QCoreApplication::translate("Media", "Name:") + " " + f->name + "\n" + QCoreApplication::translate("Media", "Filename:") + " " + f->url + "\n";
if (error.isEmpty()) {
@@ -190,7 +192,7 @@ void Media::update_tooltip(const QString& error) {
break;
case MEDIA_TYPE_SEQUENCE:
{
SequencePtr s = to_sequence();
Sequence* s = to_sequence();
tooltip = QCoreApplication::translate("Media", "Name: %1"
"\nVideo Dimensions: %2x%3"
@@ -238,7 +240,7 @@ double Media::get_frame_rate(int stream) {
switch (get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootagePtr f = to_footage();
Footage* f = to_footage();
if (stream < 0) return f->video_tracks.at(0).video_frame_rate * f->speed;
return f->get_stream_from_file_index(true, stream)->video_frame_rate * f->speed;
}
@@ -251,7 +253,7 @@ int Media::get_sampling_rate(int stream) {
switch (get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
FootagePtr f = to_footage();
Footage* f = to_footage();
if (stream < 0) return f->audio_tracks.at(0).audio_frequency * f->speed;
return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency * f->speed;
}
@@ -293,7 +295,7 @@ QVariant Media::data(int column, int role) {
case Qt::DecorationRole:
if (column == 0) {
if (get_type() == MEDIA_TYPE_FOOTAGE) {
FootagePtr f = to_footage();
Footage* f = to_footage();
if (f->video_tracks.size() > 0
&& f->video_tracks.at(0).preview_done) {
return f->video_tracks.at(0).video_preview_square;
@@ -309,11 +311,11 @@ QVariant Media::data(int column, int role) {
case 1:
if (root) return QCoreApplication::translate("Media", "Duration");
if (get_type() == MEDIA_TYPE_SEQUENCE) {
SequencePtr s = to_sequence();
Sequence* s = to_sequence();
return frame_to_timecode(s->getEndFrame(), olive::CurrentConfig.timecode_view, s->frame_rate);
}
if (get_type() == MEDIA_TYPE_FOOTAGE) {
FootagePtr f = to_footage();
Footage* f = to_footage();
double r = 30;
if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0).video_frame_rate))
@@ -327,7 +329,7 @@ QVariant Media::data(int column, int role) {
if (root) return QCoreApplication::translate("Media", "Rate");
if (get_type() == MEDIA_TYPE_SEQUENCE) return QString::number(get_frame_rate()) + " FPS";
if (get_type() == MEDIA_TYPE_FOOTAGE) {
FootagePtr f = to_footage();
Footage* f = to_footage();
double r;
if (f->video_tracks.size() > 0 && !qIsNull(r = get_frame_rate())) {
return QString::number(get_frame_rate()) + " FPS";
+2 -2
View File
@@ -44,8 +44,8 @@ class Media
public:
Media(Media* iparent);
~Media();
FootagePtr to_footage();
SequencePtr to_sequence();
Footage *to_footage();
Sequence *to_sequence();
void set_icon(const QString& str);
void set_icon(const QIcon &ico);
void set_footage(FootagePtr f);
+6 -4
View File
@@ -22,6 +22,8 @@
#include <QCoreApplication>
#include "panels/panels.h"
#include "debug.h"
Sequence::Sequence() {
@@ -35,7 +37,7 @@ Sequence::Sequence() {
Sequence::~Sequence() {}
SequencePtr Sequence::copy() {
SequencePtr s(new Sequence());
SequencePtr s = std::make_shared<Sequence>();
s->name = QCoreApplication::translate("Sequence", "%1 (copy)").arg(name);
s->width = width;
s->height = height;
@@ -50,7 +52,7 @@ SequencePtr Sequence::copy() {
if (c == nullptr) {
s->clips[i] = nullptr;
} else {
ClipPtr copy = c->copy(s);
ClipPtr copy = c->copy(s.get());
copy->linked = c->linked;
s->clips[i] = copy;
}
@@ -137,7 +139,7 @@ Effect *Sequence::GetSelectedGizmo()
if (gizmo_ptr == nullptr) {
gizmo_ptr = e;
}
if (e->container->selected) {
if (panel_effect_controls->IsEffectSelected(e)) {
gizmo_ptr = e;
break;
}
@@ -190,4 +192,4 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) {
}
// static variable for the currently active sequence
SequencePtr olive::ActiveSequence = nullptr;
Sequence* olive::ActiveSequence = nullptr;
+1 -1
View File
@@ -71,7 +71,7 @@ using SequencePtr = std::shared_ptr<Sequence>;
// static variable for the currently active sequence
namespace olive {
extern SequencePtr ActiveSequence;
extern Sequence* ActiveSequence;
}
#endif // SEQUENCE_H
+4 -4
View File
@@ -65,8 +65,8 @@ void SourcesCommon::create_seq_from_selected() {
SequencePtr 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);
panel_timeline->create_ghosts_from_media(s.get(), 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s.get());
project_parent->create_sequence_internal(ca, s, true, nullptr);
olive::UndoStack.push(ca);
@@ -342,7 +342,7 @@ void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIn
void SourcesCommon::reveal_in_browser() {
Media* media = project_parent->item_to_media(selected_items.at(0));
FootagePtr m = media->to_footage();
Footage* m = media->to_footage();
#if defined(Q_OS_WIN)
QStringList args;
@@ -405,7 +405,7 @@ void SourcesCommon::clear_proxies_from_selected() {
QList<QString> delete_list;
for (int i=0;i<cached_selected_footage.size();i++) {
FootagePtr f = cached_selected_footage.at(i)->to_footage();
Footage* f = cached_selected_footage.at(i)->to_footage();
if (f->proxy && !f->proxy_path.isEmpty()) {
if (QFileInfo::exists(f->proxy_path)) {
+31 -36
View File
@@ -94,7 +94,7 @@ void MoveClipAction::doRedo() {
}
}
DeleteClipAction::DeleteClipAction(SequencePtr s, int clip) {
DeleteClipAction::DeleteClipAction(Sequence *s, int clip) {
seq = s;
index = clip;
opening_transition = -1;
@@ -140,7 +140,7 @@ void DeleteClipAction::doRedo() {
}
}
ChangeSequenceAction::ChangeSequenceAction(SequencePtr s) {
ChangeSequenceAction::ChangeSequenceAction(Sequence *s) {
new_sequence = s;
}
@@ -153,7 +153,7 @@ void ChangeSequenceAction::doRedo() {
olive::Global->set_sequence(new_sequence);
}
SetTimelineInOutCommand::SetTimelineInOutCommand(SequencePtr s, bool enabled, long in, long out) {
SetTimelineInOutCommand::SetTimelineInOutCommand(Sequence* s, bool enabled, long in, long out) {
seq = s;
new_enabled = enabled;
new_in = in;
@@ -167,7 +167,7 @@ void SetTimelineInOutCommand::doUndo() {
// footage viewer functions
if (seq->wrapper_sequence) {
FootagePtr m = seq->clips.at(0)->media()->to_footage();
Footage* m = seq->clips.at(0)->media()->to_footage();
m->using_inout = old_enabled;
m->in = old_in;
m->out = old_out;
@@ -185,7 +185,7 @@ void SetTimelineInOutCommand::doRedo() {
// footage viewer functions
if (seq->wrapper_sequence) {
FootagePtr m = seq->clips.at(0)->media()->to_footage();
Footage* m = seq->clips.at(0)->media()->to_footage();
m->using_inout = new_enabled;
m->in = new_in;
m->out = new_out;
@@ -397,7 +397,7 @@ void DeleteMediaCommand::doRedo() {
done = true;
}
AddClipCommand::AddClipCommand(SequencePtr s, QVector<ClipPtr>& add) {
AddClipCommand::AddClipCommand(Sequence *s, QVector<ClipPtr>& add) {
link_offset_ = 0;
seq = s;
clips = add;
@@ -407,7 +407,7 @@ AddClipCommand::~AddClipCommand() {}
void AddClipCommand::doUndo() {
// clear effects panel
panel_effect_controls->clear_effects(true);
panel_effect_controls->Clear(true);
for (int i=0;i<clips.size();i++) {
ClipPtr c = seq->clips.last();
@@ -514,7 +514,7 @@ void ReplaceMediaCommand::replace(QString& filename) {
// close any clips currently using this media
QVector<Media*> all_sequences = panel_project->list_all_project_sequences();
for (int i=0;i<all_sequences.size();i++) {
SequencePtr s = all_sequences.at(i)->to_sequence();
Sequence* s = all_sequences.at(i)->to_sequence();
for (int j=0;j<s->clips.size();j++) {
ClipPtr c = s->clips.at(j);
if (c != nullptr && c->media() == item && c->IsOpen()) {
@@ -588,34 +588,28 @@ void ReplaceClipMediaCommand::doRedo() {
update_ui(true);
}
EffectDeleteCommand::EffectDeleteCommand() {
done = false;
}
EffectDeleteCommand::~EffectDeleteCommand() {}
EffectDeleteCommand::EffectDeleteCommand(Effect *e) :
effect_(e)
{}
void EffectDeleteCommand::doUndo() {
for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i);
c->effects.insert(fx.at(i), deleted_objects.at(i));
}
panel_effect_controls->reload_clips();
done = false;
parent_clip_->effects.insert(index_, deleted_obj_);
panel_effect_controls->Reload();
}
void EffectDeleteCommand::doRedo() {
deleted_objects.clear();
for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i);
int fx_id = fx.at(i) - i;
EffectPtr e = c->effects.at(fx_id);
e->close();
deleted_objects.append(e);
c->effects.removeAt(fx_id);
}
panel_effect_controls->reload_clips();
done = true;
parent_clip_ = effect_->parent_clip;
index_ = parent_clip_->IndexOfEffect(effect_);
Q_ASSERT(index_ > -1);
effect_->close();
deleted_obj_ = parent_clip_->effects.at(index_);
parent_clip_->effects.removeAt(index_);
panel_effect_controls->Reload();
}
MediaMove::MediaMove() {}
@@ -868,7 +862,7 @@ void SetBool::doRedo() {
*boolean = new_setting;
}
SetSelectionsCommand::SetSelectionsCommand(SequencePtr s) {
SetSelectionsCommand::SetSelectionsCommand(Sequence *s) {
seq = s;
done = true;
}
@@ -885,7 +879,7 @@ void SetSelectionsCommand::doRedo() {
}
}
EditSequenceCommand::EditSequenceCommand(Media* i, SequencePtr s) {
EditSequenceCommand::EditSequenceCommand(Media* i, Sequence *s) {
item = i;
seq = s;
old_name = s->name;
@@ -918,7 +912,8 @@ void EditSequenceCommand::doRedo() {
void EditSequenceCommand::update() {
// update tooltip
item->set_sequence(seq);
// TODO/FIXME: this is a lousy way to do this, Media should have a separate fuctionn for updating the tooltip
item->update_tooltip();
for (int i=0;i<seq->clips.size();i++) {
if (seq->clips.at(i) != nullptr) seq->clips.at(i)->refresh();
@@ -1042,10 +1037,10 @@ void ReloadEffectsCommand::doUndo() {
}
void ReloadEffectsCommand::doRedo() {
panel_effect_controls->reload_clips();
panel_effect_controls->Reload();
}
RippleAction::RippleAction(SequencePtr is, long ipoint, long ilength, const QVector<int> &iignore) {
RippleAction::RippleAction(Sequence *is, long ipoint, long ilength, const QVector<int> &iignore) {
s = is;
point = ipoint;
length = ilength;
@@ -1161,7 +1156,7 @@ void RefreshClips::doRedo() {
// close any clips currently using this media
QVector<Media*> all_sequences = panel_project->list_all_project_sequences();
for (int i=0;i<all_sequences.size();i++) {
SequencePtr s = all_sequences.at(i)->to_sequence();
Sequence* s = all_sequences.at(i)->to_sequence();
for (int j=0;j<s->clips.size();j++) {
ClipPtr c = s->clips.at(j);
if (c != nullptr && c->media() == media) {
+21 -22
View File
@@ -84,11 +84,11 @@ private:
class RippleAction : public OliveAction {
public:
RippleAction(SequencePtr is, long ipoint, long ilength, const QVector<int>& iignore);
RippleAction(Sequence* is, long ipoint, long ilength, const QVector<int>& iignore);
virtual void doUndo() override;
virtual void doRedo() override;
private:
SequencePtr s;
Sequence* s;
long point;
long length;
QVector<int> ignore;
@@ -97,12 +97,12 @@ private:
class DeleteClipAction : public OliveAction {
public:
DeleteClipAction(SequencePtr s, int clip);
DeleteClipAction(Sequence* s, int clip);
virtual ~DeleteClipAction() override;
virtual void doUndo() override;
virtual void doRedo() override;
private:
SequencePtr seq;
Sequence* seq;
ClipPtr ref;
int index;
@@ -115,12 +115,12 @@ private:
class ChangeSequenceAction : public OliveAction {
public:
ChangeSequenceAction(SequencePtr s);
ChangeSequenceAction(Sequence* s);
virtual void doUndo() override;
virtual void doRedo() override;
private:
SequencePtr old_sequence;
SequencePtr new_sequence;
Sequence* old_sequence;
Sequence* new_sequence;
};
class AddEffectCommand : public OliveAction {
@@ -176,11 +176,11 @@ private:
class SetTimelineInOutCommand : public OliveAction {
public:
SetTimelineInOutCommand(SequencePtr s, bool enabled, long in, long out);
SetTimelineInOutCommand(Sequence* s, bool enabled, long in, long out);
virtual void doUndo() override;
virtual void doRedo() override;
private:
SequencePtr seq;
Sequence* seq;
bool old_enabled;
long old_in;
@@ -229,12 +229,12 @@ private:
class AddClipCommand : public OliveAction {
public:
AddClipCommand(SequencePtr s, QVector<ClipPtr>& add);
AddClipCommand(Sequence* s, QVector<ClipPtr>& add);
virtual ~AddClipCommand() override;
virtual void doUndo() override;
virtual void doRedo() override;
private:
SequencePtr seq;
Sequence* seq;
QVector<ClipPtr> clips;
int link_offset_;
};
@@ -244,7 +244,7 @@ public:
LinkCommand();
virtual void doUndo() override;
virtual void doRedo() override;
SequencePtr s;
Sequence* s;
QVector<int> clips;
bool link;
private:
@@ -291,15 +291,14 @@ private:
class EffectDeleteCommand : public OliveAction {
public:
EffectDeleteCommand();
virtual ~EffectDeleteCommand() override;
EffectDeleteCommand(Effect* e);
virtual void doUndo() override;
virtual void doRedo() override;
QVector<Clip*> clips;
QVector<int> fx;
private:
bool done;
QVector<EffectPtr> deleted_objects;
Effect* effect_;
EffectPtr deleted_obj_;
Clip* parent_clip_;
int index_;
};
class MediaMove : public OliveAction {
@@ -444,19 +443,19 @@ private:
class SetSelectionsCommand : public OliveAction {
public:
SetSelectionsCommand(SequencePtr s);
SetSelectionsCommand(Sequence* s);
virtual void doUndo() override;
virtual void doRedo() override;
QVector<Selection> old_data;
QVector<Selection> new_data;
private:
SequencePtr seq;
Sequence* seq;
bool done;
};
class EditSequenceCommand : public OliveAction {
public:
EditSequenceCommand(Media *i, SequencePtr s);
EditSequenceCommand(Media *i, Sequence* s);
virtual void doUndo() override;
virtual void doRedo() override;
void update();
@@ -469,7 +468,7 @@ public:
int audio_layout;
private:
Media* item;
SequencePtr seq;
Sequence* seq;
QString old_name;
int old_width;