implemented media out value to allow speed changes in clips

This commit is contained in:
itsmattkc
2019-12-16 18:29:35 +11:00
parent 8945fbe5fe
commit 4ba024e3ae
13 changed files with 101 additions and 23 deletions
+2 -2
View File
@@ -404,7 +404,7 @@ void TimelineWidget::DeleteSelectedInternal(const QList<Block *> blocks, bool re
} else if (!previous_is_gap && !next_is_gap) {
// Make new gap and replace old Block with it for now
GapBlock* gap = new GapBlock();
gap->set_length(b->length());
gap->set_length_and_media_out(b->length());
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()),
gap,
@@ -536,7 +536,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser
GapBlock* gap = nullptr;
if (insert_gaps) {
gap = new GapBlock();
gap->set_length(ripple_length);
gap->set_length_and_media_out(ripple_length);
new NodeAddCommand(static_cast<NodeGraph*>(track->parent()), gap, command);
}
+1 -1
View File
@@ -50,7 +50,7 @@ void TimelineWidget::AddTool::MouseRelease(TimelineViewMouseEvent *event)
QUndoCommand* command = new QUndoCommand();
ClipBlock* clip = new ClipBlock();
clip->set_length(ghost_->AdjustedLength());
clip->set_length_and_media_out(ghost_->AdjustedLength());
new NodeAddCommand(static_cast<NodeGraph*>(parent()->timeline_node_->parent()),
clip,
command);
+1 -1
View File
@@ -217,7 +217,7 @@ void TimelineWidget::ImportTool::DragDrop(TimelineViewMouseEvent *event)
StreamPtr footage_stream = ghost->data(TimelineViewGhostItem::kAttachedFootage).value<StreamPtr>();
ClipBlock* clip = new ClipBlock();
clip->set_length(ghost->Length());
clip->set_length_and_media_out(ghost->Length());
clip->set_block_name(footage_stream->footage()->name());
new NodeAddCommand(dst_graph, clip, command);
+1 -1
View File
@@ -48,7 +48,7 @@ void TimelineWidget::RippleTool::MouseReleaseInternal(TimelineViewMouseEvent *ev
// Make sure there's actually a gap being created
if (ghost->AdjustedLength() > 0) {
GapBlock* gap = new GapBlock();
gap->set_length(ghost->AdjustedLength());
gap->set_length_and_media_out(ghost->AdjustedLength());
new NodeAddCommand(static_cast<NodeGraph*>(parent()->timeline_node_->parent()), gap, command);
Block* block_to_append_gap_to = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kReferenceBlock));
+1 -1
View File
@@ -43,7 +43,7 @@ void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *e
if (b->previous() == nullptr) {
// We'll need to insert a gap here, so we'll do a Place command instead
GapBlock* gap = new GapBlock();
gap->set_length(ghost->Length());
gap->set_length_and_media_out(ghost->Length());
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()),
gap,
command);
+1 -1
View File
@@ -46,7 +46,7 @@ void TimelineWidget::SlideTool::MouseReleaseInternal(TimelineViewMouseEvent *eve
new BlockResizeCommand(b, ghost->AdjustedLength(), command);
} else if (ghost->mode() == olive::timeline::kMove && b->previous() == nullptr) {
GapBlock* gap = new GapBlock();
gap->set_length(ghost->InAdjustment());
gap->set_length_and_media_out(ghost->InAdjustment());
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()), gap, command);
new TrackPrependBlockCommand(parent()->GetTrackFromReference(ghost->Track()), gap, command);
}
+1
View File
@@ -72,6 +72,7 @@ void TimelineWidget::SlipTool::MouseReleaseInternal(TimelineViewMouseEvent *even
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
new BlockSetMediaInCommand(b, ghost->GetAdjustedMediaIn(), command);
new BlockSetMediaOutCommand(b, ghost->GetAdjustedMediaIn() + b->media_length(), command);
}
olive::undo_stack.pushIfHasChildren(command);
+27 -9
View File
@@ -49,12 +49,12 @@ BlockResizeCommand::BlockResizeCommand(Block *block, rational new_length, QUndoC
void BlockResizeCommand::redo()
{
block_->set_length(new_length_);
block_->set_length_and_media_out(new_length_);
}
void BlockResizeCommand::undo()
{
block_->set_length(old_length_);
block_->set_length_and_media_out(old_length_);
}
BlockResizeWithMediaInCommand::BlockResizeWithMediaInCommand(Block *block, rational new_length, QUndoCommand *parent) :
@@ -93,6 +93,24 @@ void BlockSetMediaInCommand::undo()
block_->set_media_in(old_media_in_);
}
BlockSetMediaOutCommand::BlockSetMediaOutCommand(Block *block, rational new_media_out, QUndoCommand *parent) :
QUndoCommand(parent),
block_(block),
old_media_out_(block->media_out()),
new_media_out_(new_media_out)
{
}
void BlockSetMediaOutCommand::redo()
{
block_->set_media_in(new_media_out_);
}
void BlockSetMediaOutCommand::undo()
{
block_->set_media_in(old_media_out_);
}
TrackRippleRemoveBlockCommand::TrackRippleRemoveBlockCommand(TrackOutput *track, Block *block, QUndoCommand *parent) :
QUndoCommand(parent),
track_(track),
@@ -186,7 +204,7 @@ void TrackRippleRemoveAreaCommand::redo()
Block* copy = CreateSplitBlock(splice_, out_);
splice_original_length_ = splice_->length();
splice_->set_length(out_ - splice_->in());
splice_->set_length_and_media_out(out_ - splice_->in());
static_cast<NodeGraph*>(track_->parent())->AddNode(copy);
Node::CopyInputs(splice_, copy);
@@ -224,7 +242,7 @@ void TrackRippleRemoveAreaCommand::redo()
// If we picked up a block to trim the out point of
if (trim_out_old_length_ != trim_out_new_length_) {
trim_out_->set_length(trim_out_new_length_);
trim_out_->set_length_and_media_out(trim_out_new_length_);
}
// If we were given a block to insert, insert it here
@@ -257,7 +275,7 @@ void TrackRippleRemoveAreaCommand::undo()
// If we picked up a block to trim the out point of
if (trim_out_old_length_ != trim_out_new_length_) {
trim_out_->set_length(trim_out_old_length_);
trim_out_->set_length_and_media_out(trim_out_old_length_);
}
// Remove all blocks that are flagged for removal
@@ -281,7 +299,7 @@ void TrackRippleRemoveAreaCommand::undo()
// Remove node
TakeNodeFromParentGraph(trim_in_, &memory_manager_);
splice_->set_length(splice_original_length_);
splice_->set_length_and_media_out(splice_original_length_);
}
track_->UnblockInvalidateCache();
@@ -318,7 +336,7 @@ void TrackPlaceBlockCommand::redo()
if (in_ > track_->track_length()) {
// If so, insert a gap here
gap_ = new GapBlock();
gap_->set_length(in_ - track_->track_length());
gap_->set_length_and_media_out(in_ - track_->track_length());
static_cast<NodeGraph*>(track_->parent())->AddNode(gap_);
track_->AppendBlock(gap_);
}
@@ -376,7 +394,7 @@ void BlockSplitCommand::redo()
{
track_->BlockInvalidateCache();
block_->set_length(new_length_);
block_->set_length_and_media_out(new_length_);
static_cast<NodeGraph*>(block_->parent())->AddNode(new_block_);
Node::CopyInputs(block_, new_block_);
@@ -396,7 +414,7 @@ void BlockSplitCommand::undo()
{
track_->BlockInvalidateCache();
block_->set_length(old_length_);
block_->set_length_and_media_out(old_length_);
track_->RippleRemoveBlock(new_block_);
TakeNodeFromParentGraph(new_block_, &memory_manager_);
+13
View File
@@ -67,6 +67,19 @@ private:
rational new_media_in_;
};
class BlockSetMediaOutCommand : public QUndoCommand {
public:
BlockSetMediaOutCommand(Block* block, rational new_media_out, QUndoCommand* parent = nullptr);
virtual void redo() override;
virtual void undo() override;
private:
Block* block_;
rational old_media_out_;
rational new_media_out_;
};
class TrackRippleRemoveBlockCommand : public QUndoCommand {
public:
TrackRippleRemoveBlockCommand(TrackOutput* track, Block* block, QUndoCommand* parent = nullptr);