created timeline block node

This commit is contained in:
itsmattkc
2019-07-27 03:03:11 -07:00
parent badcade0b6
commit 53da858c45
6 changed files with 120 additions and 1 deletions
+1 -1
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#add_subdirectory(image)
add_subdirectory(timeline)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
+13
View File
@@ -23,16 +23,24 @@
Block::Block()
{
previous_input_ = new NodeInput();
previous_input_->add_data_input(NodeParam::kBlock);
AddParameter(previous_input_);
previous_output_ = new NodeOutput();
previous_output_->set_data_type(NodeParam::kBlock);
AddParameter(previous_output_);
next_input_ = new NodeInput();
next_input_->add_data_input(NodeParam::kBlock);
AddParameter(next_input_);
next_output_ = new NodeOutput();
next_output_->set_data_type(NodeParam::kBlock);
AddParameter(next_output_);
texture_output_ = new NodeOutput();
texture_output_->set_data_type(NodeParam::kTexture);
AddParameter(texture_output_);
}
QString Block::Category()
@@ -78,3 +86,8 @@ void Block::Process(const rational &time)
previous_output_->set_value(PtrToValue(this));
next_output_->set_value(PtrToValue(this));
}
NodeOutput *Block::texture_output()
{
return texture_output_;
}
+4
View File
@@ -39,6 +39,8 @@ public:
virtual Block* previous();
virtual Block* next();
NodeOutput* texture_output();
public slots:
virtual void Process(const rational &time) override;
@@ -47,6 +49,8 @@ private:
NodeInput* next_input_;
NodeOutput* previous_output_;
NodeOutput* next_output_;
NodeOutput* texture_output_;
};
#endif // BLOCK_H
+22
View File
@@ -0,0 +1,22 @@
# 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/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/block/timeline/timeline.h
node/block/timeline/timeline.cpp
PARENT_SCOPE
)
+37
View File
@@ -0,0 +1,37 @@
#include "timeline.h"
TimelineBlock::TimelineBlock() :
current_block_(nullptr)
{
}
void TimelineBlock::Process(const rational &time)
{
// Run default process function
Block::Process(time);
// This node represents the end of the timeline, so if the time is beyond its start, there's no image to display
if (time >= in()) {
texture_output_->set_value(0);
current_block_ = nullptr;
return;
}
// If we're here, we need to find the current clip to display
if (current_block_ == nullptr) {
current_block_ = this;
}
// If the time requested is an earlier Block, traverse earlier until we find it
while (time < current_block_->in()) {
current_block_ = current_block_->previous();
}
// If the time requested is in a later Block, traverse later
while (time > current_block_->out()) {
current_block_ = current_block_->next();
}
// At this point, we must have found the correct block so we use its texture output to produce the image
current_block_->texture_output()->get_value(time);
}
+43
View File
@@ -0,0 +1,43 @@
/***
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 TIMELINEBLOCK_H
#define TIMELINEBLOCK_H
#include "node/block/block.h"
/**
* @brief Node that represents the end of the Timeline as well as a time traversal Node
*/
class TimelineBlock : public Block
{
public:
TimelineBlock();
public slots:
virtual void Process(const rational &time) override;
private:
NodeOutput* texture_output_;
Block* current_block_;
};
#endif // TIMELINEBLOCK_H