merged effects into node structure

This commit is contained in:
itsmattkc
2019-04-12 21:50:52 +10:00
parent 4e4d2b1881
commit b21745f694
127 changed files with 1674 additions and 867 deletions
+25 -24
View File
@@ -32,7 +32,7 @@
#include <QApplication>
#include "panels/panels.h"
#include "effects/effect.h"
#include "nodes/node.h"
#include "effects/effectloaders.h"
#include "effects/transition.h"
#include "timeline/clip.h"
@@ -95,24 +95,24 @@ void EffectControls::menu_select(QAction* q) {
for (int i=0;i<selected_clips_.size();i++) {
Clip* c = selected_clips_.at(i);
if (c->type() == effect_menu_subtype) {
const EffectMeta* meta = reinterpret_cast<const EffectMeta*>(q->data().value<quintptr>());
NodeType node_type = static_cast<NodeType>(q->data().toInt());
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
if (c->opening_transition == nullptr) {
ca->append(new AddTransitionCommand(c,
nullptr,
nullptr,
meta,
node_type,
olive::config.default_transition_length));
}
if (c->closing_transition == nullptr) {
ca->append(new AddTransitionCommand(nullptr,
c,
nullptr,
meta,
node_type,
olive::config.default_transition_length));
}
} else {
ca->append(new AddEffectCommand(c, nullptr, meta));
ca->append(new AddEffectCommand(c, nullptr, node_type));
}
}
}
@@ -138,7 +138,7 @@ void EffectControls::scroll_to_frame(long frame) {
scroll_to_frame_internal(horizontalScrollBar, frame - keyframeView->visible_in, zoom, keyframeView->width());
}
void EffectControls::show_effect_menu(int type, Track::Type subtype) {
void EffectControls::show_effect_menu(EffectType type, olive::TrackType subtype) {
effect_menu_type = type;
effect_menu_subtype = subtype;
@@ -147,24 +147,25 @@ void EffectControls::show_effect_menu(int type, Track::Type subtype) {
Menu effects_menu(this);
effects_menu.setToolTipsVisible(true);
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
for (int i=0;i<olive::node_library.size();i++) {
if (em.type == type && em.subtype == subtype) {
NodePtr node = olive::node_library.at(i);
if (node != nullptr && node->type() == type && node->subtype() == subtype) {
QAction* action = new QAction(&effects_menu);
action->setText(em.name);
action->setData(reinterpret_cast<quintptr>(&em));
if (!em.tooltip.isEmpty()) {
action->setToolTip(em.tooltip);
action->setText(node->name());
action->setData(i);
if (!node->description().isEmpty()) {
action->setToolTip(node->description());
}
QMenu* parent = &effects_menu;
if (!em.category.isEmpty()) {
if (!node->category().isEmpty()) {
bool found = false;
for (int j=0;j<effects_menu.actions().size();j++) {
QAction* action = effects_menu.actions().at(j);
if (action->menu() != nullptr) {
if (action->menu()->title() == em.category) {
if (action->menu()->title() == node->category()) {
parent = action->menu();
found = true;
break;
@@ -174,12 +175,12 @@ void EffectControls::show_effect_menu(int type, Track::Type subtype) {
if (!found) {
parent = new Menu(&effects_menu);
parent->setToolTipsVisible(true);
parent->setTitle(em.category);
parent->setTitle(node->category());
bool found = false;
for (int i=0;i<effects_menu.actions().size();i++) {
QAction* comp_action = effects_menu.actions().at(i);
if (comp_action->text() > em.category) {
if (comp_action->text() > node->category()) {
effects_menu.insertMenu(comp_action, parent);
found = true;
break;
@@ -444,19 +445,19 @@ bool EffectControls::focused()
}
void EffectControls::video_effect_click() {
show_effect_menu(EFFECT_TYPE_EFFECT, Track::kTypeVideo);
show_effect_menu(EFFECT_TYPE_EFFECT, olive::kTypeVideo);
}
void EffectControls::audio_effect_click() {
show_effect_menu(EFFECT_TYPE_EFFECT, Track::kTypeAudio);
show_effect_menu(EFFECT_TYPE_EFFECT, olive::kTypeAudio);
}
void EffectControls::video_transition_click() {
show_effect_menu(EFFECT_TYPE_TRANSITION, Track::kTypeVideo);
show_effect_menu(EFFECT_TYPE_TRANSITION, olive::kTypeVideo);
}
void EffectControls::audio_transition_click() {
show_effect_menu(EFFECT_TYPE_TRANSITION, Track::kTypeAudio);
show_effect_menu(EFFECT_TYPE_TRANSITION, olive::kTypeAudio);
}
void EffectControls::resizeEvent(QResizeEvent*) {
@@ -491,12 +492,12 @@ void EffectControls::LoadEvent()
QVBoxLayout* layout = nullptr;
EffectUI* container = open_effects_.at(i);
Effect* e = open_effects_.at(i)->GetEffect();
Node* e = open_effects_.at(i)->GetEffect();
if (e->meta->subtype == Track::kTypeVideo) {
if (e->subtype() == olive::kTypeVideo) {
vcontainer->setVisible(true);
layout = video_effect_layout;
} else if (e->meta->subtype == Track::kTypeAudio) {
} else if (e->subtype() == olive::kTypeAudio) {
acontainer->setVisible(true);
layout = audio_effect_layout;
}
+2 -2
View File
@@ -94,14 +94,14 @@ protected:
virtual void ClearEvent() override;
virtual void LoadEvent() override;
private:
void show_effect_menu(int type, Track::Type subtype);
void show_effect_menu(EffectType type, olive::TrackType subtype);
void load_keyframes();
void UpdateTitle();
void setup_ui();
int effect_menu_type;
Track::Type effect_menu_subtype;
olive::TrackType effect_menu_subtype;
QString panel_name;
QWidget* video_effect_area;
+9 -9
View File
@@ -76,7 +76,7 @@ void EffectsPanel::Load() {
Clip* c = selected_clips_.at(i);
// Create a list of the effects we'll open
QVector<Effect*> effects_to_open;
QVector<Node*> effects_to_open;
// Determine based on the current selections whether to load all effects or just the transitions
bool whole_clip_is_selected = c->IsSelected();
@@ -100,7 +100,7 @@ void EffectsPanel::Load() {
// Check if we've already opened an effect of this type before
bool already_opened = false;
for (int k=0;k<open_effects_.size();k++) {
if (open_effects_.at(k)->GetEffect()->meta == effects_to_open.at(j)->meta
if (open_effects_.at(k)->GetEffect()->id() == effects_to_open.at(j)->id()
&& !open_effects_.at(k)->IsAttachedToClip(c)) {
open_effects_.at(k)->AddAdditionalEffect(effects_to_open.at(j));
@@ -137,7 +137,7 @@ void EffectsPanel::Load() {
LoadEvent();
}
bool EffectsPanel::IsEffectSelected(Effect *e)
bool EffectsPanel::IsEffectSelected(Node *e)
{
for (int i=0;i<open_effects_.size();i++) {
if (open_effects_.at(i)->GetEffect() == e && open_effects_.at(i)->IsSelected()) {
@@ -174,9 +174,9 @@ void EffectsPanel::copy(bool del) {
for (int i=0;i<open_effects_.size();i++) {
if (open_effects_.at(i)->IsSelected()) {
Effect* e = open_effects_.at(i)->GetEffect();
Node* e = open_effects_.at(i)->GetEffect();
if (e->meta->type == EFFECT_TYPE_EFFECT) {
if (e->type() == EFFECT_TYPE_EFFECT) {
if (!cleared) {
olive::clipboard.Clear();
@@ -205,12 +205,12 @@ void EffectsPanel::copy(bool del) {
}
}
void EffectsPanel::DeleteEffect(ComboAction* ca, Effect* effect_ref) {
if (effect_ref->meta->type == EFFECT_TYPE_EFFECT) {
void EffectsPanel::DeleteEffect(ComboAction* ca, Node* effect_ref) {
if (effect_ref->type() == EFFECT_TYPE_EFFECT) {
ca->append(new EffectDeleteCommand(effect_ref));
} else if (effect_ref->meta->type == EFFECT_TYPE_TRANSITION) {
} else if (effect_ref->type() == EFFECT_TYPE_TRANSITION) {
// Retrieve shared ptr for this transition
@@ -258,7 +258,7 @@ void EffectsPanel::DeleteSelectedEffects() {
}
}
void EffectsPanel::open_effect(Effect* e) {
void EffectsPanel::open_effect(Node* e) {
EffectUI* container = new EffectUI(e);
connect(container, SIGNAL(CutRequested()), this, SLOT(cut()));
+3 -3
View File
@@ -18,7 +18,7 @@ public:
virtual bool focused() override;
bool IsEffectSelected(Effect* e);
bool IsEffectSelected(Node* e);
void DeleteSelectedEffects();
public slots:
@@ -32,8 +32,8 @@ protected:
QVector<EffectUI*> open_effects_;
private:
void Load();
void open_effect(Effect *e);
void DeleteEffect(ComboAction* ca, Effect* effect_ref);
void open_effect(Node *e);
void DeleteEffect(ComboAction* ca, Node* effect_ref);
private slots:
void deselect_all_effects(QWidget*);
};
+2 -2
View File
@@ -30,7 +30,7 @@
#include "timeline/timelinetools.h"
#include "ui/labelslider.h"
#include "ui/graphview.h"
#include "effects/effect.h"
#include "nodes/node.h"
#include "effects/effectfields.h"
#include "effects/effectrow.h"
#include "timeline/clip.h"
@@ -210,7 +210,7 @@ void GraphEditor::set_row(EffectRow *r) {
if (found_vals) {
row = r;
current_row_desc->setText(row->GetParentEffect()->parent_clip->name()
+ " :: " + row->GetParentEffect()->meta->name
+ " :: " + row->GetParentEffect()->name()
+ " :: " + row->name());
header->set_visible_in(r->GetParentEffect()->parent_clip->timeline_in());
+20 -20
View File
@@ -221,10 +221,10 @@ void Timeline::SetSequence(SequencePtr sequence)
return;
}
sequence_ = sequence;
sequence_ = sequence;
update_sequence();
video_area->SetTrackList(sequence_.get(), Track::kTypeVideo);
audio_area->SetTrackList(sequence_.get(), Track::kTypeAudio);
video_area->SetTrackList(sequence_.get(), olive::kTypeVideo);
audio_area->SetTrackList(sequence_.get(), olive::kTypeAudio);
repaint_timeline();
emit SequenceChanged(sequence_);
@@ -276,14 +276,14 @@ void Timeline::add_transition() {
for (int i=0;i<selected_clips.size();i++) {
Clip* c = selected_clips.at(i);
int transition_to_add = (c->type() == Track::kTypeVideo) ? TRANSITION_INTERNAL_CROSSDISSOLVE
: TRANSITION_INTERNAL_LINEARFADE;
NodeType transition_to_add = (c->type() == olive::kTypeVideo) ? kCrossDissolveTransition
: kLinearFadeTransition;
if (c->opening_transition == nullptr) {
ca->append(new AddTransitionCommand(c,
nullptr,
nullptr,
Effect::GetInternalMeta(transition_to_add, EFFECT_TYPE_TRANSITION),
transition_to_add,
olive::config.default_transition_length));
adding = true;
}
@@ -292,7 +292,7 @@ void Timeline::add_transition() {
ca->append(new AddTransitionCommand(nullptr,
c,
nullptr,
Effect::GetInternalMeta(transition_to_add, EFFECT_TYPE_TRANSITION),
transition_to_add,
olive::config.default_transition_length));
adding = true;
}
@@ -873,23 +873,23 @@ void Timeline::transition_tool_click() {
Menu transition_menu(this);
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
if (em.type == EFFECT_TYPE_TRANSITION && em.subtype == Track::kTypeVideo) {
QAction* a = transition_menu.addAction(em.name);
for (int i=0;i<olive::node_library.size();i++) {
NodePtr node = olive::node_library.at(i);
if (node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeVideo) {
QAction* a = transition_menu.addAction(node->name());
a->setObjectName("v");
a->setData(reinterpret_cast<quintptr>(&em));
a->setData(i);
}
}
transition_menu.addSeparator();
for (int i=0;i<olive::effects.size();i++) {
const EffectMeta& em = olive::effects.at(i);
if (em.type == EFFECT_TYPE_TRANSITION && em.subtype == Track::kTypeAudio) {
QAction* a = transition_menu.addAction(em.name);
for (int i=0;i<olive::node_library.size();i++) {
NodePtr node = olive::node_library.at(i);
if (node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeVideo) {
QAction* a = transition_menu.addAction(node->name());
a->setObjectName("a");
a->setData(reinterpret_cast<quintptr>(&em));
a->setData(i);
}
}
@@ -901,12 +901,12 @@ void Timeline::transition_tool_click() {
}
void Timeline::transition_menu_select(QAction* a) {
transition_tool_meta = reinterpret_cast<const EffectMeta*>(a->data().value<quintptr>());
transition_tool_meta = static_cast<NodeType>(a->data().toInt());
if (a->objectName() == "v") {
transition_tool_side = Track::kTypeVideo;
transition_tool_side = olive::kTypeVideo;
} else {
transition_tool_side = Track::kTypeAudio;
transition_tool_side = olive::kTypeAudio;
}
timeline_area->setCursor(Qt::CrossCursor);
+2 -2
View File
@@ -114,8 +114,8 @@ public:
bool transition_tool_proc;
Clip* transition_tool_open_clip;
Clip* transition_tool_close_clip;
const EffectMeta* transition_tool_meta;
Track::Type transition_tool_side;
NodeType transition_tool_meta;
olive::TrackType transition_tool_side;
// hand tool variables
bool hand_moving;
+3 -3
View File
@@ -752,7 +752,7 @@ void Viewer::set_media(Media* m) {
new_sequence->frame_rate = video_stream.video_frame_rate * footage->speed;
}
ClipPtr c = std::make_shared<Clip>(new_sequence->GetTrackList(Track::kTypeVideo)->First());
ClipPtr c = std::make_shared<Clip>(new_sequence->GetTrackList(olive::kTypeVideo)->First());
c->set_media(media, video_stream.file_index);
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate));
@@ -760,7 +760,7 @@ void Viewer::set_media(Media* m) {
// FIXME: Move this magic number to Config
c->set_timeline_out(150);
}
Track* track = new_sequence->GetTrackList(Track::kTypeVideo)->First();
Track* track = new_sequence->GetTrackList(olive::kTypeVideo)->First();
c->set_track(track);
c->set_clip_in(0);
c->refresh();
@@ -774,7 +774,7 @@ void Viewer::set_media(Media* m) {
const FootageStream& audio_stream = footage->audio_tracks.at(0);
new_sequence->audio_frequency = audio_stream.audio_frequency;
Track* track = new_sequence->GetTrackList(Track::kTypeAudio)->First();
Track* track = new_sequence->GetTrackList(olive::kTypeAudio)->First();
ClipPtr c = std::make_shared<Clip>(track);
c->set_media(media, audio_stream.file_index);
c->set_timeline_in(0);