From 776c9cd88fc0799426ced87f36cb215dfdc1854b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 30 Apr 2024 17:59:40 -0400
Subject: unwinding some import cycles.  added PinFuncs and
 .from(dv:DocumentView) for CollectionFreeForm stiuff

---
 src/client/views/nodes/trails/PresBox.tsx | 121 +++---------------------------
 1 file changed, 9 insertions(+), 112 deletions(-)

(limited to 'src/client/views/nodes/trails/PresBox.tsx')

diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index 4fe7ec993..4cf9e99fa 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -6,9 +6,9 @@ import { action, computed, IReactionDisposer, makeObservable, observable, Observ
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import { lightOrDark, returnFalse, returnOne, setupMoveUpEvents, StopEvent } from '../../../../ClientUtils';
-import { Doc, DocListCast, Field, FieldType, FieldResult, NumListCast, Opt, StrListCast } from '../../../../fields/Doc';
+import { Doc, DocListCast, Field, FieldResult, FieldType, NumListCast, Opt, StrListCast } from '../../../../fields/Doc';
 import { Animation, DocData, TransitionTimer } from '../../../../fields/DocSymbols';
-import { Copy, Id } from '../../../../fields/FieldSymbols';
+import { Copy } from '../../../../fields/FieldSymbols';
 import { InkField } from '../../../../fields/InkField';
 import { List } from '../../../../fields/List';
 import { ObjectField } from '../../../../fields/ObjectField';
@@ -24,6 +24,7 @@ import { dropActionType } from '../../../util/DropActionTypes';
 import { ScriptingGlobals } from '../../../util/ScriptingGlobals';
 import { SelectionManager } from '../../../util/SelectionManager';
 import { SerializationHelper } from '../../../util/SerializationHelper';
+import { SettingsManager } from '../../../util/SettingsManager';
 import { SnappingManager } from '../../../util/SnappingManager';
 import { undoBatch, UndoManager } from '../../../util/UndoManager';
 import { CollectionDockingView } from '../../collections/CollectionDockingView';
@@ -31,15 +32,15 @@ import { CollectionFreeFormView } from '../../collections/collectionFreeForm';
 import { CollectionStackedTimeline } from '../../collections/CollectionStackedTimeline';
 import { CollectionView } from '../../collections/CollectionView';
 import { TreeView } from '../../collections/TreeView';
-import { pinDataTypes as dataTypes, PinProps, ViewBoxBaseComponent } from '../../DocComponent';
+import { ViewBoxBaseComponent } from '../../DocComponent';
 import { Colors } from '../../global/globalEnums';
 import { LightboxView } from '../../LightboxView';
+import { pinDataTypes as dataTypes } from '../../PinFuncs';
 import { DocumentView, OpenWhere, OpenWhereMod } from '../DocumentView';
 import { FieldView, FieldViewProps, FocusViewOptions } from '../FieldView';
 import { ScriptingBox } from '../ScriptingBox';
 import './PresBox.scss';
 import { PresEffect, PresEffectDirection, PresMovement, PresStatus } from './PresEnums';
-import { SettingsManager } from '../../../util/SettingsManager';
 
 @observer
 export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -144,6 +145,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
     }
 
     componentDidMount() {
+        this._disposers.pause = reaction(
+            () => SnappingManager.UserPanned,
+            () => this.pauseAutoPres()
+        );
         this._disposers.keyboard = reaction(
             () => this.selectedDoc,
             selected => {
@@ -618,114 +623,6 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
         return undefined;
     }
 
-    /// copies values from the targetDoc (which is the prototype of the pinDoc) to
-    /// reserved fields on the pinDoc so that those values can be restored to the
-    /// target doc when navigating to it.
-    @action
-    static pinDocView(pinDocIn: Doc, pinProps: PinProps, targetDoc: Doc) {
-        const pinDoc = pinDocIn;
-        pinDoc.presentation = true;
-        pinDoc.config = '';
-        if (pinProps.pinDocLayout) {
-            pinDoc.config_pinLayout = true;
-            pinDoc.config_x = NumCast(targetDoc.x);
-            pinDoc.config_y = NumCast(targetDoc.y);
-            pinDoc.config_rotation = NumCast(targetDoc.rotation);
-            pinDoc.config_width = NumCast(targetDoc.width);
-            pinDoc.config_height = NumCast(targetDoc.height);
-        }
-        if (pinProps.pinAudioPlay) pinDoc.presPlayAudio = true;
-        if (pinProps.pinData) {
-            pinDoc.config_pinData =
-                pinProps.pinData.scrollable ||
-                pinProps.pinData.temporal ||
-                pinProps.pinData.pannable ||
-                pinProps.pinData.type_collection ||
-                pinProps.pinData.clippable ||
-                pinProps.pinData.datarange ||
-                pinProps.pinData.dataview ||
-                pinProps.pinData.poslayoutview ||
-                pinProps?.activeFrame !== undefined;
-            const fkey = Doc.LayoutFieldKey(targetDoc);
-            if (pinProps.pinData.dataview) {
-                pinDoc.config_usePath = targetDoc[fkey + '_usePath'];
-                pinDoc.config_data = targetDoc[fkey] instanceof ObjectField ? (targetDoc[fkey] as ObjectField)[Copy]() : targetDoc.data;
-            }
-            if (pinProps.pinData.dataannos) {
-                const fieldKey = Doc.LayoutFieldKey(targetDoc);
-                pinDoc.config_annotations = new List<Doc>(DocListCast(targetDoc[DocData][fieldKey + '_annotations']).filter(doc => !doc.layout_unrendered));
-            }
-            if (pinProps.pinData.inkable) {
-                pinDoc.config_fillColor = targetDoc.fillColor;
-                pinDoc.config_color = targetDoc.color;
-                pinDoc.config_width = targetDoc._width;
-                pinDoc.config_height = targetDoc._height;
-            }
-            if (pinProps.pinData.scrollable) pinDoc.config_scrollTop = targetDoc._layout_scrollTop;
-            if (pinProps.pinData.clippable) {
-                const fieldKey = Doc.LayoutFieldKey(targetDoc);
-                pinDoc.config_clipWidth = targetDoc[fieldKey + '_clipWidth'];
-            }
-            if (pinProps.pinData.datarange) {
-                pinDoc.config_xRange = undefined; // targetDoc?.xrange;
-                pinDoc.config_yRange = undefined; // targetDoc?.yrange;
-            }
-            if (pinProps.pinData.map) {
-                // pinDoc.config_latitude = targetDoc?.latitude;
-                // pinDoc.config_longitude = targetDoc?.longitude;
-                pinDoc.config_map_zoom = targetDoc?.map_zoom;
-                pinDoc.config_map_type = targetDoc?.map_type;
-                // ...
-            }
-            if (pinProps.pinData.poslayoutview)
-                pinDoc.config_pinLayoutData = new List<string>(
-                    DocListCast(targetDoc[fkey] as ObjectField).map(d =>
-                        JSON.stringify({
-                            id: d[Id],
-                            x: NumCast(d.x),
-                            y: NumCast(d.y),
-                            w: NumCast(d._width),
-                            h: NumCast(d._height),
-                            fill: StrCast(d._fillColor),
-                            back: StrCast(d._backgroundColor),
-                            data: SerializationHelper.Serialize(d.data instanceof ObjectField ? d.data[Copy]() : ''),
-                            text: SerializationHelper.Serialize(d.text instanceof ObjectField ? d.text[Copy]() : ''),
-                        })
-                    )
-                );
-            if (pinProps.pinData.type_collection) pinDoc.config_viewType = targetDoc._type_collection;
-            if (pinProps.pinData.filters) pinDoc.config_docFilters = ObjectField.MakeCopy(targetDoc.childFilters as ObjectField);
-            if (pinProps.pinData.pivot) pinDoc.config_pivotField = targetDoc._pivotField;
-            if (pinProps.pinData.pannable) {
-                pinDoc.config_panX = NumCast(targetDoc._freeform_panX);
-                pinDoc.config_panY = NumCast(targetDoc._freeform_panY);
-                pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
-            }
-            if (pinProps.pinData.temporal) {
-                pinDoc.config_clipStart = targetDoc._layout_currentTimecode;
-                const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}_duration`], NumCast(targetDoc.config_clipStart) + 0.1);
-                pinDoc.config_clipEnd = NumCast(pinDoc.config_clipStart) + NumCast(targetDoc.clipEnd, duration);
-            }
-        }
-        if (pinProps?.pinViewport) {
-            // If pinWithView option set then update scale and x / y props of slide
-            const bounds = pinProps.pinViewport;
-            pinDoc.config_pinView = true;
-            pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
-            pinDoc.config_panX = bounds.left + bounds.width / 2;
-            pinDoc.config_panY = bounds.top + bounds.height / 2;
-            pinDoc.config_viewBounds = new List<number>([bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + bounds.height]);
-        }
-    }
-
-    @action
-    static reversePin(pinDoc: Doc, targetDoc: Doc) {
-        // const fkey = Doc.LayoutFieldKey(targetDoc);
-        pinDoc.config_data = targetDoc.data;
-
-        console.log(pinDoc.presData);
-    }
-
     /**
      * This method makes sure that cursor navigates to the element that
      * has the option open and last in the group.
-- 
cgit v1.2.3-70-g09d2

