timeline: updated selection changes for trimming and rippling
This commit is contained in:
@@ -56,4 +56,22 @@ void TimelineWidgetSelections::ShiftTracks(Timeline::TrackType type, int diff)
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidgetSelections::TrimIn(const rational &diff)
|
||||
{
|
||||
for (auto it=this->begin(); it!=this->end(); it++) {
|
||||
for (auto it2=it.value().begin(); it2!=it.value().end(); it2++) {
|
||||
(*it2).set_in((*it2).in() + diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidgetSelections::TrimOut(const rational &diff)
|
||||
{
|
||||
for (auto it=this->begin(); it!=this->end(); it++) {
|
||||
for (auto it2=it.value().begin(); it2!=it.value().end(); it2++) {
|
||||
(*it2).set_out((*it2).out() + diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -37,6 +37,10 @@ public:
|
||||
|
||||
void ShiftTracks(Timeline::TrackType type, int diff);
|
||||
|
||||
void TrimIn(const rational& diff);
|
||||
|
||||
void TrimOut(const rational& diff);
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -554,18 +554,32 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
|
||||
new NodeGraphBeginOperationCommand(static_cast<NodeGraph*>(parent()->GetConnectedNode()->parent()), command);
|
||||
|
||||
foreach (const GhostBlockPair& p, blocks_trimming) {
|
||||
TimelineViewGhostItem* ghost = p.ghost;
|
||||
if (!blocks_trimming.isEmpty()) {
|
||||
foreach (const GhostBlockPair& p, blocks_trimming) {
|
||||
TimelineViewGhostItem* ghost = p.ghost;
|
||||
|
||||
if (!ghost->GetData(TimelineViewGhostItem::kTrimShouldBeIgnored).toBool()) {
|
||||
// Must be an ordinary trim/roll
|
||||
BlockTrimCommand* c = new BlockTrimCommand(parent()->GetTrackFromReference(ghost->GetAdjustedTrack()),
|
||||
p.block,
|
||||
ghost->GetAdjustedLength(),
|
||||
ghost->GetMode(),
|
||||
command);
|
||||
if (!ghost->GetData(TimelineViewGhostItem::kTrimShouldBeIgnored).toBool()) {
|
||||
// Must be an ordinary trim/roll
|
||||
BlockTrimCommand* c = new BlockTrimCommand(parent()->GetTrackFromReference(ghost->GetAdjustedTrack()),
|
||||
p.block,
|
||||
ghost->GetAdjustedLength(),
|
||||
ghost->GetMode(),
|
||||
command);
|
||||
|
||||
c->SetTrimIsARollEdit(ghost->GetData(TimelineViewGhostItem::kTrimIsARollEdit).toBool());
|
||||
c->SetTrimIsARollEdit(ghost->GetData(TimelineViewGhostItem::kTrimIsARollEdit).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
if (blocks_moving.isEmpty() && blocks_sliding.isEmpty()) {
|
||||
// Trim selections (deferring to moving/sliding blocks when necessary)
|
||||
TimelineWidgetSelections new_sel = parent()->GetSelections();
|
||||
TimelineViewGhostItem* reference_ghost = blocks_trimming.first().ghost;
|
||||
if (reference_ghost->GetMode() == Timeline::kTrimIn) {
|
||||
new_sel.TrimIn(reference_ghost->GetInAdjustment());
|
||||
} else {
|
||||
new_sel.TrimOut(reference_ghost->GetOutAdjustment());
|
||||
}
|
||||
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,30 +108,43 @@ void RippleTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QVector< QList<TrackListRippleToolCommand::RippleInfo> > info_list(Timeline::kTrackTypeCount);
|
||||
if (parent()->HasGhosts()) {
|
||||
QVector< QList<TrackListRippleToolCommand::RippleInfo> > info_list(Timeline::kTrackTypeCount);
|
||||
|
||||
foreach (TimelineViewGhostItem* ghost, parent()->GetGhostItems()) {
|
||||
TrackOutput* track = parent()->GetTrackFromReference(ghost->GetTrack());
|
||||
foreach (TimelineViewGhostItem* ghost, parent()->GetGhostItems()) {
|
||||
TrackOutput* track = parent()->GetTrackFromReference(ghost->GetTrack());
|
||||
|
||||
TrackListRippleToolCommand::RippleInfo i = {Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kAttachedBlock)),
|
||||
Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kReferenceBlock)),
|
||||
track,
|
||||
ghost->GetAdjustedLength(),
|
||||
ghost->GetLength()};
|
||||
TrackListRippleToolCommand::RippleInfo i = {Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kAttachedBlock)),
|
||||
Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kReferenceBlock)),
|
||||
track,
|
||||
ghost->GetAdjustedLength(),
|
||||
ghost->GetLength()};
|
||||
|
||||
info_list[track->track_type()].append(i);
|
||||
info_list[track->track_type()].append(i);
|
||||
}
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
if (!info_list.isEmpty()) {
|
||||
for (int i=0;i<info_list.size();i++) {
|
||||
new TrackListRippleToolCommand(parent()->GetConnectedNode()->track_list(static_cast<Timeline::TrackType>(i)),
|
||||
info_list.at(i),
|
||||
drag_movement_mode(),
|
||||
command);
|
||||
}
|
||||
|
||||
TimelineWidgetSelections new_sel = parent()->GetSelections();
|
||||
TimelineViewGhostItem* reference_ghost = parent()->GetGhostItems().first();
|
||||
if (drag_movement_mode() == Timeline::kTrimIn) {
|
||||
new_sel.TrimOut(-reference_ghost->GetInAdjustment());
|
||||
} else {
|
||||
new_sel.TrimOut(reference_ghost->GetOutAdjustment());
|
||||
}
|
||||
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
for (int i=0;i<info_list.size();i++) {
|
||||
new TrackListRippleToolCommand(parent()->GetConnectedNode()->track_list(static_cast<Timeline::TrackType>(i)),
|
||||
info_list.at(i),
|
||||
drag_movement_mode(),
|
||||
command);
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user