Search in sources :

Example 1 with AddExistingClipsCommand

use of com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand 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);
    }
}
Also used : Component(com.helospark.lightdi.annotation.Component) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) TimelineUiCacheElement(com.helospark.tactview.ui.javafx.uicomponents.canvasdraw.domain.TimelineUiCacheElement) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ClipDragInformation(com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation) DragEvent(javafx.scene.input.DragEvent) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) Dragboard(javafx.scene.input.Dragboard) CloneRequestMetadata(com.helospark.tactview.core.clone.CloneRequestMetadata) Map(java.util.Map) TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) AddExistingClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand) StatelessEffect(com.helospark.tactview.core.timeline.StatelessEffect) CurrentlyPressedKeyRepository(com.helospark.tactview.ui.javafx.key.CurrentlyPressedKeyRepository) AddClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddClipsCommand) ClipChannelPair(com.helospark.tactview.core.timeline.ClipChannelPair) EffectDragAdder(com.helospark.tactview.ui.javafx.uicomponents.EffectDragAdder) AddExistingClipRequest(com.helospark.tactview.core.timeline.AddExistingClipRequest) DragRepository(com.helospark.tactview.ui.javafx.repository.DragRepository) KeyCode(javafx.scene.input.KeyCode) Logger(org.slf4j.Logger) SelectedNodeRepository(com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository) TimelineDragAndDropHandler(com.helospark.tactview.ui.javafx.uicomponents.TimelineDragAndDropHandler) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) TimelineState(com.helospark.tactview.ui.javafx.uicomponents.TimelineState) Collectors(java.util.stream.Collectors) File(java.io.File) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) TimelineUiCacheType(com.helospark.tactview.ui.javafx.uicomponents.canvasdraw.domain.TimelineUiCacheType) List(java.util.List) LinkClipRepository(com.helospark.tactview.core.timeline.LinkClipRepository) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) Entry(java.util.Map.Entry) Optional(java.util.Optional) ClipDragInformation(com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip)

Example 2 with AddExistingClipsCommand

use of com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand in project tactview by helospark.

the class CopyPasteRepository method pasteClip.

private void pasteClip() {
    TimelinePosition positionToInsertClipsTo = timelineManager.findEndPosition();
    ClipCopyPasteDomain clipCopyPasteDomain = (ClipCopyPasteDomain) clipboardContent;
    List<AddExistingClipsCommand> commands = new ArrayList<>();
    for (var element : clipCopyPasteDomain.copiedData) {
        AddExistingClipRequest request = AddExistingClipRequest.builder().withChannel(element.timelineChannel).withClipToAdd(// multiple ctrl+v
        element.clipboardContent.cloneClip(CloneRequestMetadata.ofDefault())).withPosition(Optional.of(positionToInsertClipsTo.add(element.relativeOffset))).build();
        AddExistingClipsCommand addClipCommand = new AddExistingClipsCommand(request, timelineManager);
        commands.add(addClipCommand);
    }
    commandInterpreter.sendWithResult(new CompositeCommand(commands));
}
Also used : ClipCopyPasteDomain(com.helospark.tactview.ui.javafx.repository.copypaste.ClipCopyPasteDomain) AddExistingClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand) ArrayList(java.util.ArrayList) AddExistingClipRequest(com.helospark.tactview.core.timeline.AddExistingClipRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand)

Example 3 with AddExistingClipsCommand

use of com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand in project tactview by helospark.

the class TimelineCanvasOnDragOverHandler method copyCurrentClipOnDrag.

