aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryunahi <60233430+yunahi@users.noreply.github.com>2020-10-01 18:41:45 +0900
committeryunahi <60233430+yunahi@users.noreply.github.com>2020-10-01 18:41:45 +0900
commit264292f75d17c19e65bc4707b10a713b64510cf1 (patch)
treef59e3fa33cb9169f138b13c39e63e2bebd8bec41
parent79de29454b4f4bac29987127e7251a7327befbc4 (diff)
fixed resize/rotate
-rw-r--r--src/client/views/DocumentDecorations.tsx9
-rw-r--r--src/client/views/InkStrokeProperties.ts46
-rw-r--r--src/client/views/InkingStroke.tsx1
3 files changed, 37 insertions, 19 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 9432d1ffb..dfcb6cda9 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -290,10 +290,11 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
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 ad5c70fb1..b04ac8610 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 186406424..2a7d4a5ad 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -48,6 +48,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;