From ad0cad318eb04199a0a68752b74374ff8f66a3be Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 14 Jan 2021 11:24:12 -0500 Subject: fixed rendering of labels in audioBox's to use standard dash-style provider stuff. added double click to play --- src/client/views/StyleProvider.tsx | 3 ++ src/client/views/nodes/AudioBox.scss | 2 - src/client/views/nodes/AudioBox.tsx | 81 +++++++++++++++++++-------------- src/client/views/nodes/DocumentView.tsx | 4 +- 4 files changed, 53 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index 8560f38cb..1d822439a 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -138,6 +138,9 @@ export function DefaultStyleProvider(doc: Opt, props: Opt { DocumentManager.Instance.getDocumentView(anchorDoc)?.select(false); - if (this.layoutDoc.playOnClick) this.playFrom(seekTimeInSeconds, endTime); - else this._ele && (this._ele.currentTime = this.layoutDoc._currentTimecode = seekTimeInSeconds); + this.playFrom(seekTimeInSeconds, endTime); + } + + // play back the audio from time + @action + clickMarker = (anchorDoc: Doc, seekTimeInSeconds: number, endTime: number = this.audioDuration) => { + if (this.layoutDoc.playOnClick) this.playOnClick(anchorDoc, seekTimeInSeconds, endTime); + else { + DocumentManager.Instance.getDocumentView(anchorDoc)?.select(false); + this._ele && (this._ele.currentTime = this.layoutDoc._currentTimecode = seekTimeInSeconds); + } } // play back the audio from time @action @@ -523,7 +536,6 @@ export class AudioBox extends ViewBoxAnnotatableComponent AudioBox.RangeScript; - labelScript = () => AudioBox.LabelScript; - audioStyleProvider = (doc: Doc | undefined, props: Opt, property: string) => { - if (property === StyleProp.BackgroundColor) return "transparent"; - if (property === StyleProp.PointerEvents) return "none"; - return this.props.styleProvider?.(doc, props, property); + rangeClickScript = () => AudioBox.RangeScript; + labelClickScript = () => AudioBox.LabelScript; + rangePlayScript = () => AudioBox.RangePlayScript; + labelPlayScript = () => AudioBox.LabelPlayScript; + renderMarker = (mark: Doc, script: undefined | (() => ScriptField), doublescript: undefined | (() => ScriptField), x: number, y: number, width: number, height: number) => { + return width} + PanelHeight={() => height} + focus={() => this.playLink(mark)} + rootSelected={returnFalse} + LayoutTemplate={undefined} + ContainingCollectionDoc={this.props.Document} + removeDocument={this.removeDocument} + ScreenToLocalTransform={() => this.props.ScreenToLocalTransform().translate(-x - 4, -y - 3)} + parentActive={returnTrue} + onClick={script} + onDoubleClick={this.layoutDoc.playOnClick ? undefined : doublescript} + ignoreAutoHeight={false} + bringToFront={emptyFunction} + scriptContext={this} />; } render() { const interactive = SnappingManager.GetIsDragging() || this.active() ? "-interactive" : ""; this._first = true; // for indicating the first marker that is rendered - const markerDoc = (mark: Doc, script: undefined | (() => ScriptField), x?: number, y?: number, width?: number, height?: number) => { - return width : this.props.PanelWidth} - PanelHeight={height ? () => height : this.props.PanelHeight} - focus={() => this.playLink(mark)} - pointerEvents={"all"} - rootSelected={returnFalse} - LayoutTemplate={undefined} - ContainingCollectionDoc={this.props.Document} - removeDocument={this.removeDocument} - ScreenToLocalTransform={x && y ? () => this.props.ScreenToLocalTransform().translate(-x - 4, -y - 3) : this.props.ScreenToLocalTransform} - parentActive={returnTrue} - onClick={script} - ignoreAutoHeight={false} - bringToFront={emptyFunction} - scriptContext={this} />; - }; + const heightPercent = 80; const playheadWidth = 30; const timelineContentWidth = this.props.PanelWidth() - playheadWidth; const timelineContentHeight = (this.props.PanelHeight() * heightPercent / 100) * heightPercent / 100; // panelHeight * heightPercent is player height. * heightPercent is timeline height (as per css inline) - return
+ return
{!this.path ?
@@ -586,10 +599,10 @@ export class AudioBox extends ViewBoxAnnotatableComponent e.stopPropagation()}>
- +
- +
{formatTime(Math.round(NumCast(this.layoutDoc._currentTimecode)))}
@@ -633,7 +646,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent { this.playFrom(NumCast(m.audioStart), NumCast(m.audioEnd)); e.stopPropagation(); }} >
this.onPointerDown(e, m, true)} /> - {markerDoc(m, this.rangeScript, + {this.renderMarker(m, this.rangeClickScript, this.rangePlayScript, playheadWidth + NumCast(m.audioStart) / this.audioDuration * timelineContentWidth, .1 * this.props.PanelHeight() + isOverlap / (this.dataDoc.markerAmount + 1) * timelineContentHeight, timelineContentWidth * (NumCast(m.audioEnd) - NumCast(m.audioStart)) / this.audioDuration, @@ -645,7 +658,7 @@ export class AudioBox extends ViewBoxAnnotatableComponent { this.playFrom(NumCast(m.audioStart)); e.stopPropagation(); }}> - {markerDoc(m, this.labelScript, + {this.renderMarker(m, this.labelClickScript, this.labelPlayScript, playheadWidth + NumCast(m.audioStart) / this.audioDuration * timelineContentWidth, .1 * this.props.PanelHeight(), 10, 10)} diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index b44c15a78..98995d040 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -379,14 +379,16 @@ export class DocumentViewInternal extends DocComponent this.onDoubleClickHandler.script.run({ this: this.layoutDoc, self: this.rootDoc, + scriptContext: this.props.scriptContext, thisContainer: this.props.ContainingCollectionDoc, + documentView: this.props.DocumentView, shiftKey: e.shiftKey }, console.log); undoBatch(func)(); } else if (!Doc.IsSystem(this.props.Document)) { if (this.props.Document.type === DocumentType.INK) { InkStrokeProperties.Instance && (InkStrokeProperties.Instance._controlBtn = true); - } else { + } else if (this.props.Document.type !== DocumentType.LABEL) { UndoManager.RunInBatch(() => { const fullScreenDoc = Cast(this.props.Document._fullScreenView, Doc, null) || this.props.Document; this.props.addDocTab(fullScreenDoc, "add"); -- cgit v1.2.3-70-g09d2