converted timelineblock to output node instead

This commit is contained in:
itsmattkc
2019-07-28 10:57:37 -07:00
parent 8d944387a2
commit 6cb182bfc5
8 changed files with 74 additions and 37 deletions
-1
View File
@@ -16,7 +16,6 @@
add_subdirectory(clip)
add_subdirectory(gap)
add_subdirectory(timeline)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
-22
View File
@@ -1,22 +0,0 @@
# 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
)
-104
View File
@@ -1,104 +0,0 @@
/***
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/>.
***/
#include "timeline.h"
TimelineBlock::TimelineBlock() :
current_block_(nullptr),
attached_timeline_(nullptr)
{
}
QString TimelineBlock::Name()
{
return tr("Timeline");
}
QString TimelineBlock::id()
{
return "org.olivevideoeditor.Olive.timeline";
}
QString TimelineBlock::Description()
{
return tr("Node for communicating between a Timeline panel and the node graph. Also represents the end of a Sequence.");
}
rational TimelineBlock::length()
{
return 0;
}
void TimelineBlock::AttachTimeline(TimelinePanel *timeline)
{
if (attached_timeline_ != nullptr) {
attached_timeline_->Clear();
}
attached_timeline_ = timeline;
if (attached_timeline_ != nullptr) {
attached_timeline_->Clear();
Block* previous_block = previous();
while (previous_block != nullptr) {
// FIXME: Dynamic cast is a dumb way of doing this
ClipBlock* clip_block = dynamic_cast<ClipBlock*>(previous_block);
if (clip_block != nullptr) {
attached_timeline_->AddClip(clip_block);
}
previous_block = previous_block->previous();
}
}
}
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
texture_output()->set_value(current_block_->texture_output()->get_value(time));
}
-53
View File
@@ -1,53 +0,0 @@
/***
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"
#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 QString Name() override;
virtual QString id() override;
virtual QString Description() override;
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