From 0c76c27bde33c00589a1988815afbe757988d569 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 19 Jan 2021 14:15:54 -0500 Subject: added MarqueeAnnotator to videoBox --- src/client/views/nodes/VideoBox.tsx | 45 +++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx index c2c159e4b..e03c30b7f 100644 --- a/src/client/views/nodes/VideoBox.tsx +++ b/src/client/views/nodes/VideoBox.tsx @@ -25,6 +25,9 @@ import { LinkDocPreview } from "./LinkDocPreview"; import { FormattedTextBoxComment } from "./formattedText/FormattedTextBoxComment"; import { Transform } from "../../util/Transform"; import { StyleProp } from "../StyleProvider"; +import { Dictionary } from "typescript-collections"; +import { MarqueeAnnotator } from "../MarqueeAnnotator"; +import { PDFMenu } from "../pdf/PDFMenu"; const path = require('path'); export const timeSchema = createSchema({ @@ -36,14 +39,16 @@ const VideoDocument = makeInterface(documentSchema, timeSchema); @observer export class VideoBox extends ViewBoxAnnotatableComponent(VideoDocument) { static _youtubeIframeCounter: number = 0; - // private _reactionDisposer?: IReactionDisposer; - // private _youtubeReactionDisposer?: IReactionDisposer; private _disposers: { [name: string]: IReactionDisposer } = {}; private _youtubePlayer: YT.Player | undefined = undefined; private _videoRef: HTMLVideoElement | null = null; private _youtubeIframeId: number = -1; private _youtubeContentCreated = false; private _isResetClick = 0; + private _mainCont: React.RefObject = React.createRef(); + private _annotationLayer: React.RefObject = React.createRef(); + @observable _savedAnnotations: Dictionary = new Dictionary(); + @observable _marqueeing: number[] | undefined; @observable _forceCreateYouTubeIFrame = false; @observable _playTimer?: NodeJS.Timeout = undefined; @observable _fullScreen = false; @@ -185,6 +190,15 @@ export class VideoBox extends ViewBoxAnnotatableComponent this.props.isSelected(), + selected => { + if (!selected) { + this._savedAnnotations.values().forEach(v => v.forEach(a => a.remove())); + this._savedAnnotations.clear(); + PDFMenu.Instance.fadeOut(true); + } + }, + { fireImmediately: true }); this._disposers.videoStart = reaction( () => this.Document._videoStart, (videoStart) => { @@ -225,9 +239,7 @@ export class VideoBox extends ViewBoxAnnotatableComponent disposer?.()); } @action @@ -417,17 +429,29 @@ export class VideoBox extends ViewBoxAnnotatableComponent this.props.ScreenToLocalTransform(); contentFunc = () => [this.youtubeVideoId ? this.youtubeContent : this.content]; + + @computed get annotationLayer() { + return
; + } + + marqueeDown = action((e: React.PointerEvent) => { + if (!e.altKey && e.button === 0 && this.active(true)) this._marqueeing = [e.clientX, e.clientY]; + }) + + finishMarquee = action(() => { + this._marqueeing = undefined; + this.props.select(true); + }) + render() { const borderRad = this.props.styleProvider?.(this.layoutDoc, this.props, StyleProp.BorderRounding); const borderRadius = borderRad?.includes("px") ? `${Number(borderRad.split("px")[0]) / (this.props.scaling?.() || 1)}px` : borderRad; - return (
-
+
{this.uIButtons} + {this.annotationLayer} + {!this._marqueeing || !this._mainCont.current || !this._annotationLayer.current ? (null) : + }
); } } -- cgit v1.2.3-70-g09d2