diff options
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/InkStrokeProperties.ts | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index 358274f0e..8165b7f4e 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -74,6 +74,7 @@ export class InkStrokeProperties { doc._height = (newYrange.max - newYrange.min) * ptsYscale + NumCast(doc.stroke_width); doc.x = oldXrange.coord + (newXrange.min - oldXrange.min) * ptsXscale; doc.y = oldYrange.coord + (newYrange.min - oldYrange.min) * ptsYscale; + Doc.SetInPlace(doc, 'stroke', new InkField(newPoints), true); appliedFunc = true; } @@ -248,7 +249,7 @@ export class InkStrokeProperties { /** * Handles the movement/scaling of a control point. */ - moveControlPtHandle = undoable((inkView: DocumentView, deltaX: number, deltaY: number, controlIndex: number, origInk?: InkData) => { + moveControlPtHandle = undoable((inkView: DocumentView, deltaX: number, deltaY: number, controlIndex: number, origInk?: InkData, noPush?: boolean) => { inkView && this.applyFunction(inkView, (view: DocumentView, ink: InkData) => { const order = controlIndex % 4; @@ -288,10 +289,11 @@ export class InkStrokeProperties { const { finalCtrls: rightCtrls /* , error: errorRight */ } = FitOneCurve(samplesRight, { X: startDir.x, Y: startDir.y }, { X: endDir.x, Y: endDir.y }); finalCtrls = finalCtrls.concat(rightCtrls); newink.splice(this._currentPoint - 4, 8, ...finalCtrls); - return newink; } - return ink.map((pt, i) => { + const prevData = (inkView.ComponentView as InkingStroke).screenCtrlPts; + + const newInk = ink.map((pt, i) => { const leftHandlePoint = order === 0 && i === controlIndex + 1; const rightHandlePoint = order === 0 && controlIndex !== 0 && i === controlIndex - 2; if (controlIndex === i || (order === 0 && controlIndex !== 0 && i === controlIndex - 1) || (order === 3 && i === controlIndex - 1)) { @@ -312,6 +314,26 @@ export class InkStrokeProperties { } return pt; }); + + if (inkView.IsSelected && !noPush && !InkingStroke.IsClosed(prevData)) { + const ffview = CollectionFreeFormView.from(inkView); + ffview?.childDocs.forEach(d => { + const oinkDoc = DocumentView.getDocumentView(d); + const oinkView = oinkDoc?.ComponentView as InkingStroke; + if (oinkView instanceof InkingStroke && oinkDoc && oinkDoc.Document !== inkView.Document) { + const { nearestSeg, nearestT } = InkStrokeProperties.nearestPtToStroke(oinkView.screenCtrlPts, prevData[controlIndex]); + const locdelta = inkView.screenToContentsTransform().inverse().transformDirection(deltaX, deltaY); + const index = nearestSeg + Math.round(nearestT) * 4; + const oinkData = oinkView.inkScaledData().inkData; + const closed = InkingStroke.IsClosed(oinkData); + InkStrokeProperties.Instance.moveControlPtHandle(oinkDoc, locdelta[0], locdelta[1], index, undefined, true); + if (index === oinkData.length && closed) { + InkStrokeProperties.Instance.moveControlPtHandle(oinkDoc, locdelta[0], locdelta[1], 0, undefined, true); + } + } + }); + } + return newInk; }); }, 'move ink ctrl pt'); |
