handle transition track movement
Only allow transitions to move tracks if their attached blocks are moving with them.
This commit is contained in:
@@ -230,7 +230,7 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
|
||||
}
|
||||
|
||||
const TrackReference& track_ref = ghost->GetAdjustedTrack();
|
||||
TrackOutput* track = parent()->GetTrackFromReference(track_ref);
|
||||
//TrackOutput* track = parent()->GetTrackFromReference(track_ref);
|
||||
|
||||
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
|
||||
@@ -267,12 +267,13 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e
|
||||
}
|
||||
}
|
||||
|
||||
// Remove transitions that have been reduced to zero length
|
||||
if (b->type() == Block::kTransition) {
|
||||
if (b->type() == Block::kTransition && ghost->AdjustedLength() == 0) {
|
||||
// Remove transitions that have been reduced to zero length
|
||||
new NodeRemoveCommand(static_cast<NodeGraph*>(b->parent()),
|
||||
{b},
|
||||
command);
|
||||
} else {
|
||||
// Normal block placement
|
||||
new TrackPlaceBlockCommand(parent()->timeline_node_->track_list(track_ref.type()),
|
||||
track_ref.index(),
|
||||
b,
|
||||
@@ -478,19 +479,33 @@ void TimelineWidget::PointerTool::InitiateGhosts(TimelineViewBlockItem* clicked_
|
||||
}
|
||||
|
||||
if (block) {
|
||||
AddGhostFromBlock(block, clip_item->Track(), block_mode);
|
||||
TimelineViewGhostItem* ghost = AddGhostFromBlock(block, clip_item->Track(), block_mode);
|
||||
|
||||
if (block->type() == Block::kTransition) {
|
||||
TransitionBlock* transition = static_cast<TransitionBlock*>(block);
|
||||
|
||||
bool transition_can_move_tracks = false;
|
||||
|
||||
// Create a rolling effect with the attached block
|
||||
if (transition->connected_in_block() && (block_mode == Timeline::kTrimOut || block_mode == Timeline::kMove)) {
|
||||
AddGhostFromBlock(transition->connected_in_block(), clip_item->Track(), Timeline::kTrimIn);
|
||||
if (transition->connected_in_block()) {
|
||||
if (parent()->block_items_.value(transition->connected_in_block())->isSelected()) {
|
||||
// We'll be moving this item too, no need to create a ghost for it here
|
||||
transition_can_move_tracks = true;
|
||||
} else if (block_mode == Timeline::kTrimOut || block_mode == Timeline::kMove) {
|
||||
AddGhostFromBlock(transition->connected_in_block(), clip_item->Track(), Timeline::kTrimIn);
|
||||
}
|
||||
}
|
||||
|
||||
if (transition->connected_out_block() && (block_mode == Timeline::kTrimIn || block_mode == Timeline::kMove)) {
|
||||
AddGhostFromBlock(transition->connected_out_block(), clip_item->Track(), Timeline::kTrimOut);
|
||||
if (transition->connected_out_block()) {
|
||||
if (parent()->block_items_.value(transition->connected_in_block())->isSelected()) {
|
||||
// We'll be moving this item too, no need to create a ghost for it here
|
||||
transition_can_move_tracks = true;
|
||||
} else if (block_mode == Timeline::kTrimIn || block_mode == Timeline::kMove) {
|
||||
AddGhostFromBlock(transition->connected_out_block(), clip_item->Track(), Timeline::kTrimOut);
|
||||
}
|
||||
}
|
||||
|
||||
ghost->SetCanMoveTracks(transition_can_move_tracks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ rational TimelineWidget::Tool::ValidateFrameMovement(rational movement, const QV
|
||||
if (block && block->type() == Block::kTransition) {
|
||||
TransitionBlock* transition = static_cast<TransitionBlock*>(block);
|
||||
|
||||
// Daul transitions are only allowed to move so that neither of their offsets are < 0
|
||||
// Dual transitions are only allowed to move so that neither of their offsets are < 0
|
||||
if (transition->connected_in_block() && transition->connected_out_block()) {
|
||||
if (movement > transition->out_offset()) {
|
||||
movement = transition->out_offset();
|
||||
@@ -131,13 +131,19 @@ rational TimelineWidget::Tool::ValidateFrameMovement(rational movement, const QV
|
||||
int TimelineWidget::Tool::ValidateTrackMovement(int movement, const QVector<TimelineViewGhostItem *> ghosts)
|
||||
{
|
||||
foreach (TimelineViewGhostItem* ghost, ghosts) {
|
||||
// Prevents any ghosts from going to a non-existent negative track
|
||||
if (ghost->Track().index() + movement < 0) {
|
||||
if (ghost->mode() != Timeline::kMove) {
|
||||
continue;
|
||||
}
|
||||
if (ghost->mode() != Timeline::kMove) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ghost->CanMoveTracks()) {
|
||||
|
||||
movement = 0;
|
||||
|
||||
} else if (ghost->Track().index() + movement < 0) {
|
||||
|
||||
// Prevents any ghosts from going to a non-existent negative track
|
||||
movement = -ghost->Track().index();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ TimelineViewGhostItem::TimelineViewGhostItem(QGraphicsItem *parent) :
|
||||
track_adj_(0),
|
||||
stream_(nullptr),
|
||||
mode_(Timeline::kNone),
|
||||
can_have_zero_length_(true)
|
||||
can_have_zero_length_(true),
|
||||
can_move_tracks_(true)
|
||||
{
|
||||
SetInvisible(false);
|
||||
}
|
||||
@@ -50,11 +51,21 @@ TimelineViewGhostItem *TimelineViewGhostItem::FromBlock(Block *block, const Trac
|
||||
return ghost;
|
||||
}
|
||||
|
||||
bool TimelineViewGhostItem::CanHaveZeroLength()
|
||||
bool TimelineViewGhostItem::CanHaveZeroLength() const
|
||||
{
|
||||
return can_have_zero_length_;
|
||||
}
|
||||
|
||||
bool TimelineViewGhostItem::CanMoveTracks() const
|
||||
{
|
||||
return can_move_tracks_;
|
||||
}
|
||||
|
||||
void TimelineViewGhostItem::SetCanMoveTracks(bool e)
|
||||
{
|
||||
can_move_tracks_ = e;
|
||||
}
|
||||
|
||||
void TimelineViewGhostItem::SetInvisible(bool invisible)
|
||||
{
|
||||
setBrush(Qt::NoBrush);
|
||||
|
||||
@@ -44,7 +44,10 @@ public:
|
||||
|
||||
static TimelineViewGhostItem* FromBlock(Block *block, const TrackReference &track, int y, int height);
|
||||
|
||||
bool CanHaveZeroLength();
|
||||
bool CanHaveZeroLength() const;
|
||||
|
||||
bool CanMoveTracks() const;
|
||||
void SetCanMoveTracks(bool e);
|
||||
|
||||
void SetInvisible(bool invisible);
|
||||
|
||||
@@ -99,6 +102,7 @@ private:
|
||||
Timeline::MovementMode mode_;
|
||||
|
||||
bool can_have_zero_length_;
|
||||
bool can_move_tracks_;
|
||||
};
|
||||
|
||||
#endif // TIMELINEVIEWGHOSTITEM_H
|
||||
|
||||
Reference in New Issue
Block a user