inserting blocks through the timeline implemented
This commit is contained in:
+21
-11
@@ -88,7 +88,7 @@ void Block::Process(const rational &time)
|
||||
}
|
||||
|
||||
void Block::Refresh()
|
||||
{
|
||||
{
|
||||
// Set in point to the out point of the previous Node
|
||||
if (previous() != nullptr) {
|
||||
in_point_ = previous()->out();
|
||||
@@ -98,22 +98,20 @@ void Block::Refresh()
|
||||
|
||||
// Update out point by adding this clip's length to the just calculated in point
|
||||
out_point_ = in_point_ + length();
|
||||
|
||||
emit Refreshed();
|
||||
}
|
||||
|
||||
void Block::RefreshSurrounds()
|
||||
void Block::RefreshFollowing()
|
||||
{
|
||||
Block* acting_node = previous();
|
||||
Refresh();
|
||||
|
||||
while (acting_node != nullptr) {
|
||||
acting_node->Refresh();
|
||||
acting_node = acting_node->previous();
|
||||
}
|
||||
Block* next_block = next();
|
||||
|
||||
acting_node = next();
|
||||
while (next_block != nullptr) {
|
||||
next_block->Refresh();
|
||||
|
||||
while (acting_node != nullptr) {
|
||||
acting_node->Refresh();
|
||||
acting_node = acting_node->next();
|
||||
next_block = next_block->next();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,3 +124,15 @@ NodeOutput *Block::block_output()
|
||||
{
|
||||
return block_output_;
|
||||
}
|
||||
|
||||
void Block::ConnectBlocks(Block *previous, Block *next)
|
||||
{
|
||||
NodeParam::ConnectEdge(previous->block_output(), next->previous_input());
|
||||
NodeParam::ConnectEdge(next->block_output(), previous->next_input());
|
||||
}
|
||||
|
||||
void Block::DisconnectBlocks(Block *previous, Block *next)
|
||||
{
|
||||
NodeParam::DisconnectEdge(previous->block_output(), next->previous_input());
|
||||
NodeParam::DisconnectEdge(next->block_output(), previous->next_input());
|
||||
}
|
||||
|
||||
+15
-1
@@ -35,6 +35,13 @@ class Block : public Node
|
||||
public:
|
||||
Block();
|
||||
|
||||
enum Type {
|
||||
kClip,
|
||||
kGap
|
||||
};
|
||||
|
||||
virtual Type type() = 0;
|
||||
|
||||
virtual QString Category() override;
|
||||
|
||||
const rational& in();
|
||||
@@ -52,6 +59,9 @@ public:
|
||||
NodeOutput* texture_output();
|
||||
NodeOutput* block_output();
|
||||
|
||||
static void ConnectBlocks(Block* previous, Block* next);
|
||||
static void DisconnectBlocks(Block* previous, Block* next);
|
||||
|
||||
public slots:
|
||||
virtual void Process(const rational &time) override;
|
||||
|
||||
@@ -70,8 +80,12 @@ public slots:
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
void RefreshFollowing();
|
||||
|
||||
signals:
|
||||
void Refreshed();
|
||||
|
||||
protected:
|
||||
void RefreshSurrounds();
|
||||
|
||||
private:
|
||||
NodeInput* previous_input_;
|
||||
|
||||
@@ -29,6 +29,11 @@ ClipBlock::ClipBlock()
|
||||
AddParameter(texture_input_);
|
||||
}
|
||||
|
||||
Block::Type ClipBlock::type()
|
||||
{
|
||||
return kClip;
|
||||
}
|
||||
|
||||
QString ClipBlock::Name()
|
||||
{
|
||||
return tr("Clip");
|
||||
@@ -52,6 +57,8 @@ rational ClipBlock::length()
|
||||
void ClipBlock::set_length(const rational &length)
|
||||
{
|
||||
length_ = length;
|
||||
|
||||
RefreshFollowing();
|
||||
}
|
||||
|
||||
NodeInput *ClipBlock::texture_input()
|
||||
|
||||
@@ -32,6 +32,8 @@ class ClipBlock : public Block
|
||||
public:
|
||||
ClipBlock();
|
||||
|
||||
virtual Type type() override;
|
||||
|
||||
virtual QString Name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
@@ -24,6 +24,11 @@ GapBlock::GapBlock()
|
||||
{
|
||||
}
|
||||
|
||||
Block::Type GapBlock::type()
|
||||
{
|
||||
return kGap;
|
||||
}
|
||||
|
||||
rational GapBlock::length()
|
||||
{
|
||||
return length_;
|
||||
@@ -33,5 +38,5 @@ void GapBlock::set_length(const rational &length)
|
||||
{
|
||||
length_ = length;
|
||||
|
||||
RefreshSurrounds();
|
||||
RefreshFollowing();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ class GapBlock : public Block
|
||||
public:
|
||||
GapBlock();
|
||||
|
||||
virtual Type type() override;
|
||||
|
||||
virtual rational length() override;
|
||||
virtual void set_length(const rational &length) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user