diff --git a/app/node/block/CMakeLists.txt b/app/node/block/CMakeLists.txt index 92a0fca1f..ac6857879 100644 --- a/app/node/block/CMakeLists.txt +++ b/app/node/block/CMakeLists.txt @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#add_subdirectory(image) +add_subdirectory(timeline) set(OLIVE_SOURCES ${OLIVE_SOURCES} diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index de3be141d..813bb2056 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -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_; +} diff --git a/app/node/block/block.h b/app/node/block/block.h index fd35ea06e..af9961c80 100644 --- a/app/node/block/block.h +++ b/app/node/block/block.h @@ -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 diff --git a/app/node/block/timeline/CMakeLists.txt b/app/node/block/timeline/CMakeLists.txt new file mode 100644 index 000000000..015c337d8 --- /dev/null +++ b/app/node/block/timeline/CMakeLists.txt @@ -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 . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + node/block/timeline/timeline.h + node/block/timeline/timeline.cpp + PARENT_SCOPE +) diff --git a/app/node/block/timeline/timeline.cpp b/app/node/block/timeline/timeline.cpp new file mode 100644 index 000000000..8ca50e2fd --- /dev/null +++ b/app/node/block/timeline/timeline.cpp @@ -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); +} diff --git a/app/node/block/timeline/timeline.h b/app/node/block/timeline/timeline.h new file mode 100644 index 000000000..db45718a7 --- /dev/null +++ b/app/node/block/timeline/timeline.h @@ -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 . + +***/ + +#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