use speed value instead of media out value
This functions more or less identically to using a media out value, but the desired speed is preserved through block length changes, even if the block's length is reduced to zero (i.e. no rounding errors).
This commit is contained in:
@@ -75,7 +75,6 @@ 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);
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
|
||||
@@ -104,7 +104,8 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
|
||||
command);
|
||||
|
||||
if (dual_transition_) {
|
||||
transition->set_in_and_out_offset(ghost_->AdjustedLength()/2, ghost_->AdjustedLength()/2);
|
||||
//transition->set_in_and_out_offset(ghost_->AdjustedLength()/2, ghost_->AdjustedLength()/2);
|
||||
transition->set_length_and_media_out(ghost_->AdjustedLength());
|
||||
|
||||
// Block mouse is hovering over
|
||||
Block* active_block = Node::ValueToPtr<Block>(ghost_->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
@@ -129,10 +130,10 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
|
||||
NodeInput* transition_input_to_connect;
|
||||
|
||||
if (ghost_->mode() == Timeline::kTrimIn) {
|
||||
transition->set_in_and_out_offset(ghost_->AdjustedLength(), 0);
|
||||
transition->set_length_and_media_out(ghost_->AdjustedLength());
|
||||
transition_input_to_connect = transition->in_block_input();
|
||||
} else {
|
||||
transition->set_in_and_out_offset(0, ghost_->AdjustedLength());
|
||||
transition->set_length_and_media_out(ghost_->AdjustedLength());
|
||||
transition_input_to_connect = transition->out_block_input();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,24 +48,6 @@ void BlockResizeCommand::undo()
|
||||
block_->set_length_and_media_out(old_length_);
|
||||
}
|
||||
|
||||
BlockResizeWithoutMediaOutCommand::BlockResizeWithoutMediaOutCommand(Block *block, rational new_length, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
block_(block),
|
||||
old_length_(block->length()),
|
||||
new_length_(new_length)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockResizeWithoutMediaOutCommand::redo()
|
||||
{
|
||||
block_->set_length(new_length_);
|
||||
}
|
||||
|
||||
void BlockResizeWithoutMediaOutCommand::undo()
|
||||
{
|
||||
block_->set_length(old_length_);
|
||||
}
|
||||
|
||||
BlockResizeWithMediaInCommand::BlockResizeWithMediaInCommand(Block *block, rational new_length, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
block_(block),
|
||||
@@ -102,24 +84,6 @@ 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_out(new_media_out_);
|
||||
}
|
||||
|
||||
void BlockSetMediaOutCommand::undo()
|
||||
{
|
||||
block_->set_media_out(old_media_out_);
|
||||
}
|
||||
|
||||
TrackRippleRemoveBlockCommand::TrackRippleRemoveBlockCommand(TrackOutput *track, Block *block, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
track_(track),
|
||||
@@ -411,13 +375,10 @@ void BlockSplitCommand::redo()
|
||||
Node::CopyInputs(block_, new_block_);
|
||||
|
||||
rational new_part_length = block_->length() - (point_ - block_->in());
|
||||
rational original_media_out = block_->media_out();
|
||||
|
||||
block_->set_length_and_media_out(new_length_);
|
||||
|
||||
new_block_->set_length(new_part_length);
|
||||
new_block_->set_media_in(block_->media_out());
|
||||
new_block_->set_media_out(original_media_out);
|
||||
new_block_->set_length_and_media_in(new_part_length);
|
||||
|
||||
track_->InsertBlockAfter(new_block_, block_);
|
||||
|
||||
@@ -588,7 +549,7 @@ void TrackCleanGapsCommand::redo()
|
||||
|
||||
new_gap_length += gap->length();
|
||||
}
|
||||
on_gap->set_length(new_gap_length);
|
||||
on_gap->set_length_and_media_out(new_gap_length);
|
||||
track->UnblockInvalidateCache();
|
||||
|
||||
// Reset state
|
||||
@@ -624,7 +585,7 @@ void TrackCleanGapsCommand::undo()
|
||||
for (int i=merged_gaps_.size()-1;i>=0;i--) {
|
||||
const MergedGap& merge_info = merged_gaps_.at(i);
|
||||
|
||||
merge_info.merged->set_length(merge_info.original_length);
|
||||
merge_info.merged->set_length_and_media_out(merge_info.original_length);
|
||||
|
||||
GapBlock* last_gap_added = merge_info.merged;
|
||||
|
||||
@@ -638,3 +599,21 @@ void TrackCleanGapsCommand::undo()
|
||||
|
||||
merged_gaps_.clear();
|
||||
}
|
||||
|
||||
BlockSetSpeedCommand::BlockSetSpeedCommand(Block *block, const rational &new_speed, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
block_(block),
|
||||
old_speed_(block->speed()),
|
||||
new_speed_(new_speed)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockSetSpeedCommand::redo()
|
||||
{
|
||||
block_->set_speed(new_speed_);
|
||||
}
|
||||
|
||||
void BlockSetSpeedCommand::undo()
|
||||
{
|
||||
block_->set_speed(old_speed_);
|
||||
}
|
||||
|
||||
@@ -41,19 +41,6 @@ private:
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockResizeWithoutMediaOutCommand : public QUndoCommand {
|
||||
public:
|
||||
BlockResizeWithoutMediaOutCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockResizeWithMediaInCommand : public QUndoCommand {
|
||||
public:
|
||||
BlockResizeWithMediaInCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
@@ -80,17 +67,18 @@ private:
|
||||
rational new_media_in_;
|
||||
};
|
||||
|
||||
class BlockSetMediaOutCommand : public QUndoCommand {
|
||||
class BlockSetSpeedCommand : public QUndoCommand {
|
||||
public:
|
||||
BlockSetMediaOutCommand(Block* block, rational new_media_out, QUndoCommand* parent = nullptr);
|
||||
BlockSetSpeedCommand(Block* block, const rational& new_speed, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
rational old_media_out_;
|
||||
rational new_media_out_;
|
||||
|
||||
rational old_speed_;
|
||||
rational new_speed_;
|
||||
};
|
||||
|
||||
class TrackRippleRemoveBlockCommand : public QUndoCommand {
|
||||
|
||||
Reference in New Issue
Block a user