some ripple behavior fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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_) {
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
|
||||
NodeOutput* track_output();
|
||||
|
||||
Block* NearestBlockBefore(const rational& time);
|
||||
|
||||
Block* NearestBlockAfter(const rational& time);
|
||||
|
||||
const QVector<Block*>& Blocks();
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>());
|
||||
StreamPtr footage_stream = ghost->data(TimelineViewGhostItem::kAttachedFootage).value<StreamPtr>();
|
||||
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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user