Search in sources :

Example 1 with CurrentlyPressedKeyRepository

use of com.helospark.tactview.ui.javafx.key.CurrentlyPressedKeyRepository in project tactview by helospark.

the class InputModeRepository method createMouseHandler.

private EventHandler<? super MouseEvent> createMouseHandler(Consumer<StrategyMouseInput> function, Consumer<GeneralCanvasOperationsMouseRequest> fallbackHandler) {
    return e -> {
        JavaDisplayableAudioVideoFragment cacheCurrentImage = displayUpdaterService.getCacheCurrentImage();
        double unmodifiedX = e.getX() - canvasStateHolder.getTranslateX();
        double unmodifiedY = e.getY() - canvasStateHolder.getTranslateY();
        if (inputModeInput != null) {
            double x = (sizeFunctionImplementation.scalePreviewDataUsingSizeFunction(unmodifiedX, inputModeInput.sizeFunction, projectRepository.getPreviewWidth()));
            double y = (sizeFunctionImplementation.scalePreviewDataUsingSizeFunction(unmodifiedY, inputModeInput.sizeFunction, projectRepository.getPreviewHeight()));
            StrategyMouseInput strategyInput = StrategyMouseInput.builder().withx(x).withy(y).withMouseEvent(e).withUnscaledX(unmodifiedX).withUnscaledY(unmodifiedY).withCanvasImage(() -> {
                return playbackController.getVideoFrameAt(timelineManager.getCurrentPosition(), Optional.empty()).getImage();
            }).withCurrentlyPressedKeyRepository(currentlyPressedKeyRepository).build();
            function.accept(strategyInput);
            if (inputModeInput.currentStrategy.getResultType() == ResultType.PARTIAL) {
                handleStrategyHasResult();
            }
            if (inputModeInput.currentStrategy.getResultType() == ResultType.DONE) {
                handleStrategyHasResult();
                reset();
            }
            updateCanvas(e);
        } else if (cacheCurrentImage != null) {
            Map<String, RegularRectangle> filteredRectangles = cacheCurrentImage.getClipRectangle().entrySet().stream().filter(entry -> selectedNodeRepository.getSelectedClipIds().contains(entry.getKey())).collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()));
            GeneralCanvasOperationsMouseRequest fallbackRequest = GeneralCanvasOperationsMouseRequest.builder().withCanvas(canvas).withUnscaledX(unmodifiedX).withUnscaledY(unmodifiedY).withCanvasRelativeX(e.getX()).withCanvasRelativeY(e.getY()).withx(unmodifiedX / projectRepository.getPreviewWidth()).withy(unmodifiedY / projectRepository.getPreviewHeight()).withMouseEvent(e).withRectangles(filteredRectangles).build();
            fallbackHandler.accept(fallbackRequest);
        }
    };
}
Also used : PointInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.PointInputTypeStrategy) EventHandler(javafx.event.EventHandler) Component(com.helospark.lightdi.annotation.Component) VideoStatusBarUpdater(com.helospark.tactview.ui.javafx.uicomponents.VideoStatusBarUpdater) CanvasStateHolder(com.helospark.tactview.ui.javafx.CanvasStateHolder) SizeFunctionImplementation(com.helospark.tactview.ui.javafx.inputmode.sizefunction.SizeFunctionImplementation) MouseEvent(javafx.scene.input.MouseEvent) LineInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.LineInputTypeStrategy) DrawRequestParameter(com.helospark.tactview.ui.javafx.inputmode.strategy.DrawRequestParameter) ArrayList(java.util.ArrayList) GeneralCanvasOperationsMouseRequest(com.helospark.tactview.ui.javafx.inputmode.strategy.generalops.GeneralCanvasOperationsMouseRequest) JavaDisplayableAudioVideoFragment(com.helospark.tactview.ui.javafx.JavaDisplayableAudioVideoFragment) Map(java.util.Map) ColorInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.ColorInputTypeStrategy) ResultType(com.helospark.tactview.ui.javafx.inputmode.strategy.ResultType) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) CurrentlyPressedKeyRepository(com.helospark.tactview.ui.javafx.key.CurrentlyPressedKeyRepository) PolygonInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.PolygonInputTypeStrategy) BezierPolygon(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygon) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) InputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.InputTypeStrategy) StrategyKeyInput(com.helospark.tactview.ui.javafx.inputmode.strategy.StrategyKeyInput) RelativePointInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.RelativePointInputTypeStrategy) KeyCode(javafx.scene.input.KeyCode) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) BezierPolygonInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.BezierPolygonInputTypeStrategy) RectangleInputTypeStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.RectangleInputTypeStrategy) SelectedNodeRepository(com.helospark.tactview.ui.javafx.repository.SelectedNodeRepository) DisplayUpdaterService(com.helospark.tactview.ui.javafx.DisplayUpdaterService) GraphicsContext(javafx.scene.canvas.GraphicsContext) PlaybackFrameAccessor(com.helospark.tactview.ui.javafx.PlaybackFrameAccessor) UiProjectRepository(com.helospark.tactview.ui.javafx.repository.UiProjectRepository) Canvas(javafx.scene.canvas.Canvas) GeneralCanvasOperationStrategy(com.helospark.tactview.ui.javafx.inputmode.strategy.generalops.GeneralCanvasOperationStrategy) Polygon(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon) Collectors(java.util.stream.Collectors) RegularRectangle(com.helospark.tactview.core.timeline.TimelineRenderResult.RegularRectangle) Rectangle(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Rectangle) Consumer(java.util.function.Consumer) Platform(javafx.application.Platform) List(java.util.List) BezierPolygonPoint(com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygonPoint) SizeFunction(com.helospark.tactview.core.timeline.effect.interpolation.provider.SizeFunction) StrategyMouseInput(com.helospark.tactview.ui.javafx.inputmode.strategy.StrategyMouseInput) Optional(java.util.Optional) CleanableMode(com.helospark.tactview.ui.javafx.repository.CleanableMode) Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) JavaDisplayableAudioVideoFragment(com.helospark.tactview.ui.javafx.JavaDisplayableAudioVideoFragment) StrategyMouseInput(com.helospark.tactview.ui.javafx.inputmode.strategy.StrategyMouseInput) RegularRectangle(com.helospark.tactview.core.timeline.TimelineRenderResult.RegularRectangle) GeneralCanvasOperationsMouseRequest(com.helospark.tactview.ui.javafx.inputmode.strategy.generalops.GeneralCanvasOperationsMouseRequest)

