fix line endings
This commit is contained in:
+414
-414
@@ -1,414 +1,414 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "nodeio.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "undo/undo.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/sequence.h"
|
||||
#include "panels/panels.h"
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "panels/grapheditor.h"
|
||||
#include "nodes/oldeffectnode.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "ui/keyframenavigator.h"
|
||||
#include "ui/clickablelabel.h"
|
||||
|
||||
NodeIO::NodeIO(Node *parent,
|
||||
const QString &id,
|
||||
const QString &name,
|
||||
bool savable,
|
||||
bool keyframable) :
|
||||
QObject(parent),
|
||||
id_(id),
|
||||
name_(name),
|
||||
keyframable_(keyframable),
|
||||
keyframing_(false),
|
||||
savable_(savable),
|
||||
output_type_(olive::nodes::kInvalid)
|
||||
{
|
||||
Q_ASSERT(parent != nullptr);
|
||||
|
||||
parent->AddParameter(this);
|
||||
}
|
||||
|
||||
void NodeIO::AddField(EffectField *field)
|
||||
{
|
||||
field->setParent(this);
|
||||
|
||||
connect(field, SIGNAL(Clicked()), this, SIGNAL(Clicked()));
|
||||
connect(field, SIGNAL(Changed()), this, SIGNAL(Changed()));
|
||||
|
||||
fields_.append(field);
|
||||
}
|
||||
|
||||
void NodeIO::AddAcceptedNodeInput(olive::nodes::DataType type)
|
||||
{
|
||||
Q_ASSERT(output_type_ == olive::nodes::kInvalid);
|
||||
|
||||
accepted_inputs_.append(type);
|
||||
}
|
||||
|
||||
void NodeIO::ConnectEdge(NodeIO *output, NodeIO *input)
|
||||
{
|
||||
// Make sure one is an output and one is an input
|
||||
Q_ASSERT(output->IsNodeInput() != input->IsNodeInput());
|
||||
|
||||
// Swap them if necessary
|
||||
if (input->IsNodeOutput()) {
|
||||
NodeIO* temp = output;
|
||||
output = input;
|
||||
input = temp;
|
||||
}
|
||||
|
||||
// Inputs can only have one edge, so we disconnect it here if there is one
|
||||
if (!input->node_edges_.isEmpty()) {
|
||||
DisconnectEdge(input->node_edges_.first());
|
||||
}
|
||||
|
||||
NodeEdgePtr edge = std::make_shared<NodeEdge>(output, input);
|
||||
|
||||
output->node_edges_.append(edge);
|
||||
input->node_edges_.append(edge);
|
||||
|
||||
emit output->EdgesChanged();
|
||||
}
|
||||
|
||||
void NodeIO::DisconnectEdge(NodeEdgePtr edge)
|
||||
{
|
||||
NodeIO* output = edge->output();
|
||||
NodeIO* input = edge->input();
|
||||
|
||||
output->node_edges_.removeAll(edge);
|
||||
input->node_edges_.removeAll(edge);
|
||||
|
||||
emit output->EdgesChanged();
|
||||
}
|
||||
|
||||
QVector<NodeEdgePtr> NodeIO::edges()
|
||||
{
|
||||
return node_edges_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsKeyframing() {
|
||||
return keyframing_;
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframingInternal(bool b) {
|
||||
/* FIXME
|
||||
if (GetParentEffect()->type() != EFFECT_TYPE_TRANSITION) {
|
||||
keyframing_ = b;
|
||||
emit KeyframingSetChanged(keyframing_);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool NodeIO::IsSavable()
|
||||
{
|
||||
return savable_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsKeyframable()
|
||||
{
|
||||
return keyframable_;
|
||||
}
|
||||
|
||||
QVariant NodeIO::GetValue()
|
||||
{
|
||||
return GetValueAt(0);
|
||||
}
|
||||
|
||||
QVariant NodeIO::GetValueAt(double timecode)
|
||||
{
|
||||
if (FieldCount() == 0) {
|
||||
return data_;
|
||||
}
|
||||
|
||||
Q_ASSERT(FieldCount() == 1);
|
||||
|
||||
return Field(0)->GetValueAt(timecode);
|
||||
}
|
||||
|
||||
void NodeIO::SetValue(const QVariant &value)
|
||||
{
|
||||
SetValueAt(0, value);
|
||||
}
|
||||
|
||||
void NodeIO::SetValueAt(double timecode, const QVariant &value)
|
||||
{
|
||||
if (FieldCount() == 0) {
|
||||
data_ = value;
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(FieldCount() == 1);
|
||||
|
||||
Field(0)->SetValueAt(timecode, value);
|
||||
}
|
||||
|
||||
void NodeIO::SetEnabled(bool enabled)
|
||||
{
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->SetEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeIO::SetOutputDataType(olive::nodes::DataType type)
|
||||
{
|
||||
Q_ASSERT(accepted_inputs_.isEmpty());
|
||||
|
||||
output_type_ = type;
|
||||
}
|
||||
|
||||
bool NodeIO::CanAcceptDataType(olive::nodes::DataType type)
|
||||
{
|
||||
if (!IsNodeInput()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return accepted_inputs_.contains(type);
|
||||
}
|
||||
|
||||
olive::nodes::DataType NodeIO::OutputDataType()
|
||||
{
|
||||
return output_type_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsNodeInput()
|
||||
{
|
||||
return !accepted_inputs_.isEmpty();
|
||||
}
|
||||
|
||||
bool NodeIO::IsNodeOutput()
|
||||
{
|
||||
return output_type_ != olive::nodes::kInvalid;
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframingEnabled(bool enabled) {
|
||||
if (enabled == keyframing_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// Enable keyframing setting on this row
|
||||
ca->append(new SetIsKeyframing(this, true));
|
||||
|
||||
// Prepare each field's data to start keyframing
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->PrepareDataForKeyframing(true, ca);
|
||||
}
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
update_ui(false);
|
||||
|
||||
} else {
|
||||
|
||||
// Confirm with the user whether they really want to disable keyframing
|
||||
if (QMessageBox::question(panel_effect_controls,
|
||||
tr("Disable Keyframes"),
|
||||
tr("Disabling keyframes will delete all current keyframes. "
|
||||
"Are you sure you want to do this?"),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// Prepare each field's data to stop keyframing
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->PrepareDataForKeyframing(false, ca);
|
||||
}
|
||||
|
||||
// Disable keyframing setting on this row
|
||||
ca->append(new SetIsKeyframing(this, false));
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
update_ui(false);
|
||||
|
||||
} else {
|
||||
|
||||
SetKeyframingInternal(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeIO::GoToPreviousKeyframe() {
|
||||
/* FIXME
|
||||
long key = LONG_MIN;
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
long sequence_playhead = c->track()->sequence()->playhead;
|
||||
|
||||
// Used to convert clip frame number to sequence frame number
|
||||
long time_adjustment = c->timeline_in() - c->clip_in();
|
||||
|
||||
// Loop through all of this row's fields
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
|
||||
EffectField* f = Field(i);
|
||||
|
||||
// Loop through all of this field's keyframes for a keyframe EARLIER than the playhead
|
||||
for (int j=0;j<f->keyframes.size();j++) {
|
||||
long comp = f->keyframes.at(j).time + time_adjustment;
|
||||
|
||||
// Get the closest keyframe
|
||||
if (comp < sequence_playhead) {
|
||||
key = qMax(comp, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we found a keyframe less than the playhead, jump to it
|
||||
if (key != LONG_MIN) panel_sequence_viewer->seek(key);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::ToggleKeyframe() {
|
||||
/* FIXME
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
long sequence_playhead = c->track()->sequence()->playhead;
|
||||
|
||||
// Used to convert clip frame number to sequence frame number
|
||||
long time_adjustment = c->timeline_in() - c->clip_in();
|
||||
|
||||
QVector<EffectField*> key_fields;
|
||||
QVector<int> key_field_index;
|
||||
|
||||
// See if any keyframes on any fields are at the current time
|
||||
for (int j=0;j<FieldCount();j++) {
|
||||
EffectField* f = Field(j);
|
||||
for (int i=0;i<f->keyframes.size();i++) {
|
||||
long comp = f->keyframes.at(i).time + time_adjustment;
|
||||
|
||||
if (comp == sequence_playhead) {
|
||||
|
||||
// Cache the keyframes if they are at the current time
|
||||
key_fields.append(f);
|
||||
key_field_index.append(i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
if (key_fields.isEmpty()) {
|
||||
|
||||
// If we didn't find any current keyframes, create one for each field
|
||||
SetKeyframeOnAllFields(ca);
|
||||
|
||||
} else {
|
||||
|
||||
// If we DID find keyframes at this time, delete them
|
||||
|
||||
QVector<EffectField*> sorted_key_fields;
|
||||
QVector<int> sorted_key_field_index;
|
||||
|
||||
// Since QVectors shift themselves when removing items, we need to sort these in reverse order
|
||||
for (int i=0;i<key_field_index.size();i++) {
|
||||
bool found = false;
|
||||
|
||||
for (int j=0;j<sorted_key_field_index.size();j++) {
|
||||
if (sorted_key_field_index.at(j) < key_field_index.at(i)) {
|
||||
sorted_key_fields.insert(j, key_fields.at(i));
|
||||
sorted_key_field_index.insert(j, key_field_index.at(i));
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
sorted_key_fields.append(key_fields.at(i));
|
||||
sorted_key_field_index.append(key_field_index.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<sorted_key_fields.size();i++) {
|
||||
ca->append(new KeyframeDelete(sorted_key_fields.at(i), sorted_key_field_index.at(i)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(false);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::GoToNextKeyframe() {
|
||||
/* FIXME
|
||||
long key = LONG_MAX;
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
EffectField* f = Field(i);
|
||||
for (int j=0;j<f->keyframes.size();j++) {
|
||||
long comp = f->keyframes.at(j).time - c->clip_in() + c->timeline_in();
|
||||
if (comp > c->track()->sequence()->playhead) {
|
||||
key = qMin(comp, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key != LONG_MAX) panel_sequence_viewer->seek(key);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::FocusRow() {
|
||||
panel_graph_editor->set_row(this);
|
||||
}
|
||||
|
||||
Node* NodeIO::ParentNode() {
|
||||
return static_cast<Node*>(parent());
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) {
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
EffectField* field = Field(i);
|
||||
|
||||
KeyframeDataChange* kdc = new KeyframeDataChange(field);
|
||||
|
||||
field->SetValueAt(ParentNode()->Time(), field->GetValueAt(ParentNode()->Time()));
|
||||
|
||||
kdc->SetNewKeyframes();
|
||||
ca->append(kdc);
|
||||
}
|
||||
|
||||
panel_effect_controls->update_keyframes();
|
||||
}
|
||||
|
||||
const QString &NodeIO::name() {
|
||||
return name_;
|
||||
}
|
||||
|
||||
EffectField* NodeIO::Field(int i) {
|
||||
return fields_.at(i);
|
||||
}
|
||||
|
||||
int NodeIO::FieldCount() {
|
||||
return fields_.size();
|
||||
}
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "nodeio.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "undo/undo.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/sequence.h"
|
||||
#include "panels/panels.h"
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "panels/grapheditor.h"
|
||||
#include "nodes/oldeffectnode.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "ui/keyframenavigator.h"
|
||||
#include "ui/clickablelabel.h"
|
||||
|
||||
NodeIO::NodeIO(Node *parent,
|
||||
const QString &id,
|
||||
const QString &name,
|
||||
bool savable,
|
||||
bool keyframable) :
|
||||
QObject(parent),
|
||||
id_(id),
|
||||
name_(name),
|
||||
keyframable_(keyframable),
|
||||
keyframing_(false),
|
||||
savable_(savable),
|
||||
output_type_(olive::nodes::kInvalid)
|
||||
{
|
||||
Q_ASSERT(parent != nullptr);
|
||||
|
||||
parent->AddParameter(this);
|
||||
}
|
||||
|
||||
void NodeIO::AddField(EffectField *field)
|
||||
{
|
||||
field->setParent(this);
|
||||
|
||||
connect(field, SIGNAL(Clicked()), this, SIGNAL(Clicked()));
|
||||
connect(field, SIGNAL(Changed()), this, SIGNAL(Changed()));
|
||||
|
||||
fields_.append(field);
|
||||
}
|
||||
|
||||
void NodeIO::AddAcceptedNodeInput(olive::nodes::DataType type)
|
||||
{
|
||||
Q_ASSERT(output_type_ == olive::nodes::kInvalid);
|
||||
|
||||
accepted_inputs_.append(type);
|
||||
}
|
||||
|
||||
void NodeIO::ConnectEdge(NodeIO *output, NodeIO *input)
|
||||
{
|
||||
// Make sure one is an output and one is an input
|
||||
Q_ASSERT(output->IsNodeInput() != input->IsNodeInput());
|
||||
|
||||
// Swap them if necessary
|
||||
if (input->IsNodeOutput()) {
|
||||
NodeIO* temp = output;
|
||||
output = input;
|
||||
input = temp;
|
||||
}
|
||||
|
||||
// Inputs can only have one edge, so we disconnect it here if there is one
|
||||
if (!input->node_edges_.isEmpty()) {
|
||||
DisconnectEdge(input->node_edges_.first());
|
||||
}
|
||||
|
||||
NodeEdgePtr edge = std::make_shared<NodeEdge>(output, input);
|
||||
|
||||
output->node_edges_.append(edge);
|
||||
input->node_edges_.append(edge);
|
||||
|
||||
emit output->EdgesChanged();
|
||||
}
|
||||
|
||||
void NodeIO::DisconnectEdge(NodeEdgePtr edge)
|
||||
{
|
||||
NodeIO* output = edge->output();
|
||||
NodeIO* input = edge->input();
|
||||
|
||||
output->node_edges_.removeAll(edge);
|
||||
input->node_edges_.removeAll(edge);
|
||||
|
||||
emit output->EdgesChanged();
|
||||
}
|
||||
|
||||
QVector<NodeEdgePtr> NodeIO::edges()
|
||||
{
|
||||
return node_edges_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsKeyframing() {
|
||||
return keyframing_;
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframingInternal(bool b) {
|
||||
/* FIXME
|
||||
if (GetParentEffect()->type() != EFFECT_TYPE_TRANSITION) {
|
||||
keyframing_ = b;
|
||||
emit KeyframingSetChanged(keyframing_);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool NodeIO::IsSavable()
|
||||
{
|
||||
return savable_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsKeyframable()
|
||||
{
|
||||
return keyframable_;
|
||||
}
|
||||
|
||||
QVariant NodeIO::GetValue()
|
||||
{
|
||||
return GetValueAt(0);
|
||||
}
|
||||
|
||||
QVariant NodeIO::GetValueAt(double timecode)
|
||||
{
|
||||
if (FieldCount() == 0) {
|
||||
return data_;
|
||||
}
|
||||
|
||||
Q_ASSERT(FieldCount() == 1);
|
||||
|
||||
return Field(0)->GetValueAt(timecode);
|
||||
}
|
||||
|
||||
void NodeIO::SetValue(const QVariant &value)
|
||||
{
|
||||
SetValueAt(0, value);
|
||||
}
|
||||
|
||||
void NodeIO::SetValueAt(double timecode, const QVariant &value)
|
||||
{
|
||||
if (FieldCount() == 0) {
|
||||
data_ = value;
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(FieldCount() == 1);
|
||||
|
||||
Field(0)->SetValueAt(timecode, value);
|
||||
}
|
||||
|
||||
void NodeIO::SetEnabled(bool enabled)
|
||||
{
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->SetEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeIO::SetOutputDataType(olive::nodes::DataType type)
|
||||
{
|
||||
Q_ASSERT(accepted_inputs_.isEmpty());
|
||||
|
||||
output_type_ = type;
|
||||
}
|
||||
|
||||
bool NodeIO::CanAcceptDataType(olive::nodes::DataType type)
|
||||
{
|
||||
if (!IsNodeInput()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return accepted_inputs_.contains(type);
|
||||
}
|
||||
|
||||
olive::nodes::DataType NodeIO::OutputDataType()
|
||||
{
|
||||
return output_type_;
|
||||
}
|
||||
|
||||
bool NodeIO::IsNodeInput()
|
||||
{
|
||||
return !accepted_inputs_.isEmpty();
|
||||
}
|
||||
|
||||
bool NodeIO::IsNodeOutput()
|
||||
{
|
||||
return output_type_ != olive::nodes::kInvalid;
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframingEnabled(bool enabled) {
|
||||
if (enabled == keyframing_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// Enable keyframing setting on this row
|
||||
ca->append(new SetIsKeyframing(this, true));
|
||||
|
||||
// Prepare each field's data to start keyframing
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->PrepareDataForKeyframing(true, ca);
|
||||
}
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
update_ui(false);
|
||||
|
||||
} else {
|
||||
|
||||
// Confirm with the user whether they really want to disable keyframing
|
||||
if (QMessageBox::question(panel_effect_controls,
|
||||
tr("Disable Keyframes"),
|
||||
tr("Disabling keyframes will delete all current keyframes. "
|
||||
"Are you sure you want to do this?"),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// Prepare each field's data to stop keyframing
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
Field(i)->PrepareDataForKeyframing(false, ca);
|
||||
}
|
||||
|
||||
// Disable keyframing setting on this row
|
||||
ca->append(new SetIsKeyframing(this, false));
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
update_ui(false);
|
||||
|
||||
} else {
|
||||
|
||||
SetKeyframingInternal(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeIO::GoToPreviousKeyframe() {
|
||||
/* FIXME
|
||||
long key = LONG_MIN;
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
long sequence_playhead = c->track()->sequence()->playhead;
|
||||
|
||||
// Used to convert clip frame number to sequence frame number
|
||||
long time_adjustment = c->timeline_in() - c->clip_in();
|
||||
|
||||
// Loop through all of this row's fields
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
|
||||
EffectField* f = Field(i);
|
||||
|
||||
// Loop through all of this field's keyframes for a keyframe EARLIER than the playhead
|
||||
for (int j=0;j<f->keyframes.size();j++) {
|
||||
long comp = f->keyframes.at(j).time + time_adjustment;
|
||||
|
||||
// Get the closest keyframe
|
||||
if (comp < sequence_playhead) {
|
||||
key = qMax(comp, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we found a keyframe less than the playhead, jump to it
|
||||
if (key != LONG_MIN) panel_sequence_viewer->seek(key);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::ToggleKeyframe() {
|
||||
/* FIXME
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
long sequence_playhead = c->track()->sequence()->playhead;
|
||||
|
||||
// Used to convert clip frame number to sequence frame number
|
||||
long time_adjustment = c->timeline_in() - c->clip_in();
|
||||
|
||||
QVector<EffectField*> key_fields;
|
||||
QVector<int> key_field_index;
|
||||
|
||||
// See if any keyframes on any fields are at the current time
|
||||
for (int j=0;j<FieldCount();j++) {
|
||||
EffectField* f = Field(j);
|
||||
for (int i=0;i<f->keyframes.size();i++) {
|
||||
long comp = f->keyframes.at(i).time + time_adjustment;
|
||||
|
||||
if (comp == sequence_playhead) {
|
||||
|
||||
// Cache the keyframes if they are at the current time
|
||||
key_fields.append(f);
|
||||
key_field_index.append(i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
if (key_fields.isEmpty()) {
|
||||
|
||||
// If we didn't find any current keyframes, create one for each field
|
||||
SetKeyframeOnAllFields(ca);
|
||||
|
||||
} else {
|
||||
|
||||
// If we DID find keyframes at this time, delete them
|
||||
|
||||
QVector<EffectField*> sorted_key_fields;
|
||||
QVector<int> sorted_key_field_index;
|
||||
|
||||
// Since QVectors shift themselves when removing items, we need to sort these in reverse order
|
||||
for (int i=0;i<key_field_index.size();i++) {
|
||||
bool found = false;
|
||||
|
||||
for (int j=0;j<sorted_key_field_index.size();j++) {
|
||||
if (sorted_key_field_index.at(j) < key_field_index.at(i)) {
|
||||
sorted_key_fields.insert(j, key_fields.at(i));
|
||||
sorted_key_field_index.insert(j, key_field_index.at(i));
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
sorted_key_fields.append(key_fields.at(i));
|
||||
sorted_key_field_index.append(key_field_index.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<sorted_key_fields.size();i++) {
|
||||
ca->append(new KeyframeDelete(sorted_key_fields.at(i), sorted_key_field_index.at(i)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(false);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::GoToNextKeyframe() {
|
||||
/* FIXME
|
||||
long key = LONG_MAX;
|
||||
Clip* c = GetParentEffect()->parent_clip;
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
EffectField* f = Field(i);
|
||||
for (int j=0;j<f->keyframes.size();j++) {
|
||||
long comp = f->keyframes.at(j).time - c->clip_in() + c->timeline_in();
|
||||
if (comp > c->track()->sequence()->playhead) {
|
||||
key = qMin(comp, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key != LONG_MAX) panel_sequence_viewer->seek(key);
|
||||
*/
|
||||
}
|
||||
|
||||
void NodeIO::FocusRow() {
|
||||
panel_graph_editor->set_row(this);
|
||||
}
|
||||
|
||||
Node* NodeIO::ParentNode() {
|
||||
return static_cast<Node*>(parent());
|
||||
}
|
||||
|
||||
void NodeIO::SetKeyframeOnAllFields(ComboAction* ca) {
|
||||
for (int i=0;i<FieldCount();i++) {
|
||||
EffectField* field = Field(i);
|
||||
|
||||
KeyframeDataChange* kdc = new KeyframeDataChange(field);
|
||||
|
||||
field->SetValueAt(ParentNode()->Time(), field->GetValueAt(ParentNode()->Time()));
|
||||
|
||||
kdc->SetNewKeyframes();
|
||||
ca->append(kdc);
|
||||
}
|
||||
|
||||
panel_effect_controls->update_keyframes();
|
||||
}
|
||||
|
||||
const QString &NodeIO::name() {
|
||||
return name_;
|
||||
}
|
||||
|
||||
EffectField* NodeIO::Field(int i) {
|
||||
return fields_.at(i);
|
||||
}
|
||||
|
||||
int NodeIO::FieldCount() {
|
||||
return fields_.size();
|
||||
}
|
||||
|
||||
+491
-491
@@ -1,491 +1,491 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef EFFECTROW_H
|
||||
#define EFFECTROW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class Node;
|
||||
class QGridLayout;
|
||||
class EffectField;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class ComboAction;
|
||||
class QHBoxLayout;
|
||||
class KeyframeNavigator;
|
||||
class ClickableLabel;
|
||||
|
||||
#include "effects/effectfields.h"
|
||||
#include "nodes/nodeedge.h"
|
||||
|
||||
/**
|
||||
* @brief The EffectRow class
|
||||
*
|
||||
* Primarily a way of grouping EffectField objects together. As UI objects, Effects are largely formatted as a table
|
||||
* and you can think of EffectRows as the rows of the table and EffectFields as the columns.
|
||||
*
|
||||
* Within Olive, keyframing is enabled on the EffectRow (rather than individual EffectFields) so all attached fields
|
||||
* will be keyframed together.
|
||||
*
|
||||
* Unlike EffectField, there's no reason to derive from EffectRow as it's simply a container of fields and a few
|
||||
* keyframe functions.
|
||||
*/
|
||||
class NodeIO : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief EffectRow Constructor
|
||||
*
|
||||
* @param parent
|
||||
*
|
||||
* Every EffectRow object must be attached to a valid Effect object. The Effect object takes ownership of the
|
||||
* EffectRow and automatically frees it through the QObject parent/child system. EffectRows are never intended to
|
||||
* change parents throughout their lifetimes.
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* Field ID. Must be non-empty. Must also be unique within this Effect. Used for saving/loading values into project
|
||||
* files so that if ordering of fields are changed, or fields are added/removed from Effects later in development,
|
||||
* saved values in project files will still link with the correct field. Also used as the uniform variable name
|
||||
* in GLSL shaders.
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* Row name. This is not used as an internal identifier, it's just for the user interface, so it can be translated
|
||||
* with no issue.
|
||||
*
|
||||
* @param savable
|
||||
*
|
||||
* Whether the fields in this row should be saved to the project file. This is true by default. If the row contains
|
||||
* non-value UI widgets, setting this to false is recommended.
|
||||
*
|
||||
* @param keyframable
|
||||
*
|
||||
* Whether keyframing can be enabled on this row or not. This is true by default. Some values you may want to prevent
|
||||
* the user from keyframing (e.g. the filename of a VST plugin), which can be done by setting this to false.
|
||||
*/
|
||||
NodeIO(Node* parent,
|
||||
const QString& id,
|
||||
const QString& name,
|
||||
bool savable = true,
|
||||
bool keyframable = true);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the EffectField at this index. Must be less than FieldCount().
|
||||
*
|
||||
* @param i
|
||||
*
|
||||
* Index to retrieve the EffectField at.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* EffectField at the provided index.
|
||||
*/
|
||||
EffectField* Field(int i);
|
||||
|
||||
/**
|
||||
* @brief Number of fields currently contained in this row.
|
||||
*
|
||||
* @return The number of fields currently contained in this row as an integer. Any field index (retrieved with
|
||||
* Field()) is guaranteed to be valid >= 0 and < FieldCount().
|
||||
*/
|
||||
int FieldCount();
|
||||
|
||||
/**
|
||||
* @brief Set a keyframe at the current playhead on all fields contained within this row
|
||||
*
|
||||
* @param ca
|
||||
*
|
||||
* The ComboAction to add this action to. This may not be nullptr.
|
||||
*/
|
||||
void SetKeyframeOnAllFields(ComboAction *ca);
|
||||
|
||||
/**
|
||||
* @brief Get parent Effect
|
||||
*
|
||||
* Equivalent to `static_cast<Effect*>(parent())`.
|
||||
*
|
||||
* @return The parent Effect object that this row is attached to.
|
||||
*/
|
||||
Node* ParentNode();
|
||||
|
||||
/**
|
||||
* @brief Return the row's name
|
||||
*
|
||||
* @return The name specified in the constructor as a QString
|
||||
*/
|
||||
const QString& name();
|
||||
|
||||
/**
|
||||
* @brief Get the unique identifier of this field set in the constructor
|
||||
*
|
||||
* Mostly used for saving/loading or interacting with GLSL-based shader effects (see EffectField() for more details).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
const QString& id();
|
||||
|
||||
/**
|
||||
* @brief Get whether this row is keyframing or not
|
||||
*
|
||||
* @return True if this row is keyframing.
|
||||
*/
|
||||
bool IsKeyframing();
|
||||
|
||||
/**
|
||||
* @brief Set whether this row is keyframing or not.
|
||||
*
|
||||
* It's not recommended to use this function for any user-initiated keyframe setting change as it doesn't create any
|
||||
* undoable actions. Use SetKeyframingEnabled() instead for a user-friendly variant.
|
||||
*/
|
||||
void SetKeyframingInternal(bool);
|
||||
|
||||
/**
|
||||
* @brief Get whether this row should be saved into a project file or not
|
||||
*
|
||||
* @return True if this row should be saved. This value is set in the constructor.
|
||||
*/
|
||||
bool IsSavable();
|
||||
|
||||
/**
|
||||
* @brief Get whether this row can be keyframed or not.
|
||||
*
|
||||
* @return True if this row can be keyframed. This value is set in the constructor.
|
||||
*/
|
||||
bool IsKeyframable();
|
||||
|
||||
/**
|
||||
* @brief Get value
|
||||
*
|
||||
* A convenience value for a parameters that doesn't keyframe. Equivalent to GetValueAt(0) where the parameter
|
||||
* doesn't keyframe so the 0 is ignored.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
QVariant GetValue();
|
||||
|
||||
/**
|
||||
* @brief Get value at a given timecode
|
||||
*
|
||||
* Functions as a wrapper for EffectField::GetValueAt().
|
||||
*
|
||||
* The default function is to return the result of the first EffectField on this EffectRow which should be sufficient
|
||||
* for most input types. If this EffectRow has more or less than one EffectField, you must override this function in a
|
||||
* derived class to provide the correct field <-> row coordination or else it will trigger an abort.
|
||||
*
|
||||
* @param timecode
|
||||
*
|
||||
* Timecode to get the value at
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The value of the first EffectField at the given timecode
|
||||
*/
|
||||
virtual QVariant GetValueAt(double timecode);
|
||||
|
||||
/**
|
||||
* @brief Set value
|
||||
*
|
||||
* A convenience value for a parameters that doesn't keyframe. Equivalent to SetValueAt(0, value) where the parameter
|
||||
* doesn't keyframe so the 0 is ignored.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetValue(const QVariant& value);
|
||||
|
||||
/**
|
||||
* @brief SetValueAt
|
||||
*
|
||||
* Functions as a wrapper for EffectField::SetValueAt().
|
||||
*
|
||||
* The default function is to call the function of the first EffectField on this EffectRow which should be sufficient
|
||||
* for most input types. If this EffectRow has more or less than one EffectField, you must override this function in a
|
||||
* derived class to provide the correct field <-> row coordination or else it will trigger an abort.
|
||||
*
|
||||
* @param timecode
|
||||
*
|
||||
* Timecode to set the value at
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* Value to set at this timecode
|
||||
*/
|
||||
virtual void SetValueAt(double timecode, const QVariant& value);
|
||||
|
||||
/**
|
||||
* @brief Sets the enabled state on all EffectField objects on this row to enabled
|
||||
*/
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Check if nodes can be connected to this as an input.
|
||||
*
|
||||
* Connecting is enabled by adding an accepted node input using AddNodeInput().
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if nodes can be connected as an input.
|
||||
*/
|
||||
bool IsNodeInput();
|
||||
|
||||
/**
|
||||
* @brief Check if nodes can be connected to this as an output
|
||||
*
|
||||
* Connecting is enabled by setting an output data type in SetOutputDataType().
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if nodes can be connected as an output
|
||||
*/
|
||||
bool IsNodeOutput();
|
||||
|
||||
/**
|
||||
* @brief Set output data type
|
||||
*
|
||||
* Set the type of data this row outputs to type
|
||||
*/
|
||||
void SetOutputDataType(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Check if this row can accept the data type specified in type
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if this row can accept this data type. If this row is not an input, this function will always return FALSE.
|
||||
*/
|
||||
bool CanAcceptDataType(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Get this row's output data type
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* If this is not an output, this will always return olive::nodes::kInvalid
|
||||
*/
|
||||
olive::nodes::DataType OutputDataType();
|
||||
|
||||
/**
|
||||
* @brief Adds a node data type that can be accepted by this input
|
||||
*
|
||||
* Allows this input to take a node connection from a data type specified by type. An input can take several data
|
||||
* types.
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* The data type to add
|
||||
*/
|
||||
void AddAcceptedNodeInput(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Connect two node sockets together
|
||||
*
|
||||
* For outputs, the maximum amount of edges is unlimited and this will continually add to a list of edges. For inputs,
|
||||
* there can only be one edge and adding a second will destroy the first.
|
||||
*
|
||||
* @param edge
|
||||
*
|
||||
* The edge to add (output) or replace the current edge (input).
|
||||
*/
|
||||
static void ConnectEdge(NodeIO* output, NodeIO* input);
|
||||
|
||||
/**
|
||||
* @brief Disconnect an edge
|
||||
*
|
||||
* Disconnects two nodes and destroys the edge object connecting them together
|
||||
*
|
||||
* @param edge
|
||||
*
|
||||
* Edge to be removed
|
||||
*/
|
||||
static void DisconnectEdge(NodeEdgePtr edge);
|
||||
|
||||
/**
|
||||
* @brief Get a list of references to all edges currently connected to this row
|
||||
*/
|
||||
QVector<NodeEdgePtr> edges();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a field to this row
|
||||
*
|
||||
* Ownership of the EffectField is transferred to this row and the row will free its memory. In the Effect's UI, this
|
||||
* will add the field to an additional column.
|
||||
*
|
||||
* @param Field
|
||||
*
|
||||
* The field to add to this row.
|
||||
*/
|
||||
void AddField(EffectField* Field);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Go to previous keyframe
|
||||
*
|
||||
* Gets the closest keyframe prior to the current playhead and seeks to it.
|
||||
*
|
||||
* Attach to KeyframeNavigator::goto_previous_key() signal.
|
||||
*/
|
||||
void GoToPreviousKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Toggle a keyframe at this point in time
|
||||
*
|
||||
* Either deletes (if any child EffectFields have any keyframes here) or creates (if none do) a keyframe on all
|
||||
* EffectField children at the current time.
|
||||
*
|
||||
* Attach to KeyframeNavigator::toggle_key() signal.
|
||||
*/
|
||||
void ToggleKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Go to next keyframe
|
||||
*
|
||||
* Gets the closest keyframe after the current playhead and seeks to it.
|
||||
*
|
||||
* Attach to KeyframeNavigator::goto_next_key() signal.
|
||||
*/
|
||||
void GoToNextKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Slot for whenever this EffectRow is focused.
|
||||
*
|
||||
* Connect UI objects gaining focus to this slot. Automatically updates the Graph Editor to attach to this row.
|
||||
*/
|
||||
void FocusRow();
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief Keyframing setting changed signal
|
||||
*
|
||||
* Emitted whenever keyframing is enabled or disabled.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* True if keyframing was enabled, false if keyframing was disabled.
|
||||
*/
|
||||
void KeyframingSetChanged(bool);
|
||||
|
||||
/**
|
||||
* @brief Changed signal
|
||||
*
|
||||
* Wrapper for EffectField::Changed().
|
||||
*/
|
||||
void Changed();
|
||||
|
||||
/**
|
||||
* @brief Clicked signal
|
||||
*
|
||||
* Wrapper for EffectField::Clicked().
|
||||
*/
|
||||
void Clicked();
|
||||
|
||||
/**
|
||||
* @brief Edges changed signal
|
||||
*
|
||||
* Signal emitted any time an edge is connected or disconnected from this row
|
||||
*/
|
||||
void EdgesChanged();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Set keyframing enabled state
|
||||
*
|
||||
* A user-friendly function for enabling or disabling keyframes on this row. Preferred to SetKeyframingInternal()
|
||||
* for any user-initiated change. Automatically creates an undoable action so users can undo the enabling/disabling.
|
||||
* Also confirms with the user when disabling keyframing whether they wish to continue and remove all the current
|
||||
* keyframes.
|
||||
*
|
||||
* Attach to KeyframeNavigator::keyframe_enabled_changed() signal.
|
||||
*/
|
||||
void SetKeyframingEnabled(bool);
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Internal unique identifier for this field set in the constructor. Access with id().
|
||||
*/
|
||||
QString id_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for the row's name
|
||||
*
|
||||
* Set in the constructor, retrieved with name().
|
||||
*/
|
||||
QString name_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row can be keyframed.
|
||||
*
|
||||
* Set in the constructor, retrieved with IsKeyframable().
|
||||
*/
|
||||
bool keyframable_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row is currently keyframing.
|
||||
*
|
||||
* Set by SetKeyframingInternal() and retrieved with IsKeyframing().
|
||||
*/
|
||||
bool keyframing_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row should be saved.
|
||||
*
|
||||
* Set in the constructor, retrieved with IsSavable().
|
||||
*/
|
||||
bool savable_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of EffectField objects.
|
||||
*
|
||||
* It is not necessary to delete the elements in this array as they're already children of this QObject, so they'll
|
||||
* get freed automatically.
|
||||
*/
|
||||
QVector<EffectField*> fields_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of accepted node data types.
|
||||
*
|
||||
* Is mutally-exclusive with accepted_outputs_, i.e. you cannot have values added to this and also a value set in
|
||||
* accepted_outputs_.
|
||||
*/
|
||||
QVector<olive::nodes::DataType> accepted_inputs_;
|
||||
|
||||
/**
|
||||
* @brief Internal value for what kind of data this row outputs
|
||||
*
|
||||
* Is mutally-exclusive with accepted_inputs_, i.e. you cannot have values added to it and also a value set in
|
||||
* this.
|
||||
*/
|
||||
olive::nodes::DataType output_type_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of node edges. Access with AddEdge() and RemoveEdge().
|
||||
*/
|
||||
QVector<NodeEdgePtr> node_edges_;
|
||||
|
||||
/**
|
||||
* @brief Internal data object for rows without fields
|
||||
*/
|
||||
QVariant data_;
|
||||
};
|
||||
|
||||
#endif // EFFECTROW_H
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef EFFECTROW_H
|
||||
#define EFFECTROW_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class Node;
|
||||
class QGridLayout;
|
||||
class EffectField;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class ComboAction;
|
||||
class QHBoxLayout;
|
||||
class KeyframeNavigator;
|
||||
class ClickableLabel;
|
||||
|
||||
#include "effects/effectfields.h"
|
||||
#include "nodes/nodeedge.h"
|
||||
|
||||
/**
|
||||
* @brief The EffectRow class
|
||||
*
|
||||
* Primarily a way of grouping EffectField objects together. As UI objects, Effects are largely formatted as a table
|
||||
* and you can think of EffectRows as the rows of the table and EffectFields as the columns.
|
||||
*
|
||||
* Within Olive, keyframing is enabled on the EffectRow (rather than individual EffectFields) so all attached fields
|
||||
* will be keyframed together.
|
||||
*
|
||||
* Unlike EffectField, there's no reason to derive from EffectRow as it's simply a container of fields and a few
|
||||
* keyframe functions.
|
||||
*/
|
||||
class NodeIO : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief EffectRow Constructor
|
||||
*
|
||||
* @param parent
|
||||
*
|
||||
* Every EffectRow object must be attached to a valid Effect object. The Effect object takes ownership of the
|
||||
* EffectRow and automatically frees it through the QObject parent/child system. EffectRows are never intended to
|
||||
* change parents throughout their lifetimes.
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* Field ID. Must be non-empty. Must also be unique within this Effect. Used for saving/loading values into project
|
||||
* files so that if ordering of fields are changed, or fields are added/removed from Effects later in development,
|
||||
* saved values in project files will still link with the correct field. Also used as the uniform variable name
|
||||
* in GLSL shaders.
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* Row name. This is not used as an internal identifier, it's just for the user interface, so it can be translated
|
||||
* with no issue.
|
||||
*
|
||||
* @param savable
|
||||
*
|
||||
* Whether the fields in this row should be saved to the project file. This is true by default. If the row contains
|
||||
* non-value UI widgets, setting this to false is recommended.
|
||||
*
|
||||
* @param keyframable
|
||||
*
|
||||
* Whether keyframing can be enabled on this row or not. This is true by default. Some values you may want to prevent
|
||||
* the user from keyframing (e.g. the filename of a VST plugin), which can be done by setting this to false.
|
||||
*/
|
||||
NodeIO(Node* parent,
|
||||
const QString& id,
|
||||
const QString& name,
|
||||
bool savable = true,
|
||||
bool keyframable = true);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the EffectField at this index. Must be less than FieldCount().
|
||||
*
|
||||
* @param i
|
||||
*
|
||||
* Index to retrieve the EffectField at.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* EffectField at the provided index.
|
||||
*/
|
||||
EffectField* Field(int i);
|
||||
|
||||
/**
|
||||
* @brief Number of fields currently contained in this row.
|
||||
*
|
||||
* @return The number of fields currently contained in this row as an integer. Any field index (retrieved with
|
||||
* Field()) is guaranteed to be valid >= 0 and < FieldCount().
|
||||
*/
|
||||
int FieldCount();
|
||||
|
||||
/**
|
||||
* @brief Set a keyframe at the current playhead on all fields contained within this row
|
||||
*
|
||||
* @param ca
|
||||
*
|
||||
* The ComboAction to add this action to. This may not be nullptr.
|
||||
*/
|
||||
void SetKeyframeOnAllFields(ComboAction *ca);
|
||||
|
||||
/**
|
||||
* @brief Get parent Effect
|
||||
*
|
||||
* Equivalent to `static_cast<Effect*>(parent())`.
|
||||
*
|
||||
* @return The parent Effect object that this row is attached to.
|
||||
*/
|
||||
Node* ParentNode();
|
||||
|
||||
/**
|
||||
* @brief Return the row's name
|
||||
*
|
||||
* @return The name specified in the constructor as a QString
|
||||
*/
|
||||
const QString& name();
|
||||
|
||||
/**
|
||||
* @brief Get the unique identifier of this field set in the constructor
|
||||
*
|
||||
* Mostly used for saving/loading or interacting with GLSL-based shader effects (see EffectField() for more details).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
const QString& id();
|
||||
|
||||
/**
|
||||
* @brief Get whether this row is keyframing or not
|
||||
*
|
||||
* @return True if this row is keyframing.
|
||||
*/
|
||||
bool IsKeyframing();
|
||||
|
||||
/**
|
||||
* @brief Set whether this row is keyframing or not.
|
||||
*
|
||||
* It's not recommended to use this function for any user-initiated keyframe setting change as it doesn't create any
|
||||
* undoable actions. Use SetKeyframingEnabled() instead for a user-friendly variant.
|
||||
*/
|
||||
void SetKeyframingInternal(bool);
|
||||
|
||||
/**
|
||||
* @brief Get whether this row should be saved into a project file or not
|
||||
*
|
||||
* @return True if this row should be saved. This value is set in the constructor.
|
||||
*/
|
||||
bool IsSavable();
|
||||
|
||||
/**
|
||||
* @brief Get whether this row can be keyframed or not.
|
||||
*
|
||||
* @return True if this row can be keyframed. This value is set in the constructor.
|
||||
*/
|
||||
bool IsKeyframable();
|
||||
|
||||
/**
|
||||
* @brief Get value
|
||||
*
|
||||
* A convenience value for a parameters that doesn't keyframe. Equivalent to GetValueAt(0) where the parameter
|
||||
* doesn't keyframe so the 0 is ignored.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
QVariant GetValue();
|
||||
|
||||
/**
|
||||
* @brief Get value at a given timecode
|
||||
*
|
||||
* Functions as a wrapper for EffectField::GetValueAt().
|
||||
*
|
||||
* The default function is to return the result of the first EffectField on this EffectRow which should be sufficient
|
||||
* for most input types. If this EffectRow has more or less than one EffectField, you must override this function in a
|
||||
* derived class to provide the correct field <-> row coordination or else it will trigger an abort.
|
||||
*
|
||||
* @param timecode
|
||||
*
|
||||
* Timecode to get the value at
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The value of the first EffectField at the given timecode
|
||||
*/
|
||||
virtual QVariant GetValueAt(double timecode);
|
||||
|
||||
/**
|
||||
* @brief Set value
|
||||
*
|
||||
* A convenience value for a parameters that doesn't keyframe. Equivalent to SetValueAt(0, value) where the parameter
|
||||
* doesn't keyframe so the 0 is ignored.
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetValue(const QVariant& value);
|
||||
|
||||
/**
|
||||
* @brief SetValueAt
|
||||
*
|
||||
* Functions as a wrapper for EffectField::SetValueAt().
|
||||
*
|
||||
* The default function is to call the function of the first EffectField on this EffectRow which should be sufficient
|
||||
* for most input types. If this EffectRow has more or less than one EffectField, you must override this function in a
|
||||
* derived class to provide the correct field <-> row coordination or else it will trigger an abort.
|
||||
*
|
||||
* @param timecode
|
||||
*
|
||||
* Timecode to set the value at
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* Value to set at this timecode
|
||||
*/
|
||||
virtual void SetValueAt(double timecode, const QVariant& value);
|
||||
|
||||
/**
|
||||
* @brief Sets the enabled state on all EffectField objects on this row to enabled
|
||||
*/
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Check if nodes can be connected to this as an input.
|
||||
*
|
||||
* Connecting is enabled by adding an accepted node input using AddNodeInput().
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if nodes can be connected as an input.
|
||||
*/
|
||||
bool IsNodeInput();
|
||||
|
||||
/**
|
||||
* @brief Check if nodes can be connected to this as an output
|
||||
*
|
||||
* Connecting is enabled by setting an output data type in SetOutputDataType().
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if nodes can be connected as an output
|
||||
*/
|
||||
bool IsNodeOutput();
|
||||
|
||||
/**
|
||||
* @brief Set output data type
|
||||
*
|
||||
* Set the type of data this row outputs to type
|
||||
*/
|
||||
void SetOutputDataType(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Check if this row can accept the data type specified in type
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* TRUE if this row can accept this data type. If this row is not an input, this function will always return FALSE.
|
||||
*/
|
||||
bool CanAcceptDataType(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Get this row's output data type
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* If this is not an output, this will always return olive::nodes::kInvalid
|
||||
*/
|
||||
olive::nodes::DataType OutputDataType();
|
||||
|
||||
/**
|
||||
* @brief Adds a node data type that can be accepted by this input
|
||||
*
|
||||
* Allows this input to take a node connection from a data type specified by type. An input can take several data
|
||||
* types.
|
||||
*
|
||||
* @param type
|
||||
*
|
||||
* The data type to add
|
||||
*/
|
||||
void AddAcceptedNodeInput(olive::nodes::DataType type);
|
||||
|
||||
/**
|
||||
* @brief Connect two node sockets together
|
||||
*
|
||||
* For outputs, the maximum amount of edges is unlimited and this will continually add to a list of edges. For inputs,
|
||||
* there can only be one edge and adding a second will destroy the first.
|
||||
*
|
||||
* @param edge
|
||||
*
|
||||
* The edge to add (output) or replace the current edge (input).
|
||||
*/
|
||||
static void ConnectEdge(NodeIO* output, NodeIO* input);
|
||||
|
||||
/**
|
||||
* @brief Disconnect an edge
|
||||
*
|
||||
* Disconnects two nodes and destroys the edge object connecting them together
|
||||
*
|
||||
* @param edge
|
||||
*
|
||||
* Edge to be removed
|
||||
*/
|
||||
static void DisconnectEdge(NodeEdgePtr edge);
|
||||
|
||||
/**
|
||||
* @brief Get a list of references to all edges currently connected to this row
|
||||
*/
|
||||
QVector<NodeEdgePtr> edges();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a field to this row
|
||||
*
|
||||
* Ownership of the EffectField is transferred to this row and the row will free its memory. In the Effect's UI, this
|
||||
* will add the field to an additional column.
|
||||
*
|
||||
* @param Field
|
||||
*
|
||||
* The field to add to this row.
|
||||
*/
|
||||
void AddField(EffectField* Field);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Go to previous keyframe
|
||||
*
|
||||
* Gets the closest keyframe prior to the current playhead and seeks to it.
|
||||
*
|
||||
* Attach to KeyframeNavigator::goto_previous_key() signal.
|
||||
*/
|
||||
void GoToPreviousKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Toggle a keyframe at this point in time
|
||||
*
|
||||
* Either deletes (if any child EffectFields have any keyframes here) or creates (if none do) a keyframe on all
|
||||
* EffectField children at the current time.
|
||||
*
|
||||
* Attach to KeyframeNavigator::toggle_key() signal.
|
||||
*/
|
||||
void ToggleKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Go to next keyframe
|
||||
*
|
||||
* Gets the closest keyframe after the current playhead and seeks to it.
|
||||
*
|
||||
* Attach to KeyframeNavigator::goto_next_key() signal.
|
||||
*/
|
||||
void GoToNextKeyframe();
|
||||
|
||||
/**
|
||||
* @brief Slot for whenever this EffectRow is focused.
|
||||
*
|
||||
* Connect UI objects gaining focus to this slot. Automatically updates the Graph Editor to attach to this row.
|
||||
*/
|
||||
void FocusRow();
|
||||
signals:
|
||||
|
||||
/**
|
||||
* @brief Keyframing setting changed signal
|
||||
*
|
||||
* Emitted whenever keyframing is enabled or disabled.
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* True if keyframing was enabled, false if keyframing was disabled.
|
||||
*/
|
||||
void KeyframingSetChanged(bool);
|
||||
|
||||
/**
|
||||
* @brief Changed signal
|
||||
*
|
||||
* Wrapper for EffectField::Changed().
|
||||
*/
|
||||
void Changed();
|
||||
|
||||
/**
|
||||
* @brief Clicked signal
|
||||
*
|
||||
* Wrapper for EffectField::Clicked().
|
||||
*/
|
||||
void Clicked();
|
||||
|
||||
/**
|
||||
* @brief Edges changed signal
|
||||
*
|
||||
* Signal emitted any time an edge is connected or disconnected from this row
|
||||
*/
|
||||
void EdgesChanged();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Set keyframing enabled state
|
||||
*
|
||||
* A user-friendly function for enabling or disabling keyframes on this row. Preferred to SetKeyframingInternal()
|
||||
* for any user-initiated change. Automatically creates an undoable action so users can undo the enabling/disabling.
|
||||
* Also confirms with the user when disabling keyframing whether they wish to continue and remove all the current
|
||||
* keyframes.
|
||||
*
|
||||
* Attach to KeyframeNavigator::keyframe_enabled_changed() signal.
|
||||
*/
|
||||
void SetKeyframingEnabled(bool);
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Internal unique identifier for this field set in the constructor. Access with id().
|
||||
*/
|
||||
QString id_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for the row's name
|
||||
*
|
||||
* Set in the constructor, retrieved with name().
|
||||
*/
|
||||
QString name_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row can be keyframed.
|
||||
*
|
||||
* Set in the constructor, retrieved with IsKeyframable().
|
||||
*/
|
||||
bool keyframable_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row is currently keyframing.
|
||||
*
|
||||
* Set by SetKeyframingInternal() and retrieved with IsKeyframing().
|
||||
*/
|
||||
bool keyframing_;
|
||||
|
||||
/**
|
||||
* @brief Internal variable for whether this row should be saved.
|
||||
*
|
||||
* Set in the constructor, retrieved with IsSavable().
|
||||
*/
|
||||
bool savable_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of EffectField objects.
|
||||
*
|
||||
* It is not necessary to delete the elements in this array as they're already children of this QObject, so they'll
|
||||
* get freed automatically.
|
||||
*/
|
||||
QVector<EffectField*> fields_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of accepted node data types.
|
||||
*
|
||||
* Is mutally-exclusive with accepted_outputs_, i.e. you cannot have values added to this and also a value set in
|
||||
* accepted_outputs_.
|
||||
*/
|
||||
QVector<olive::nodes::DataType> accepted_inputs_;
|
||||
|
||||
/**
|
||||
* @brief Internal value for what kind of data this row outputs
|
||||
*
|
||||
* Is mutally-exclusive with accepted_inputs_, i.e. you cannot have values added to it and also a value set in
|
||||
* this.
|
||||
*/
|
||||
olive::nodes::DataType output_type_;
|
||||
|
||||
/**
|
||||
* @brief Internal array of node edges. Access with AddEdge() and RemoveEdge().
|
||||
*/
|
||||
QVector<NodeEdgePtr> node_edges_;
|
||||
|
||||
/**
|
||||
* @brief Internal data object for rows without fields
|
||||
*/
|
||||
QVariant data_;
|
||||
};
|
||||
|
||||
#endif // EFFECTROW_H
|
||||
|
||||
+72
-72
@@ -1,72 +1,72 @@
|
||||
#include "nodeblock.h"
|
||||
|
||||
NodeBlock::NodeBlock(NodeGraph *graph) :
|
||||
Node(graph)
|
||||
{
|
||||
previous_block_ = new NodeIO(this, "prev_block", tr("Previous"), true, false);
|
||||
previous_block_->AddAcceptedNodeInput(olive::nodes::kBlock);
|
||||
previous_block_->SetValue(0);
|
||||
AddParameter(previous_block_);
|
||||
|
||||
next_block_ = new NodeIO(this, "next_block", tr("Next"), true, false);
|
||||
next_block_->SetOutputDataType(olive::nodes::kBlock);
|
||||
next_block_->SetValue(0);
|
||||
AddParameter(next_block_);
|
||||
}
|
||||
|
||||
rational NodeBlock::track_in()
|
||||
{
|
||||
rational in_point;
|
||||
|
||||
NodeBlock* previous = previous_block();
|
||||
while (previous != nullptr) {
|
||||
in_point += previous->length();
|
||||
}
|
||||
|
||||
return in_point;
|
||||
}
|
||||
|
||||
rational NodeBlock::track_out()
|
||||
{
|
||||
return track_in() + length();
|
||||
}
|
||||
|
||||
const rational &NodeBlock::length()
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
void NodeBlock::set_length(const rational &l)
|
||||
{
|
||||
length_ = l;
|
||||
}
|
||||
|
||||
QString NodeBlock::name()
|
||||
{
|
||||
return tr("Block");
|
||||
}
|
||||
|
||||
QString NodeBlock::id()
|
||||
{
|
||||
return "block";
|
||||
}
|
||||
|
||||
NodeBlock *NodeBlock::previous_block()
|
||||
{
|
||||
return reinterpret_cast<NodeBlock*>(previous_block_->GetValue().value<quintptr>());
|
||||
}
|
||||
|
||||
void NodeBlock::set_previous_block(NodeBlock *p)
|
||||
{
|
||||
previous_block_->SetValue(reinterpret_cast<quintptr>(p));
|
||||
}
|
||||
|
||||
NodeBlock *NodeBlock::next_block()
|
||||
{
|
||||
return reinterpret_cast<NodeBlock*>(next_block_->GetValue().value<quintptr>());
|
||||
}
|
||||
|
||||
void NodeBlock::set_next_block(NodeBlock *p)
|
||||
{
|
||||
next_block_->SetValue(reinterpret_cast<quintptr>(p));
|
||||
}
|
||||
#include "nodeblock.h"
|
||||
|
||||
NodeBlock::NodeBlock(NodeGraph *graph) :
|
||||
Node(graph)
|
||||
{
|
||||
previous_block_ = new NodeIO(this, "prev_block", tr("Previous"), true, false);
|
||||
previous_block_->AddAcceptedNodeInput(olive::nodes::kBlock);
|
||||
previous_block_->SetValue(0);
|
||||
AddParameter(previous_block_);
|
||||
|
||||
next_block_ = new NodeIO(this, "next_block", tr("Next"), true, false);
|
||||
next_block_->SetOutputDataType(olive::nodes::kBlock);
|
||||
next_block_->SetValue(0);
|
||||
AddParameter(next_block_);
|
||||
}
|
||||
|
||||
rational NodeBlock::track_in()
|
||||
{
|
||||
rational in_point;
|
||||
|
||||
NodeBlock* previous = previous_block();
|
||||
while (previous != nullptr) {
|
||||
in_point += previous->length();
|
||||
}
|
||||
|
||||
return in_point;
|
||||
}
|
||||
|
||||
rational NodeBlock::track_out()
|
||||
{
|
||||
return track_in() + length();
|
||||
}
|
||||
|
||||
const rational &NodeBlock::length()
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
void NodeBlock::set_length(const rational &l)
|
||||
{
|
||||
length_ = l;
|
||||
}
|
||||
|
||||
QString NodeBlock::name()
|
||||
{
|
||||
return tr("Block");
|
||||
}
|
||||
|
||||
QString NodeBlock::id()
|
||||
{
|
||||
return "block";
|
||||
}
|
||||
|
||||
NodeBlock *NodeBlock::previous_block()
|
||||
{
|
||||
return reinterpret_cast<NodeBlock*>(previous_block_->GetValue().value<quintptr>());
|
||||
}
|
||||
|
||||
void NodeBlock::set_previous_block(NodeBlock *p)
|
||||
{
|
||||
previous_block_->SetValue(reinterpret_cast<quintptr>(p));
|
||||
}
|
||||
|
||||
NodeBlock *NodeBlock::next_block()
|
||||
{
|
||||
return reinterpret_cast<NodeBlock*>(next_block_->GetValue().value<quintptr>());
|
||||
}
|
||||
|
||||
void NodeBlock::set_next_block(NodeBlock *p)
|
||||
{
|
||||
next_block_->SetValue(reinterpret_cast<quintptr>(p));
|
||||
}
|
||||
|
||||
+48
-48
@@ -1,48 +1,48 @@
|
||||
#ifndef NODEBLOCK_H
|
||||
#define NODEBLOCK_H
|
||||
|
||||
#include "global/rational.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
/**
|
||||
* @brief The NodeBlock class
|
||||
*
|
||||
* A "Block" node is a node with a timed in-point and out-point that can appear on the Timeline.
|
||||
*/
|
||||
class NodeBlock : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeBlock(NodeGraph* graph);
|
||||
|
||||
rational track_in();
|
||||
rational track_out();
|
||||
|
||||
const rational& length();
|
||||
void set_length(const rational& l);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the NodeBlock connected to the "Previous" parameter
|
||||
*/
|
||||
NodeBlock* previous_block();
|
||||
void set_previous_block(NodeBlock* p);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the NodeBlock connected to the "Next" parameter
|
||||
*/
|
||||
NodeBlock* next_block();
|
||||
void set_next_block(NodeBlock* p);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
rational length_;
|
||||
|
||||
NodeIO* previous_block_;
|
||||
NodeIO* next_block_;
|
||||
};
|
||||
|
||||
#endif // NODEBLOCK_H
|
||||
#ifndef NODEBLOCK_H
|
||||
#define NODEBLOCK_H
|
||||
|
||||
#include "global/rational.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
/**
|
||||
* @brief The NodeBlock class
|
||||
*
|
||||
* A "Block" node is a node with a timed in-point and out-point that can appear on the Timeline.
|
||||
*/
|
||||
class NodeBlock : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeBlock(NodeGraph* graph);
|
||||
|
||||
rational track_in();
|
||||
rational track_out();
|
||||
|
||||
const rational& length();
|
||||
void set_length(const rational& l);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the NodeBlock connected to the "Previous" parameter
|
||||
*/
|
||||
NodeBlock* previous_block();
|
||||
void set_previous_block(NodeBlock* p);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the NodeBlock connected to the "Next" parameter
|
||||
*/
|
||||
NodeBlock* next_block();
|
||||
void set_next_block(NodeBlock* p);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
rational length_;
|
||||
|
||||
NodeIO* previous_block_;
|
||||
NodeIO* next_block_;
|
||||
};
|
||||
|
||||
#endif // NODEBLOCK_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include "nodevideoclip.h"
|
||||
|
||||
NodeVideoClip::NodeVideoClip(NodeGraph *parent) :
|
||||
NodeBlock(parent)
|
||||
{
|
||||
texture_input_ = new NodeIO(this, "texture", tr("Texture"), true, false);
|
||||
texture_input_->AddAcceptedNodeInput(olive::nodes::kTexture);
|
||||
|
||||
texture_output_ = new NodeIO(this, "texture", tr("Texture"), true, false);
|
||||
texture_output_->SetOutputDataType(olive::nodes::kTexture);
|
||||
}
|
||||
|
||||
NodeIO *NodeVideoClip::texture_output()
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
#include "nodevideoclip.h"
|
||||
|
||||
NodeVideoClip::NodeVideoClip(NodeGraph *parent) :
|
||||
NodeBlock(parent)
|
||||
{
|
||||
texture_input_ = new NodeIO(this, "texture", tr("Texture"), true, false);
|
||||
texture_input_->AddAcceptedNodeInput(olive::nodes::kTexture);
|
||||
|
||||
texture_output_ = new NodeIO(this, "texture", tr("Texture"), true, false);
|
||||
texture_output_->SetOutputDataType(olive::nodes::kTexture);
|
||||
}
|
||||
|
||||
NodeIO *NodeVideoClip::texture_output()
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
+19
-19
@@ -1,19 +1,19 @@
|
||||
#ifndef NODEVIDEOCLIP_H
|
||||
#define NODEVIDEOCLIP_H
|
||||
|
||||
#include "nodeblock.h"
|
||||
|
||||
class NodeVideoClip : public NodeBlock
|
||||
{
|
||||
public:
|
||||
NodeVideoClip(NodeGraph* parent);
|
||||
|
||||
NodeIO* texture_input();
|
||||
NodeIO* texture_output();
|
||||
|
||||
private:
|
||||
NodeIO* texture_input_;
|
||||
NodeIO* texture_output_;
|
||||
};
|
||||
|
||||
#endif // NODEVIDEOCLIP_H
|
||||
#ifndef NODEVIDEOCLIP_H
|
||||
#define NODEVIDEOCLIP_H
|
||||
|
||||
#include "nodeblock.h"
|
||||
|
||||
class NodeVideoClip : public NodeBlock
|
||||
{
|
||||
public:
|
||||
NodeVideoClip(NodeGraph* parent);
|
||||
|
||||
NodeIO* texture_input();
|
||||
NodeIO* texture_output();
|
||||
|
||||
private:
|
||||
NodeIO* texture_input_;
|
||||
NodeIO* texture_output_;
|
||||
};
|
||||
|
||||
#endif // NODEVIDEOCLIP_H
|
||||
|
||||
+920
-920
File diff suppressed because it is too large
Load Diff
+281
-281
@@ -1,281 +1,281 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef EFFECT_H
|
||||
#define EFFECT_H
|
||||
|
||||
#include <memory>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMouseEvent>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <random>
|
||||
|
||||
#include "timeline/tracktypes.h"
|
||||
#include "rendering/qopenglshaderprogramptr.h"
|
||||
#include "inputs.h"
|
||||
#include "effects/effectgizmo.h"
|
||||
#include "node.h"
|
||||
|
||||
class EffectGizmo;
|
||||
class KeyframeDataChange;
|
||||
|
||||
class Clip;
|
||||
using ClipPtr = std::shared_ptr<Clip>;
|
||||
|
||||
class OldEffectNode;
|
||||
using OldEffectNodePtr = std::shared_ptr<OldEffectNode>;
|
||||
|
||||
enum NodeType {
|
||||
kTransformEffect,
|
||||
kTextInput,
|
||||
kSolidInput,
|
||||
kNoiseInput,
|
||||
kVolumeEffect,
|
||||
kPanEffect,
|
||||
kToneInput,
|
||||
kShakeEffect,
|
||||
kTimecodeEffect,
|
||||
kMaskEffect,
|
||||
kFillLeftRightEffect,
|
||||
kVstEffect,
|
||||
kCornerPinEffect,
|
||||
kRichTextInput,
|
||||
kMediaInput,
|
||||
kShaderEffect,
|
||||
kImageOutput,
|
||||
kCrossDissolveTransition,
|
||||
kLinearFadeTransition,
|
||||
kExponentialFadeTransition,
|
||||
kLogarithmicFadeTransition,
|
||||
kInvalidNode
|
||||
};
|
||||
|
||||
double log_volume(double linear);
|
||||
|
||||
enum EffectType {
|
||||
EFFECT_TYPE_INVALID,
|
||||
EFFECT_TYPE_EFFECT,
|
||||
EFFECT_TYPE_TRANSITION
|
||||
};
|
||||
|
||||
enum EffectKeyframeType {
|
||||
EFFECT_KEYFRAME_LINEAR,
|
||||
EFFECT_KEYFRAME_BEZIER,
|
||||
EFFECT_KEYFRAME_HOLD
|
||||
};
|
||||
|
||||
struct GLTextureCoords {
|
||||
QMatrix4x4 matrix;
|
||||
|
||||
QVector3D vertex_top_left;
|
||||
QVector3D vertex_top_right;
|
||||
QVector3D vertex_bottom_left;
|
||||
QVector3D vertex_bottom_right;
|
||||
|
||||
QVector2D texture_top_left;
|
||||
QVector2D texture_top_right;
|
||||
QVector2D texture_bottom_left;
|
||||
QVector2D texture_bottom_right;
|
||||
|
||||
float opacity;
|
||||
};
|
||||
|
||||
class OldEffectNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OldEffectNode(Clip *c);
|
||||
~OldEffectNode();
|
||||
|
||||
Clip* parent_clip;
|
||||
|
||||
virtual QString name() = 0;
|
||||
virtual QString id() = 0;
|
||||
virtual QString category();
|
||||
virtual QString description();
|
||||
virtual EffectType type() = 0;
|
||||
virtual olive::TrackType subtype() = 0;
|
||||
virtual bool IsCreatable();
|
||||
virtual OldEffectNodePtr Create(Clip *c) = 0;
|
||||
|
||||
EffectGizmo* add_gizmo(int type);
|
||||
EffectGizmo* gizmo(int i);
|
||||
int gizmo_count();
|
||||
|
||||
QVector<NodeEdgePtr> GetAllEdges();
|
||||
|
||||
bool IsEnabled();
|
||||
bool IsExpanded();
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
virtual OldEffectNodePtr copy(Clip* c);
|
||||
void copy_field_keyframes(OldEffectNodePtr e);
|
||||
|
||||
virtual void load(QXmlStreamReader& stream);
|
||||
virtual void custom_load(QXmlStreamReader& stream);
|
||||
virtual void save(QXmlStreamWriter& stream);
|
||||
|
||||
void load_from_string(const QByteArray &s);
|
||||
QByteArray save_to_string();
|
||||
|
||||
// glsl handling
|
||||
bool is_open();
|
||||
void open();
|
||||
void close();
|
||||
bool is_shader_linked();
|
||||
QOpenGLShaderProgram* GetShaderPipeline();
|
||||
|
||||
enum VideoEffectFlags {
|
||||
ShaderFlag = 0x1,
|
||||
CoordsFlag = 0x2,
|
||||
SuperimposeFlag = 0x4
|
||||
};
|
||||
int Flags();
|
||||
void SetFlags(int flags);
|
||||
|
||||
int getIterations();
|
||||
void setIterations(int i);
|
||||
|
||||
|
||||
|
||||
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
|
||||
virtual void process_shader(double timecode, GLTextureCoords&, int iteration);
|
||||
virtual void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||
virtual GLuint process_superimpose(QOpenGLContext *ctx, double timecode);
|
||||
virtual void process_audio(double timecode_start, double timecode_end, float **samples, int nb_samples, int nb_channels, int type);
|
||||
|
||||
virtual void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode, bool done);
|
||||
void gizmo_world_to_screen(const QMatrix4x4 &matrix, const QMatrix4x4 &projection);
|
||||
bool are_gizmos_enabled();
|
||||
|
||||
/**
|
||||
* @brief Get the current clip/media time
|
||||
*
|
||||
* A convenience function that can be plugged into GetValueAt() to get the value wherever the appropriate Sequence's
|
||||
* playhead it.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Current clip/media time in seconds.
|
||||
*/
|
||||
double Now();
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current clip as a frame number
|
||||
*
|
||||
* Same as Now() but retrieves the value as a frame number (in the appropriate Sequence's frame rate) instead of
|
||||
* seconds.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The current clip time in frames
|
||||
*/
|
||||
long NowInFrames();
|
||||
|
||||
template <typename T>
|
||||
T randomNumber()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::mt19937 generator(device());
|
||||
static std::uniform_int_distribution<> distribution(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
|
||||
return distribution(generator);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T randomFloat()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::mt19937 generator(device());
|
||||
static std::uniform_int_distribution<> distribution(-1.0, 1.0);
|
||||
return distribution(generator);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void FieldChanged();
|
||||
void SetEnabled(bool b);
|
||||
void SetExpanded(bool e);
|
||||
|
||||
signals:
|
||||
void EnabledChanged(bool);
|
||||
private slots:
|
||||
void delete_self();
|
||||
void move_up();
|
||||
void move_down();
|
||||
void save_to_file();
|
||||
void load_from_file();
|
||||
protected:
|
||||
// glsl effect
|
||||
QOpenGLShaderProgramPtr shader_program_;
|
||||
QString shader_vert_path_;
|
||||
QString shader_frag_path_;
|
||||
QString shader_function_name_;
|
||||
|
||||
// superimpose effect
|
||||
QImage img;
|
||||
GLuint texture;
|
||||
QOpenGLContext* texture_ctx;
|
||||
int tex_width_;
|
||||
int tex_height_;
|
||||
|
||||
// enable effect to update constantly
|
||||
virtual bool AlwaysUpdate();
|
||||
|
||||
private:
|
||||
bool isOpen;
|
||||
QVector<EffectGizmo*> gizmos;
|
||||
bool bound;
|
||||
int iterations;
|
||||
|
||||
bool enabled_;
|
||||
bool expanded_;
|
||||
|
||||
int flags_;
|
||||
|
||||
QVector<KeyframeDataChange*> gizmo_dragging_actions_;
|
||||
|
||||
|
||||
|
||||
// superimpose functions
|
||||
virtual void redraw(double timecode);
|
||||
bool valueHasChanged(double timecode);
|
||||
QVector<QVariant> cachedValues;
|
||||
void delete_texture();
|
||||
void validate_meta_path();
|
||||
};
|
||||
|
||||
namespace olive {
|
||||
extern QVector<OldEffectNodePtr> node_library;
|
||||
}
|
||||
|
||||
#endif // EFFECT_H
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef EFFECT_H
|
||||
#define EFFECT_H
|
||||
|
||||
#include <memory>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMouseEvent>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <random>
|
||||
|
||||
#include "timeline/tracktypes.h"
|
||||
#include "rendering/qopenglshaderprogramptr.h"
|
||||
#include "inputs.h"
|
||||
#include "effects/effectgizmo.h"
|
||||
#include "node.h"
|
||||
|
||||
class EffectGizmo;
|
||||
class KeyframeDataChange;
|
||||
|
||||
class Clip;
|
||||
using ClipPtr = std::shared_ptr<Clip>;
|
||||
|
||||
class OldEffectNode;
|
||||
using OldEffectNodePtr = std::shared_ptr<OldEffectNode>;
|
||||
|
||||
enum NodeType {
|
||||
kTransformEffect,
|
||||
kTextInput,
|
||||
kSolidInput,
|
||||
kNoiseInput,
|
||||
kVolumeEffect,
|
||||
kPanEffect,
|
||||
kToneInput,
|
||||
kShakeEffect,
|
||||
kTimecodeEffect,
|
||||
kMaskEffect,
|
||||
kFillLeftRightEffect,
|
||||
kVstEffect,
|
||||
kCornerPinEffect,
|
||||
kRichTextInput,
|
||||
kMediaInput,
|
||||
kShaderEffect,
|
||||
kImageOutput,
|
||||
kCrossDissolveTransition,
|
||||
kLinearFadeTransition,
|
||||
kExponentialFadeTransition,
|
||||
kLogarithmicFadeTransition,
|
||||
kInvalidNode
|
||||
};
|
||||
|
||||
double log_volume(double linear);
|
||||
|
||||
enum EffectType {
|
||||
EFFECT_TYPE_INVALID,
|
||||
EFFECT_TYPE_EFFECT,
|
||||
EFFECT_TYPE_TRANSITION
|
||||
};
|
||||
|
||||
enum EffectKeyframeType {
|
||||
EFFECT_KEYFRAME_LINEAR,
|
||||
EFFECT_KEYFRAME_BEZIER,
|
||||
EFFECT_KEYFRAME_HOLD
|
||||
};
|
||||
|
||||
struct GLTextureCoords {
|
||||
QMatrix4x4 matrix;
|
||||
|
||||
QVector3D vertex_top_left;
|
||||
QVector3D vertex_top_right;
|
||||
QVector3D vertex_bottom_left;
|
||||
QVector3D vertex_bottom_right;
|
||||
|
||||
QVector2D texture_top_left;
|
||||
QVector2D texture_top_right;
|
||||
QVector2D texture_bottom_left;
|
||||
QVector2D texture_bottom_right;
|
||||
|
||||
float opacity;
|
||||
};
|
||||
|
||||
class OldEffectNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OldEffectNode(Clip *c);
|
||||
~OldEffectNode();
|
||||
|
||||
Clip* parent_clip;
|
||||
|
||||
virtual QString name() = 0;
|
||||
virtual QString id() = 0;
|
||||
virtual QString category();
|
||||
virtual QString description();
|
||||
virtual EffectType type() = 0;
|
||||
virtual olive::TrackType subtype() = 0;
|
||||
virtual bool IsCreatable();
|
||||
virtual OldEffectNodePtr Create(Clip *c) = 0;
|
||||
|
||||
EffectGizmo* add_gizmo(int type);
|
||||
EffectGizmo* gizmo(int i);
|
||||
int gizmo_count();
|
||||
|
||||
QVector<NodeEdgePtr> GetAllEdges();
|
||||
|
||||
bool IsEnabled();
|
||||
bool IsExpanded();
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
virtual OldEffectNodePtr copy(Clip* c);
|
||||
void copy_field_keyframes(OldEffectNodePtr e);
|
||||
|
||||
virtual void load(QXmlStreamReader& stream);
|
||||
virtual void custom_load(QXmlStreamReader& stream);
|
||||
virtual void save(QXmlStreamWriter& stream);
|
||||
|
||||
void load_from_string(const QByteArray &s);
|
||||
QByteArray save_to_string();
|
||||
|
||||
// glsl handling
|
||||
bool is_open();
|
||||
void open();
|
||||
void close();
|
||||
bool is_shader_linked();
|
||||
QOpenGLShaderProgram* GetShaderPipeline();
|
||||
|
||||
enum VideoEffectFlags {
|
||||
ShaderFlag = 0x1,
|
||||
CoordsFlag = 0x2,
|
||||
SuperimposeFlag = 0x4
|
||||
};
|
||||
int Flags();
|
||||
void SetFlags(int flags);
|
||||
|
||||
int getIterations();
|
||||
void setIterations(int i);
|
||||
|
||||
|
||||
|
||||
virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size);
|
||||
virtual void process_shader(double timecode, GLTextureCoords&, int iteration);
|
||||
virtual void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||
virtual GLuint process_superimpose(QOpenGLContext *ctx, double timecode);
|
||||
virtual void process_audio(double timecode_start, double timecode_end, float **samples, int nb_samples, int nb_channels, int type);
|
||||
|
||||
virtual void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||
void gizmo_move(EffectGizmo* sender, int x_movement, int y_movement, double timecode, bool done);
|
||||
void gizmo_world_to_screen(const QMatrix4x4 &matrix, const QMatrix4x4 &projection);
|
||||
bool are_gizmos_enabled();
|
||||
|
||||
/**
|
||||
* @brief Get the current clip/media time
|
||||
*
|
||||
* A convenience function that can be plugged into GetValueAt() to get the value wherever the appropriate Sequence's
|
||||
* playhead it.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Current clip/media time in seconds.
|
||||
*/
|
||||
double Now();
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current clip as a frame number
|
||||
*
|
||||
* Same as Now() but retrieves the value as a frame number (in the appropriate Sequence's frame rate) instead of
|
||||
* seconds.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* The current clip time in frames
|
||||
*/
|
||||
long NowInFrames();
|
||||
|
||||
template <typename T>
|
||||
T randomNumber()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::mt19937 generator(device());
|
||||
static std::uniform_int_distribution<> distribution(std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
|
||||
return distribution(generator);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T randomFloat()
|
||||
{
|
||||
static std::random_device device;
|
||||
static std::mt19937 generator(device());
|
||||
static std::uniform_int_distribution<> distribution(-1.0, 1.0);
|
||||
return distribution(generator);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void FieldChanged();
|
||||
void SetEnabled(bool b);
|
||||
void SetExpanded(bool e);
|
||||
|
||||
signals:
|
||||
void EnabledChanged(bool);
|
||||
private slots:
|
||||
void delete_self();
|
||||
void move_up();
|
||||
void move_down();
|
||||
void save_to_file();
|
||||
void load_from_file();
|
||||
protected:
|
||||
// glsl effect
|
||||
QOpenGLShaderProgramPtr shader_program_;
|
||||
QString shader_vert_path_;
|
||||
QString shader_frag_path_;
|
||||
QString shader_function_name_;
|
||||
|
||||
// superimpose effect
|
||||
QImage img;
|
||||
GLuint texture;
|
||||
QOpenGLContext* texture_ctx;
|
||||
int tex_width_;
|
||||
int tex_height_;
|
||||
|
||||
// enable effect to update constantly
|
||||
virtual bool AlwaysUpdate();
|
||||
|
||||
private:
|
||||
bool isOpen;
|
||||
QVector<EffectGizmo*> gizmos;
|
||||
bool bound;
|
||||
int iterations;
|
||||
|
||||
bool enabled_;
|
||||
bool expanded_;
|
||||
|
||||
int flags_;
|
||||
|
||||
QVector<KeyframeDataChange*> gizmo_dragging_actions_;
|
||||
|
||||
|
||||
|
||||
// superimpose functions
|
||||
virtual void redraw(double timecode);
|
||||
bool valueHasChanged(double timecode);
|
||||
QVector<QVariant> cachedValues;
|
||||
void delete_texture();
|
||||
void validate_meta_path();
|
||||
};
|
||||
|
||||
namespace olive {
|
||||
extern QVector<OldEffectNodePtr> node_library;
|
||||
}
|
||||
|
||||
#endif // EFFECT_H
|
||||
|
||||
Reference in New Issue
Block a user