barebones prototype of timeline/clip functionality
This commit is contained in:
+35
-9
@@ -218,6 +218,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/viewer/viewer.h"
|
||||
#include "node/generator/solid/solid.h"
|
||||
@@ -269,17 +271,41 @@ void Core::CreateNewSequence()
|
||||
new_sequence);
|
||||
|
||||
// FIXME: Test code
|
||||
NodeGraph* graph = new NodeGraph();
|
||||
graph->setParent(this);
|
||||
SolidGenerator* sg = new SolidGenerator();
|
||||
new_sequence->AddNode(sg);
|
||||
|
||||
MediaInput* ii = new MediaInput();
|
||||
new_sequence->AddNode(ii);
|
||||
|
||||
ClipBlock* cb1 = new ClipBlock();
|
||||
cb1->set_length(1);
|
||||
new_sequence->AddNode(cb1);
|
||||
|
||||
ClipBlock* cb2 = new ClipBlock();
|
||||
cb2->set_length(1);
|
||||
new_sequence->AddNode(cb2);
|
||||
|
||||
TimelineBlock* tb = new TimelineBlock();
|
||||
tb->AttachTimeline(olive::panel_focus_manager->MostRecentlyFocused<TimelinePanel>());
|
||||
new_sequence->AddNode(tb);
|
||||
|
||||
ViewerOutput* vo = new ViewerOutput();
|
||||
vo->AttachViewer(olive::panel_focus_manager->MostRecentlyFocused<ViewerPanel>());
|
||||
graph->AddNode(vo);
|
||||
SolidGenerator* sg = new SolidGenerator();
|
||||
NodeInput::ConnectEdge(sg->texture_output(), vo->texture_input());
|
||||
graph->AddNode(sg);
|
||||
MediaInput* ii = new MediaInput();
|
||||
graph->AddNode(ii);
|
||||
olive::panel_focus_manager->MostRecentlyFocused<NodePanel>()->SetGraph(graph);
|
||||
new_sequence->AddNode(vo);
|
||||
|
||||
NodeParam::ConnectEdge(sg->texture_output(), cb1->texture_input());
|
||||
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(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
|
||||
|
||||
olive::undo_stack.push(aic);
|
||||
|
||||
@@ -54,6 +54,11 @@ const rational &Block::out()
|
||||
return out_point_;
|
||||
}
|
||||
|
||||
void Block::set_length(const rational &length)
|
||||
{
|
||||
Q_UNUSED(length)
|
||||
}
|
||||
|
||||
Block *Block::previous()
|
||||
{
|
||||
return ValueToPtr<Block>(previous_input_->get_value(0));
|
||||
@@ -64,6 +69,16 @@ Block *Block::next()
|
||||
return ValueToPtr<Block>(next_input_->get_value(0));
|
||||
}
|
||||
|
||||
NodeInput *Block::previous_input()
|
||||
{
|
||||
return previous_input_;
|
||||
}
|
||||
|
||||
NodeInput *Block::next_input()
|
||||
{
|
||||
return next_input_;
|
||||
}
|
||||
|
||||
void Block::Process(const rational &time)
|
||||
{
|
||||
Q_UNUSED(time)
|
||||
@@ -106,3 +121,8 @@ NodeOutput *Block::texture_output()
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
NodeOutput *Block::block_output()
|
||||
{
|
||||
return block_output_;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ public:
|
||||
const rational& out();
|
||||
|
||||
virtual rational length() = 0;
|
||||
virtual void set_length(const rational& length) = 0;
|
||||
virtual void set_length(const rational& length);
|
||||
|
||||
virtual Block* previous();
|
||||
virtual Block* next();
|
||||
|
||||
NodeInput* previous_input();
|
||||
NodeInput* next_input();
|
||||
|
||||
NodeOutput* texture_output();
|
||||
NodeOutput* block_output();
|
||||
|
||||
public slots:
|
||||
virtual void Process(const rational &time) override;
|
||||
|
||||
@@ -27,6 +27,31 @@ ClipBlock::ClipBlock()
|
||||
AddParameter(texture_input_);
|
||||
}
|
||||
|
||||
QString ClipBlock::Name()
|
||||
{
|
||||
return tr("Clip");
|
||||
}
|
||||
|
||||
QString ClipBlock::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.clip";
|
||||
}
|
||||
|
||||
QString ClipBlock::Description()
|
||||
{
|
||||
return tr("A time-based node that represents a media source.");
|
||||
}
|
||||
|
||||
rational ClipBlock::length()
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
void ClipBlock::set_length(const rational &length)
|
||||
{
|
||||
length_ = length;
|
||||
}
|
||||
|
||||
NodeInput *ClipBlock::texture_input()
|
||||
{
|
||||
return texture_input_;
|
||||
|
||||
@@ -32,6 +32,13 @@ class ClipBlock : public Block
|
||||
public:
|
||||
ClipBlock();
|
||||
|
||||
virtual QString Name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
virtual rational length() override;
|
||||
virtual void set_length(const rational &length) override;
|
||||
|
||||
NodeInput* texture_input();
|
||||
|
||||
public slots:
|
||||
@@ -41,6 +48,8 @@ private:
|
||||
NodeInput* texture_input_;
|
||||
|
||||
rational media_in_;
|
||||
|
||||
rational length_;
|
||||
};
|
||||
|
||||
#endif // TIMELINEBLOCK_H
|
||||
|
||||
@@ -26,11 +26,52 @@ TimelineBlock::TimelineBlock() :
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -33,6 +33,10 @@ class TimelineBlock : public Block
|
||||
public:
|
||||
TimelineBlock();
|
||||
|
||||
virtual QString Name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
virtual rational length() override;
|
||||
|
||||
void AttachTimeline(TimelinePanel* timeline);
|
||||
|
||||
@@ -37,12 +37,24 @@ TimelinePanel::TimelinePanel(QWidget *parent) :
|
||||
|
||||
TimeRuler* tr = new TimeRuler(true, this);
|
||||
layout->addWidget(tr);
|
||||
layout->addStretch();
|
||||
|
||||
view_ = new TimelineView(this);
|
||||
layout->addWidget(view_);
|
||||
// End test code
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void TimelinePanel::Clear()
|
||||
{
|
||||
view_->Clear();
|
||||
}
|
||||
|
||||
void TimelinePanel::AddClip(ClipBlock *clip)
|
||||
{
|
||||
view_->AddClip(clip);
|
||||
}
|
||||
|
||||
void TimelinePanel::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define TIMELINE_PANEL_H
|
||||
|
||||
#include "widget/panel/panel.h"
|
||||
#include "widget/timelineview/timelineview.h"
|
||||
|
||||
class TimelinePanel : public PanelWidget
|
||||
{
|
||||
@@ -29,11 +30,17 @@ class TimelinePanel : public PanelWidget
|
||||
public:
|
||||
TimelinePanel(QWidget* parent);
|
||||
|
||||
void Clear();
|
||||
|
||||
void AddClip(ClipBlock* clip);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
|
||||
TimelineView* view_;
|
||||
};
|
||||
|
||||
#endif // TIMELINE_PANEL_H
|
||||
|
||||
@@ -1,16 +1,29 @@
|
||||
#include "timelineview.h"
|
||||
|
||||
#include "timelineviewclipitem.h"
|
||||
|
||||
TimelineView::TimelineView(QWidget *parent) :
|
||||
QGraphicsView(parent),
|
||||
sequence_(nullptr)
|
||||
QGraphicsView(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TimelineView::SetSequence(Sequence *s)
|
||||
void TimelineView::AddClip(ClipBlock *clip)
|
||||
{
|
||||
TimelineViewClipItem* clip_item = new TimelineViewClipItem();
|
||||
clip_item->SetClip(clip);
|
||||
scene_.addItem(clip_item);
|
||||
|
||||
// FIXME: Test code only
|
||||
clip_item->setRect(clip->in().ToDouble(), 0, clip->out().ToDouble(), 100);
|
||||
// End test code
|
||||
}
|
||||
|
||||
void TimelineView::SetScale(const double &scale)
|
||||
{
|
||||
scale_ = scale;
|
||||
}
|
||||
|
||||
void TimelineView::Clear()
|
||||
{
|
||||
scene_.clear();
|
||||
|
||||
sequence_ = s;
|
||||
|
||||
QList<Node*> sequence_nodes = sequence_->nodes();
|
||||
}
|
||||
|
||||
@@ -3,19 +3,23 @@
|
||||
|
||||
#include <QGraphicsView>
|
||||
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "node/block/clip/clip.h"
|
||||
|
||||
class TimelineView : public QGraphicsView
|
||||
{
|
||||
public:
|
||||
TimelineView(QWidget* parent);
|
||||
|
||||
void SetSequence(Sequence* s);
|
||||
void AddClip(ClipBlock* clip);
|
||||
|
||||
void SetScale(const double& scale);
|
||||
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
Sequence* sequence_;
|
||||
|
||||
QGraphicsScene scene_;
|
||||
|
||||
double scale_;
|
||||
};
|
||||
|
||||
#endif // TIMELINEVIEW_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#include "timelineviewclipitem.h"
|
||||
|
||||
TimelineViewClipItem::TimelineViewClipItem(QGraphicsItem* parent) :
|
||||
QGraphicsRectItem(parent)
|
||||
QGraphicsRectItem(parent),
|
||||
clip_(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TimelineViewClipItem::SetClip(ClipBlock *clip)
|
||||
{
|
||||
clip_ = clip;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,17 @@
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
#include "node/block/clip/clip.h"
|
||||
|
||||
class TimelineViewClipItem : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
TimelineViewClipItem(QGraphicsItem* parent = nullptr);
|
||||
|
||||
void SetClip(ClipBlock* clip);
|
||||
|
||||
private:
|
||||
ClipBlock* clip_;
|
||||
};
|
||||
|
||||
#endif // TIMELINEVIEWCLIPITEM_H
|
||||
|
||||
Reference in New Issue
Block a user