diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index 357d1ee7d..e4baa0251 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -64,6 +64,8 @@ const rational& Block::length() void Block::set_length(const rational &length) { + Q_ASSERT(length > 0); + Lock(); length_ = length; @@ -177,6 +179,16 @@ void Block::set_media_in(const rational &media_in) } } +const QString &Block::block_name() +{ + return block_name_; +} + +void Block::set_block_name(const QString &name) +{ + block_name_ = name; +} + rational Block::SequenceToMediaTime(const rational &sequence_time) { // These constants are not considered "values" per se, so we don't modify them diff --git a/app/node/block/block.h b/app/node/block/block.h index f8670db4c..e5034c10a 100644 --- a/app/node/block/block.h +++ b/app/node/block/block.h @@ -67,6 +67,9 @@ public: const rational& media_in(); void set_media_in(const rational& media_in); + const QString& block_name(); + void set_block_name(const QString& name); + public slots: /** * @brief Refreshes internal cache of in/out points up to date @@ -113,6 +116,8 @@ private: Block* next_; + QString block_name_; + private slots: void EdgeAddedSlot(NodeEdgePtr edge); diff --git a/app/node/output/track/track.cpp b/app/node/output/track/track.cpp index 73ae473aa..94b056bfe 100644 --- a/app/node/output/track/track.cpp +++ b/app/node/output/track/track.cpp @@ -147,6 +147,18 @@ NodeOutput* TrackOutput::track_output() return track_output_; } +Block *TrackOutput::NearestBlockBefore(const rational &time) +{ + foreach (Block* block, block_cache_) { + // Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block + if (block->out() >= time) { + return block; + } + } + + return nullptr; +} + Block *TrackOutput::NearestBlockAfter(const rational &time) { foreach (Block* block, block_cache_) { diff --git a/app/node/output/track/track.h b/app/node/output/track/track.h index 6bfe6aafb..be923392a 100644 --- a/app/node/output/track/track.h +++ b/app/node/output/track/track.h @@ -59,6 +59,8 @@ public: NodeOutput* track_output(); + Block* NearestBlockBefore(const rational& time); + Block* NearestBlockAfter(const rational& time); const QVector& Blocks(); diff --git a/app/widget/timelineview/timelineviewblockitem.cpp b/app/widget/timelineview/timelineviewblockitem.cpp index 902a99cf6..bf27ea1bd 100644 --- a/app/widget/timelineview/timelineviewblockitem.cpp +++ b/app/widget/timelineview/timelineviewblockitem.cpp @@ -58,6 +58,8 @@ void TimelineViewBlockItem::UpdateRect() // -1 on width and height so we don't overlap any adjacent clips setRect(0, y_, item_width - 1, height_ - 1); setPos(item_left, 0.0); + + update(); } void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) @@ -84,6 +86,8 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI painter->drawLine(rect().topLeft(), QPointF(rect().right(), rect().top())); painter->drawLine(rect().topLeft(), QPointF(rect().left(), rect().bottom() - 1)); + painter->drawText(rect(), Qt::AlignLeft | Qt::AlignTop, block_->block_name()); + painter->setPen(QColor(64, 64, 64)); painter->drawLine(QPointF(rect().left(), rect().bottom() - 1), QPointF(rect().right(), rect().bottom() - 1)); painter->drawLine(QPointF(rect().right(), rect().bottom() - 1), QPointF(rect().right(), rect().top())); diff --git a/app/widget/timelineview/timelineviewghostitem.cpp b/app/widget/timelineview/timelineviewghostitem.cpp index 5fb050e41..7a07d571d 100644 --- a/app/widget/timelineview/timelineviewghostitem.cpp +++ b/app/widget/timelineview/timelineviewghostitem.cpp @@ -29,7 +29,7 @@ TimelineViewGhostItem::TimelineViewGhostItem(QGraphicsItem *parent) : track_adj_(0), stream_(nullptr), mode_(olive::timeline::kNone), - can_have_zero_length_(false) + can_have_zero_length_(true) { SetInvisible(false); } @@ -45,8 +45,8 @@ TimelineViewGhostItem *TimelineViewGhostItem::FromBlock(Block *block, int track, ghost->SetHeight(height); ghost->setData(kAttachedBlock, Node::PtrToValue(block)); - if (block->type() == Block::kGap) { - ghost->can_have_zero_length_ = true; + if (block->type() == Block::kClip) { + ghost->can_have_zero_length_ = false; } return ghost; diff --git a/app/widget/timelineview/tool/import.cpp b/app/widget/timelineview/tool/import.cpp index 630ee18b3..881708290 100644 --- a/app/widget/timelineview/tool/import.cpp +++ b/app/widget/timelineview/tool/import.cpp @@ -179,7 +179,9 @@ void TimelineView::ImportTool::DragDrop(QDropEvent *event) opacity->setParent(&node_memory_manager); clip->set_length(ghost->Length()); - media->SetFootage(ghost->data(TimelineViewGhostItem::kAttachedFootage).value()); + StreamPtr footage_stream = ghost->data(TimelineViewGhostItem::kAttachedFootage).value(); + media->SetFootage(footage_stream); + clip->set_block_name(footage_stream->footage()->name()); NodeParam::ConnectEdge(opacity->texture_output(), clip->texture_input()); NodeParam::ConnectEdge(media->texture_output(), opacity->texture_input()); diff --git a/app/widget/timelineview/tool/ripple.cpp b/app/widget/timelineview/tool/ripple.cpp index 8985abc40..9ad23cd97 100644 --- a/app/widget/timelineview/tool/ripple.cpp +++ b/app/widget/timelineview/tool/ripple.cpp @@ -134,7 +134,9 @@ void TimelineView::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_ite Block* block_before_ripple = track->NearestBlockBefore(earliest_ripple); // If block is null, there will be no blocks after to ripple - if (block_before_ripple != nullptr && block_before_ripple->type() != Block::kEnd) { + if (block_before_ripple != nullptr + && block_before_ripple->type() != Block::kEnd + && block_before_ripple->next()->type() != Block::kEnd) { TimelineViewGhostItem* ghost; if (block_before_ripple->type() == Block::kGap) { @@ -146,7 +148,7 @@ void TimelineView::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_ite ghost->setData(TimelineViewGhostItem::kReferenceBlock, Node::PtrToValue(block_before_ripple)); } -// ghost->SetInvisible(true); + ghost->SetInvisible(true); } } }