aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/trails/PresBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/trails/PresBox.tsx')
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx235
1 files changed, 118 insertions, 117 deletions
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index bd2be8f11..505e39d97 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -3,9 +3,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Tooltip } from '@material-ui/core';
import { action, computed, IReactionDisposer, observable, ObservableSet, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
-import { AnimationSym, Doc, DocListCast, Field, FieldResult, Opt, StrListCast } from '../../../../fields/Doc';
+import { Doc, DocListCast, Field, FieldResult, Opt, StrListCast } from '../../../../fields/Doc';
+import { Animation } from '../../../../fields/DocSymbols';
import { Copy, Id } from '../../../../fields/FieldSymbols';
-import { InkField, InkTool } from '../../../../fields/InkField';
+import { InkField } from '../../../../fields/InkField';
import { List } from '../../../../fields/List';
import { ObjectField } from '../../../../fields/ObjectField';
import { listSpec } from '../../../../fields/Schema';
@@ -41,7 +42,7 @@ export interface pinDataTypes {
scrollable?: boolean;
dataviz?: number[];
pannable?: boolean;
- viewType?: boolean;
+ type_collection?: boolean;
inkable?: boolean;
filters?: boolean;
pivot?: boolean;
@@ -103,10 +104,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@observable _presKeyEvents: boolean = false;
@observable _forceKeyEvents: boolean = false;
@computed get isTreeOrStack() {
- return [CollectionViewType.Tree, CollectionViewType.Stacking].includes(StrCast(this.layoutDoc._viewType) as any);
+ return [CollectionViewType.Tree, CollectionViewType.Stacking].includes(StrCast(this.layoutDoc._type_collection) as any);
}
@computed get isTree() {
- return this.layoutDoc._viewType === CollectionViewType.Tree;
+ return this.layoutDoc._type_collection === CollectionViewType.Tree;
}
@computed get presFieldKey() {
return StrCast(this.layoutDoc.presFieldKey, 'data');
@@ -128,14 +129,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
public static targetRenderedDoc = (doc: Doc) => {
const targetDoc = Cast(doc?.presentationTargetDoc, Doc, null);
- return targetDoc?.unrendered ? DocCast(targetDoc.annotationOn) : targetDoc;
+ return targetDoc?.layout_unrendered ? DocCast(targetDoc.annotationOn) : targetDoc;
};
@computed get scrollable() {
- if ([DocumentType.PDF, DocumentType.WEB, DocumentType.RTF].includes(this.targetDoc.type as DocumentType) || this.targetDoc._viewType === CollectionViewType.Stacking) return true;
+ if ([DocumentType.PDF, DocumentType.WEB, DocumentType.RTF].includes(this.targetDoc.type as DocumentType) || this.targetDoc._type_collection === CollectionViewType.Stacking) return true;
return false;
}
@computed get panable() {
- if ((this.targetDoc.type === DocumentType.COL && this.targetDoc._viewType === CollectionViewType.Freeform) || this.targetDoc.type === DocumentType.IMG) return true;
+ if ((this.targetDoc.type === DocumentType.COL && this.targetDoc._type_collection === CollectionViewType.Freeform) || this.targetDoc.type === DocumentType.IMG) return true;
return false;
}
@computed get selectedDocumentView() {
@@ -196,7 +197,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.turnOffEdit(true);
this._disposers.selection = reaction(
() => SelectionManager.Views(),
- views => views.some(view => view.props.Document === this.rootDoc) && this.updateCurrentPresentation()
+ views => (!PresBox.Instance || views.some(view => view.props.Document === this.rootDoc)) && this.updateCurrentPresentation(),
+ { fireImmediately: true }
);
this._disposers.editing = reaction(
() => this.layoutDoc.presStatus === PresStatus.Edit,
@@ -273,8 +275,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
progressivizedItems = (doc: Doc) => {
const targetList = PresBox.targetRenderedDoc(doc);
if (doc.presIndexed !== undefined && targetList) {
- const listItems = (Cast(targetList[Doc.LayoutFieldKey(targetList)], listSpec(Doc), null)?.filter(d => d instanceof Doc) as Doc[]) ?? DocListCast(targetList[Doc.LayoutFieldKey(targetList) + '-annotations']);
- return listItems.filter(doc => !doc.unrendered);
+ const listItems = (Cast(targetList[Doc.LayoutFieldKey(targetList)], listSpec(Doc), null)?.filter(d => d instanceof Doc) as Doc[]) ?? DocListCast(targetList[Doc.LayoutFieldKey(targetList) + '_annotations']);
+ return listItems.filter(doc => !doc.layout_unrendered);
}
};
// Called when the user activates 'next' - to move to the next part of the pres. trail
@@ -330,7 +332,6 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@action
back = () => {
const activeItem: Doc = this.activeItem;
- const prevItem = Cast(this.childDocs[Math.max(0, this.itemIndex - 1)], Doc, null);
let prevSelected = this.itemIndex;
// Functionality for group with up
let didZoom = activeItem.presMovement;
@@ -376,25 +377,25 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
static pinDataTypes(target?: Doc): pinDataTypes {
const targetType = target?.type as any;
const inkable = [DocumentType.INK].includes(targetType);
- const scrollable = [DocumentType.PDF, DocumentType.RTF, DocumentType.WEB].includes(targetType) || target?._viewType === CollectionViewType.Stacking;
- const pannable = [DocumentType.IMG, DocumentType.PDF].includes(targetType) || (targetType === DocumentType.COL && target?._viewType === CollectionViewType.Freeform);
+ const scrollable = [DocumentType.PDF, DocumentType.RTF, DocumentType.WEB].includes(targetType) || target?._type_collection === CollectionViewType.Stacking;
+ const pannable = [DocumentType.IMG, DocumentType.PDF].includes(targetType) || (targetType === DocumentType.COL && target?._type_collection === CollectionViewType.Freeform);
const temporal = [DocumentType.AUDIO, DocumentType.VID].includes(targetType);
const clippable = [DocumentType.COMPARISON].includes(targetType);
const datarange = [DocumentType.FUNCPLOT].includes(targetType);
const dataview = [DocumentType.INK, DocumentType.COL, DocumentType.IMG, DocumentType.RTF].includes(targetType) && target?.activeFrame === undefined;
const poslayoutview = [DocumentType.COL].includes(targetType) && target?.activeFrame === undefined;
- const viewType = targetType === DocumentType.COL;
+ const type_collection = targetType === DocumentType.COL;
const filters = true;
const pivot = true;
const dataannos = false;
- return { scrollable, pannable, inkable, viewType, pivot, filters, temporal, clippable, dataview, datarange, poslayoutview, dataannos };
+ return { scrollable, pannable, inkable, type_collection, pivot, filters, temporal, clippable, dataview, datarange, poslayoutview, dataannos };
}
@action
playAnnotation = (anno: AudioField) => {};
@action
static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.presPinLayout), pinDataTypes?: pinDataTypes, targetDoc?: Doc) {
- const bestTarget = bestTargetView?.rootDoc ?? (targetDoc?.unrendered ? DocCast(targetDoc?.annotationOn) : targetDoc);
+ const bestTarget = bestTargetView?.rootDoc ?? (targetDoc?.layout_unrendered ? DocCast(targetDoc?.annotationOn) : targetDoc);
if (!bestTarget || activeItem === bestTarget) return;
let changed = false;
if (pinDocLayout) {
@@ -419,7 +420,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const activeFrame = activeItem.presActiveFrame ?? activeItem.presCurrentFrame;
if (activeFrame !== undefined) {
const transTime = NumCast(activeItem.presTransition, 500);
- const acontext = activeItem.presActiveFrame !== undefined ? DocCast(DocCast(activeItem.presentationTargetDoc).context) : DocCast(activeItem.presentationTargetDoc);
+ const acontext = activeItem.presActiveFrame !== undefined ? DocCast(DocCast(activeItem.presentationTargetDoc).embedContainer) : DocCast(activeItem.presentationTargetDoc);
const context = DocCast(acontext)?.annotationOn ? DocCast(DocCast(acontext).annotationOn) : acontext;
if (context) {
const ffview = DocumentManager.Instance.getFirstDocumentView(context)?.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView;
@@ -429,6 +430,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
}
+ if ((pinDataTypes?.dataview && activeItem.presData !== undefined) || (!pinDataTypes && activeItem.presData !== undefined)) {
+ bestTarget._dataTransition = `all ${transTime}ms`;
+ const fkey = Doc.LayoutFieldKey(bestTarget);
+ const setData = bestTargetView?.ComponentView?.setData;
+ if (setData) setData(activeItem.presData);
+ else Doc.GetProto(bestTarget)[fkey] = activeItem.presData instanceof ObjectField ? activeItem.presData[Copy]() : activeItem.presData;
+ bestTarget[fkey + '_usePath'] = activeItem.presUsePath;
+ setTimeout(() => (bestTarget._dataTransition = undefined), transTime + 10);
+ }
if (pinDataTypes?.datarange || (!pinDataTypes && activeItem.presXRange !== undefined)) {
if (bestTarget.xRange !== activeItem.presXRange) {
bestTarget.xRange = (activeItem.presXRange as ObjectField)?.[Copy]();
@@ -440,14 +450,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
if (pinDataTypes?.clippable || (!pinDataTypes && activeItem.presClipWidth !== undefined)) {
- if (bestTarget._clipWidth !== activeItem.presClipWidth) {
- bestTarget._clipWidth = activeItem.presClipWidth;
+ const fkey = '_' + Doc.LayoutFieldKey(bestTarget);
+ if (bestTarget[fkey + '_clipWidth'] !== activeItem.presClipWidth) {
+ bestTarget[fkey + '_clipWidth'] = activeItem.presClipWidth;
changed = true;
}
}
if (pinDataTypes?.temporal || (!pinDataTypes && activeItem.presStartTime !== undefined)) {
- if (bestTarget._currentTimecode !== activeItem.presStartTime) {
- bestTarget._currentTimecode = activeItem.presStartTime;
+ if (bestTarget._layout_currentTimecode !== activeItem.presStartTime) {
+ bestTarget._layout_currentTimecode = activeItem.presStartTime;
changed = true;
}
}
@@ -469,16 +480,16 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
changed = true;
}
}
- if ((pinDataTypes?.viewType && activeItem.presViewType !== undefined) || (!pinDataTypes && activeItem.presViewType !== undefined)) {
- if (bestTarget._viewType !== activeItem.presViewType) {
- bestTarget._viewType = activeItem.presViewType;
+ if ((pinDataTypes?.type_collection && activeItem.presViewType !== undefined) || (!pinDataTypes && activeItem.presViewType !== undefined)) {
+ if (bestTarget._type_collection !== activeItem.presViewType) {
+ bestTarget._type_collection = activeItem.presViewType;
changed = true;
}
}
if ((pinDataTypes?.filters && activeItem.presDocFilters !== undefined) || (!pinDataTypes && activeItem.presDocFilters !== undefined)) {
- if (bestTarget.docFilters !== activeItem.presDocFilters) {
- bestTarget.docFilters = ObjectField.MakeCopy(activeItem.presDocFilters as ObjectField) || new List<string>([]);
+ if (bestTarget.childFilters !== activeItem.presDocFilters) {
+ bestTarget.childFilters = ObjectField.MakeCopy(activeItem.presDocFilters as ObjectField) || new List<string>([]);
changed = true;
}
}
@@ -495,8 +506,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
if (pinDataTypes?.scrollable || (!pinDataTypes && activeItem.presViewScroll !== undefined)) {
- if (bestTarget._scrollTop !== activeItem.presViewScroll) {
- bestTarget._scrollTop = activeItem.presViewScroll;
+ if (bestTarget._layout_scrollTop !== activeItem.presViewScroll) {
+ bestTarget._layout_scrollTop = activeItem.presViewScroll;
changed = true;
const contentBounds = Cast(activeItem.presPinViewBounds, listSpec('number'));
if (contentBounds) {
@@ -507,26 +518,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
if (pinDataTypes?.dataannos || (!pinDataTypes && activeItem.presAnnotations !== undefined)) {
const fkey = Doc.LayoutFieldKey(bestTarget);
- const oldItems = DocListCast(bestTarget[fkey + '-annotations']).filter(doc => doc.unrendered);
+ const oldItems = DocListCast(bestTarget[fkey + '_annotations']).filter(doc => doc.layout_unrendered);
const newItems = DocListCast(activeItem.presAnnotations).map(doc => {
doc.hidden = false;
return doc;
});
- const hiddenItems = DocListCast(bestTarget[fkey + '-annotations'])
- .filter(doc => !doc.unrendered && !newItems.includes(doc))
+ const hiddenItems = DocListCast(bestTarget[fkey + '_annotations'])
+ .filter(doc => !doc.layout_unrendered && !newItems.includes(doc))
.map(doc => {
doc.hidden = true;
return doc;
});
const newList = new List<Doc>([...oldItems, ...hiddenItems, ...newItems]);
- Doc.GetProto(bestTarget)[fkey + '-annotations'] = newList;
- }
- if ((pinDataTypes?.dataview && activeItem.presData !== undefined) || (!pinDataTypes && activeItem.presData !== undefined)) {
- bestTarget._dataTransition = `all ${transTime}ms`;
- const fkey = Doc.LayoutFieldKey(bestTarget);
- Doc.GetProto(bestTarget)[fkey] = activeItem.presData instanceof ObjectField ? activeItem.presData[Copy]() : activeItem.presData;
- bestTarget[fkey + '-usePath'] = activeItem.presUsePath;
- setTimeout(() => (bestTarget._dataTransition = undefined), transTime + 10);
+ Doc.GetProto(bestTarget)[fkey + '_annotations'] = newList;
}
if (pinDataTypes?.poslayoutview || (!pinDataTypes && activeItem.presPinLayoutData !== undefined)) {
changed = true;
@@ -558,20 +562,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const contentBounds = Cast(activeItem.presPinViewBounds, listSpec('number'));
if (contentBounds) {
const viewport = { panX: (contentBounds[0] + contentBounds[2]) / 2, panY: (contentBounds[1] + contentBounds[3]) / 2, width: contentBounds[2] - contentBounds[0], height: contentBounds[3] - contentBounds[1] };
- bestTarget._panX = viewport.panX;
- bestTarget._panY = viewport.panY;
+ bestTarget._freeform_panX = viewport.panX;
+ bestTarget._freeform_panY = viewport.panY;
const dv = DocumentManager.Instance.getDocumentView(bestTarget);
if (dv) {
changed = true;
const computedScale = NumCast(activeItem.presZoom, 1) * Math.min(dv.props.PanelWidth() / viewport.width, dv.props.PanelHeight() / viewport.height);
- activeItem.presMovement === PresMovement.Zoom && (bestTarget._viewScale = computedScale);
+ activeItem.presMovement === PresMovement.Zoom && (bestTarget._freeform_scale = computedScale);
dv.ComponentView?.brushView?.(viewport);
}
} else {
- if (bestTarget._panX !== activeItem.presPanX || bestTarget._panY !== activeItem.presPanY || bestTarget._viewScale !== activeItem.presViewScale) {
- bestTarget._panX = activeItem.presPanX ?? bestTarget._panX;
- bestTarget._panY = activeItem.presPanY ?? bestTarget._panY;
- bestTarget._viewScale = activeItem.presViewScale ?? bestTarget._viewScale;
+ if (bestTarget._freeform_panX !== activeItem.presPanX || bestTarget._freeform_panY !== activeItem.presPanY || bestTarget._freeform_scale !== activeItem.presViewScale) {
+ bestTarget._freeform_panX = activeItem.presPanX ?? bestTarget._freeform_panX;
+ bestTarget._freeform_panY = activeItem.presPanY ?? bestTarget._freeform_panY;
+ bestTarget._freeform_scale = activeItem.presViewScale ?? bestTarget._freeform_scale;
changed = true;
}
}
@@ -600,7 +604,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
pinProps.pinData.scrollable ||
pinProps.pinData.temporal ||
pinProps.pinData.pannable ||
- pinProps.pinData.viewType ||
+ pinProps.pinData.type_collection ||
pinProps.pinData.clippable ||
pinProps.pinData.datarange ||
pinProps.pinData.dataview ||
@@ -608,12 +612,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
pinProps?.activeFrame !== undefined;
const fkey = Doc.LayoutFieldKey(targetDoc);
if (pinProps.pinData.dataview) {
- pinDoc.presUsePath = targetDoc[fkey + '-usePath'];
+ pinDoc.presUsePath = targetDoc[fkey + '_usePath'];
pinDoc.presData = targetDoc[fkey] instanceof ObjectField ? (targetDoc[fkey] as ObjectField)[Copy]() : targetDoc.data;
}
if (pinProps.pinData.dataannos) {
const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.presAnnotations = new List<Doc>(DocListCast(Doc.GetProto(targetDoc)[fkey + '-annotations']).filter(doc => !doc.unrendered));
+ pinDoc.presAnnotations = new List<Doc>(DocListCast(Doc.GetProto(targetDoc)[fkey + '_annotations']).filter(doc => !doc.layout_unrendered));
}
if (pinProps.pinData.inkable) {
pinDoc.presFillColor = targetDoc.fillColor;
@@ -621,8 +625,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
pinDoc.presWidth = targetDoc._width;
pinDoc.presHeight = targetDoc._height;
}
- if (pinProps.pinData.scrollable) pinDoc.presViewScroll = targetDoc._scrollTop;
- if (pinProps.pinData.clippable) pinDoc.presClipWidth = targetDoc._clipWidth;
+ if (pinProps.pinData.scrollable) pinDoc.presViewScroll = targetDoc._layout_scrollTop;
+ if (pinProps.pinData.clippable) {
+ const fkey = Doc.LayoutFieldKey(targetDoc);
+ pinDoc.presClipWidth = targetDoc[fkey + '_clipWidth'];
+ }
if (pinProps.pinData.datarange) {
pinDoc.presXRange = undefined; //targetDoc?.xrange;
pinDoc.presYRange = undefined; //targetDoc?.yrange;
@@ -643,17 +650,17 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
})
)
);
- if (pinProps.pinData.viewType) pinDoc.presViewType = targetDoc._viewType;
- if (pinProps.pinData.filters) pinDoc.presDocFilters = ObjectField.MakeCopy(targetDoc.docFilters as ObjectField);
+ if (pinProps.pinData.type_collection) pinDoc.presViewType = targetDoc._type_collection;
+ if (pinProps.pinData.filters) pinDoc.presDocFilters = ObjectField.MakeCopy(targetDoc.childFilters as ObjectField);
if (pinProps.pinData.pivot) pinDoc.presPivotField = targetDoc._pivotField;
if (pinProps.pinData.pannable) {
- pinDoc.presPanX = NumCast(targetDoc._panX);
- pinDoc.presPanY = NumCast(targetDoc._panY);
- pinDoc.presViewScale = NumCast(targetDoc._viewScale, 1);
+ pinDoc.presPanX = NumCast(targetDoc._freeform_panX);
+ pinDoc.presPanY = NumCast(targetDoc._freeform_panY);
+ pinDoc.presViewScale = NumCast(targetDoc._freeform_scale, 1);
}
if (pinProps.pinData.temporal) {
- pinDoc.presStartTime = targetDoc._currentTimecode;
- const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}-duration`], NumCast(targetDoc.presStartTime) + 0.1);
+ pinDoc.presStartTime = targetDoc._layout_currentTimecode;
+ const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}_duration`], NumCast(targetDoc.presStartTime) + 0.1);
pinDoc.presEndTime = NumCast(targetDoc.clipEnd, duration);
}
}
@@ -661,7 +668,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// If pinWithView option set then update scale and x / y props of slide
const bounds = pinProps.pinViewport;
pinDoc.presPinView = true;
- pinDoc.presViewScale = NumCast(targetDoc._viewScale, 1);
+ pinDoc.presViewScale = NumCast(targetDoc._freeform_scale, 1);
pinDoc.presPanX = bounds.left + bounds.width / 2;
pinDoc.presPanY = bounds.top + bounds.height / 2;
pinDoc.presPinViewBounds = new List<number>([bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + bounds.height]);
@@ -681,7 +688,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const finished = () => {
afterNav?.();
console.log('Finish Slide Nav: ' + targetDoc.title);
- targetDoc[AnimationSym] = undefined;
+ targetDoc[Animation] = undefined;
};
const selViewCache = Array.from(this.selectedArray);
const dragViewCache = Array.from(this._dragArray);
@@ -727,7 +734,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
if (targetDoc) {
- if (activeItem.presentationTargetDoc instanceof Doc) activeItem.presentationTargetDoc[AnimationSym] = undefined;
+ if (activeItem.presentationTargetDoc instanceof Doc) activeItem.presentationTargetDoc[Animation] = undefined;
DocumentManager.Instance.AddViewRenderedCb(LightboxView.LightboxDoc, dv => {
// if target or the doc it annotates is not in the lightbox, then close the lightbox
@@ -791,7 +798,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const savedStates = docs.map(doc => {
switch (doc.type) {
case DocumentType.COL:
- if (doc._viewType === CollectionViewType.Freeform) return { type: CollectionViewType.Freeform, doc, x: NumCast(doc.panX), y: NumCast(doc.panY), s: NumCast(doc.viewScale) };
+ if (doc._type_collection === CollectionViewType.Freeform) return { type: CollectionViewType.Freeform, doc, x: NumCast(doc.freeform_panX), y: NumCast(doc.freeform_panY), s: NumCast(doc.freeform_scale) };
break;
case DocumentType.INK:
if (doc.data instanceof InkField) {
@@ -809,9 +816,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
case CollectionViewType.Freeform:
{
const { x, y, s, doc } = savedState!;
- doc._panX = x;
- doc._panY = y;
- doc._viewScale = s;
+ doc._freeform_panX = x;
+ doc._freeform_panY = y;
+ doc._freeform_scale = s;
}
break;
case DocumentType.INK:
@@ -827,7 +834,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
});
LightboxView.SetLightboxDoc(undefined);
- Doc.RemoveDocFromList(Doc.MyOverlayDocs, undefined, this.rootDoc);
+ Doc.RemFromMyOverlay(this.rootDoc);
return PresStatus.Edit;
};
};
@@ -923,8 +930,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return PresBox.OpenPresMinimized(this.rootDoc, [pt[0] + (this.props.PanelWidth() - 250), pt[1] + 10]);
};
exitMinimize = () => {
- if (DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc)) {
- Doc.RemoveDocFromList(Doc.MyOverlayDocs, undefined, this.rootDoc);
+ if (Doc.IsInMyOverlay(this.layoutDoc)) {
+ Doc.RemFromMyOverlay(this.rootDoc);
CollectionDockingView.AddSplit(this.rootDoc, OpenWhereMod.right);
}
return PresStatus.Edit;
@@ -936,7 +943,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
doc.overlayY = pt[1];
doc._height = 30;
doc._width = PresBox.minimizedWidth;
- Doc.AddDocToList(Doc.MyOverlayDocs, undefined, doc);
+ Doc.AddToMyOverlay(doc);
PresBox.Instance?.initializePresState(PresBox.Instance.itemIndex);
return (doc.presStatus = PresStatus.Manual);
}
@@ -948,11 +955,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@undoBatch
viewChanged = action((e: React.ChangeEvent) => {
//@ts-ignore
- const viewType = e.target.selectedOptions[0].value as CollectionViewType;
- this.layoutDoc.presFieldKey = this.fieldKey + (viewType === CollectionViewType.Tree ? '-linearized' : '');
+ const type_collection = e.target.selectedOptions[0].value as CollectionViewType;
+ this.layoutDoc.presFieldKey = this.fieldKey + (type_collection === CollectionViewType.Tree ? '-linearized' : '');
// pivot field may be set by the user in timeline view (or some other way) -- need to reset it here
- [CollectionViewType.Tree || CollectionViewType.Stacking].includes(viewType) && (this.rootDoc._pivotField = undefined);
- this.rootDoc._viewType = viewType;
+ [CollectionViewType.Tree || CollectionViewType.Stacking].includes(type_collection) && (this.rootDoc._pivotField = undefined);
+ this.rootDoc._type_collection = type_collection;
if (this.isTreeOrStack) {
this.layoutDoc._gridGap = 0;
}
@@ -1006,17 +1013,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return false;
}
} else {
- if (!doc.aliasOf) {
- const original = Doc.MakeAlias(doc);
- TabDocView.PinDoc(original, {});
- setTimeout(() => this.removeDocument(doc), 0);
- return false;
- } else {
- if (!doc.presentationTargetDoc) doc.title = doc.title + ' - Slide';
- doc.aliasOf instanceof Doc && (doc.presentationTargetDoc = doc.aliasOf);
- doc.presMovement = PresMovement.Zoom;
- if (this._expandBoolean) doc.presExpandInlineButton = true;
- }
+ if (!doc.presentationTargetDoc) doc.title = doc.title + ' - Slide';
+ doc.presentationTargetDoc = doc.createdFrom; // dropped document will be a new embedding of an embedded document somewhere else.
+ doc.presMovement = PresMovement.Zoom;
+ if (this._expandBoolean) doc.presExpandInlineButton = true;
}
});
return true;
@@ -1084,7 +1084,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.rootDoc._itemIndex = index;
}
} else this.gotoDocument(this.childDocs.indexOf(doc), this.activeItem);
- this.updateCurrentPresentation(DocCast(doc.context));
+ this.updateCurrentPresentation(DocCast(doc.embedContainer));
};
//Command click
@@ -1160,7 +1160,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
break;
case 'Escape':
- if (DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc)) {
+ if (Doc.IsInMyOverlay(this.layoutDoc)) {
this.exitClicked();
} else if (this.layoutDoc.presStatus === PresStatus.Edit) {
this.clearSelectedArray();
@@ -1238,7 +1238,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
.filter(doc => Cast(doc.presentationTargetDoc, Doc, null))
.forEach((doc, index) => {
const tagDoc = Cast(doc.presentationTargetDoc, Doc, null);
- const srcContext = Cast(tagDoc.context, Doc, null);
+ const srcContext = Cast(tagDoc.embedContainer, Doc, null);
const width = NumCast(tagDoc._width) / 10;
const height = Math.max(NumCast(tagDoc._height) / 10, 15);
const edge = Math.max(width, height);
@@ -1298,7 +1298,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
/**
* Method called for viewing paths which adds a single line with
* points at the center of each document added.
- * Design choice: When this is called it sets _fitContentsToBox as true so the
+ * Design choice: When this is called it sets _freeform_fitContentsToBox as true so the
* user can have an overview of all of the documents in the collection.
* (Design needed for when documents in presentation trail are in another
* collection)
@@ -1429,6 +1429,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
min={min}
max={max}
value={value}
+ readOnly={true}
style={{ marginLeft: hmargin, marginRight: hmargin, width: `calc(100% - ${2 * (hmargin ?? 0)}px)` }}
className={`toolbar-slider ${active ? '' : 'none'}`}
onPointerDown={e => {
@@ -1502,7 +1503,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="ribbon-doubleButton">
<div className="presBox-subheading">Slide Duration</div>
<div className="ribbon-property">
- <input className="presBox-input" type="number" value={duration} onKeyDown={e => e.stopPropagation()} onChange={e => this.updateDurationTime(e.target.value)} /> s
+ <input className="presBox-input" type="number" readOnly={true} value={duration} onKeyDown={e => e.stopPropagation()} onChange={e => this.updateDurationTime(e.target.value)} /> s
</div>
<div className="ribbon-propertyUpDown">
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateDurationTime(String(duration), 1000)}>
@@ -1551,7 +1552,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// a progressivized slide doesn't have sub-slides, but rather iterates over the data list of the target being progressivized.
// to avoid creating a new slide to correspond to each of the target's data list, we create a computedField to refernce the target's data list.
let dataField = Doc.LayoutFieldKey(tagDoc);
- if (Cast(tagDoc[dataField], listSpec(Doc), null)?.filter(d => d instanceof Doc) === undefined) dataField = dataField + '-annotations';
+ if (Cast(tagDoc[dataField], listSpec(Doc), null)?.filter(d => d instanceof Doc) === undefined) dataField = dataField + '_annotations';
if (DocCast(activeItem.presentationTargetDoc).annotationOn) activeItem.data = ComputedField.MakeFunction(`self.presentationTargetDoc.annotationOn["${dataField}"]`);
else activeItem.data = ComputedField.MakeFunction(`self.presentationTargetDoc["${dataField}"]`);
@@ -1655,7 +1656,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="ribbon-doubleButton" style={{ display: activeItem.presMovement === PresMovement.Zoom ? 'inline-flex' : 'none' }}>
<div className="presBox-subheading">Zoom (% screen filled)</div>
<div className="ribbon-property">
- <input className="presBox-input" type="number" value={zoom} onChange={e => this.updateZoom(e.target.value)} />%
+ <input className="presBox-input" type="number" readOnly={true} value={zoom} onChange={e => this.updateZoom(e.target.value)} />%
</div>
<div className="ribbon-propertyUpDown">
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateZoom(String(zoom), 0.1)}>
@@ -1670,7 +1671,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Transition Time</div>
<div className="ribbon-property">
- <input className="presBox-input" type="number" value={transitionSpeed} onKeyDown={e => e.stopPropagation()} onChange={action(e => this.updateTransitionTime(e.target.value))} /> s
+ <input className="presBox-input" type="number" readOnly={true} value={transitionSpeed} onKeyDown={e => e.stopPropagation()} onChange={action(e => this.updateTransitionTime(e.target.value))} /> s
</div>
<div className="ribbon-propertyUpDown">
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateTransitionTime(String(transitionSpeed), 1000)}>
@@ -1741,7 +1742,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const activeItem = this.activeItem;
if (activeItem && this.targetDoc) {
const clipStart = NumCast(activeItem.clipStart);
- const clipEnd = NumCast(activeItem.clipEnd, NumCast(activeItem[Doc.LayoutFieldKey(activeItem) + '-duration']));
+ const clipEnd = NumCast(activeItem.clipEnd, NumCast(activeItem[Doc.LayoutFieldKey(activeItem) + '_duration']));
return (
<div className={'presBox-ribbon'} onClick={e => e.stopPropagation()} onPointerUp={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
<div>
@@ -1757,6 +1758,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
className="presBox-input"
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
+ readOnly={true}
value={NumCast(activeItem.presStartTime).toFixed(2)}
onKeyDown={e => e.stopPropagation()}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => {
@@ -1783,6 +1785,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
onKeyDown={e => e.stopPropagation()}
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
+ readOnly={true}
value={NumCast(activeItem.presEndTime).toFixed(2)}
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => {
activeItem.presEndTime = Number(e.target.value);
@@ -2065,20 +2068,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
createTemplate = (layout: string, input?: string) => {
const x = this.activeItem && this.targetDoc ? NumCast(this.targetDoc.x) : 0;
const y = this.activeItem && this.targetDoc ? NumCast(this.targetDoc.y) + NumCast(this.targetDoc._height) + 20 : 0;
- const title = () => Docs.Create.TextDocument('Click to change title', { title: 'Slide title', _width: 380, _height: 60, x: 10, y: 58, _fontSize: '24pt' });
- const subtitle = () => Docs.Create.TextDocument('Click to change subtitle', { title: 'Slide subtitle', _width: 380, _height: 50, x: 10, y: 118, _fontSize: '16pt' });
- const header = () => Docs.Create.TextDocument('Click to change header', { title: 'Slide header', _width: 380, _height: 65, x: 10, y: 80, _fontSize: '20pt' });
- const contentTitle = () => Docs.Create.TextDocument('Click to change title', { title: 'Slide title', _width: 380, _height: 60, x: 10, y: 10, _fontSize: '24pt' });
- const content = () => Docs.Create.TextDocument('Click to change text', { title: 'Slide text', _width: 380, _height: 145, x: 10, y: 70, _fontSize: '14pt' });
- const content1 = () => Docs.Create.TextDocument('Click to change text', { title: 'Column 1', _width: 185, _height: 140, x: 10, y: 80, _fontSize: '14pt' });
- const content2 = () => Docs.Create.TextDocument('Click to change text', { title: 'Column 2', _width: 185, _height: 140, x: 205, y: 80, _fontSize: '14pt' });
+ const title = () => Docs.Create.TextDocument('Click to change title', { title: 'Slide title', _width: 380, _height: 60, x: 10, y: 58, _text_fontSize: '24pt' });
+ const subtitle = () => Docs.Create.TextDocument('Click to change subtitle', { title: 'Slide subtitle', _width: 380, _height: 50, x: 10, y: 118, _text_fontSize: '16pt' });
+ const header = () => Docs.Create.TextDocument('Click to change header', { title: 'Slide header', _width: 380, _height: 65, x: 10, y: 80, _text_fontSize: '20pt' });
+ const contentTitle = () => Docs.Create.TextDocument('Click to change title', { title: 'Slide title', _width: 380, _height: 60, x: 10, y: 10, _text_fontSize: '24pt' });
+ const content = () => Docs.Create.TextDocument('Click to change text', { title: 'Slide text', _width: 380, _height: 145, x: 10, y: 70, _text_fontSize: '14pt' });
+ const content1 = () => Docs.Create.TextDocument('Click to change text', { title: 'Column 1', _width: 185, _height: 140, x: 10, y: 80, _text_fontSize: '14pt' });
+ const content2 = () => Docs.Create.TextDocument('Click to change text', { title: 'Column 2', _width: 185, _height: 140, x: 205, y: 80, _text_fontSize: '14pt' });
// prettier-ignore
switch (layout) {
case 'blank': return Docs.Create.FreeformDocument([], { title: input ? input : 'Blank slide', _width: 400, _height: 225, x, y });
- case 'title': return Docs.Create.FreeformDocument([title(), subtitle()], { title: input ? input : 'Title slide', _width: 400, _height: 225, _fitContentsToBox: true, x, y });
- case 'header': return Docs.Create.FreeformDocument([header()], { title: input ? input : 'Section header', _width: 400, _height: 225, _fitContentsToBox: true, x, y });
- case 'content': return Docs.Create.FreeformDocument([contentTitle(), content()], { title: input ? input : 'Title and content', _width: 400, _height: 225, _fitContentsToBox: true, x, y });
- case 'twoColumns': return Docs.Create.FreeformDocument([contentTitle(), content1(), content2()], { title: input ? input : 'Title and two columns', _width: 400, _height: 225, _fitContentsToBox: true, x, y })
+ case 'title': return Docs.Create.FreeformDocument([title(), subtitle()], { title: input ? input : 'Title slide', _width: 400, _height: 225, _layout_fitContentsToBox: true, x, y });
+ case 'header': return Docs.Create.FreeformDocument([header()], { title: input ? input : 'Section header', _width: 400, _height: 225, _layout_fitContentsToBox: true, x, y });
+ case 'content': return Docs.Create.FreeformDocument([contentTitle(), content()], { title: input ? input : 'Title and content', _width: 400, _height: 225, _layout_fitContentsToBox: true, x, y });
+ case 'twoColumns': return Docs.Create.FreeformDocument([contentTitle(), content1(), content2()], { title: input ? input : 'Title and two columns', _width: 400, _height: 225, _layout_fitContentsToBox: true, x, y })
}
};
@@ -2127,12 +2130,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get toolbar() {
const propIcon = SettingsManager.propertiesWidth > 0 ? 'angle-double-right' : 'angle-double-left';
const propTitle = SettingsManager.propertiesWidth > 0 ? 'Close Presentation Panel' : 'Open Presentation Panel';
- const mode = StrCast(this.rootDoc._viewType) as CollectionViewType;
+ const mode = StrCast(this.rootDoc._type_collection) as CollectionViewType;
const isMini: boolean = this.toolbarWidth <= 100;
- const inOverlay = DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc);
const activeColor = Colors.LIGHT_BLUE;
const inactiveColor = Colors.WHITE;
- return mode === CollectionViewType.Carousel3D || inOverlay ? null : (
+ return mode === CollectionViewType.Carousel3D || Doc.IsInMyOverlay(this.rootDoc) ? null : (
<div id="toolbarContainer" className={'presBox-toolbar'}>
{/* <Tooltip title={<><div className="dash-tooltip">{"Add new slide"}</div></>}><div className={`toolbar-button ${this.newDocumentTools ? "active" : ""}`} onClick={action(() => this.newDocumentTools = !this.newDocumentTools)}>
<FontAwesomeIcon icon={"plus"} />
@@ -2171,11 +2173,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
* presentPanel: The button to start the presentation / open minimized view of the presentation
*/
@computed get topPanel() {
- const mode = StrCast(this.rootDoc._viewType) as CollectionViewType;
+ const mode = StrCast(this.rootDoc._type_collection) as CollectionViewType;
const isMini: boolean = this.toolbarWidth <= 100;
- const inOverlay = DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc);
return (
- <div className={`presBox-buttons${inOverlay ? ' inOverlay' : ''}`} style={{ background: Doc.ActivePresentation === this.rootDoc ? Colors.LIGHT_BLUE : undefined, display: !this.rootDoc._chromeHidden ? 'none' : undefined }}>
+ <div
+ className={`presBox-buttons${Doc.IsInMyOverlay(this.rootDoc) ? ' inOverlay' : ''}`}
+ style={{ background: Doc.ActivePresentation === this.rootDoc ? Colors.LIGHT_BLUE : undefined, display: !this.rootDoc._chromeHidden ? 'none' : undefined }}>
{isMini ? null : (
<select className="presBox-viewPicker" style={{ display: this.layoutDoc.presStatus === 'edit' ? 'block' : 'none' }} onPointerDown={e => e.stopPropagation()} onChange={this.viewChanged} value={mode}>
<option onPointerDown={StopEvent} value={CollectionViewType.Stacking}>
@@ -2225,7 +2228,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get playButtons() {
const presEnd = !this.layoutDoc.presLoop && this.itemIndex === this.childDocs.length - 1 && (this.activeItem.presIndexed === undefined || NumCast(this.activeItem.presIndexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
const presStart: boolean = !this.layoutDoc.presLoop && this.itemIndex === 0;
- const inOverlay = DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc);
+ const inOverlay = Doc.IsInMyOverlay(this.rootDoc);
// Case 1: There are still other frames and should go through all frames before going to next slide
return (
<div className="presPanelOverlay" style={{ display: this.layoutDoc.presStatus !== 'edit' ? 'inline-flex' : 'none' }}>
@@ -2396,10 +2399,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
render() {
// needed to ensure that the childDocs are loaded for looking up fields
this.childDocs.slice();
- const mode = StrCast(this.rootDoc._viewType) as CollectionViewType;
+ const mode = StrCast(this.rootDoc._type_collection) as CollectionViewType;
const presEnd = !this.layoutDoc.presLoop && this.itemIndex === this.childDocs.length - 1 && (this.activeItem.presIndexed === undefined || NumCast(this.activeItem.presIndexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
const presStart = !this.layoutDoc.presLoop && this.itemIndex === 0;
- const inOverlay = DocListCast(Doc.MyOverlayDocs?.data).includes(this.layoutDoc);
return this.props.addDocTab === returnFalse ? ( // bcz: hack!! - addDocTab === returnFalse only when this is being rendered by the OverlayView which means the doc is a mini player
<div className="miniPres" onClick={e => e.stopPropagation()} onPointerEnter={action(e => (this._forceKeyEvents = true))}>
<div
@@ -2442,7 +2444,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</div>
) : (
- <div className="presBox-cont" style={{ minWidth: inOverlay ? PresBox.minimizedWidth : undefined }}>
+ <div className="presBox-cont" style={{ minWidth: Doc.IsInMyOverlay(this.rootDoc) ? PresBox.minimizedWidth : undefined }}>
{this.topPanel}
{this.toolbar}
{this.newDocumentToolbarDropdown}
@@ -2456,9 +2458,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
childIgnoreNativeSize={true}
moveDocument={returnFalse}
ignoreUnrendered={true}
- //childFitWidth={returnTrue}
+ //childLayoutFitWidth={returnTrue}
childOpacity={returnOne}
- //childLayoutString={PresElementBox.LayoutString('data')}
childClickScript={PresBox.navigateToDocScript}
childLayoutTemplate={this.childLayoutTemplate}
childXPadding={Doc.IsComicStyle(this.rootDoc) ? 20 : undefined}