diff options
| author | bobzel <zzzman@gmail.com> | 2024-05-08 21:03:08 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-05-08 21:03:08 -0400 |
| commit | b858bd3cad81da41e63b9f8e807e41421ca4aa34 (patch) | |
| tree | 99355f0595194e136494d50c527c859209935191 /src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | |
| parent | b8907e69160d97d919fcd83eb86d60e3634205ca (diff) | |
lots of api cleanup and cycle removal
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 74de6524b..dbd9fb11f 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -28,7 +28,6 @@ import { CollectionViewType, DocumentType } from '../../../documents/DocumentTyp import { DocUtils } from '../../../documents/DocUtils'; import { DragManager } from '../../../util/DragManager'; import { dropActionType } from '../../../util/DropActionTypes'; -import { ReplayMovements } from '../../../util/ReplayMovements'; import { CompileScript } from '../../../util/Scripting'; import { ScriptingGlobals } from '../../../util/ScriptingGlobals'; import { freeformScrollMode, SnappingManager } from '../../../util/SnappingManager'; @@ -36,9 +35,7 @@ import { Transform } from '../../../util/Transform'; import { undoable, undoBatch, UndoManager } from '../../../util/UndoManager'; import { Timeline } from '../../animationtimeline/Timeline'; import { ContextMenu } from '../../ContextMenu'; -import { GestureOverlay } from '../../GestureOverlay'; import { InkingStroke } from '../../InkingStroke'; -import { LightboxView } from '../../LightboxView'; import { CollectionFreeFormDocumentView } from '../../nodes/CollectionFreeFormDocumentView'; import { SchemaCSVPopUp } from '../../nodes/DataVizBox/SchemaCSVPopUp'; import { DocumentView } from '../../nodes/DocumentView'; @@ -367,7 +364,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection } const xfToCollection = options?.docTransform ?? Transform.Identity(); const savedState = { panX: NumCast(this.Document[this.panXFieldKey]), panY: NumCast(this.Document[this.panYFieldKey]), scale: options?.willZoomCentered ? this.Document[this.scaleFieldKey] : undefined }; - const cantTransform = this.fitContentsToBox || ((this.Document.isGroup || this.layoutDoc._lockedTransform) && !LightboxView.LightboxDoc); + const cantTransform = this.fitContentsToBox || ((this.Document.isGroup || this.layoutDoc._lockedTransform) && !DocumentView.LightboxDoc()); const { panX, panY, scale } = cantTransform || (!options.willPan && !options.willZoomCentered) ? savedState : this.calculatePanIntoView(anchor, xfToCollection, options?.willZoomCentered ? options?.zoomScale ?? 0.75 : undefined); // focus on the document in the collection @@ -620,7 +617,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection return false; }; forceStrokeGesture = (e: PointerEvent, gesture: Gestures, points: InkData, text?: any) => { - this.onGesture(e, new GestureUtils.GestureEvent(gesture, points, GestureOverlay.getBounds(points), text)); + this.onGesture(e, new GestureUtils.GestureEvent(gesture, points, InkField.getBounds(points), text)); }; onPointerMove = (e: PointerEvent) => { @@ -838,8 +835,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection @action setPan(panXIn: number, panYIn: number, panTime: number = 0, allowScroll = false) { let [panX, panY] = [panXIn, panYIn]; - // this is the easiest way to do this -> will talk with Bob about using mobx to do this to remove this line of code. - if (Doc.UserDoc()?.presentationMode === 'watching') ReplayMovements.Instance.pauseFromInteraction(); if (!this.isAnnotationOverlay && this.childDocs.length) { // this section wraps the pan position, horizontally and/or vertically whenever the content is panned out of the viewing bounds @@ -849,7 +844,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection panX = clamp(panX, xrangeMin - widScaling / 2, xrangeMax + widScaling / 2); panY = clamp(panY, yrangeMin - hgtScaling / 2, yrangeMax + hgtScaling / 2); } - if (!this.layoutDoc._lockedTransform || LightboxView.LightboxDoc) { + if (!this.layoutDoc._lockedTransform || DocumentView.LightboxDoc()) { this.setPanZoomTransition(panTime); const minScale = NumCast(this.dataDoc._freeform_scale_min, 1); const scale = 1 - minScale / this.zoomScaling(); @@ -882,6 +877,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection nudge = (x: number, y: number, nudgeTime: number = 500) => { const collectionDoc = this.Document; if (collectionDoc?._type_collection !== CollectionViewType.Freeform) { + SnappingManager.TriggerUserPanned(); this.setPan( NumCast(this.layoutDoc[this.panXFieldKey]) + ((this._props.PanelWidth() / 2) * x) / this.zoomScaling(), // nudge x,y as a function of panel dimension and scale NumCast(this.layoutDoc[this.panYFieldKey]) + ((this._props.PanelHeight() / 2) * -y) / this.zoomScaling(), @@ -1008,6 +1004,15 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection } return undefined; }; + + removeDocument = (docs: Doc | Doc[], annotationKey?: string | undefined) => { + const ret = !!this._props.removeDocument?.(docs, annotationKey); + // if this is a group and we have fewer than 2 Docs, then just promote what's left to our parent and get rid of the group. + if (ret && DocListCast(this.dataDoc[annotationKey ?? this.fieldKey]).length < 2 && this.Document.isGroup) { + this.promoteCollection(); + } + return ret; + }; childPointerEventsFunc = () => this._childPointerEvents; childContentsActive = () => (this._props.childContentsActive ?? this.isContentActive() === false ? returnFalse : emptyFunction)(); getChildDocView(entry: PoolData) { @@ -1050,7 +1055,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection focus={this.Document.isGroup ? this.groupFocus : this.isAnnotationOverlay ? this._props.focus : this.focus} addDocTab={this.addDocTab} addDocument={this._props.addDocument} - removeDocument={this._props.removeDocument} + removeDocument={this.removeDocument} moveDocument={this._props.moveDocument} pinToPres={this._props.pinToPres} whenChildContentsActiveChanged={this._props.whenChildContentsActiveChanged} @@ -1525,7 +1530,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection incrementalRendering = () => this.childDocs.filter(doc => !this._renderCutoffData.get(doc[Id])).length !== 0; incrementalRender = action(() => { - if (!LightboxView.LightboxDoc || LightboxView.Contains(this.DocumentView?.())) { + if (!DocumentView.LightboxDoc() || DocumentView.LightboxContains(this.DocumentView?.())) { const layoutUnrendered = this.childDocs.filter(doc => !this._renderCutoffData.get(doc[Id])); const loadIncrement = this.Document.isTemplateDoc ? Number.MAX_VALUE : 5; for (let i = 0; i < Math.min(layoutUnrendered.length, loadIncrement); i++) { |