private void copyCurrentClipOnDrag(List<String> clipIds, String channelId, TimelinePosition newX) {
    TimelineChannel channel = timelineAccessor.findChannelWithId(channelId).get();
    int relativeChannelMove = timelineAccessor.findChannelIndexByChannelId(channelId).get() - timelineAccessor.findChannelIndexForClipId(clipIds.get(0)).get();
    List<TimelineClip> clips = new ArrayList<>();
    List<TimelineClip> allClipsToCopyOriginal = timelineAccessor.resolveClipIdsWithAllLinkedClip(clipIds);
    for (var clip : allClipsToCopyOriginal) {
        int currentChannelIndex = timelineAccessor.findChannelIndexForClipId(clip.getId()).get();
        int newChannelIndex = currentChannelIndex + relativeChannelMove;
        if (newChannelIndex < 0 || newChannelIndex >= timelineAccessor.getChannels().size()) {
            LOGGER.debug("Cannot copy clip, becase {} would be in non-existent channel {}", clip.getId(), newChannelIndex);
            return;
        }
    }
    Map<TimelineClip, TimelineClip> originalToNewClipMap = new HashMap<>();
    List<ClipChannelPair> allClonedClips = allClipsToCopyOriginal.stream().filter(a -> !a.getId().equals(clipIds.get(0))).map(a -> {
        TimelineClip newClip = a.cloneClip(CloneRequestMetadata.ofDefault());
        int currentChannelIndex = timelineAccessor.findChannelIndexForClipId(a.getId()).get();
        int newChannelIndex = currentChannelIndex + relativeChannelMove;
        TimelineChannel newChannel = timelineAccessor.findChannelOnIndex(newChannelIndex).get();
        originalToNewClipMap.put(a, newClip);
        return new ClipChannelPair(newClip, newChannel);
    }).collect(Collectors.toList());
    TimelineClip clip = timelineAccessor.findClipById(clipIds.get(0)).get();
    TimelineClip clonedClip = clip.cloneClip(CloneRequestMetadata.ofDefault());
    originalToNewClipMap.put(clip, clonedClip);
    AddExistingClipRequest request = AddExistingClipRequest.builder().withChannel(channel).withClipToAdd(clonedClip).withPosition(Optional.of(newX)).withAdditionalClipsToAdd(allClonedClips).build();
    AddExistingClipsCommand addClipCommand = new AddExistingClipsCommand(request, timelineAccessor);
    clips.add(clonedClip);
    commandInterpreter.synchronousSend(addClipCommand);
    setNewClipDragInformationAfterCopy(channelId, addClipCommand, clips, originalToNewClipMap);
}
Also used : Component(com.helospark.lightdi.annotation.Component) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) TimelineUiCacheElement(com.helospark.tactview.ui.javafx.uicomponents.canvasdraw.domain.TimelineUiCacheElement) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ClipDragInformation(com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation) DragEvent(javafx.scene.input.DragEvent) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) Dragboard(javafx.scene.input.Dragboard) CloneRequestMetadata(com.helospark.tactview.core.clone.CloneRequestMetadata) Map(java.util.Map) TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) AddExistingClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand) StatelessEffect(com.helospark.tactview.core.timeline.StatelessEffect) CurrentlyPressedKeyRepository(com.helospark.tactview.ui.javafx.key.CurrentlyPressedKeyRepository) AddClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddClipsCommand) ClipChannelPair(com.helospark.tactview.core.timeline.ClipChannelPair) EffectDragAdder(com.helospark.tactview.ui.javafx.uicomponents.EffectDragAdder) AddExistingClipRequest(com.helospark.tactview.core.timeline.AddExistingClipRequest) DragRepository(com.helospark.tactview.ui.javafx.repository.DragRepository) KeyCode(javafx.scene.input.KeyCode) Logger(org.slf4j.Logger) SelectedNodeRepository(com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository) TimelineDragAndDropHandler(com.helospark.tactview.ui.javafx.uicomponents.TimelineDragAndDropHandler) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) TimelineState(com.helospark.tactview.ui.javafx.uicomponents.TimelineState) Collectors(java.util.stream.Collectors) File(java.io.File) TimelineInterval(com.helospark.tactview.core.timeline.TimelineInterval) TimelineUiCacheType(com.helospark.tactview.ui.javafx.uicomponents.canvasdraw.domain.TimelineUiCacheType) List(java.util.List) LinkClipRepository(com.helospark.tactview.core.timeline.LinkClipRepository) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) Entry(java.util.Map.Entry) Optional(java.util.Optional) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) AddExistingClipsCommand(com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand) AddExistingClipRequest(com.helospark.tactview.core.timeline.AddExistingClipRequest) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) ClipChannelPair(com.helospark.tactview.core.timeline.ClipChannelPair)

Aggregations

AddExistingClipRequest (com.helospark.tactview.core.timeline.AddExistingClipRequest)3 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)3 AddExistingClipsCommand (com.helospark.tactview.ui.javafx.commands.impl.AddExistingClipsCommand)3 ArrayList (java.util.ArrayList)3 Component (com.helospark.lightdi.annotation.Component)2 CloneRequestMetadata (com.helospark.tactview.core.clone.CloneRequestMetadata)2 ClipChannelPair (com.helospark.tactview.core.timeline.ClipChannelPair)2 LinkClipRepository (com.helospark.tactview.core.timeline.LinkClipRepository)2 StatelessEffect (com.helospark.tactview.core.timeline.StatelessEffect)2 TimelineChannel (com.helospark.tactview.core.timeline.TimelineChannel)2 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)2 TimelineInterval (com.helospark.tactview.core.timeline.TimelineInterval)2 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)2 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)2 AddClipsCommand (com.helospark.tactview.ui.javafx.commands.impl.AddClipsCommand)2 CurrentlyPressedKeyRepository (com.helospark.tactview.ui.javafx.key.CurrentlyPressedKeyRepository)2 DragRepository (com.helospark.tactview.ui.javafx.repository.DragRepository)2 SelectedNodeRepository (com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository)2 ClipDragInformation (com.helospark.tactview.ui.javafx.repository.drag.ClipDragInformation)2 EffectDragAdder (com.helospark.tactview.ui.javafx.uicomponents.EffectDragAdder)2