converted timelineblock to output node instead
This commit is contained in:
+3
-5
@@ -219,8 +219,8 @@ void Core::CreateNewFolder()
|
||||
|
||||
// FIXME: Test code
|
||||
#include "node/block/clip/clip.h"
|
||||
#include "node/block/timeline/timeline.h"
|
||||
#include "node/input/media/media.h"
|
||||
#include "node/output/timeline/timeline.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
#include "node/generator/solid/solid.h"
|
||||
#include "panel/panelmanager.h"
|
||||
@@ -285,7 +285,7 @@ void Core::CreateNewSequence()
|
||||
cb2->set_length(1);
|
||||
new_sequence->AddNode(cb2);
|
||||
|
||||
TimelineBlock* tb = new TimelineBlock();
|
||||
TimelineOutput* tb = new TimelineOutput();
|
||||
tb->AttachTimeline(olive::panel_focus_manager->MostRecentlyFocused<TimelinePanel>());
|
||||
new_sequence->AddNode(tb);
|
||||
|
||||
@@ -297,13 +297,11 @@ void Core::CreateNewSequence()
|
||||
NodeParam::ConnectEdge(ii->texture_output(), cb2->texture_input());
|
||||
NodeParam::ConnectEdge(cb1->block_output(), cb2->previous_input());
|
||||
NodeParam::ConnectEdge(cb2->block_output(), cb1->next_input());
|
||||
NodeParam::ConnectEdge(cb2->block_output(), tb->previous_input());
|
||||
NodeParam::ConnectEdge(tb->block_output(), cb2->next_input());
|
||||
NodeParam::ConnectEdge(cb2->block_output(), tb->block_input());
|
||||
NodeParam::ConnectEdge(tb->texture_output(), vo->texture_input());
|
||||
|
||||
cb1->Refresh();
|
||||
cb2->Refresh();
|
||||
tb->Refresh();
|
||||
|
||||
olive::panel_focus_manager->MostRecentlyFocused<NodePanel>()->SetGraph(new_sequence.get());
|
||||
// End test code
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
add_subdirectory(clip)
|
||||
add_subdirectory(gap)
|
||||
add_subdirectory(timeline)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
|
||||
@@ -14,6 +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(timeline)
|
||||
add_subdirectory(viewer)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/block/timeline/timeline.h
|
||||
node/block/timeline/timeline.cpp
|
||||
node/output/timeline/timeline.h
|
||||
node/output/timeline/timeline.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -20,33 +20,43 @@
|
||||
|
||||
#include "timeline.h"
|
||||
|
||||
TimelineBlock::TimelineBlock() :
|
||||
TimelineOutput::TimelineOutput() :
|
||||
current_block_(nullptr),
|
||||
attached_timeline_(nullptr)
|
||||
{
|
||||
block_input_ = new NodeInput();
|
||||
block_input_->add_data_input(NodeInput::kBlock);
|
||||
AddParameter(block_input_);
|
||||
|
||||
texture_output_ = new NodeOutput();
|
||||
texture_output_->set_data_type(NodeOutput::kTexture);
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
QString TimelineBlock::Name()
|
||||
QString TimelineOutput::Name()
|
||||
{
|
||||
return tr("Timeline");
|
||||
}
|
||||
|
||||
QString TimelineBlock::id()
|
||||
QString TimelineOutput::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.timeline";
|
||||
}
|
||||
|
||||
QString TimelineBlock::Description()
|
||||
QString TimelineOutput::Category()
|
||||
{
|
||||
return tr("Node for communicating between a Timeline panel and the node graph. Also represents the end of a Sequence.");
|
||||
return tr("Output");
|
||||
}
|
||||
|
||||
rational TimelineBlock::length()
|
||||
QString TimelineOutput::Description()
|
||||
{
|
||||
return 0;
|
||||
return tr("Node for communicating between a Timeline panel and the node graph. Also represents the end of a"
|
||||
"Sequence.");
|
||||
}
|
||||
|
||||
void TimelineBlock::AttachTimeline(TimelinePanel *timeline)
|
||||
#include "project/item/sequence/sequence.h"
|
||||
|
||||
void TimelineOutput::AttachTimeline(TimelinePanel *timeline)
|
||||
{
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->Clear();
|
||||
@@ -57,7 +67,7 @@ void TimelineBlock::AttachTimeline(TimelinePanel *timeline)
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->Clear();
|
||||
|
||||
Block* previous_block = previous();
|
||||
Block* previous_block = attached_block();
|
||||
while (previous_block != nullptr) {
|
||||
|
||||
// FIXME: Dynamic cast is a dumb way of doing this
|
||||
@@ -72,21 +82,29 @@ void TimelineBlock::AttachTimeline(TimelinePanel *timeline)
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineBlock::Process(const rational &time)
|
||||
NodeInput *TimelineOutput::block_input()
|
||||
{
|
||||
// Run default process function
|
||||
Block::Process(time);
|
||||
return block_input_;
|
||||
}
|
||||
|
||||
// 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);
|
||||
NodeOutput *TimelineOutput::texture_output()
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
void TimelineOutput::Process(const rational &time)
|
||||
{
|
||||
// This node is intended to connect to the end of the timeline, so being beyond its out point is considered the end
|
||||
// of the sequence
|
||||
if (attached_block() == nullptr || time >= attached_block()->out()) {
|
||||
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;
|
||||
current_block_ = attached_block();
|
||||
}
|
||||
|
||||
// If the time requested is an earlier Block, traverse earlier until we find it
|
||||
@@ -100,5 +118,10 @@ 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));
|
||||
}
|
||||
|
||||
Block *TimelineOutput::attached_block()
|
||||
{
|
||||
return ValueToPtr<Block>(block_input_->get_value(0));
|
||||
}
|
||||
@@ -18,36 +18,42 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEBLOCK_H
|
||||
#define TIMELINEBLOCK_H
|
||||
#ifndef TIMELINEOUTPUT_H
|
||||
#define TIMELINEOUTPUT_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
#include "node/node.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
|
||||
class TimelineOutput : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TimelineBlock();
|
||||
TimelineOutput();
|
||||
|
||||
virtual QString Name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString Category() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
virtual rational length() override;
|
||||
|
||||
void AttachTimeline(TimelinePanel* timeline);
|
||||
|
||||
NodeInput* block_input();
|
||||
NodeOutput* texture_output();
|
||||
|
||||
public slots:
|
||||
virtual void Process(const rational &time) override;
|
||||
|
||||
private:
|
||||
Block* attached_block();
|
||||
Block* current_block_;
|
||||
|
||||
NodeInput* block_input_;
|
||||
NodeOutput* texture_output_;
|
||||
|
||||
TimelinePanel* attached_timeline_;
|
||||
};
|
||||
|
||||
#endif // TIMELINEBLOCK_H
|
||||
#endif // TIMELINEOUTPUT_H
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "widget/timeruler/timeruler.h"
|
||||
|
||||
TimelinePanel::TimelinePanel(QWidget *parent) :
|
||||
PanelWidget(parent)
|
||||
{
|
||||
@@ -35,8 +33,8 @@ TimelinePanel::TimelinePanel(QWidget *parent) :
|
||||
layout->setSpacing(0);
|
||||
layout->setMargin(0);
|
||||
|
||||
TimeRuler* tr = new TimeRuler(true, this);
|
||||
layout->addWidget(tr);
|
||||
ruler_ = new TimeRuler(true, this);
|
||||
layout->addWidget(ruler_);
|
||||
|
||||
view_ = new TimelineView(this);
|
||||
layout->addWidget(view_);
|
||||
@@ -47,6 +45,8 @@ TimelinePanel::TimelinePanel(QWidget *parent) :
|
||||
|
||||
void TimelinePanel::Clear()
|
||||
{
|
||||
SetTimebase(0);
|
||||
|
||||
view_->Clear();
|
||||
}
|
||||
|
||||
@@ -55,6 +55,11 @@ void TimelinePanel::AddClip(ClipBlock *clip)
|
||||
view_->AddClip(clip);
|
||||
}
|
||||
|
||||
void TimelinePanel::SetTimebase(const rational &timebase)
|
||||
{
|
||||
ruler_->SetTimebase(timebase);
|
||||
}
|
||||
|
||||
void TimelinePanel::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "widget/panel/panel.h"
|
||||
#include "widget/timelineview/timelineview.h"
|
||||
#include "widget/timeruler/timeruler.h"
|
||||
|
||||
class TimelinePanel : public PanelWidget
|
||||
{
|
||||
@@ -34,6 +35,8 @@ public:
|
||||
|
||||
void AddClip(ClipBlock* clip);
|
||||
|
||||
void SetTimebase(const rational& timebase);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* e) override;
|
||||
|
||||
@@ -41,6 +44,8 @@ private:
|
||||
void Retranslate();
|
||||
|
||||
TimelineView* view_;
|
||||
|
||||
TimeRuler* ruler_;
|
||||
};
|
||||
|
||||
#endif // TIMELINE_PANEL_H
|
||||
|
||||
Reference in New Issue
Block a user