From 416d9a1ef143cffed341fdb390a245b82c4b4137 Mon Sep 17 00:00:00 2001 From: Jenny Yu Date: Thu, 28 Apr 2022 17:55:49 -0400 Subject: feat: hiding recording --- src/client/views/nodes/trails/PresElementBox.tsx | 55 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'src/client/views/nodes/trails/PresElementBox.tsx') diff --git a/src/client/views/nodes/trails/PresElementBox.tsx b/src/client/views/nodes/trails/PresElementBox.tsx index f4f33482e..bc1cea505 100644 --- a/src/client/views/nodes/trails/PresElementBox.tsx +++ b/src/client/views/nodes/trails/PresElementBox.tsx @@ -43,6 +43,7 @@ export class PresElementBox extends ViewBoxBaseComponent() { @computed get presBox() { return Cast(this.lookupField("presBox"), Doc, null); } @computed get targetDoc() { return Cast(this.rootDoc.presentationTargetDoc, Doc, null) || this.rootDoc; } + @observable isShowingVideo = false; @action setIsShowingVideo(shown: boolean) { this.isShowingVideo = shown @@ -271,10 +272,31 @@ export class PresElementBox extends ViewBoxBaseComponent() { } } + @computed get recordingIsInOverlay() { + let isInOverlay = false + DocListCast((Doc.UserDoc().myOverlayDocs as Doc).data).forEach((doc) => { + if (doc.slides === this.rootDoc) { + isInOverlay = true + return + } + }) + return isInOverlay + } + @undoBatch @action - startRecording = (targetDoc: Doc, activeItem: Doc) => { + hideRecording = (targetDoc: Doc, activeItem: Doc) => { + console.log("hide recording") + DocListCast((Doc.UserDoc().myOverlayDocs as Doc).data).forEach((doc) => { + if (doc.slides === activeItem) { + Doc.RemoveDocFromList((Doc.UserDoc().myOverlayDocs as Doc), undefined, doc); + } + }) + } + @undoBatch + @action + startRecording = (targetDoc: Doc, activeItem: Doc) => { // Remove every recording that already exists in overlay view DocListCast((Doc.UserDoc().myOverlayDocs as Doc).data).forEach((doc) => { if (doc.slides !== null) { @@ -284,21 +306,24 @@ export class PresElementBox extends ViewBoxBaseComponent() { if (activeItem.recording) { // if we already have an existing recording + console.log("recording exists") Doc.AddDocToList((Doc.UserDoc().myOverlayDocs as Doc), undefined, Cast(activeItem.recording, Doc, null)); } else { + console.log("creating new recording") // if we dont have any recording const recording = Docs.Create.WebCamDocument("", { _width: 400, _height: 200, title: "recording", system: true, cloneFieldFilter: new List(["system"]) }); + // attach the recording to the slide, and attach the slide to the recording recording.slides = activeItem activeItem.recording = recording + // TODO: Figure out exactly where we want the video to appear const pt = this.props.ScreenToLocalTransform().inverse().transformPoint(0, 0); recording.x = pt[0]; recording.y = pt[1]; Doc.AddDocToList((Doc.UserDoc().myOverlayDocs as Doc), undefined, recording); } - } @computed @@ -375,13 +400,25 @@ export class PresElementBox extends ViewBoxBaseComponent() { onClick={() => this.updateView(targetDoc, activeItem)} style={{ fontWeight: 700, display: activeItem.presPinView ? "flex" : "none" }}>V -
{"Start recording"}
}> -
this.startRecording(targetDoc, activeItem)} - style={{ fontWeight: 700 }}> - e.stopPropagation()} /> -
-
+ + {this.recordingIsInOverlay ? +
{"Hide Recording"}
}> +
this.hideRecording(targetDoc, activeItem)} + style={{ fontWeight: 700 }}> + e.stopPropagation()} /> +
+
: +
{"Start recording"}
}> +
this.startRecording(targetDoc, activeItem)} + style={{ fontWeight: 700 }}> + e.stopPropagation()} /> +
+
+ } + + {this.indexInPres === 0 ? (null) :
{activeItem.groupWithUp ? "Ungroup" : "Group with up"}
}>
activeItem.groupWithUp = !activeItem.groupWithUp} -- cgit v1.2.3-70-g09d2 From 4381f14cfc058c534d4117a61ece34c6db72da9d Mon Sep 17 00:00:00 2001 From: Jenny Yu Date: Tue, 3 May 2022 16:43:02 -0400 Subject: feat: close recording when deleting slides --- src/client/views/nodes/trails/PresElementBox.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/client/views/nodes/trails/PresElementBox.tsx') diff --git a/src/client/views/nodes/trails/PresElementBox.tsx b/src/client/views/nodes/trails/PresElementBox.tsx index bc1cea505..23c80253c 100644 --- a/src/client/views/nodes/trails/PresElementBox.tsx +++ b/src/client/views/nodes/trails/PresElementBox.tsx @@ -234,6 +234,7 @@ export class PresElementBox extends ViewBoxBaseComponent() { if (PresBox.Instance._selectedArray.has(this.rootDoc)) { PresBox.Instance._selectedArray.delete(this.rootDoc); } + this.hideRecording(); e.stopPropagation(); }); @@ -285,10 +286,10 @@ export class PresElementBox extends ViewBoxBaseComponent() { @undoBatch @action - hideRecording = (targetDoc: Doc, activeItem: Doc) => { + hideRecording = () => { console.log("hide recording") DocListCast((Doc.UserDoc().myOverlayDocs as Doc).data).forEach((doc) => { - if (doc.slides === activeItem) { + if (doc.slides === this.rootDoc) { Doc.RemoveDocFromList((Doc.UserDoc().myOverlayDocs as Doc), undefined, doc); } }) @@ -322,6 +323,7 @@ export class PresElementBox extends ViewBoxBaseComponent() { const pt = this.props.ScreenToLocalTransform().inverse().transformPoint(0, 0); recording.x = pt[0]; recording.y = pt[1]; + console.log(pt) Doc.AddDocToList((Doc.UserDoc().myOverlayDocs as Doc), undefined, recording); } } @@ -404,7 +406,7 @@ export class PresElementBox extends ViewBoxBaseComponent() { {this.recordingIsInOverlay ?
{"Hide Recording"}
}>
this.hideRecording(targetDoc, activeItem)} + onClick={this.hideRecording} style={{ fontWeight: 700 }}> e.stopPropagation()} />
-- cgit v1.2.3-70-g09d2