Aggregations

Component (com.helospark.lightdi.annotation.Component)1 RegularRectangle (com.helospark.tactview.core.timeline.TimelineRenderResult.RegularRectangle)1 Color (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color)1 InterpolationLine (com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine)1 Point (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point)1 Polygon (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Polygon)1 Rectangle (com.helospark.tactview.core.timeline.effect.interpolation.pojo.Rectangle)1 SizeFunction (com.helospark.tactview.core.timeline.effect.interpolation.provider.SizeFunction)1 BezierPolygon (com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygon)1 BezierPolygonPoint (com.helospark.tactview.core.timeline.proceduralclip.polygon.impl.bezier.BezierPolygonPoint)1 CanvasStateHolder (com.helospark.tactview.ui.javafx.CanvasStateHolder)1 DisplayUpdaterService (com.helospark.tactview.ui.javafx.DisplayUpdaterService)1 JavaDisplayableAudioVideoFragment (com.helospark.tactview.ui.javafx.JavaDisplayableAudioVideoFragment)1 PlaybackFrameAccessor (com.helospark.tactview.ui.javafx.PlaybackFrameAccessor)1 UiTimelineManager (com.helospark.tactview.ui.javafx.UiTimelineManager)1 SizeFunctionImplementation (com.helospark.tactview.ui.javafx.inputmode.sizefunction.SizeFunctionImplementation)1 BezierPolygonInputTypeStrategy (com.helospark.tactview.ui.javafx.inputmode.strategy.BezierPolygonInputTypeStrategy)1 ColorInputTypeStrategy (com.helospark.tactview.ui.javafx.inputmode.strategy.ColorInputTypeStrategy)1 DrawRequestParameter (com.helospark.tactview.ui.javafx.inputmode.strategy.DrawRequestParameter)1 InputTypeStrategy (com.helospark.tactview.ui.javafx.inputmode.strategy.InputTypeStrategy)1