From 196b92cb84095780d2b36244831cac03e9b66d8e Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 14 Nov 2024 10:48:16 -0500 Subject: changed isScribble related code to be more robust at determine cusps and deciding if cusps amount to a scribble. enabled undo of scribble erase without undoing scribble. added cusp visualizer for debugging, and cleaned up downDocView to be downFfview on CollectionFreeformView. --- src/client/views/GestureOverlay.tsx | 34 ++++++++++++---------- .../collectionFreeForm/CollectionFreeFormView.tsx | 7 +++++ src/client/views/nodes/DocumentView.tsx | 7 +---- 3 files changed, 27 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index b0a750a9a..777a34ebc 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -64,6 +64,8 @@ export class GestureOverlay extends ObservableReactComponent { const quarterArrayLength = Math.ceil(intersectArray.length / 3.9); // use 3.9 instead of 4 to work better with strokes with only 4 cusps @@ -182,7 +184,7 @@ export class GestureOverlay extends ObservableReactComponent value).length / intersectArray.length; - return intersectArray.length > 3 && (percentCuspsWithContent >= 0.5 || (start && end)); + return intersectArray.length > 3 && (percentCuspsWithContent >= Math.max(0.2, 1 / (intersectArray.length - 1)) || (start && end)); }; /** * determines if inks intersect @@ -236,9 +238,8 @@ export class GestureOverlay extends ObservableReactComponent { - const ffView = DocumentView.DownDocView?.ComponentView instanceof CollectionFreeFormView && DocumentView.DownDocView.ComponentView; - const downView = DocumentView.DownDocView; - DocumentView.DownDocView = undefined; + const ffView = CollectionFreeFormView.DownFfview; + CollectionFreeFormView.DownFfview = undefined; if (this._points.length > 1) { const B = this.svgBounds; const points = this._points.map(p => ({ X: p.X - B.left, Y: p.Y - B.top })); @@ -251,6 +252,8 @@ export class GestureOverlay extends ObservableReactComponent ({ X: p.X + B.left - rect?.left, Y: p.Y + B.top - rect.top })) : []; // if any of the shape is activated in the CollectionFreeFormViewChrome // need to decide when to turn gestures back on const actionPerformed = ((name: Gestures) => { @@ -272,14 +275,14 @@ export class GestureOverlay extends ObservableReactComponent ffView.removeDocument(scribbledOver), 'scribble erase')(); - } else { - this.dryInk(); + // can undo the erase without undoing the scribble, or undo a second time to undo the scribble + setTimeout(undoable(() => ffView.removeDocument(scribbledOver.concat([ffView.childDocs.lastElement()])), 'scribble erase')); } } } else { - (downView?.ComponentView as CollectionFreeFormView)?._marqueeViewRef?.current?.setPreviewCursor?.(this._points[0].X, this._points[0].Y, false, false, undefined); + ffView?._marqueeViewRef?.current?.setPreviewCursor?.(this._points[0].X, this._points[0].Y, false, false, undefined); e.preventDefault(); } this.primCreated(); @@ -336,13 +339,14 @@ export class GestureOverlay extends ObservableReactComponent {this.elements} - + {this._debugGestures && this._debugCusps.map(c =>
)}
{ + if (!CollectionFreeFormView.DownFfview) CollectionFreeFormView.DownFfview = this; + this._downX = this._lastX = e.pageX; this._downY = this._lastY = e.pageY; this._downTime = Date.now(); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 92e98db87..4bfa7fc92 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -355,7 +355,6 @@ export class DocumentViewInternal extends DocComponent { if (this._props.isGroupActive?.() === GroupActive.child && !this._props.isDocumentActive?.()) return; this._longPressSelector = setTimeout(() => SnappingManager.LongPress && this._props.select(false), 1000); - if (!DocumentView.DownDocView) DocumentView.DownDocView = this._docView; this._downX = e.clientX; this._downY = e.clientY; @@ -459,7 +458,7 @@ export class DocumentViewInternal extends DocComponent() { ?.ComponentView?.updateIcon?.() .then(() => ImageCast(DocCast(doc).icon)); } - /** - * The DocumentView below the cursor at the start of a gesture (that receives the pointerDown event). Used by GestureOverlay to determine the doc a gesture should apply to. - */ - public static DownDocView: DocumentView | undefined; // the first DocView that receives a pointerdown event. used by GestureOverlay to determine the doc a gesture should apply to. public get displayName() { return 'DocumentView(' + (this.Document?.title??"") + ')'; } // prettier-ignore private _htmlOverlayEffect: Opt; -- cgit v1.2.3-70-g09d2