multicam: finished UI implementation
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#include "multicamnode.h"
|
||||
|
||||
#include "node/project/sequence/sequence.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString MultiCamNode::kCurrentInput = QStringLiteral("current_in");
|
||||
const QString MultiCamNode::kSourcesInput = QStringLiteral("sources_in");
|
||||
const QString MultiCamNode::kSequenceInput = QStringLiteral("sequence_in");
|
||||
const QString MultiCamNode::kSequenceTypeInput = QStringLiteral("sequence_type_in");
|
||||
|
||||
MultiCamNode::MultiCamNode()
|
||||
{
|
||||
@@ -17,6 +21,11 @@ MultiCamNode::MultiCamNode()
|
||||
|
||||
AddInput(kSourcesInput, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable | kInputFlagArray));
|
||||
SetInputProperty(kSourcesInput, QStringLiteral("arraystart"), 1);
|
||||
|
||||
AddInput(kSequenceInput, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSequenceTypeInput, NodeValue::kCombo, InputFlags(kInputFlagStatic | kInputFlagHidden));
|
||||
|
||||
sequence_ = nullptr;
|
||||
}
|
||||
|
||||
QString MultiCamNode::Name() const
|
||||
@@ -43,7 +52,7 @@ Node::ActiveElements MultiCamNode::GetActiveElementsAtTime(const QString &input,
|
||||
{
|
||||
if (input == kSourcesInput) {
|
||||
int src = GetCurrentSource();
|
||||
if (src >= 0 && src < InputArraySize(kSourcesInput)) {
|
||||
if (src >= 0 && src < GetSourceCount()) {
|
||||
Node::ActiveElements a;
|
||||
a.add(src);
|
||||
return a;
|
||||
@@ -71,12 +80,65 @@ void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols, int
|
||||
*row = index/total_cols;
|
||||
}
|
||||
|
||||
Node *MultiCamNode::GetConnectedRenderOutput(const QString &input, int element) const
|
||||
{
|
||||
if (sequence_ && input == kSourcesInput && element >= 0 && element < GetSourceCount()) {
|
||||
return GetTrackList()->GetTrackAt(element);
|
||||
} else {
|
||||
return Node::GetConnectedRenderOutput(input, element);
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiCamNode::IsInputConnectedForRender(const QString &input, int element) const
|
||||
{
|
||||
if (sequence_ && input == kSourcesInput && element >= 0 && element < GetSourceCount()) {
|
||||
return true;
|
||||
} else {
|
||||
return Node::IsInputConnectedForRender(input, element);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::InputConnectedEvent(const QString &input, int element, Node *output)
|
||||
{
|
||||
if (input == kSequenceInput) {
|
||||
if (Sequence *s = dynamic_cast<Sequence*>(output)) {
|
||||
SetInputFlags(kSequenceTypeInput, GetInputFlags(kSequenceTypeInput) & InputFlag(~kInputFlagHidden));
|
||||
sequence_ = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::InputDisconnectedEvent(const QString &input, int element, Node *output)
|
||||
{
|
||||
if (input == kSequenceInput) {
|
||||
SetInputFlags(kSequenceTypeInput, GetInputFlags(kSequenceTypeInput) | kInputFlagHidden);
|
||||
sequence_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
TrackList *MultiCamNode::GetTrackList() const
|
||||
{
|
||||
return sequence_->track_list(static_cast<Track::Type>(GetStandardValue(kSequenceTypeInput).toInt()));
|
||||
}
|
||||
|
||||
void MultiCamNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kCurrentInput, tr("Current"));
|
||||
SetInputName(kSourcesInput, tr("Sources"));
|
||||
SetInputName(kSequenceInput, tr("Sequence"));
|
||||
SetInputName(kSequenceTypeInput, tr("Sequence Type"));
|
||||
SetComboBoxStrings(kSequenceTypeInput, {tr("Video"), tr("Audio")});
|
||||
}
|
||||
|
||||
int MultiCamNode::GetSourceCount() const
|
||||
{
|
||||
if (sequence_) {
|
||||
return GetTrackList()->GetTrackCount();
|
||||
} else {
|
||||
return InputArraySize(kSourcesInput);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::GetRowsAndColumns(int sources, int *rows_in, int *cols_in)
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
#define MULTICAMNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "node/output/track/tracklist.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class Sequence;
|
||||
|
||||
class MultiCamNode : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -26,16 +29,15 @@ public:
|
||||
|
||||
static const QString kCurrentInput;
|
||||
static const QString kSourcesInput;
|
||||
static const QString kSequenceInput;
|
||||
static const QString kSequenceTypeInput;
|
||||
|
||||
int GetCurrentSource() const
|
||||
{
|
||||
return GetStandardValue(kCurrentInput).toInt();
|
||||
}
|
||||
|
||||
int GetSourceCount() const
|
||||
{
|
||||
return InputArraySize(kSourcesInput);
|
||||
}
|
||||
int GetSourceCount() const;
|
||||
|
||||
static void GetRowsAndColumns(int sources, int *rows, int *cols);
|
||||
void GetRowsAndColumns(int *rows, int *cols) const
|
||||
@@ -43,6 +45,11 @@ public:
|
||||
return GetRowsAndColumns(GetSourceCount(), rows, cols);
|
||||
}
|
||||
|
||||
void SetSequenceType(Track::Type t)
|
||||
{
|
||||
SetStandardValue(kSequenceTypeInput, t);
|
||||
}
|
||||
|
||||
static void IndexToRowCols(int index, int total_rows, int total_cols, int *row, int *col);
|
||||
|
||||
static int RowsColsToIndex(int row, int col, int total_rows, int total_cols)
|
||||
@@ -50,6 +57,18 @@ public:
|
||||
return col + row * total_cols;
|
||||
}
|
||||
|
||||
virtual Node *GetConnectedRenderOutput(const QString& input, int element = -1) const override;
|
||||
virtual bool IsInputConnectedForRender(const QString& input, int element = -1) const override;
|
||||
|
||||
protected:
|
||||
virtual void InputConnectedEvent(const QString &input, int element, Node *output) override;
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override;
|
||||
|
||||
private:
|
||||
TrackList *GetTrackList() const;
|
||||
|
||||
Sequence *sequence_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user