use of com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation in project tactview by helospark.
the class TimelineCanvasOnDragOverHandler method setNewClipDragInformationAfterCopy.
private void setNewClipDragInformationAfterCopy(String channelId, AddExistingClipsCommand commands, List<TimelineClip> clips, Map<TimelineClip, TimelineClip> originalToNewClipMap) {
TimelineClip clip = clips.get(0);
if (commands.isSuccess()) {
dragRepository.currentlyDraggedClip().setShouldCopyClip(false);
List<String> elementIds = clips.stream().map(a -> a.getId()).collect(Collectors.toList());
ClipDragInformation clipDragInformation = new ClipDragInformation(clip.getGlobalInterval().getStartPosition(), elementIds, channelId, dragRepository.getClipDragInformation().getAnchorPointX(), clip.getGlobalInterval());
relinkClips(originalToNewClipMap);
dragRepository.onClipDragged(clipDragInformation);
}
}
use of com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation in project tactview by helospark.
the class TimelineCanvasElementClickHandler method onElementClick.
public void onElementClick(MouseEvent event, double currentX, TimelineUiCacheElement element) {
boolean isResizing = isResizing(element, event.getX());
if (element.elementType.equals(TimelineUiCacheType.CLIP)) {
TimelineClip clip = timelineAccessor.findClipById(element.elementId).get();
String channelId = timelineAccessor.findChannelForClipId(element.elementId).get().getId();
double clipPositionAsDouble = clip.getGlobalInterval().getStartPosition().getSeconds().doubleValue();
if (isResizing) {
boolean resizingLeft = isResizingLeft(element, event.getX());
TimelinePosition originalPosition = resizingLeft ? clip.getGlobalInterval().getStartPosition() : clip.getGlobalInterval().getEndPosition();
List<String> clipIds = timelineAccessor.findLinkedClipsWithSameInterval(element.elementId);
ClipDragInformation clipDragInformation = new ClipDragInformation(originalPosition, clipIds, channelId, currentX - clipPositionAsDouble, clip.getGlobalInterval());
dragRepository.onClipResizing(clipDragInformation, resizingLeft ? DragDirection.LEFT : DragDirection.RIGHT);
} else {
ClipDragInformation clipDragInformation = new ClipDragInformation(clip.getGlobalInterval().getStartPosition(), List.of(element.elementId), channelId, currentX - clipPositionAsDouble, clip.getGlobalInterval());
if (currentlyPressedKeyRepository.isKeyModifiersMatch(copyOnDragHotkey.getCombination())) {
clipDragInformation.setShouldCopyClip(true);
}
dragRepository.onClipDragged(clipDragInformation);
}
} else {
TimelineClip clip = timelineAccessor.findClipForEffect(element.elementId).get();
StatelessEffect effect = timelineAccessor.findEffectById(element.elementId).get();
if (isResizing) {
boolean resizingLeft = isResizingLeft(element, event.getX());
TimelinePosition originalPosition = resizingLeft ? effect.getGlobalInterval().getStartPosition() : effect.getGlobalInterval().getEndPosition();
EffectDragInformation effectDragInformation = new EffectDragInformation(clip.getId(), effect.getId(), originalPosition, currentX);
dragRepository.onEffectResized(effectDragInformation, resizingLeft ? DragDirection.LEFT : DragDirection.RIGHT);
} else {
TimelinePosition originalPosition = effect.getGlobalInterval().getStartPosition();
double clipStartSecondDouble = effect.getGlobalInterval().getStartPosition().getSeconds().doubleValue();
EffectDragInformation effectDragInformation = new EffectDragInformation(clip.getId(), effect.getId(), originalPosition, currentX - clipStartSecondDouble);
dragRepository.onEffectDragged(effectDragInformation);
}
}
}
use of com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation in project tactview by helospark.
the class TimelineCanvasOnDragOverHandler method onClipDraggedToCanvas.
private void onClipDraggedToCanvas(DragEvent event, Dragboard db, TimelineCanvasOnDragOverHandlerRequest request) {
Optional<TimelineChannel> optionalChannel = request.channel;
if (optionalChannel.isPresent()) {
List<File> dbFiles = db.getFiles();
String dbString = db.getString();
double currentX = event.getX();
String channelId = optionalChannel.get().getId();
if (!isLoadingInprogress && dragRepository.currentlyDraggedClip() == null && ((dbFiles != null && !dbFiles.isEmpty()) || timelineDragAndDropHandler.isStringClip(db))) {
selectedNodeRepository.clearAllSelectedItems();
isLoadingInprogress = true;
try {
AddClipsCommand command = timelineDragAndDropHandler.buildAddClipsCommand(channelId, dbFiles, dbString, currentX);
AddClipsCommand result = commandInterpreter.synchronousSend(command);
List<String> addedClipIds = result.getAddedClipIds();
if (addedClipIds.size() > 0) {
TimelineInterval originalInterval = timelineAccessor.findClipById(addedClipIds.get(0)).get().getInterval();
selectedNodeRepository.clearAndSetSelectedClips(addedClipIds);
ClipDragInformation clipDragInformation = new ClipDragInformation(result.getRequestedPosition(), addedClipIds, channelId, 0, originalInterval);
dragRepository.onClipDragged(clipDragInformation);
}
db.clear();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
isLoadingInprogress = false;
}
}
}
}
use of com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation in project tactview by helospark.
the class TimelineDragAndDropHandler method createMoveClipCommand.
public ClipMovedCommand createMoveClipCommand(String channelId, boolean revertable, TimelinePosition position) {
ClipDragInformation currentlyDraggedClip = dragRepository.currentlyDraggedClip();
if (currentlyDraggedClip != null) {
String clipId = currentlyDraggedClip.getClipIds().get(0);
if (position.isLessThan(TimelinePosition.ofZero())) {
position = TimelinePosition.ofZero();
}
Set<String> clipIds = new HashSet<>(selectedNodeRepository.getSelectedClipIds());
Set<TimelineClip> rippleElements = new HashSet<>();
Optional<TimelinePosition> leftestPositionOptional = Streams.concat(clipIds.stream(), Stream.of(clipId)).flatMap(clip -> timelineManager.findClipById(clip).stream()).sorted((clip1, clip2) -> clip1.getInterval().getStartPosition().compareTo(clip2.getInterval().getStartPosition())).findFirst().map(a -> a.getInterval().getStartPosition());
if (leftestPositionOptional.isEmpty()) {
return null;
}
var leftestPosition = leftestPositionOptional.get();
if (timelineEditModeRepository.getMode().equals(TimelineEditMode.ALL_CHANNEL_RIPPLE)) {
rippleElements.addAll(timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(leftestPosition, timelineManager.getAllChannelIndices(), List.of()));
} else if (timelineEditModeRepository.getMode().equals(TimelineEditMode.SINGLE_CHANNEL_RIPPLE)) {
List<Integer> channels = Streams.concat(clipIds.stream(), Stream.of(clipId)).flatMap(clip -> timelineManager.findChannelForClipId(clip).stream()).flatMap(channel -> timelineManager.findChannelIndexByChannelId(channel.getId()).stream()).collect(Collectors.toList());
rippleElements.addAll(timelineManager.findClipsRightFromPositionAndOnChannelIgnoring(leftestPosition, channels, List.of()));
}
rippleElements.stream().forEach(element -> clipIds.add(element.getId()));
boolean useSpecialPoints = timelineEditModeRepository.isMagnetEditModeEnabled(currentlyPressedKeyRepository.isKeyDown(SPECIAL_POSITION_DISABLE_KEY));
return ClipMovedCommand.builder().withIsRevertable(revertable).withClipId(clipId).withAdditionalClipIds(new ArrayList<>(clipIds)).withNewPosition(position).withPreviousPosition(currentlyDraggedClip.getOriginalPosition()).withOriginalChannelId(currentlyDraggedClip.getOriginalChannelId()).withNewChannelId(channelId).withTimelineManager(timelineManager).withEnableJumpingToSpecialPosition(useSpecialPoints).withMoreMoveExpected(!revertable).withMaximumJumpLength(new TimelineLength(timelineState.pixelsToSecondsWithZoom(MAXIMUM_SPECIAL_POINT_JUMP_LENGTH_IN_PIXELS).getSeconds())).withAdditionalPositions(List.of(uiTimelineManager.getCurrentPosition())).build();
} else {
return null;
}
}
use of com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation in project tactview by helospark.
the class TimelineDragAndDropHandler method resizeClip.
public void resizeClip(TimelinePosition position, boolean revertable, TimelinePosition relativeMove) {
ClipDragInformation currentlyDraggedEffect = dragRepository.currentlyDraggedClip();
if (currentlyDraggedEffect != null) {
List<String> clipId = currentlyDraggedEffect.getClipIds();
boolean useSpecialPoints = timelineEditModeRepository.isMagnetEditModeEnabled(currentlyPressedKeyRepository.isKeyDown(SPECIAL_POSITION_DISABLE_KEY));
ClipResizedCommand command = ClipResizedCommand.builder().withClipIds(clipId).withLeft(dragRepository.getDragDirection().equals(DragRepository.DragDirection.LEFT)).withPosition(position).withOriginalPosition(currentlyDraggedEffect.getOriginalPosition()).withOriginalInterval(currentlyDraggedEffect.getOriginalInterval()).withRevertable(revertable).withTimelineManager(timelineManager).withUseSpecialPoints(useSpecialPoints).withMinimumSize(new TimelineLength(timelineState.pixelsToSecondsWithZoom(MINIMUM_CLIP_SIZE).getSeconds())).withMoreResizeExpected(!revertable).withMaximumJumpLength(new TimelineLength(timelineState.pixelsToSecondsWithZoom(MAXIMUM_SPECIAL_POINT_JUMP_LENGTH_IN_PIXELS).getSeconds())).withTimelineEditMode(timelineEditModeRepository.getMode()).withRelativeMove(relativeMove).build();
commandInterpreter.sendWithResult(command).join();
}
}
Aggregations