use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.
the class ClipInsertCommand method moveBackClipsBehind.
private TimelinePosition moveBackClipsBehind(TimelinePosition positionToInsertTo, List<Integer> channelIndices, TimelinePosition distanceToMove, boolean moveBackward, TimelineInterval combinedInterval) {
TreeSet<TimelineClip> clipsToMoveBack = new TreeSet<>();
if (timelineEditMode.equals(TimelineEditMode.SINGLE_CHANNEL_RIPPLE)) {
clipsToMoveBack = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, channelIndices, List.of());
} else if (timelineEditMode.equals(TimelineEditMode.ALL_CHANNEL_RIPPLE)) {
clipsToMoveBack = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, timelineManager.getAllChannelIndices(), List.of());
} else {
if (moveBackward) {
TreeSet<TimelineClip> clipsRightOf = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(positionToInsertTo, channelIndices, clipIdsToInsert);
TreeSet<TimelineClip> clipsLeftOf = timelineManager.findClipLeftOfPositionIncludingPartialOnChannels(combinedInterval.getStartPosition(), channelIndices, clipIdsToInsert);
clipsRightOf.retainAll(clipsLeftOf);
clipsToMoveBack = clipsRightOf;
} else {
TreeSet<TimelineClip> clipsRightOf = timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(combinedInterval.getEndPosition(), channelIndices, clipIdsToInsert);
TreeSet<TimelineClip> clipsLeftOf = timelineManager.findClipLeftOfPositionOnChannels(positionToInsertTo.add(insertInPlace.getInterval().getLength()), channelIndices, clipIdsToInsert);
clipsRightOf.retainAll(clipsLeftOf);
clipsToMoveBack = clipsRightOf;
}
}
if (clipsToMoveBack.size() > 0) {
TimelineClip firstClipToMove = clipsToMoveBack.stream().findFirst().get();
MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(clipsToMoveBack.stream().map(a -> a.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(firstClipToMove.getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(firstClipToMove.getId()).get().getId()).withNewPosition(firstClipToMove.getInterval().getStartPosition().add(distanceToMove)).build();
timelineManager.moveClip(moveClipRequest);
}
if (moveBackward || clipsToMoveBack.size() == 0) {
return positionToInsertTo;
} else {
return findCombinedInterval(new ArrayList<>(clipsToMoveBack)).getEndPosition();
}
}
use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.
the class RippleRemoveClipCommand method revert.
@Override
public void revert() {
if (!rippleDeletePerformed) {
return;
}
MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(movedClips.stream().map(a -> a.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(movedClips.get(0).getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(movedClips.get(0).getId()).get().getId()).withNewPosition(movedClips.get(0).getInterval().getStartPosition().add(moveDistance)).build();
timelineManager.moveClip(moveClipRequest);
for (var entry : removedClips.entries()) {
timelineManager.addClip(entry.getKey(), entry.getValue());
}
}
use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.
the class ClipMovedCommand method execute.
@Override
public void execute() {
MoveClipRequest request = MoveClipRequest.builder().withClipId(clipId).withAdditionalClipIds(additionalClipIds).withNewPosition(newPosition).withNewChannelId(newChannelId).withMaximumJump(maximumJumpLength).withMoreMoveExpected(moreMoveExpected).withEnableJumpingToSpecialPosition(enableJumpingToSpecialPosition).withAdditionalSpecialPositions(additionalPositions).build();
TimelineInterval newInterval = timelineManager.findClipById(clipId).get().getInterval();
wasOperationSuccessful = timelineManager.moveClip(request);
hasIntervalChanged = !previousPosition.equals(newInterval.getStartPosition());
}
use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.
the class ClipMovedCommand method revert.
@Override
public void revert() {
MoveClipRequest request = MoveClipRequest.builder().withClipId(clipId).withAdditionalClipIds(additionalClipIds).withNewPosition(previousPosition).withNewChannelId(originalChannelId).withEnableJumpingToSpecialPosition(false).build();
timelineManager.moveClip(request);
}
use of com.helospark.tactview.core.timeline.MoveClipRequest in project tactview by helospark.
the class ClipResizedCommand method revert.
@Override
public void revert() {
boolean isAnyRippleModeEnabled = !timelineEditMode.equals(TimelineEditMode.NORMAL);
TimelinePosition lengthToJumpToUse = lengthToJump;
for (var clipId : clipIds) {
TimelineClip clip = timelineManager.findClipById(clipId).orElseThrow(() -> new IllegalArgumentException("No clip found"));
TimelinePosition previousPosition = originalPosition;
boolean wasLeftRipple = left && isAnyRippleModeEnabled;
TimelinePosition positionToUse = previousPosition;
if (wasLeftRipple) {
TimelineLength intervalSizeDiff = clip.getGlobalInterval().getLength().subtract(originalInterval.getLength());
positionToUse = positionToUse.add(intervalSizeDiff.toPosition());
lengthToJumpToUse = intervalSizeDiff.toPosition().negate();
} else {
lengthToJumpToUse = originalInterval.getEndPosition().subtract(clip.getInterval().getEndPosition());
}
ResizeClipRequest request = ResizeClipRequest.builder().withClip(clip).withLeft(left).withUseSpecialPoints(false).withPosition(positionToUse).withKeepLeftSideOfClipAtSamePlace(wasLeftRipple).withIgnoreIntersection(clipsToMove.stream().map(a -> a.clip).collect(Collectors.toList())).build();
timelineManager.resizeClip(request);
}
if (clipsToMove.size() > 0) {
TimelineClip firstClipToMove = clipsToMove.stream().findFirst().get().clip;
MoveClipRequest moveClipRequest = MoveClipRequest.builder().withAdditionalClipIds(clipsToMove.stream().map(a -> a.clip.getId()).collect(Collectors.toList())).withAdditionalSpecialPositions(List.of()).withClipId(firstClipToMove.getId()).withEnableJumpingToSpecialPosition(false).withMoreMoveExpected(false).withNewChannelId(timelineManager.findChannelForClipId(firstClipToMove.getId()).get().getId()).withNewPosition(firstClipToMove.getInterval().getStartPosition().add(lengthToJumpToUse)).build();
timelineManager.moveClip(moveClipRequest);
}
}
Aggregations