diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 9 | ||||
-rw-r--r-- | src/client/views/InkStrokeProperties.ts | 46 | ||||
-rw-r--r-- | src/client/views/InkingStroke.tsx | 1 | ||||
-rw-r--r-- | src/client/views/collections/TabDocView.tsx | 10 | ||||
-rw-r--r-- | src/client/views/nodes/PresBox.tsx | 37 |
5 files changed, 81 insertions, 22 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index a24db53c2..2f4126a1e 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -271,10 +271,11 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b const right = Math.max(...xs); const bottom = Math.max(...ys); - // doc._height = (bottom - top) * element.props.ScreenToLocalTransform().Scale; - // doc._width = (right - left) * element.props.ScreenToLocalTransform().Scale; - doc._height = (bottom - top); - doc._width = (right - left); + doc._height = (bottom - top) * element.props.ScreenToLocalTransform().Scale; + doc._width = (right - left) * element.props.ScreenToLocalTransform().Scale; + // doc._height = (bottom - top); + // doc._width = (right - left); + } index++; diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index 2dac44bf8..df0f354cd 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -7,6 +7,8 @@ import { Cast, NumCast } from "../../fields/Types"; import { DocumentType } from "../documents/DocumentTypes"; import { SelectionManager } from "../util/SelectionManager"; import { undoBatch } from "../util/UndoManager"; +import { DocumentView } from "./nodes/DocumentView"; +import { returnVal } from "../../Utils"; export class InkStrokeProperties { static Instance: InkStrokeProperties | undefined; @@ -14,6 +16,7 @@ export class InkStrokeProperties { private _lastFill = "#D0021B"; private _lastLine = "#D0021B"; private _lastDash = "2"; + private _inkDocs: { x: number, y: number, width: number, height: number }[] = []; @observable _lock = false; @observable _controlBtn = false; @@ -190,6 +193,7 @@ export class InkStrokeProperties { doc._height = (bottom - top); doc._width = (right - left); + } index++; } @@ -198,6 +202,13 @@ export class InkStrokeProperties { @undoBatch @action + resetPoints = () => { + + } + + + @undoBatch + @action control = (xDiff: number, yDiff: number, controlNum: number) => { this.selectedInk?.forEach(action(inkView => { if (this.selectedInk?.length === 1) { @@ -218,31 +229,36 @@ export class InkStrokeProperties { (order === 3 && controlNum !== ink.length - 1 && i === controlNum + 2) || ((ink[0].X === ink[ink.length - 1].X) && (ink[0].Y === ink[ink.length - 1].Y) && (i === 0 || i === ink.length - 1) && (controlNum === 0 || controlNum === ink.length - 1)) ) { - newPoints.push({ X: ink[i].X - (xDiff * inkView.props.ScreenToLocalTransform().Scale), Y: ink[i].Y - (yDiff * inkView.props.ScreenToLocalTransform().Scale) }); + newPoints.push({ X: ink[i].X - (xDiff), Y: ink[i].Y - (yDiff) }); } else { newPoints.push({ X: ink[i].X, Y: ink[i].Y }); } } + const oldHeight = doc._height; + const oldWidth = doc._width; const oldx = doc.x; const oldy = doc.y; - const xs = ink.map(p => p.X); - const ys = ink.map(p => p.Y); - const left = Math.min(...xs); - const top = Math.min(...ys); + const oldxs = ink.map(p => p.X); + const oldys = ink.map(p => p.Y); + const oldleft = Math.min(...oldxs); + const oldtop = Math.min(...oldys); + const oldright = Math.max(...oldxs); + const oldbottom = Math.max(...oldys); Doc.GetProto(doc).data = new InkField(newPoints); - const xs2 = newPoints.map(p => p.X); - const ys2 = newPoints.map(p => p.Y); - const left2 = Math.min(...xs2); - const top2 = Math.min(...ys2); - const right2 = Math.max(...xs2); - const bottom2 = Math.max(...ys2); - doc._height = (bottom2 - top2); - doc._width = (right2 - left2); + const newxs = newPoints.map(p => p.X); + const newys = newPoints.map(p => p.Y); + const newleft = Math.min(...newxs); + const newtop = Math.min(...newys); + const newright = Math.max(...newxs); + const newbottom = Math.max(...newys); + //if points move out of bounds + doc._height = (newbottom - newtop) * inkView.props.ScreenToLocalTransform().Scale; + doc._width = (newright - newleft) * inkView.props.ScreenToLocalTransform().Scale; - doc.x = oldx - (left - left2); - doc.y = oldy - (top - top2); + doc.x = oldx - (oldleft - newleft) * inkView.props.ScreenToLocalTransform().Scale; + doc.y = oldy - (oldtop - newtop) * inkView.props.ScreenToLocalTransform().Scale; } } diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index dbe2d73d1..8df7f7eef 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -47,6 +47,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume @action onControlDown = (e: React.PointerEvent, i: number): void => { //TODO:renew points before controlling + InkStrokeProperties.Instance?.control(0.001, 0.001, 1); setupMoveUpEvents(this, e, this.onControlMove, this.onControlup, (e) => { }); this._controlUndo = UndoManager.StartBatch("DocDecs set radius"); this._prevX = e.clientX; diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 0d03936dc..9a0759fe5 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -189,6 +189,16 @@ export class TabDocView extends React.Component<TabDocViewProps> { pinDoc.presStartTime = 0; pinDoc.presEndTime = pinDoc.type === DocumentType.AUDIO ? doc.duration : NumCast(doc["data-duration"]); } + //save position + if (pinDoc.isInkMask) { + pinDoc.y = doc.y; + pinDoc.x = doc.x; + pinDoc.presHideAfter = true; + pinDoc.presHideBefore = true; + pinDoc.title = doc.title + "- Spotlight"; + pinDoc.presMovement = PresMovement.None; + + } if (curPres.expandBoolean) pinDoc.presExpandInlineButton = true; const dview = CollectionDockingView.Instance.props.Document; const fieldKey = CollectionDockingView.Instance.props.fieldKey; diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx index 42462000b..fb3598a04 100644 --- a/src/client/views/nodes/PresBox.tsx +++ b/src/client/views/nodes/PresBox.tsx @@ -423,8 +423,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> } else if (curDoc.presMovement === PresMovement.Pan && targetDoc) { await DocumentManager.Instance.jumpToDocument(targetDoc, false, openInTab, srcContext, undefined, undefined, undefined, includesDoc || tab ? undefined : resetSelection); // documents open in new tab instead of on right } else if ((curDoc.presMovement === PresMovement.Zoom || curDoc.presMovement === PresMovement.Jump) && targetDoc) { - //awaiting jump so that new scale can be found, since jumping is async - await DocumentManager.Instance.jumpToDocument(targetDoc, true, openInTab, srcContext, undefined, undefined, undefined, includesDoc || tab ? undefined : resetSelection); // documents open in new tab instead of on right + //awaiting jump so that new scale can be found, since jumping is async + await DocumentManager.Instance.jumpToDocument(targetDoc, true, openInTab, srcContext, undefined, undefined, undefined, includesDoc || tab ? undefined : resetSelection); // documents open in new tab instead of on right } // After navigating to the document, if it is added as a presPinView then it will // adjust the pan and scale to that of the pinView when it was added. @@ -433,6 +433,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> this.navigateToView(targetDoc, activeItem); } // TODO: Add progressivize for navigating web (storing websites for given frames) + } /** @@ -536,6 +537,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> this.next(); } } + await timer(duration); this.next(); // then the created Promise can be awaited if (i === this.childDocs.length - 1) { setTimeout(() => { @@ -766,11 +768,40 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> //Regular click @action - selectElement = (doc: Doc) => { + selectElement = async (doc: Doc) => { const context = Cast(doc.context, Doc, null); this.gotoDocument(this.childDocs.indexOf(doc), this.activeItem); if (doc.presPinView || doc.presentationTargetDoc === this.layoutDoc.presCollection) setTimeout(() => this.updateCurrentPresentation(context), 0); else this.updateCurrentPresentation(context); + + + + if (this.targetDoc.isInkMask) { + if (this.activeItem.y !== undefined && + this.activeItem.x !== undefined && + this.targetDoc.y !== undefined && + this.targetDoc.y !== undefined) { + const timer = (ms: number) => new Promise(res => this._presTimer = setTimeout(res, ms)); + + const ydiff = this.activeItem.y - this.targetDoc.y; + const xdiff = this.activeItem.x - this.targetDoc.x; + + const time = 10; + + const yOffset = ydiff / time; + const xOffset = xdiff / time; + + for (let i = 0; i < time; i++) { + const newy = Number(this.targetDoc.y) + yOffset; + const newx = Number(this.targetDoc.x) + xOffset; + this.targetDoc.y = newy; + this.targetDoc.x = newx; + await timer(0.1); + } + + } + + } } //Command click |