From 32c7d089aa8eaddedfd59c32f1a3e757ebdc675d Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 28 Jul 2019 01:27:06 -0700 Subject: [PATCH] created clip block node --- app/node/block/CMakeLists.txt | 1 + app/node/block/block.cpp | 13 +++----- app/node/block/block.h | 3 +- app/node/block/clip/CMakeLists.txt | 22 +++++++++++++ app/node/block/clip/clip.cpp | 45 +++++++++++++++++++++++++++ app/node/block/clip/clip.h | 46 ++++++++++++++++++++++++++++ app/node/block/gap/gap.cpp | 20 ++++++++++++ app/node/block/gap/gap.h | 7 +++-- app/node/block/timeline/timeline.cpp | 27 ++++++++++++++-- app/node/block/timeline/timeline.h | 6 ++++ 10 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 app/node/block/clip/CMakeLists.txt create mode 100644 app/node/block/clip/clip.cpp create mode 100644 app/node/block/clip/clip.h diff --git a/app/node/block/CMakeLists.txt b/app/node/block/CMakeLists.txt index 92c3b27ea..30cbd9858 100644 --- a/app/node/block/CMakeLists.txt +++ b/app/node/block/CMakeLists.txt @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +add_subdirectory(clip) add_subdirectory(gap) add_subdirectory(timeline) diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index f8c9a6f8f..690916804 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -26,18 +26,14 @@ Block::Block() previous_input_->add_data_input(NodeParam::kBlock); AddParameter(previous_input_); - previous_output_ = new NodeOutput(); - previous_output_->set_data_type(NodeParam::kBlock); - AddParameter(previous_output_); + block_output_ = new NodeOutput(); + block_output_->set_data_type(NodeParam::kBlock); + AddParameter(block_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_); @@ -73,8 +69,7 @@ void Block::Process(const rational &time) Q_UNUSED(time) // Simply set both output values as a pointer to this object - previous_output_->set_value(PtrToValue(this)); - next_output_->set_value(PtrToValue(this)); + block_output_->set_value(PtrToValue(this)); } void Block::Refresh() diff --git a/app/node/block/block.h b/app/node/block/block.h index a613332a8..30e2b6528 100644 --- a/app/node/block/block.h +++ b/app/node/block/block.h @@ -72,8 +72,7 @@ protected: private: NodeInput* previous_input_; NodeInput* next_input_; - NodeOutput* previous_output_; - NodeOutput* next_output_; + NodeOutput* block_output_; NodeOutput* texture_output_; diff --git a/app/node/block/clip/CMakeLists.txt b/app/node/block/clip/CMakeLists.txt new file mode 100644 index 000000000..378335849 --- /dev/null +++ b/app/node/block/clip/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/clip/clip.h + node/block/clip/clip.cpp + PARENT_SCOPE +) diff --git a/app/node/block/clip/clip.cpp b/app/node/block/clip/clip.cpp new file mode 100644 index 000000000..74c364f73 --- /dev/null +++ b/app/node/block/clip/clip.cpp @@ -0,0 +1,45 @@ +/*** + + 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 . + +***/ + +#include "clip.h" + +ClipBlock::ClipBlock() +{ + texture_input_ = new NodeInput(); + texture_input_->add_data_input(NodeInput::kTexture); + AddParameter(texture_input_); +} + +NodeInput *ClipBlock::texture_input() +{ + return texture_input_; +} + +void ClipBlock::Process(const rational &time) +{ + // Run default node processing + Block::Process(time); + + // We convert the time given (timeline time) to media time + rational media_time = time - in() + media_in_; + + // Retrieve texture + texture_output()->set_value(texture_input_->get_value(media_time)); +} diff --git a/app/node/block/clip/clip.h b/app/node/block/clip/clip.h new file mode 100644 index 000000000..a2f6a93b1 --- /dev/null +++ b/app/node/block/clip/clip.h @@ -0,0 +1,46 @@ +/*** + + 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 CLIPBLOCK_H +#define CLIPBLOCK_H + +#include "node/block/block.h" + +/** + * @brief Node that represents a block of Media + */ +class ClipBlock : public Block +{ + Q_OBJECT +public: + ClipBlock(); + + NodeInput* texture_input(); + +public slots: + virtual void Process(const rational &time) override; + +private: + NodeInput* texture_input_; + + rational media_in_; +}; + +#endif // TIMELINEBLOCK_H diff --git a/app/node/block/gap/gap.cpp b/app/node/block/gap/gap.cpp index 3c9a61582..9fb47acb8 100644 --- a/app/node/block/gap/gap.cpp +++ b/app/node/block/gap/gap.cpp @@ -1,3 +1,23 @@ +/*** + + 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 . + +***/ + #include "gap.h" GapBlock::GapBlock() diff --git a/app/node/block/gap/gap.h b/app/node/block/gap/gap.h index 62f7d7f2e..8512b2026 100644 --- a/app/node/block/gap/gap.h +++ b/app/node/block/gap/gap.h @@ -18,16 +18,17 @@ ***/ -#ifndef TIMELINEBLOCK_H -#define TIMELINEBLOCK_H +#ifndef GAPBLOCK_H +#define GAPBLOCK_H #include "node/block/block.h" /** - * @brief Node that represents the end of the Timeline as well as a time traversal Node + * @brief Node that represents nothing in its respective track for a certain period of time */ class GapBlock : public Block { + Q_OBJECT public: GapBlock(); diff --git a/app/node/block/timeline/timeline.cpp b/app/node/block/timeline/timeline.cpp index 76cbbc6f8..bb045d3af 100644 --- a/app/node/block/timeline/timeline.cpp +++ b/app/node/block/timeline/timeline.cpp @@ -1,7 +1,28 @@ +/*** + + 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 . + +***/ + #include "timeline.h" TimelineBlock::TimelineBlock() : - current_block_(nullptr) + current_block_(nullptr), + attached_timeline_(nullptr) { } @@ -17,7 +38,7 @@ void TimelineBlock::Process(const rational &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); + texture_output()->set_value(0); current_block_ = nullptr; return; } @@ -38,5 +59,5 @@ void TimelineBlock::Process(const rational &time) } // At this point, we must have found the correct block so we use its texture output to produce the image - texture_output_->set_value(current_block_->texture_output()->get_value(time)); + texture_output()->set_value(current_block_->texture_output()->get_value(time)); } diff --git a/app/node/block/timeline/timeline.h b/app/node/block/timeline/timeline.h index 316737830..e94bf3176 100644 --- a/app/node/block/timeline/timeline.h +++ b/app/node/block/timeline/timeline.h @@ -22,22 +22,28 @@ #define TIMELINEBLOCK_H #include "node/block/block.h" +#include "panel/timeline/timeline.h" /** * @brief Node that represents the end of the Timeline as well as a time traversal Node */ class TimelineBlock : public Block { + Q_OBJECT public: TimelineBlock(); virtual rational length() override; + void AttachTimeline(TimelinePanel* timeline); + public slots: virtual void Process(const rational &time) override; private: Block* current_block_; + + TimelinePanel* attached_timeline_; }; #endif // TIMELINEBLOCK_H