Search in sources :

Example 1 with CompositeCommand

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

the class PrimitiveEffectLine method removeAllAndSetKeyframe.

@Override
public void removeAllAndSetKeyframe(TimelinePosition currentPosition) {
    RemoveAllKeyframeCommand removeAllKeyFrameCommand = new RemoveAllKeyframeCommand(effectParametersRepository, descriptorId);
    KeyframeAddedRequest keyframeRequest = KeyframeAddedRequest.builder().withDescriptorId(descriptorId).withGlobalTimelinePosition(currentPosition).withValue(currentValueSupplier.get()).build();
    AddKeyframeForPropertyCommand addKeyframeCommand = new AddKeyframeForPropertyCommand(effectParametersRepository, keyframeRequest);
    commandInterpreter.sendWithResult(new CompositeCommand(removeAllKeyFrameCommand, addKeyframeCommand));
}
Also used : KeyframeAddedRequest(com.helospark.tactview.core.timeline.message.KeyframeAddedRequest) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand)

Example 2 with CompositeCommand

use of com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand 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 CompositeCommand

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

the class GeneralCanvasOperationStrategy method onMouseDraggedEvent.

public void onMouseDraggedEvent(GeneralCanvasOperationsMouseRequest input) {
    if (input.mouseEvent.getButton().equals(MouseButton.MIDDLE)) {
        Point relativeMoveNormalized = new Point(input.canvasRelativeX, input.canvasRelativeY).subtract(dragStartPointAbsoluteCanvasPos);
        if (Math.abs(relativeMoveNormalized.distanceFrom(0.0, 0.0)) >= 1.0) {
            canvasStateHolder.increaseTranslateX(relativeMoveNormalized.x);
            canvasStateHolder.increaseTranslateY(relativeMoveNormalized.y);
            messagingService.sendMessage(new DisplayUpdateRequestMessage(false));
        }
        dragStartPointAbsoluteCanvasPos = new Point(input.canvasRelativeX, input.canvasRelativeY);
    } else if (dragData != null) {
        Point relativeMoveNormalized = new Point(input.x, input.y).subtract(dragStartPoint);
        Point relativeScale = relativeMoveNormalized.multiply(projectRepository.getPreviewWidth() / dragData.boundingBox.getWidth(), projectRepository.getPreviewHeight() / dragData.boundingBox.getHeight());
        Point relativeMove = relativeMoveNormalized.multiply(projectRepository.getPreviewWidth(), projectRepository.getPreviewHeight()).scalarDivide(projectRepository.getScaleFactor());
        Point newPosition = dragData.originalClipPosition.add(relativeMove);
        if (dragData.dragPointType.equals(DragPointType.CENTER)) {
            commandInterpreterService.sendWithResult(createKeyframeCommandWithValue(newPosition, "translate", dragData.draggedClip));
        } else if (dragData.dragPointType.equals(DragPointType.BOTTOM_RIGHT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 + relativeScale.x) * dragData.originalScale.x;
            double newHeight = (1.0 + relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(widthScaleCommand, heigthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.BOTTOM_LEFT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 - relativeScale.x) * dragData.originalScale.x;
            double newHeight = (1.0 + relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand xMoveCommand = createKeyframeCommandWithValue(new Point(newPosition.x, dragData.originalClipPosition.y), "translate", dragData.draggedClip);
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(xMoveCommand, widthScaleCommand, heigthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.TOP_RIGHT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 + relativeScale.x) * dragData.originalScale.x;
            double newHeight = (1.0 - relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand xMoveCommand = createKeyframeCommandWithValue(new Point(dragData.originalClipPosition.x, newPosition.y), "translate", dragData.draggedClip);
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(xMoveCommand, widthScaleCommand, heigthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.TOP_LEFT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 - relativeScale.x) * dragData.originalScale.x;
            double newHeight = (1.0 - relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand xMoveCommand = createKeyframeCommandWithValue(newPosition, "translate", dragData.draggedClip);
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(xMoveCommand, widthScaleCommand, heigthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.LEFT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 - relativeScale.x) * dragData.originalScale.x;
            AddKeyframeForPropertyCommand xMoveCommand = createKeyframeCommandWithValue(new Point(newPosition.x, dragData.originalClipPosition.y), "translate", dragData.draggedClip);
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(xMoveCommand, widthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.RIGHT)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newWidth = (1.0 + relativeScale.x) * dragData.originalScale.x;
            AddKeyframeForPropertyCommand widthScaleCommand = createKeyframeCommandWithValue(newWidth, "width scale", scaleEffectId);
            commandInterpreterService.sendWithResult(widthScaleCommand);
        } else if (dragData.dragPointType.equals(DragPointType.TOP)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newHeight = (1.0 - relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand xMoveCommand = createKeyframeCommandWithValue(new Point(dragData.originalClipPosition.x, newPosition.y), "translate", dragData.draggedClip);
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(new CompositeCommand(xMoveCommand, heigthScaleCommand));
        } else if (dragData.dragPointType.equals(DragPointType.BOTTOM)) {
            String scaleEffectId = getOrAddScaleEffect(dragData.draggedClip);
            double newHeight = (1.0 + relativeScale.y) * dragData.originalScale.y;
            AddKeyframeForPropertyCommand heigthScaleCommand = createKeyframeCommandWithValue(newHeight, "height scale", scaleEffectId);
            commandInterpreterService.sendWithResult(heigthScaleCommand);
        }
    }
}
Also used : DisplayUpdateRequestMessage(com.helospark.tactview.ui.javafx.DisplayUpdateRequestMessage) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) AddKeyframeForPropertyCommand(com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand)

Example 4 with CompositeCommand

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

the class StandardClipContextMenuChainItemConfiguration method deleteAllEffectsMenuItem.

@Bean
@Order(102)
public ClipContextMenuChainItem deleteAllEffectsMenuItem(CopyPasteRepository copyPasteRepository, UiCommandInterpreterService commandInterpreter, TimelineManagerAccessor timelineManager) {
    return alwaysSupportedContextMenuItem(request -> {
        MenuItem deleteEffectsFromClipMenuItem = new MenuItem("Delete all effects");
        deleteEffectsFromClipMenuItem.setOnAction(e -> {
            List<RemoveEffectCommand> removeEffectsCommand = request.getPrimaryClip().getEffects().stream().map(effect -> new RemoveEffectCommand(timelineManager, effect.getId())).collect(Collectors.toList());
            commandInterpreter.sendWithResult(new CompositeCommand(removeEffectsCommand));
        });
        if (request.getPrimaryClip().getEffects().isEmpty()) {
            deleteEffectsFromClipMenuItem.setDisable(true);
        }
        return deleteEffectsFromClipMenuItem;
    });
}
Also used : RemoveEffectCommand(com.helospark.tactview.ui.javafx.commands.impl.RemoveEffectCommand) EffectFactoryChain(com.helospark.tactview.core.timeline.EffectFactoryChain) Qualifier(com.helospark.lightdi.annotation.Qualifier) AddScaleCommand(com.helospark.tactview.ui.javafx.commands.impl.AddScaleCommand) TimelineEditMode(com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode) MenuItem(javafx.scene.control.MenuItem) SelectedNodeRepository(com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand) RemoveEffectCommand(com.helospark.tactview.ui.javafx.commands.impl.RemoveEffectCommand) RemoveClipService(com.helospark.tactview.ui.javafx.RemoveClipService) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) Configuration(com.helospark.lightdi.annotation.Configuration) Order(com.helospark.lightdi.annotation.Order) List(java.util.List) EffectFactory(com.helospark.tactview.core.timeline.effect.EffectFactory) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) CopyPasteRepository(com.helospark.tactview.ui.javafx.repository.CopyPasteRepository) Bean(com.helospark.lightdi.annotation.Bean) MenuItem(javafx.scene.control.MenuItem) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Example 5 with CompositeCommand

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

the class StandardClipContextMenuChainItemConfiguration method scaleToFrameMenuItem.

@Bean
@Order(0)
public ClipContextMenuChainItem scaleToFrameMenuItem(UiCommandInterpreterService commandInterpreter, TimelineManagerAccessor timelineManager, ProjectRepository projectRepository, @Qualifier("scaleEffect") EffectFactory scaleFactory, EffectFactoryChain effectFactoryChain, SelectedNodeRepository selectedNodeRepository) {
    return typeSupportingContextMenuItem(VisualTimelineClip.class, request -> {
        MenuItem scaleToImageMenuItem = new MenuItem("Scale to frame");
        scaleToImageMenuItem.setOnAction(e -> {
            List<AddScaleCommand> commands = request.getAllClips().stream().map(a -> a.getId()).map(clipId -> AddScaleCommand.builder().withClipId(clipId).withProjectRepository(projectRepository).withScaleEffectFactory(scaleFactory).withTimelineManager(timelineManager).withEffectFactoryChain(effectFactoryChain).build()).collect(Collectors.toList());
            if (commands.size() > 0) {
                commandInterpreter.sendWithResult(new CompositeCommand(commands));
            }
        });
        return scaleToImageMenuItem;
    });
}
Also used : EffectFactoryChain(com.helospark.tactview.core.timeline.EffectFactoryChain) Qualifier(com.helospark.lightdi.annotation.Qualifier) AddScaleCommand(com.helospark.tactview.ui.javafx.commands.impl.AddScaleCommand) TimelineEditMode(com.helospark.tactview.ui.javafx.repository.timelineeditmode.TimelineEditMode) MenuItem(javafx.scene.control.MenuItem) SelectedNodeRepository(com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository) UiCommandInterpreterService(com.helospark.tactview.ui.javafx.UiCommandInterpreterService) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand) RemoveEffectCommand(com.helospark.tactview.ui.javafx.commands.impl.RemoveEffectCommand) RemoveClipService(com.helospark.tactview.ui.javafx.RemoveClipService) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) Configuration(com.helospark.lightdi.annotation.Configuration) Order(com.helospark.lightdi.annotation.Order) List(java.util.List) EffectFactory(com.helospark.tactview.core.timeline.effect.EffectFactory) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) CopyPasteRepository(com.helospark.tactview.ui.javafx.repository.CopyPasteRepository) Bean(com.helospark.lightdi.annotation.Bean) MenuItem(javafx.scene.control.MenuItem) AddScaleCommand(com.helospark.tactview.ui.javafx.commands.impl.AddScaleCommand) CompositeCommand(com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand) Order(com.helospark.lightdi.annotation.Order) Bean(com.helospark.lightdi.annotation.Bean)

Aggregations

CompositeCommand (com.helospark.tactview.ui.javafx.commands.impl.CompositeCommand)7 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)3 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)3 RemoveEffectCommand (com.helospark.tactview.ui.javafx.commands.impl.RemoveEffectCommand)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Bean (com.helospark.lightdi.annotation.Bean)2 Configuration (com.helospark.lightdi.annotation.Configuration)2 Order (com.helospark.lightdi.annotation.Order)2 Qualifier (com.helospark.lightdi.annotation.Qualifier)2 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)2 EffectFactoryChain (com.helospark.tactview.core.timeline.EffectFactoryChain)2 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)2 VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)2 EffectFactory (com.helospark.tactview.core.timeline.effect.EffectFactory)2 RemoveClipService (com.helospark.tactview.ui.javafx.RemoveClipService)2 UiCommandInterpreterService (com.helospark.tactview.ui.javafx.UiCommandInterpreterService)2 AddKeyframeForPropertyCommand (com.helospark.tactview.ui.javafx.commands.impl.AddKeyframeForPropertyCommand)2 AddScaleCommand (com.helospark.tactview.ui.javafx.commands.impl.AddScaleCommand)2 CopyPasteRepository (com.helospark.tactview.ui.javafx.repository.CopyPasteRepository)2