clip: retrieve any connected viewer on invalidate
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "clip.h"
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/rationalslider.h"
|
||||
|
||||
@@ -35,7 +36,8 @@ const QString ClipBlock::kReverseInput = QStringLiteral("reverse_in");
|
||||
|
||||
ClipBlock::ClipBlock() :
|
||||
in_transition_(nullptr),
|
||||
out_transition_(nullptr)
|
||||
out_transition_(nullptr),
|
||||
connected_viewer_(nullptr)
|
||||
{
|
||||
AddInput(kMediaInInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
SetInputProperty(kMediaInInput, QStringLiteral("view"), RationalSlider::kTime);
|
||||
@@ -189,6 +191,14 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const QString& from, int
|
||||
adj = TimeRange(MediaToSequenceTime(range.in()), MediaToSequenceTime(range.out()));
|
||||
}
|
||||
|
||||
// Find connected viewer node
|
||||
auto viewers = FindInputNodesConnectedToInput<ViewerOutput>(NodeInput(this, kBufferIn));
|
||||
if (viewers.isEmpty()) {
|
||||
connected_viewer_ = nullptr;
|
||||
} else {
|
||||
connected_viewer_ = viewers.first();
|
||||
}
|
||||
|
||||
super::InvalidateCache(adj, from, element, options);
|
||||
} else {
|
||||
// Otherwise, pass signal along normally
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ViewerOutput;
|
||||
|
||||
/**
|
||||
* @brief Node that represents a block of Media
|
||||
*/
|
||||
@@ -99,6 +101,11 @@ public:
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
ViewerOutput *connected_viewer() const
|
||||
{
|
||||
return connected_viewer_;
|
||||
}
|
||||
|
||||
static const QString kBufferIn;
|
||||
static const QString kMediaInInput;
|
||||
static const QString kSpeedInput;
|
||||
@@ -121,6 +128,8 @@ private:
|
||||
TransitionBlock* in_transition_;
|
||||
TransitionBlock* out_transition_;
|
||||
|
||||
ViewerOutput *connected_viewer_;
|
||||
|
||||
private:
|
||||
AudioVisualWaveform waveform_;
|
||||
|
||||
|
||||
+40
-8
@@ -644,6 +644,12 @@ public:
|
||||
template<class T>
|
||||
QVector<T*> FindInputNodes() const;
|
||||
|
||||
/**
|
||||
* @brief Find nodes of a certain type that this Node takes inputs from
|
||||
*/
|
||||
template<class T>
|
||||
static QVector<T*> FindInputNodesConnectedToInput(const NodeInput &input);
|
||||
|
||||
template<class T>
|
||||
/**
|
||||
* @brief Find a node of a certain type that this Node outputs to
|
||||
@@ -1169,6 +1175,12 @@ private:
|
||||
*/
|
||||
int GetInternalInputArraySize(const QString& input);
|
||||
|
||||
/**
|
||||
* @brief Find nodes of a certain type that this Node takes inputs from
|
||||
*/
|
||||
template<class T>
|
||||
static void FindInputNodesConnectedToInputInternal(const NodeInput &input, QVector<T *>& list);
|
||||
|
||||
template<class T>
|
||||
static void FindInputNodeInternal(const Node* n, QVector<T *>& list);
|
||||
|
||||
@@ -1274,18 +1286,38 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void Node::FindInputNodesConnectedToInputInternal(const NodeInput &input, QVector<T *> &list)
|
||||
{
|
||||
Node* edge = input.GetConnectedOutput();
|
||||
if (!edge) {
|
||||
return;
|
||||
}
|
||||
|
||||
T* cast_test = dynamic_cast<T*>(edge);
|
||||
|
||||
if (cast_test) {
|
||||
list.append(cast_test);
|
||||
}
|
||||
|
||||
FindInputNodeInternal<T>(edge, list);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
QVector<T *> Node::FindInputNodesConnectedToInput(const NodeInput &input)
|
||||
{
|
||||
QVector<T *> list;
|
||||
|
||||
FindInputNodesConnectedToInputInternal<T>(input, list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Node::FindInputNodeInternal(const Node* n, QVector<T *> &list)
|
||||
{
|
||||
for (auto it=n->input_connections_.cbegin(); it!=n->input_connections_.cend(); it++) {
|
||||
Node* edge = it->second;
|
||||
T* cast_test = dynamic_cast<T*>(edge);
|
||||
|
||||
if (cast_test) {
|
||||
list.append(cast_test);
|
||||
}
|
||||
|
||||
FindInputNodeInternal<T>(edge, list);
|
||||
FindInputNodesConnectedToInputInternal(it->first, list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user