moved input signals to graph to prevent signal desyncs
This commit is contained in:
@@ -44,15 +44,48 @@ void NodeGraph::childEvent(QChildEvent *event)
|
||||
if (event->type() == QEvent::ChildAdded) {
|
||||
|
||||
node_children_.append(node);
|
||||
|
||||
// Connect to each input
|
||||
foreach (NodeInput* input, node->parameters()) {
|
||||
connect(input, &NodeInput::InputConnected, this, &NodeGraph::SignalInputConnected);
|
||||
connect(input, &NodeInput::InputDisconnected, this, &NodeGraph::SignalInputDisconnected);
|
||||
connect(input, &NodeInput::ValueChanged, this, &NodeGraph::SignalValueChanged);
|
||||
}
|
||||
|
||||
emit NodeAdded(node);
|
||||
|
||||
} else if (event->type() == QEvent::ChildRemoved) {
|
||||
|
||||
node_children_.removeOne(node);
|
||||
|
||||
// Disconnect from inputs
|
||||
foreach (NodeInput* input, node->parameters()) {
|
||||
disconnect(input, &NodeInput::InputConnected, this, &NodeGraph::SignalInputConnected);
|
||||
disconnect(input, &NodeInput::InputDisconnected, this, &NodeGraph::SignalInputDisconnected);
|
||||
disconnect(input, &NodeInput::ValueChanged, this, &NodeGraph::SignalValueChanged);
|
||||
}
|
||||
|
||||
emit NodeRemoved(node);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeGraph::SignalInputConnected(Node *output, int element)
|
||||
{
|
||||
emit InputConnected(output, static_cast<NodeInput*>(sender()), element);
|
||||
}
|
||||
|
||||
void NodeGraph::SignalInputDisconnected(Node *output, int element)
|
||||
{
|
||||
emit InputDisconnected(output, static_cast<NodeInput*>(sender()), element);
|
||||
}
|
||||
|
||||
void NodeGraph::SignalValueChanged(const TimeRange &range, int element)
|
||||
{
|
||||
Q_UNUSED(range)
|
||||
|
||||
emit ValueChanged(static_cast<NodeInput*>(sender()), element);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,12 +65,25 @@ signals:
|
||||
*/
|
||||
void NodeRemoved(Node* node);
|
||||
|
||||
void InputConnected(Node* output, NodeInput* input, int element);
|
||||
|
||||
void InputDisconnected(Node* output, NodeInput* input, int element);
|
||||
|
||||
void ValueChanged(NodeInput* input, int element);
|
||||
|
||||
protected:
|
||||
virtual void childEvent(QChildEvent* event) override;
|
||||
|
||||
private:
|
||||
QVector<Node*> node_children_;
|
||||
|
||||
private slots:
|
||||
void SignalInputConnected(Node* output, int element);
|
||||
|
||||
void SignalInputDisconnected(Node* output, int element);
|
||||
|
||||
void SignalValueChanged(const TimeRange& range, int element);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -100,9 +100,8 @@ TimeRange Track::InputTimeAdjustment(NodeInput *input, int element, const TimeRa
|
||||
{
|
||||
if (input == block_input_ && element >= 0) {
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
const rational& block_in = blocks_.at(cache_index)->in();
|
||||
|
||||
return input_time - block_in;
|
||||
return TransformRangeForBlock(blocks_.at(cache_index), input_time);
|
||||
}
|
||||
|
||||
return Node::InputTimeAdjustment(input, element, input_time);
|
||||
@@ -120,6 +119,11 @@ TimeRange Track::OutputTimeAdjustment(NodeInput *input, int element, const TimeR
|
||||
return Node::OutputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
TimeRange Track::TransformRangeForBlock(Block *block, const TimeRange &range)
|
||||
{
|
||||
return range - block->in();
|
||||
}
|
||||
|
||||
const double &Track::GetTrackHeight() const
|
||||
{
|
||||
return track_height_;
|
||||
@@ -229,7 +233,9 @@ Block *Track::BlockAtTime(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
foreach (Block* block, blocks_) {
|
||||
for (int i=0; i<blocks_.size(); i++) {
|
||||
Block* block = blocks_.at(i);
|
||||
|
||||
if (block
|
||||
&& block->in() <= time
|
||||
&& block->out() > time) {
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
static TimeRange TransformRangeForBlock(Block* block, const TimeRange& range);
|
||||
|
||||
const double& GetTrackHeight() const;
|
||||
void SetTrackHeight(const double& height);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ NodeValueTable NodeTraverser::GenerateBlockTable(const Track *track, const TimeR
|
||||
NodeValueTable table;
|
||||
|
||||
if (active_block) {
|
||||
table = GenerateTable(active_block, range);
|
||||
table = GenerateTable(active_block, Track::TransformRangeForBlock(active_block, range));
|
||||
}
|
||||
|
||||
return table;
|
||||
|
||||
Reference in New Issue
Block a user