From 7c93a65535a278dd1381b27fbd4c3869eed19527 Mon Sep 17 00:00:00 2001
From: yunahi <60233430+yunahi@users.noreply.github.com>
Date: Fri, 3 Jul 2020 20:22:52 +0900
Subject: pin and icon
---
.../collectionFreeForm/InkOptionsMenu.scss | 5 +
.../collectionFreeForm/InkOptionsMenu.tsx | 267 ++++++++++++++-------
2 files changed, 179 insertions(+), 93 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
index a9fab4c1e..7329f4fc1 100644
--- a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
+++ b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
@@ -26,6 +26,11 @@
/* Make the buttons appear below each other */
}
+.btn-draw {
+ display: inline;
+ /* Make the buttons appear below each other */
+}
+
.btn2-group {
display: block;
background: #323232;
diff --git a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
index f1032adaa..7de70b8cd 100644
--- a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
+++ b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
@@ -17,6 +17,7 @@ import { DocumentType } from "../../../documents/DocumentTypes";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { IconProp, library } from '@fortawesome/fontawesome-svg-core';
import { faBold, faItalic, faChevronLeft, faUnderline, faStrikethrough, faSubscript, faSuperscript, faIndent, faEyeDropper, faCaretDown, faPalette, faArrowsAlt, faHighlighter, faLink, faPaintRoller, faSleigh, faBars, faFillDrip, faBrush, faPenNib, faShapes, faArrowLeft, faEllipsisH, faBezierCurve, } from "@fortawesome/free-solid-svg-icons";
+import { Cast, StrCast, BoolCast } from "../../../../fields/Types";
library.add(faBold, faItalic, faChevronLeft, faUnderline, faStrikethrough, faSuperscript, faSubscript, faIndent, faEyeDropper, faCaretDown, faPalette, faArrowsAlt, faHighlighter, faLink, faPaintRoller, faBars, faFillDrip, faBrush, faPenNib, faShapes, faArrowLeft, faEllipsisH, faBezierCurve);
@@ -28,36 +29,67 @@ export default class InkOptionsMenu extends AntimodeMenu {
private _width = ["1", "5", "10", "100"];
// private _buttons = ["circle", "triangle", "rectangle", "arrow", "line"];
// private _icons = ["O", "∆", "ロ", "➜", "-"];
- private _buttons = ["circle", "triangle", "rectangle", "line", "noRec", "",];
- private _icons = ["O", "∆", "ロ", "⎯", "✖︎", " "];
+ // private _buttons = ["circle", "triangle", "rectangle", "line", "noRec", "",];
+ // private _icons = ["O", "∆", "ロ", "⎯⎯⎯", "✖︎", " "];
//arrowStart and arrowEnd must match and defs must exist in Inking Stroke
- private _arrowStart = ["arrowHead", "arrowHead", "dot", "dot", "none"];
- private _arrowEnd = ["none", "arrowEnd", "none", "dot", "none"];
- private _arrowIcons = ["→", "↔︎", "•", "••", " "];
+ // private _arrowStart = ["arrowHead", "arrowHead", "dot", "dot", "none"];
+ // private _arrowEnd = ["none", "arrowEnd", "none", "dot", "none"];
+ // private _arrowIcons = ["→", "↔︎", "•", "••", " "];
+ private _draw = ["⎯", "→", "↔︎", "∿", "↝", "↭", "ロ", "O", "∆"];
+ private _head = ["none", "arrowHead", "arrowHead", "none", "arrowHead", "arrowHead", "none", "none", "none"];
+ private _end = ["none", "none", "arrowEnd", "none", "none", "arrowEnd", "none", "none", "none"];
+ private _shape = ["", "", "", "", "", "", "rectangle", "circle", "triangle"];
+
+ @observable _shapesNum = this._shape.length;
+ @observable _selected = this._shapesNum;
+
+ @observable private collapsed: boolean = false;
@observable _colorBtn = false;
@observable _widthBtn = false;
@observable _fillBtn = false;
- @observable _arrowBtn = false;
- @observable _dashBtn = false;
- @observable _shapeBtn = false;
+ // @observable _arrowBtn = false;
+ // @observable _dashBtn = false;
+ // @observable _shapeBtn = false;
constructor(props: Readonly<{}>) {
super(props);
InkOptionsMenu.Instance = this;
this._canFade = false; // don't let the inking menu fade away
+ this.Pinned = BoolCast(Doc.UserDoc()["inkOptionsMenu-pinned"]);
+
}
- getColors = () => {
- return this._palette;
+ @action
+ toggleMenuPin = (e: React.MouseEvent) => {
+ Doc.UserDoc()["inkOptionsMenu-pinned"] = this.Pinned = !this.Pinned;
+ if (!this.Pinned) {
+ // this.fadeOut(true);
+ }
}
@action
- changeArrow = (arrowStart: string, arrowEnd: string) => {
- SetActiveArrowStart(arrowStart);
- SetActiveArrowEnd(arrowEnd);
+ protected toggleCollapse = (e: React.MouseEvent) => {
+ this.collapsed = !this.collapsed;
+ setTimeout(() => {
+ const x = Math.min(this._left, window.innerWidth - InkOptionsMenu.Instance.width);
+ InkOptionsMenu.Instance.jumpTo(x, this._top, true);
+ }, 0);
+ }
+
+
+
+
+ getColors = () => {
+ return this._palette;
}
+ // @action
+ // changeArrow = (arrowStart: string, arrowEnd: string) => {
+ // SetActiveArrowStart(arrowStart);
+ // SetActiveArrowEnd(arrowEnd);
+ // }
+
@action
changeColor = (color: string, type: string) => {
const col: ColorState = {
@@ -116,40 +148,77 @@ export default class InkOptionsMenu extends AntimodeMenu {
this.editProperties(ActiveDash(), "dash");
}
- @computed get arrowPicker() {
- var currIcon;
- for (var i = 0; i < this._arrowStart.length; i++) {
- if (this._arrowStart[i] === ActiveArrowStart() && this._arrowEnd[i] === ActiveArrowEnd()) {
- currIcon = this._arrowIcons[i];
- if (this._arrowIcons[i] === " ") {
- currIcon = "➤";
- }
- }
- }
- var arrowPicker = ;
- if (this._arrowBtn) {
- arrowPicker =
- {arrowPicker}
- {this._arrowStart.map((arrowStart, i) => {
- return ;
- })}
-
;
- }
- return arrowPicker;
+ @computed get drawButtons() {
+ const drawButtons =
+ {this._draw.map((icon, i) => {
+ return ;
+ })}
;
+ return drawButtons;
}
+ // @computed get arrowPicker() {
+ // var currIcon;
+ // for (var i = 0; i < this._arrowStart.length; i++) {
+ // if (this._arrowStart[i] === ActiveArrowStart() && this._arrowEnd[i] === ActiveArrowEnd()) {
+ // currIcon = this._arrowIcons[i];
+ // if (this._arrowIcons[i] === " ") {
+ // currIcon = "➤";
+ // }
+ // }
+ // }
+ // var arrowPicker = ;
+ // if (this._arrowBtn) {
+ // arrowPicker =
+ // {arrowPicker}
+ // {this._arrowStart.map((arrowStart, i) => {
+ // return ;
+ // })}
+ //
;
+ // }
+ // return arrowPicker;
+ // }
+
@computed get widthPicker() {
var widthPicker = ;
- } else {
- for (var i = 0; i < this._icons.length; i++) {
- if (GestureOverlay.Instance.InkShape === this._buttons[i]) {
- currIcon = this._icons[i];
- }
- }
- }
- var shapePicker = ;
- if (this._shapeBtn) {
- shapePicker =
- {shapePicker}
- {this._buttons.map((btn, i) => {
- var ttl = btn;
- if (btn === "") {
- ttl = "no shape";
- }
- if (btn === "noRec") {
- ttl = "disable shape recognition";
- }
- return ;
- })}
-
;
- }
- return shapePicker;
- }
+ // @computed get shapePicker() {
+ // var currIcon;
+ // if (GestureOverlay.Instance.InkShape === "") {
+ // currIcon = ;
+ // } else {
+ // for (var i = 0; i < this._icons.length; i++) {
+ // if (GestureOverlay.Instance.InkShape === this._buttons[i]) {
+ // currIcon = this._icons[i];
+ // }
+ // }
+ // }
+ // var shapePicker = ;
+ // if (this._shapeBtn) {
+ // shapePicker =
+ // {shapePicker}
+ // {this._buttons.map((btn, i) => {
+ // var ttl = btn;
+ // if (btn === "") {
+ // ttl = "no shape";
+ // }
+ // if (btn === "noRec") {
+ // ttl = "disable shape recognition";
+ // }
+ // return ;
+ // })}
+ //
;
+ // }
+ // return shapePicker;
+ // }
@computed get bezierButton() {
return ,
- this.shapePicker,
- this.bezierButton,
+ // this.shapePicker,
+ // this.bezierButton,
this.widthPicker,
this.colorPicker,
this.fillPicker,
- this.arrowPicker,
- this.dashButton,
+ this.drawButtons,
+ // this.arrowPicker,
+ // this.dashButton,
+
+
];
+
+ // return this.getElement(buttons);
return this.getElement(buttons);
}
}
Scripting.addGlobal(function activatePen(penBtn: any) {
if (penBtn) {
- Doc.SetSelectedTool(InkTool.Pen);
+ //no longer changes to inkmode
+ // Doc.SetSelectedTool(InkTool.Pen);
InkOptionsMenu.Instance.jumpTo(300, 300);
+ InkOptionsMenu.Instance.Pinned = true;
+
} else {
- Doc.SetSelectedTool(InkTool.None);
+ // Doc.SetSelectedTool(InkTool.None);
+ InkOptionsMenu.Instance.Pinned = false;
InkOptionsMenu.Instance.fadeOut(true);
+
}
});
\ No newline at end of file
--
cgit v1.2.3-70-g09d2
From 3beca8e7d268dc7b67b20b2c8760ea5e4b6fdb88 Mon Sep 17 00:00:00 2001
From: anika-ahluwalia
Date: Wed, 8 Jul 2020 18:59:37 -0500
Subject: added dashDragging event
---
src/client/util/DragManager.ts | 48 ++++++++++++++++++++++
.../collectionFreeForm/CollectionFreeFormView.tsx | 15 +++++++
src/client/views/nodes/DocumentLinksButton.tsx | 2 +-
3 files changed, 64 insertions(+), 1 deletion(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 2ceafff30..64c3d8458 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -427,6 +427,54 @@ export namespace DragManager {
}, dragData.droppedDocuments);
}
+ const target = document.elementFromPoint(e.x, e.y);
+
+ const complete = new DragCompleteEvent(false, dragData);
+
+ if (target) {
+ target.dispatchEvent(
+ new CustomEvent("dashDragging", {
+ bubbles: true,
+ detail: {
+ shiftKey: e.shiftKey,
+ altKey: e.altKey,
+ metaKey: e.metaKey,
+ ctrlKey: e.ctrlKey,
+ clientX: e.clientX,
+ clientY: e.clientY,
+ dataTransfer: new DataTransfer,
+ button: e.button,
+ buttons: e.buttons,
+ getModifierState: e.getModifierState,
+ movementX: e.movementX,
+ movementY: e.movementY,
+ pageX: e.pageX,
+ pageY: e.pageY,
+ relatedTarget: e.relatedTarget,
+ screenX: e.screenX,
+ screenY: e.screenY,
+ detail: e.detail,
+ view: e.view ? e.view : new Window,
+ nativeEvent: new DragEvent("dashDragging"),
+ currentTarget: target,
+ target: target,
+ bubbles: true,
+ cancelable: true,
+ defaultPrevented: true,
+ eventPhase: e.eventPhase,
+ isTrusted: true,
+ preventDefault: e.preventDefault,
+ isDefaultPrevented: () => true,
+ stopPropagation: e.stopPropagation,
+ isPropagationStopped: () => true,
+ persist: emptyFunction,
+ timeStamp: e.timeStamp,
+ type: "dashDragging"
+ }
+ })
+ );
+ }
+
const { thisX, thisY } = snapDrag(e, xFromLeft, yFromTop, xFromRight, yFromBottom);
const moveX = thisX - lastX;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9bf425db2..5a762a85c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1143,10 +1143,19 @@ export class CollectionFreeFormView extends CollectionSubView this.doLayoutComputation,
(elements) => this._layoutElements = elements || [],
{ fireImmediately: true, name: "doLayout" });
+
+ const handler = (e: Event) => this.handleDragging(e, (e as CustomEvent).detail);
+
+ document.addEventListener("dashDragging", handler);
}
+
componentWillUnmount() {
this._layoutComputeReaction?.();
+
+ const handler = (e: Event) => this.handleDragging(e, (e as CustomEvent).detail);
+ document.removeEventListener("dashDragging", handler);
}
+
@computed get views() { return this._layoutElements.filter(ele => ele.bounds && !ele.bounds.z).map(ele => ele.ele); }
elementFunc = () => this._layoutElements;
@@ -1155,6 +1164,12 @@ export class CollectionFreeFormView extends CollectionSubView {
+ console.log(de.clientX);
+ console.log(de.clientX);
+ }
+
promoteCollection = undoBatch(action(() => {
const childDocs = this.childDocs.slice();
childDocs.forEach(doc => {
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx
index 7fb447cab..44e72215d 100644
--- a/src/client/views/nodes/DocumentLinksButton.tsx
+++ b/src/client/views/nodes/DocumentLinksButton.tsx
@@ -152,7 +152,7 @@ export class DocumentLinksButton extends React.Component
Date: Thu, 9 Jul 2020 01:54:29 -0500
Subject: started dragging pans screen (needs cleaning)
---
src/client/util/LinkManager.ts | 2 +
.../collectionFreeForm/CollectionFreeFormView.tsx | 105 ++++++++++++++++++---
2 files changed, 96 insertions(+), 11 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 6da581f35..50f3fc1d6 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -3,6 +3,7 @@ import { List } from "../../fields/List";
import { listSpec } from "../../fields/Schema";
import { Cast, StrCast } from "../../fields/Types";
import { Scripting } from "./Scripting";
+import { undoBatch } from "./UndoManager";
/*
* link doc:
@@ -52,6 +53,7 @@ export class LinkManager {
return false;
}
+ @undoBatch
public deleteLink(linkDoc: Doc): boolean {
if (LinkManager.Instance.LinkManagerDoc && linkDoc instanceof Doc) {
Doc.RemoveDocFromList(LinkManager.Instance.LinkManagerDoc, "data", linkDoc);
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 5a762a85c..a3d3a210d 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -101,6 +101,10 @@ export class CollectionFreeFormView extends CollectionSubView
();
+ @observable _marqueeRef = React.createRef();
+ @observable canPanX: boolean = true;
+ @observable canPanY: boolean = true;
+
@computed get fitToContentScaling() { return this.fitToContent ? NumCast(this.layoutDoc.fitToContentScaling, 1) : 1; }
@computed get fitToContent() { return (this.props.fitToBox || this.Document._fitToBox) && !this.isAnnotationOverlay; }
@computed get parentScaling() { return this.props.ContentScaling && this.fitToContent && !this.isAnnotationOverlay ? this.props.ContentScaling() : 1; }
@@ -1164,10 +1168,87 @@ export class CollectionFreeFormView extends CollectionSubView
+
@action
handleDragging = (e: Event, de: DragEvent) => {
- console.log(de.clientX);
- console.log(de.clientX);
+
+ const nw = NumCast(this.Document._nativeWidth, this.props.NativeWidth());
+ const nh = NumCast(this.Document._nativeHeight, this.props.NativeHeight());
+ const hscale = nh ? this.props.PanelHeight() / nh : 1;
+ const wscale = nw ? this.props.PanelWidth() / nw : 1;
+
+ if (this._marqueeRef) {
+ if (this._marqueeRef.current) {
+
+ // console.log("left: " + this._marqueeRef.current.clientLeft);
+ // console.log("width: " + this._marqueeRef.current.clientWidth);
+ // console.log("client x: " + de.clientX);
+
+ // console.log("top: " + this._marqueeRef.current.clientTop);
+ // console.log("height: " + this._marqueeRef.current.clientHeight);
+ // console.log("client y: " + de.clientY);
+
+
+ if (this._marqueeRef.current.clientWidth > 0) {
+ if (de.clientX - 315 - this._marqueeRef.current.clientLeft < 25) {
+ console.log("PAN left ");
+ if (this.canPanX) {
+ this.Document._panX = de.clientX - 20 - this._marqueeRef.current.clientLeft;
+ setTimeout(action(() => {
+ this.canPanX = true;
+ this.panX();
+ }), 2500);
+ this.canPanX = false;
+ }
+ } else if (de.clientX - 315 - this._marqueeRef.current.clientLeft -
+ this._marqueeRef.current.clientWidth < 25) {
+ console.log("PAN right ");
+ if (this.canPanX) {
+ this.Document._panX = de.clientX - 315 - this._marqueeRef.current.clientLeft -
+ this._marqueeRef.current.clientWidth;
+
+ setTimeout(action(() => {
+ this.panX();
+ this.canPanX = true;
+ }), 2500);
+ this.canPanX = false;
+ }
+
+ }
+ }
+
+ if (this._marqueeRef.current.clientHeight > 0) {
+ if (de.clientY - 120 - this._marqueeRef.current.clientTop < 25) {
+ console.log("PAN top ");
+ if (this.canPanY) {
+ this.Document._panY = de.clientY - 20 - this._marqueeRef.current.clientTop;
+ setTimeout(action(() => {
+ this.canPanY = true;
+ this.panY();
+ }), 2500);
+ this.canPanY = false;
+ }
+ } else if (de.clientY - 120 - this._marqueeRef.current.clientTop -
+ this._marqueeRef.current.clientHeight < 25) {
+ console.log("PAN bottom ");
+ if (this.canPanY) {
+ this.Document._panY = de.clientY - 120 - this._marqueeRef.current.clientTop -
+ this._marqueeRef.current.clientHeight;
+
+ setTimeout(action(() => {
+ this.panY();
+ this.canPanY = true;
+ }), 2500);
+ this.canPanY = false;
+ }
+
+ }
+
+ }
+ }
+ }
}
promoteCollection = undoBatch(action(() => {
@@ -1351,7 +1432,8 @@ export class CollectionFreeFormView extends CollectionSubView
-
- {this.children}
-
+
+
+ {this.children}
+
{this.showTimeline ? : (null)}
;
}
--
cgit v1.2.3-70-g09d2
From 58865aa5f27fa4a23af3a589bfc45868c7a77151 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Thu, 9 Jul 2020 11:31:04 -0400
Subject: fixed issues with frame based animations for annotations on
images,etc.
---
.../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 2 +-
src/client/views/nodes/CollectionFreeFormDocumentView.tsx | 6 +++---
src/client/views/presentationview/PresElementBox.tsx | 4 +++-
3 files changed, 7 insertions(+), 5 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9bf425db2..60c9d7f4a 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1065,7 +1065,7 @@ export class CollectionFreeFormView extends CollectionSubView) {
const layoutDocs = this.childLayoutPairs.map(pair => pair.layout);
- const initResult = this.Document.arrangeInit && this.Document.arrangeInit.script.run({ docs: layoutDocs, collection: this.Document }, console.log);
+ const initResult = this.Document.arrangeInit?.script.run({ docs: layoutDocs, collection: this.Document }, console.log);
const state = initResult?.success ? initResult.result.scriptState : undefined;
const elements = initResult?.success ? this.viewDefsToJSX(initResult.result.views) : [];
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index a3020f912..d79e2c9ff 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -73,9 +73,9 @@ export class CollectionFreeFormDocumentView extends DocComponent (i <= timecode && x !== undefined) || p === undefined ? x : p, undefined as any as number),
- y: Cast(doc["y-indexed"], listSpec("number"), []).reduce((p, y, i) => (i <= timecode && y !== undefined) || p === undefined ? y : p, undefined as any as number),
- opacity: Cast(doc["opacity-indexed"], listSpec("number"), []).reduce((p, o, i) => i <= timecode || p === undefined ? o : p, undefined as any as number),
+ x: Cast(doc["x-indexed"], listSpec("number"), [NumCast(doc.x)]).reduce((p, x, i) => (i <= timecode && x !== undefined) || p === undefined ? x : p, undefined as any as number),
+ y: Cast(doc["y-indexed"], listSpec("number"), [NumCast(doc.y)]).reduce((p, y, i) => (i <= timecode && y !== undefined) || p === undefined ? y : p, undefined as any as number),
+ opacity: Cast(doc["opacity-indexed"], listSpec("number"), [NumCast(doc.opacity, 1)]).reduce((p, o, i) => i <= timecode || p === undefined ? o : p, undefined as any as number),
});
}
diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx
index 6fd3455b6..4c0972736 100644
--- a/src/client/views/presentationview/PresElementBox.tsx
+++ b/src/client/views/presentationview/PresElementBox.tsx
@@ -15,6 +15,7 @@ import { FieldView, FieldViewProps } from '../nodes/FieldView';
import "./PresElementBox.scss";
import React = require("react");
import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
+import { DocumentType } from "../../documents/DocumentTypes";
export const presSchema = createSchema({
presentationTargetDoc: Doc,
@@ -100,7 +101,8 @@ export class PresElementBox extends ViewBoxBaseComponent
Date: Thu, 9 Jul 2020 11:36:48 -0400
Subject: from last
---
.../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 60c9d7f4a..d9aabd7c2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -205,7 +205,7 @@ export class CollectionFreeFormView extends CollectionSubView
Date: Thu, 9 Jul 2020 12:15:42 -0500
Subject: fixed linking undo issues
---
.../collectionFreeForm/CollectionFreeFormView.tsx | 96 ++++++++++++----------
src/client/views/nodes/DocumentLinksButton.tsx | 6 +-
.../views/nodes/formattedText/FormattedTextBox.tsx | 2 +
3 files changed, 57 insertions(+), 47 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index a3d3a210d..ffa4be4b9 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1174,47 +1174,55 @@ export class CollectionFreeFormView extends CollectionSubView {
- const nw = NumCast(this.Document._nativeWidth, this.props.NativeWidth());
- const nh = NumCast(this.Document._nativeHeight, this.props.NativeHeight());
- const hscale = nh ? this.props.PanelHeight() / nh : 1;
- const wscale = nw ? this.props.PanelWidth() / nw : 1;
+ const top = this.panX();
+ const left = this.panY();
+
+ const size = this.getTransform().transformDirection(this.props.PanelWidth(), this.props.PanelHeight());
+
+ const scale = this.getLocalTransform().inverse().Scale;
if (this._marqueeRef) {
+
if (this._marqueeRef.current) {
+ // console.log("top: " + this._marqueeRef.current.clientTop);
// console.log("left: " + this._marqueeRef.current.clientLeft);
// console.log("width: " + this._marqueeRef.current.clientWidth);
- // console.log("client x: " + de.clientX);
-
- // console.log("top: " + this._marqueeRef.current.clientTop);
// console.log("height: " + this._marqueeRef.current.clientHeight);
- // console.log("client y: " + de.clientY);
+
+ console.log("width: " + this._marqueeRef.current.getBoundingClientRect().width);
+ console.log("height: " + this._marqueeRef.current.getBoundingClientRect().width);
+ console.log("x: " + this._marqueeRef.current.getBoundingClientRect().x);
+ console.log("y: " + this._marqueeRef.current.getBoundingClientRect().y);
+
+ // console.log("mouse x: " + de.screenX);
+ // console.log("mouse y: " + de.screenY);
if (this._marqueeRef.current.clientWidth > 0) {
if (de.clientX - 315 - this._marqueeRef.current.clientLeft < 25) {
console.log("PAN left ");
- if (this.canPanX) {
- this.Document._panX = de.clientX - 20 - this._marqueeRef.current.clientLeft;
- setTimeout(action(() => {
- this.canPanX = true;
- this.panX();
- }), 2500);
- this.canPanX = false;
- }
+
+ // if (this.canPanX) {
+ // this.Document._panX = left - 5;
+ // setTimeout(action(() => {
+ // this.canPanX = true;
+ // this.panX();
+ // }), 250);
+ // this.canPanX = false;
+ // }
} else if (de.clientX - 315 - this._marqueeRef.current.clientLeft -
this._marqueeRef.current.clientWidth < 25) {
console.log("PAN right ");
- if (this.canPanX) {
- this.Document._panX = de.clientX - 315 - this._marqueeRef.current.clientLeft -
- this._marqueeRef.current.clientWidth;
-
- setTimeout(action(() => {
- this.panX();
- this.canPanX = true;
- }), 2500);
- this.canPanX = false;
- }
+
+ // if (this.canPanX) {
+ // this.Document._panX = left + 5;
+ // setTimeout(action(() => {
+ // this.panX();
+ // this.canPanX = true;
+ // }), 250);
+ // this.canPanX = false;
+ // }
}
}
@@ -1222,27 +1230,27 @@ export class CollectionFreeFormView extends CollectionSubView 0) {
if (de.clientY - 120 - this._marqueeRef.current.clientTop < 25) {
console.log("PAN top ");
- if (this.canPanY) {
- this.Document._panY = de.clientY - 20 - this._marqueeRef.current.clientTop;
- setTimeout(action(() => {
- this.canPanY = true;
- this.panY();
- }), 2500);
- this.canPanY = false;
- }
+
+ // if (this.canPanY) {
+ // this.Document._panY = top - 5;
+ // setTimeout(action(() => {
+ // this.canPanY = true;
+ // this.panY();
+ // }), 250);
+ // this.canPanY = false;
+ // }
} else if (de.clientY - 120 - this._marqueeRef.current.clientTop -
this._marqueeRef.current.clientHeight < 25) {
console.log("PAN bottom ");
- if (this.canPanY) {
- this.Document._panY = de.clientY - 120 - this._marqueeRef.current.clientTop -
- this._marqueeRef.current.clientHeight;
-
- setTimeout(action(() => {
- this.panY();
- this.canPanY = true;
- }), 2500);
- this.canPanY = false;
- }
+
+ // if (this.canPanY) {
+ // this.Document._panY = top + 5;
+ // setTimeout(action(() => {
+ // this.panY();
+ // this.canPanY = true;
+ // }), 250);
+ // this.canPanY = false;
+ // }
}
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx
index 44e72215d..ce96eddfe 100644
--- a/src/client/views/nodes/DocumentLinksButton.tsx
+++ b/src/client/views/nodes/DocumentLinksButton.tsx
@@ -3,7 +3,7 @@ import { observer } from "mobx-react";
import { Doc, DocListCast } from "../../../fields/Doc";
import { emptyFunction, setupMoveUpEvents, returnFalse } from "../../../Utils";
import { DragManager } from "../../util/DragManager";
-import { UndoManager } from "../../util/UndoManager";
+import { UndoManager, undoBatch } from "../../util/UndoManager";
import './DocumentLinksButton.scss';
import { DocumentView } from "./DocumentView";
import React = require("react");
@@ -29,7 +29,7 @@ export class DocumentLinksButton extends React.Component {
if (this._linkButton.current !== null) {
const linkDrag = UndoManager.StartBatch("Drag Link");
@@ -56,7 +56,7 @@ export class DocumentLinksButton extends React.Component {
setupMoveUpEvents(this, e, this.onLinkButtonMoved, emptyFunction, action((e, doubleTap) => {
if (doubleTap && this.props.InMenu) {
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index fc63dfbf5..30e0738bf 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -944,6 +944,8 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
frag.forEach(node => nodes.push(marker(node)));
return Fragment.fromArray(nodes);
}
+
+
function addLinkMark(node: Node, title: string, linkId: string) {
if (!node.isText) {
const content = addMarkToFrag(node.content, (node: Node) => addLinkMark(node, title, linkId));
--
cgit v1.2.3-70-g09d2
From f774d6953d23dda9b8b20ed24b64e28607d3d88c Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Thu, 9 Jul 2020 14:53:52 -0400
Subject: fixed auto panning in collectionview.
---
.../collectionFreeForm/CollectionFreeFormView.tsx | 124 +++++++++------------
1 file changed, 51 insertions(+), 73 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index ffa4be4b9..7a7505319 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1172,89 +1172,67 @@ export class CollectionFreeFormView extends CollectionSubView
@action
- handleDragging = (e: Event, de: DragEvent) => {
+ handleDragging = (e: CustomEvent, de: DragEvent) => {
const top = this.panX();
const left = this.panY();
const size = this.getTransform().transformDirection(this.props.PanelWidth(), this.props.PanelHeight());
-
const scale = this.getLocalTransform().inverse().Scale;
- if (this._marqueeRef) {
-
- if (this._marqueeRef.current) {
-
- // console.log("top: " + this._marqueeRef.current.clientTop);
- // console.log("left: " + this._marqueeRef.current.clientLeft);
- // console.log("width: " + this._marqueeRef.current.clientWidth);
- // console.log("height: " + this._marqueeRef.current.clientHeight);
-
- console.log("width: " + this._marqueeRef.current.getBoundingClientRect().width);
- console.log("height: " + this._marqueeRef.current.getBoundingClientRect().width);
- console.log("x: " + this._marqueeRef.current.getBoundingClientRect().x);
- console.log("y: " + this._marqueeRef.current.getBoundingClientRect().y);
-
- // console.log("mouse x: " + de.screenX);
- // console.log("mouse y: " + de.screenY);
-
-
- if (this._marqueeRef.current.clientWidth > 0) {
- if (de.clientX - 315 - this._marqueeRef.current.clientLeft < 25) {
- console.log("PAN left ");
-
- // if (this.canPanX) {
- // this.Document._panX = left - 5;
- // setTimeout(action(() => {
- // this.canPanX = true;
- // this.panX();
- // }), 250);
- // this.canPanX = false;
- // }
- } else if (de.clientX - 315 - this._marqueeRef.current.clientLeft -
- this._marqueeRef.current.clientWidth < 25) {
- console.log("PAN right ");
-
- // if (this.canPanX) {
- // this.Document._panX = left + 5;
- // setTimeout(action(() => {
- // this.panX();
- // this.canPanX = true;
- // }), 250);
- // this.canPanX = false;
- // }
-
- }
- }
+ if (this._marqueeRef?.current) {
+ const dragX = e.detail.clientX;
+ const dragY = e.detail.clientY;
+ const bounds = this._marqueeRef.current?.getBoundingClientRect()!;
+
+ if (dragX - bounds.left < 25) {
+ console.log("PAN left ");
+
+ // if (this.canPanX) {
+ // this.Document._panX = left - 5;
+ // setTimeout(action(() => {
+ // this.canPanX = true;
+ // this.panX();
+ // }), 250);
+ // this.canPanX = false;
+ // }
+ } else if (bounds.right - dragX < 25) {
+ console.log("PAN right ");
+
+ // if (this.canPanX) {
+ // this.Document._panX = left + 5;
+ // setTimeout(action(() => {
+ // this.panX();
+ // this.canPanX = true;
+ // }), 250);
+ // this.canPanX = false;
+ // }
- if (this._marqueeRef.current.clientHeight > 0) {
- if (de.clientY - 120 - this._marqueeRef.current.clientTop < 25) {
- console.log("PAN top ");
-
- // if (this.canPanY) {
- // this.Document._panY = top - 5;
- // setTimeout(action(() => {
- // this.canPanY = true;
- // this.panY();
- // }), 250);
- // this.canPanY = false;
- // }
- } else if (de.clientY - 120 - this._marqueeRef.current.clientTop -
- this._marqueeRef.current.clientHeight < 25) {
- console.log("PAN bottom ");
-
- // if (this.canPanY) {
- // this.Document._panY = top + 5;
- // setTimeout(action(() => {
- // this.panY();
- // this.canPanY = true;
- // }), 250);
- // this.canPanY = false;
- // }
+ }
- }
+ if (dragY - bounds.top < 25) {
+ console.log("PAN top ");
+
+ // if (this.canPanY) {
+ // this.Document._panY = top - 5;
+ // setTimeout(action(() => {
+ // this.canPanY = true;
+ // this.panY();
+ // }), 250);
+ // this.canPanY = false;
+ // }
+ } else if (bounds.bottom - dragY < 25) {
+ console.log("PAN bottom ");
+
+ // if (this.canPanY) {
+ // this.Document._panY = top + 5;
+ // setTimeout(action(() => {
+ // this.panY();
+ // this.canPanY = true;
+ // }), 250);
+ // this.canPanY = false;
+ // }
- }
}
}
}
--
cgit v1.2.3-70-g09d2
From 065a29e87c771b5cd9301b0468fb036e070cad17 Mon Sep 17 00:00:00 2001
From: yunahi <60233430+yunahi@users.noreply.github.com>
Date: Fri, 10 Jul 2020 05:08:53 +0900
Subject: added format shape
---
src/client/documents/Documents.ts | 3 +-
src/client/util/InteractionUtils.tsx | 8 +
src/client/util/SelectionManager.ts | 5 +
src/client/views/AntimodeMenu.tsx | 18 +
src/client/views/ContextMenu.tsx | 1 +
src/client/views/DocumentDecorations.tsx | 2 +
src/client/views/GestureOverlay.tsx | 17 +-
src/client/views/InkingStroke.tsx | 15 +-
src/client/views/MainView.tsx | 13 +-
.../collectionFreeForm/FormatShapePane.scss | 53 ++
.../collectionFreeForm/FormatShapePane.tsx | 996 +++++++++++++++++++++
.../collectionFreeForm/InkOptionsMenu.scss | 2 +-
.../collectionFreeForm/InkOptionsMenu.tsx | 40 +-
13 files changed, 1152 insertions(+), 21 deletions(-)
create mode 100644 src/client/views/collections/collectionFreeForm/FormatShapePane.scss
create mode 100644 src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b70971c2d..eb8e04317 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -653,7 +653,7 @@ export namespace Docs {
I.type = DocumentType.INK;
I.layout = InkingStroke.LayoutString("data");
I.color = color;
- I.strokeWidth = strokeWidth;
+ I.strokeWidth = Number(strokeWidth);
I.strokeBezier = strokeBezier;
I.fillColor = fillColor;
I.arrowStart = arrowStart;
@@ -667,6 +667,7 @@ export namespace Docs {
I._width = options._width;
I._height = options._height;
I.author = Doc.CurrentUserEmail;
+ I.rotation = 0;
I.data = new InkField(points);
return I;
// return I;
diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index edeb461e0..2883e2056 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -3,6 +3,7 @@ import * as beziercurve from 'bezier-curve';
import * as fitCurve from 'fit-curve';
import "./InteractionUtils.scss";
import { Utils } from "../../Utils";
+import InkOptionsMenu from "../views/collections/collectionFreeForm/InkOptionsMenu";
export namespace InteractionUtils {
export const MOUSETYPE = "mouse";
@@ -94,6 +95,13 @@ export namespace InteractionUtils {
export function CreatePolyline(points: { X: number, Y: number }[], left: number, top: number,
color: string, width: number, strokeWidth: number, bezier: string, fill: string, arrowStart: string, arrowEnd: string,
dash: string, scalex: number, scaley: number, shape: string, pevents: string, drawHalo: boolean, nodefs: boolean) {
+
+ // if (InkOptionsMenu.Instance.Pinned) {
+ // for (var i = 0; i < points.length; i++) {
+ // points[i].Y -= 35;
+ // }
+ // }
+
let pts: { X: number; Y: number; }[] = [];
if (shape) { //if any of the shape are true
pts = makePolygon(shape, points);
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 024532f90..aea2c542b 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -5,6 +5,7 @@ import { computedFn } from "mobx-utils";
import { List } from "../../fields/List";
import { Scripting } from "./Scripting";
import { DocumentManager } from "./DocumentManager";
+import FormatShapePane from "../views/collections/collectionFreeForm/FormatShapePane";
export namespace SelectionManager {
@@ -14,6 +15,8 @@ export namespace SelectionManager {
SelectedDocuments: ObservableMap = new ObservableMap();
@action
SelectDoc(docView: DocumentView, ctrlPressed: boolean): void {
+ console.log("select"
+ );
// if doc is not in SelectedDocuments, add it
if (!manager.SelectedDocuments.get(docView)) {
if (!ctrlPressed) {
@@ -29,6 +32,8 @@ export namespace SelectionManager {
manager.SelectedDocuments.set(docView, true);
}
Doc.UserDoc().activeSelection = new List(SelectionManager.SelectedDocuments().map(dv => dv.props.Document));
+ FormatShapePane.Instance.selected();
+
}
@action
DeselectDoc(docView: DocumentView): void {
diff --git a/src/client/views/AntimodeMenu.tsx b/src/client/views/AntimodeMenu.tsx
index d83ac434c..cb6de1785 100644
--- a/src/client/views/AntimodeMenu.tsx
+++ b/src/client/views/AntimodeMenu.tsx
@@ -1,6 +1,7 @@
import React = require("react");
import { observable, action } from "mobx";
import "./AntimodeMenu.scss";
+import { inherits } from "util";
/**
* This is an abstract class that serves as the base for a PDF-style or Marquee-style
@@ -147,6 +148,23 @@ export default abstract class AntimodeMenu extends React.Component {
);
}
+ protected getElementVert(buttons: JSX.Element[]) {
+ return (
+
+ {buttons}
+
+ );
+ }
+
protected getElementWithRows(rows: JSX.Element[], numRows: number, hasDragger: boolean = true) {
diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx
index 941d7b44a..1a6b7ab90 100644
--- a/src/client/views/ContextMenu.tsx
+++ b/src/client/views/ContextMenu.tsx
@@ -224,6 +224,7 @@ export class ContextMenu extends React.Component {
}
render() {
+ console.log("context");
if (!this._display) {
return null;
}
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 4fda10926..8edd4c4a9 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -293,6 +293,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
const doc = Document(element.rootDoc);
if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
+ doc.rotation = Number(doc.rotation) + Number(angle);
+ console.log(doc.rotation);
const ink = Cast(doc.data, InkField)?.inkData;
if (ink) {
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index bfd659207..26a06090b 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -633,7 +633,8 @@ export default class GestureOverlay extends Touchable {
this.makePolygon(this.InkShape, false);
this.dispatchGesture(GestureUtils.Gestures.Stroke);
this._points = [];
- if (this.InkShape !== "noRec") {
+ if (InkOptionsMenu.Instance._double === "") {
+
this.InkShape = "";
}
}
@@ -687,12 +688,14 @@ export default class GestureOverlay extends Touchable {
}
//get out of ink mode after each stroke=
console.log("now");
- Doc.SetSelectedTool(InkTool.None);
- InkOptionsMenu.Instance._selected = InkOptionsMenu.Instance._shapesNum;
- SetActiveArrowStart("none");
- GestureOverlay.Instance.SavedArrowStart = ActiveArrowStart();
- SetActiveArrowEnd("none");
- GestureOverlay.Instance.SavedArrowEnd = ActiveArrowEnd();
+ if (InkOptionsMenu.Instance._double === "") {
+ Doc.SetSelectedTool(InkTool.None);
+ InkOptionsMenu.Instance._selected = InkOptionsMenu.Instance._shapesNum;
+ SetActiveArrowStart("none");
+ GestureOverlay.Instance.SavedArrowStart = ActiveArrowStart();
+ SetActiveArrowEnd("none");
+ GestureOverlay.Instance.SavedArrowEnd = ActiveArrowEnd();
+ }
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index c32e76cec..4a7ec40be 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -15,6 +15,8 @@ import { FieldView, FieldViewProps } from "./nodes/FieldView";
import React = require("react");
import { Scripting } from "../util/Scripting";
import { Doc } from "../../fields/Doc";
+import FormatShapePane from "./collections/collectionFreeForm/FormatShapePane";
+import { action } from "mobx";
library.add(faPaintBrush);
@@ -38,10 +40,19 @@ export class InkingStroke extends ViewBoxBaseComponent {
+ console.log("Clicked");
+ FormatShapePane.Instance.Pinned = true;
+ FormatShapePane.Instance.selected();
+
+ }
+
render() {
TraceMobx();
const data: InkData = Cast(this.dataDoc[this.fieldKey], InkField)?.inkData ?? [];
- const strokeWidth = Number(StrCast(this.layoutDoc.strokeWidth, ActiveInkWidth()));
+ // const strokeWidth = Number(StrCast(this.layoutDoc.strokeWidth, ActiveInkWidth()));
+ const strokeWidth = Number(this.layoutDoc.strokeWidth);
const xs = data.map(p => p.X);
const ys = data.map(p => p.Y);
const left = Math.min(...xs) - strokeWidth / 2;
@@ -74,6 +85,8 @@ export class InkingStroke extends ViewBoxBaseComponent {
ContextMenu.Instance.addItem({ description: "Analyze Stroke", event: this.analyzeStrokes, icon: "paint-brush" });
ContextMenu.Instance.addItem({ description: "Make Mask", event: this.makeMask, icon: "paint-brush" });
+ ContextMenu.Instance.addItem({ description: "Format Shape", event: this.formatShape, icon: "paint-brush" });
+
}}
>
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index afdff4ed8..3eed44654 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -58,7 +58,7 @@ import { DocumentManager } from '../util/DocumentManager';
import { DocumentLinksButton } from './nodes/DocumentLinksButton';
import { LinkMenu } from './linking/LinkMenu';
import { LinkDocPreview } from './nodes/LinkDocPreview';
-
+import FormatShapePane from "./collections/collectionFreeForm/FormatShapePane";
@observer
export class MainView extends React.Component {
public static Instance: MainView;
@@ -453,12 +453,13 @@ export class MainView extends React.Component {
@computed get mainContent() {
const sidebar = this.userDoc?.["tabs-panelContainer"];
- console.log(InkOptionsMenu.Instance?.Pinned);
+ console.log('${ ANTIMODEMENU_HEIGHT }');
return !this.userDoc || !(sidebar instanceof Doc) ? (null) : (
@@ -597,7 +598,10 @@ export class MainView extends React.Component {
+
+
+
{this.mainContent}
@@ -608,6 +612,7 @@ export class MainView extends React.Component {
linkDoc={LinkDocPreview.LinkInfo.linkDoc} linkSrc={LinkDocPreview.LinkInfo.linkSrc} href={LinkDocPreview.LinkInfo.href}
addDocTab={LinkDocPreview.LinkInfo.addDocTab} /> : (null)}
+
diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.scss b/src/client/views/collections/collectionFreeForm/FormatShapePane.scss
new file mode 100644
index 000000000..5789c6c75
--- /dev/null
+++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.scss
@@ -0,0 +1,53 @@
+.antimodeMenu-button {
+ width: 200px;
+
+ .color-previewI {
+ width: 100%;
+ height: 40%;
+ }
+
+ .color-previewII {
+ width: 100%;
+ height: 100%;
+ }
+
+
+}
+
+.sketch-picker {
+ background: #323232;
+
+ .flexbox-fit {
+ background: #323232;
+ }
+}
+
+.btn-group {
+ display: grid;
+ grid-template-columns: auto auto auto auto;
+ /* Make the buttons appear below each other */
+}
+
+.btn-group-palette {
+ display: block;
+ /* Make the buttons appear below each other */
+}
+
+.btn-draw {
+ display: inline;
+ /* Make the buttons appear below each other */
+}
+
+.btn2-group {
+ display: block;
+ background: #323232;
+ grid-template-columns: auto;
+
+ /* Make the buttons appear below each other */
+ .antimodeMenu-button {
+ background: #323232;
+ display: block;
+
+
+ }
+}
\ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
new file mode 100644
index 000000000..7b47b7ca4
--- /dev/null
+++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
@@ -0,0 +1,996 @@
+import React = require("react");
+import AntimodeMenu from "../../AntimodeMenu";
+import { observer } from "mobx-react";
+import { observable, action, computed } from "mobx";
+import "./FormatShapePane.scss";
+import { ActiveInkColor, ActiveInkBezierApprox, ActiveFillColor, ActiveArrowStart, ActiveArrowEnd, SetActiveInkWidth, SetActiveInkColor, SetActiveBezierApprox, SetActiveFillColor, SetActiveArrowStart, SetActiveArrowEnd, ActiveDash, SetActiveDash } from "../../InkingStroke";
+import { Scripting } from "../../../util/Scripting";
+import { InkTool, InkField } from "../../../../fields/InkField";
+import { ColorState } from "react-color";
+import { Utils } from "../../../../Utils";
+import GestureOverlay from "../../GestureOverlay";
+import { Doc } from "../../../../fields/Doc";
+import { SelectionManager } from "../../../util/SelectionManager";
+import { DocumentView } from "../../../views/nodes/DocumentView";
+import { Document } from "../../../../fields/documentSchemas";
+import { DocumentType } from "../../../documents/DocumentTypes";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { IconProp, library } from '@fortawesome/fontawesome-svg-core';
+import { faRulerCombined, faFillDrip, faPenNib } from "@fortawesome/free-solid-svg-icons";
+import { Cast, StrCast, BoolCast, NumCast } from "../../../../fields/Types";
+import e = require("express");
+import { ChangeEvent } from "mongodb";
+import { black } from "colors";
+
+
+library.add(faRulerCombined, faFillDrip, faPenNib);
+
+@observer
+export default class FormatShapePane extends AntimodeMenu {
+ static Instance: FormatShapePane;
+
+ private _palette = ["#D0021B", "#F5A623", "#F8E71C", "#8B572A", "#7ED321", "#417505", "#9013FE", "#4A90E2", "#50E3C2", "#B8E986", "#000000", "#4A4A4A", "#9B9B9B", "#FFFFFF"];
+ private _width = ["1", "5", "10", "100"];
+ private _mode = ["fill-drip", "ruler-combined"];
+ private _subMenu = ["fill", "line", "size", "position"];
+ private _headIcon = ["⎯", "←"];
+ private _endIcon = ["⎯", "→"];
+ private _head = ["none", "arrowHead"];
+ private _end = ["none", "arrowEnd"];
+
+ @observable private _subOpen = [false, false, false, false];
+
+ @observable private collapsed: boolean = false;
+ @observable private currMode: string = "fill-drip";
+ @observable _fillBtn = false;
+ @observable _lineBtn = false;
+
+ @observable _selectDoc: DocumentView[] = [];
+
+ @observable _noFill = false;
+ @observable _solidFill = false;
+ @observable _noLine = false;
+ @observable _solidLine = false;
+ @observable _dashLine = false;
+ @observable _lock = false;
+
+ @observable _multiple = false;
+
+ @observable _widthBtn = false;
+
+ @observable _currWidth = "10";
+
+ @observable _single = false;
+ @observable _currFill = "#D0021B";
+ @observable _currColor = "#D0021B";
+
+ @observable _arrowHead = false;
+ @observable _arrowEnd = false;
+
+
+ @observable _currSizeHeight = "10";
+ @observable _currSizeWidth = "10";
+ @observable _currRotation = "10";
+
+ @observable _currPositionHorizontal = "10";
+ @observable _currPositionVertical = "10";
+
+
+ constructor(props: Readonly<{}>) {
+ super(props);
+ FormatShapePane.Instance = this;
+ this._canFade = false; // don't let the inking menu fade away
+ this.Pinned = BoolCast(Doc.UserDoc()["formatShapePane-pinned"]);
+
+ }
+
+ @action
+ toggleMenuPin = (e: React.MouseEvent) => {
+ Doc.UserDoc()["formatShapePane-pinned"] = this.Pinned = !this.Pinned;
+ if (!this.Pinned) {
+ // this.fadeOut(true);
+ }
+ }
+
+ @action
+ protected toggleCollapse = (e: React.MouseEvent) => {
+ this.collapsed = !this.collapsed;
+ setTimeout(() => {
+ const x = Math.min(this._left, window.innerWidth - FormatShapePane.Instance.width);
+ FormatShapePane.Instance.jumpTo(x, this._top, true);
+ }, 0);
+ }
+
+ @action
+ closePane = () => {
+ this.jumpTo(-300, -300);
+ this.Pinned = false;
+
+ }
+
+ @action
+ checkSame = () => {
+ const docs = SelectionManager.SelectedDocuments();
+ const inks: DocumentView[] = [];
+ for (var i = 0; i < docs.length; i++) {
+ if (Document(docs[i].rootDoc).type === DocumentType.INK) {
+ inks.push(docs[i]);
+ }
+ }
+ const firstWidth = Document(inks[0].rootDoc).strokeWidth;
+ const firstColor = Document(inks[0].rootDoc).color;
+ const firstFill = Document(inks[0].rootDoc).fillColor;
+ // const firstBezier
+ const firstRotation = Document(inks[0].rootDoc).rotation;
+ const firstArrowStart = Document(inks[0].rootDoc).arrowStart;
+ const firstArrowEnd = Document(inks[0].rootDoc).arrowEnd;
+ const firstDash = Document(inks[0].rootDoc).dash;
+ const firstWidthSize = Document(inks[0].rootDoc)._width;
+ const firstHeightSize = Document(inks[0].rootDoc)._height;
+ const firstHorizontal = Document(inks[0].rootDoc).x;
+ const firstVertical = Document(inks[0].rootDoc).y;
+ this._noFill = Document(inks[0].rootDoc).fillColor === "none" ? true : false;
+ this._solidFill = Document(inks[0].rootDoc).fillColor === "none" ? false : true;
+ this._noLine = Document(inks[0].rootDoc).color === "none" ? true : false;
+ if (Document(inks[0].rootDoc).color !== "none") {
+ this._solidLine = true;
+ this._dashLine = true;
+ if (Document(inks[0].rootDoc).dash === "0") {
+ this._dashLine = false;
+ } else {
+ this._solidLine = false;
+
+ }
+ }
+ // this._solidLine = (Document(inks[0].rootDoc).color === "none") ? false : Document(inks[0].rootDoc).dash === 0 ? true : false;
+ // this._dashLine = (Document(inks[0].rootDoc).color === "none") ? false : Document(inks[0].rootDoc).dash !== 0 ? true : false;
+ // // this._widthBtn = false;
+ this._currWidth = String(Document(inks[0].rootDoc).strokeWidth);
+ // this._single = false;
+ this._currFill = String(Document(inks[0].rootDoc).fillColor);
+ this._currColor = String(Document(inks[0].rootDoc).color);
+ this._arrowHead = Document(inks[0].rootDoc).arrowStart === "none" ? false : true;
+ this._arrowEnd = Document(inks[0].rootDoc).arrowEnd === "none" ? false : true;
+ this._currSizeHeight = String(Document(inks[0].rootDoc)._height);
+ this._currSizeWidth = String(Document(inks[0].rootDoc)._width);
+ this._currRotation = String(Document(inks[0].rootDoc).rotation);
+ this._currPositionHorizontal = String(Document(inks[0].rootDoc).x);
+ this._currPositionVertical = String(Document(inks[0].rootDoc).y);
+ for (var i = 0; i < inks.length; i++) {
+ if (Document(inks[i].rootDoc).strokeWidth !== firstWidth) {
+ this._currWidth = "";
+ }
+ if (Document(inks[i].rootDoc).color !== firstColor) {
+ this._noLine = false;
+ this._solidLine = false;
+ this._dashLine = false;
+ }
+ if (Document(inks[i].rootDoc).fillColor !== firstFill) {
+ this._solidFill = false;
+ this._noFill = false;
+ }
+ if (Document(inks[i].rootDoc).arrowStart !== firstArrowStart) {
+ this._arrowHead = false;
+ }
+ if (Document(inks[i].rootDoc).arrowEnd !== firstArrowEnd) {
+ this._arrowEnd = false;
+ }
+ if (Document(inks[i].rootDoc).x !== firstHorizontal) {
+ this._currPositionHorizontal = "";
+ }
+ if (Document(inks[i].rootDoc).y !== firstVertical) {
+ this._currPositionVertical = "";
+ }
+ if (Document(inks[i].rootDoc)._width !== firstWidthSize) {
+ this._currSizeWidth = "";
+ }
+ if (Document(inks[i].rootDoc)._height !== firstHeightSize) {
+ this._currSizeHeight = "";
+ }
+ if (Document(inks[i].rootDoc).rotation !== firstRotation) {
+ this._currRotation = "";
+ }
+ }
+
+
+
+ }
+
+ @action
+ upDownButtons = (dirs: string, field: string) => {
+ SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
+ const doc = Document(element.rootDoc);
+ if (doc.type === DocumentType.INK) {
+ switch (field) {
+ case "width":
+ if (doc.strokeWidth) {
+ doc.strokeWidth = dirs === "up" ? doc.strokeWidth + 1 : doc.strokeWidth - 1;
+ SetActiveInkWidth(String(doc.strokeWidth));
+
+ }
+ break;
+ case "sizeWidth":
+ if (doc._width && doc._height) {
+ const oldWidth = doc._width;
+ const oldHeight = doc._height;
+
+ doc._width = dirs === "up" ? doc._width + 10 : doc._width - 10;
+ if (this._lock) {
+ doc._height = (doc._width * oldHeight) / oldWidth;
+ }
+ }
+ break;
+ case "sizeHeight":
+ if (doc._width && doc._height) {
+ const oldWidth = doc._width;
+ const oldHeight = doc._height;
+ doc._height = dirs === "up" ? doc._height + 10 : doc._height - 10;
+ if (this._lock) {
+ doc._width = (doc._height * oldWidth) / oldHeight;
+ }
+ }
+ break;
+ case "horizontal":
+ if (doc.x) {
+ doc.x = dirs === "up" ? doc.x + 10 : doc.x - 10;
+ }
+ break;
+ case "vertical":
+ if (doc.y) {
+ doc.y = dirs === "up" ? doc.y + 10 : doc.y - 10;
+ }
+ case "rotation":
+
+ this.rotate(dirs === "up" ? Number(doc.rotation) + Number(0.1) : Number(doc.rotation) - Number(0.1));
+
+ break;
+ default:
+ break;
+ }
+ this.selected();
+
+ }
+ }));
+ }
+
+ @action
+ editProperties = (value: any, field: string) => {
+ SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
+ const doc = Document(element.rootDoc);
+ if (doc.type === DocumentType.INK) {
+ switch (field) {
+ case "width":
+ SetActiveInkWidth(value);
+ doc.strokeWidth = Number(value);
+ break;
+ case "color":
+ doc.color = String(value);
+ break;
+ case "fill":
+ doc.fillColor = String(value);
+ break;
+ case "bezier":
+ // doc.strokeBezier === 300 ? doc.strokeBezier = 0 : doc.strokeBezier = 300;
+ break;
+ case "arrowStart":
+ doc.arrowStart = String(value);
+ break;
+ case "arrowEnd":
+ doc.arrowEnd = String(value);
+ break;
+ case "dash":
+ doc.dash = String(value);
+ break;
+ case "widthSize":
+ if (doc._width && doc._height) {
+ const oldWidth = doc._width;
+ const oldHeight = doc._height;
+
+ doc._width = Number(value);
+ if (this._lock) {
+ doc._height = (doc._width * oldHeight) / oldWidth;
+ }
+ }
+ break;
+ case "heightSize":
+ if (doc._width && doc._height) {
+ const oldWidth = doc._width;
+ const oldHeight = doc._height;
+
+ doc._height = Number(value);
+ if (this._lock) {
+ doc._width = (doc._height * oldWidth) / oldHeight;
+ }
+ }
+ break;
+ case "horizontal":
+ doc.x = Number(value);
+ break;
+ case "vertical":
+ doc.y = Number(value);
+
+ break;
+ default:
+ break;
+ }
+ }
+ this.selected();
+ }));
+ this.checkSame();
+
+ }
+
+ @computed get close() {
+ const close = ;
+ return close;
+ }
+
+ @computed get modes() {
+ const modes =
+ {this._mode.map(mode => {
+ return ;
+ })
+ }
;
+ return modes;
+ }
+
+ @action
+ selected = () => {
+ this._selectDoc = SelectionManager.SelectedDocuments();
+ if (this._selectDoc.length === 1 && Document(this._selectDoc[0].rootDoc).type === DocumentType.INK) {
+ this._single = true;
+ const doc = Document(this._selectDoc[0].rootDoc);
+ if (doc.type === DocumentType.INK) {
+ console.log(doc.fillColor);
+ if (doc.fillColor === "none") {
+ this._noFill = true;
+ this._solidFill = false;
+ } else {
+ this._solidFill = true;
+ this._noFill = false;
+ this._currFill = String(doc.fillColor);
+ }
+ if (doc.color === "none") {
+ this._noLine = true;
+ this._solidLine = false;
+ this._dashLine = false;
+ } else {
+ console.log(doc.strokeWidth);
+ this._currWidth = String(doc.strokeWidth);
+ this._currColor = String(doc.color);
+ if (doc.dash === "0") {
+ this._solidLine = true;
+ this._noLine = false;
+ this._dashLine = false;
+ } else {
+ this._dashLine = true;
+ this._noLine = false;
+ this._solidLine = false;
+ }
+
+ this._arrowHead = doc.arrowStart === "none" ? false : true;
+ this._arrowEnd = doc.arrowEnd === "none" ? false : true;
+
+
+ this._currPositionHorizontal = String(doc.x);
+ this._currPositionVertical = String(doc.y);
+ console.log(doc.rotation);
+ this._currRotation = String(doc.rotation);
+ this._currSizeHeight = String(doc._height);
+ this._currSizeWidth = String(doc._width);
+ }
+
+ }
+ } else {
+ this._noFill = false;
+ this._solidFill = false;
+ this._single = false;
+ this._currFill = "#D0021B";
+ this._noLine = false;
+ this._solidLine = false;
+ this._dashLine = false;
+ this._currColor = "#D0021B";
+ this._arrowHead = false;
+ this._arrowEnd = false;
+ this._currPositionHorizontal = "";
+ this._currPositionVertical = "";
+ this._currRotation = "";
+ this._currSizeHeight = "";
+ this._currSizeWidth = "";
+ }
+ this.checkSame();
+ }
+
+ @action
+ rotate = (degrees: number) => {
+ SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
+ const doc = Document(element.rootDoc);
+ if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
+ // doc.rotation = (Number(doc.rotation) + (Number(angle) * 180 / Math.PI));
+ // console.log(doc.rotation);
+ const angle = Number(degrees) - Number(doc.rotation);
+ doc.rotation = Number(degrees);
+ const ink = Cast(doc.data, InkField)?.inkData;
+ if (ink) {
+ 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 right = Math.max(...xs);
+ const bottom = Math.max(...ys);
+ const _centerPoints: { X: number, Y: number }[] = [];
+ _centerPoints.push({ X: left, Y: top });
+
+ const newPoints: { X: number, Y: number }[] = [];
+ for (var i = 0; i < ink.length; i++) {
+ const newX = Math.cos(angle) * (ink[i].X - _centerPoints[0].X) - Math.sin(angle) * (ink[i].Y - _centerPoints[0].Y) + _centerPoints[0].X;
+ const newY = Math.sin(angle) * (ink[i].X - _centerPoints[0].X) + Math.cos(angle) * (ink[i].Y - _centerPoints[0].Y) + _centerPoints[0].Y;
+ newPoints.push({ X: newX, Y: newY });
+ }
+ 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) * element.props.ScreenToLocalTransform().Scale;
+ doc._width = (right2 - left2) * element.props.ScreenToLocalTransform().Scale;
+
+ }
+ }
+ }));
+ }
+
+ @action
+ toggle = (check: string) => {
+ switch (check) {
+ case "noFill":
+ if (!this._noFill) {
+ this._noFill = true;
+ this._solidFill = false;
+ }
+ break;
+ case "solidFill":
+ if (!this._solidFill) {
+ this._solidFill = true;
+ this._noFill = false;
+ if (this._currFill === "none") {
+ this._currFill = "#D0021B";
+ }
+ }
+ break;
+ case "noLine":
+ if (!this._noLine) {
+ this._noLine = true;
+ this._solidLine = false;
+ this._dashLine = false;
+ }
+ break;
+ case "solidLine":
+ if (!this._solidLine) {
+ this._solidLine = true;
+ this._noLine = false;
+ this._dashLine = false;
+ if (this._currColor === "none") {
+ this._currColor = "#D0021B";
+ }
+ }
+ break;
+ case "dashLine":
+ if (!this._dashLine) {
+ this._dashLine = true;
+ this._solidLine = false;
+ this._noLine = false;
+ if (this._currColor === "none") {
+ this._currColor = "#D0021B";
+ }
+ }
+ break;
+ case "lock":
+ if (this._lock) {
+ this._lock = false;
+ } else {
+ this._lock = true;
+ }
+ break;
+ case "arrowHead":
+ this._arrowHead = this._arrowHead ? false : true;
+ break;
+ case "arrowEnd":
+ this._arrowEnd = this._arrowEnd ? false : true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ @computed get subMenu() {
+ const fillCheck =
+ { this.toggle("noFill"); this.editProperties("none", "fill"); })} />
+ No Fill
+
+ { this.toggle("solidFill"); this.editProperties(this._currFill, "fill"); })} />
+ Solid Fill
+
+
+ {this._solidFill ? "Color" : ""}
+ {this._solidFill ? this.fillButton : ""}
+ {this._fillBtn && this._solidFill ? this.fillPicker : ""}
+
+
;
+ const arrows = <> { this.toggle("arrowHead"); this.editProperties(this._arrowHead ? "arrowHead" : "none", "arrowStart"); })} />
+ Arrow Head
+
+
+ { this.toggle("arrowEnd"); this.editProperties(this._arrowEnd ? "arrowEnd" : "none", "arrowEnd"); })} />
+ Arrow End
+
>;
+ const lineCheck =
+ { this.toggle("noLine"); this.editProperties("none", "color"); })} />
+ No Line
+
+ { this.toggle("solidLine"); this.editProperties(this._currColor, "color"); this.editProperties("0", "dash"); })} />
+ Solid Line
+
+ { this.toggle("dashLine"); this.editProperties(this._currColor, "color"); this.editProperties("2", "dash"); })} />
+ Dash Line
+
+
+ {(this._solidLine || this._dashLine) ? "Color" : ""}
+ {(this._solidLine || this._dashLine) ? this.lineButton : ""}
+ {this._lineBtn && (this._solidLine || this._dashLine) ? this.linePicker : ""}
+
+ {(this._solidLine || this._dashLine) ? "Width" : ""}
+ {(this._solidLine || this._dashLine) ? this.widthInput : ""}
+
+
+ {(this._solidLine || this._dashLine) ? arrows : ""}
+
+
;
+
+ const sizeCheck =
+ Height {this.sizeHeightInput}
+
+
+
+
+ Width {this.sizeWidthInput}
+
+
+
+ { this.toggle("lock"); })} />
+ Lock Ratio
+
+
+
+
+ Rotation {this.rotationInput}
+
+
+
+
+
;
+ const positionCheck =
+ Horizontal {this.positionHorizontalInput}
+
+
+
+ Vertical {this.positionVerticalInput}
+
+
+
+
+
;
+
+ const subMenu =
+ {this._subMenu.map((subMenu, i) => {
+ if (subMenu === "fill" || subMenu === "line") {
+ return
+ {this.currMode === "fill-drip" && subMenu === "fill" && this._subOpen[0] ? fillCheck : ""}
+ {this.currMode === "fill-drip" && subMenu === "line" && this._subOpen[1] ? lineCheck : ""}
+
+
;
+ }
+ else if (subMenu === "size" || subMenu === "position") {
+ return
+ {this.currMode === "ruler-combined" && subMenu === "size" && this._subOpen[2] ? sizeCheck : ""}
+ {this.currMode === "ruler-combined" && subMenu === "position" && this._subOpen[3] ? positionCheck : ""}
+
+
+ ;
+
+ }
+ })
+ }
;
+ return subMenu;
+ }
+
+ @computed get fillButton() {
+ const fillButton = <>
+
+
>;
+ return fillButton;
+ }
+ @computed get fillPicker() {
+ const fillPicker =
+ {this._palette.map(color => {
+ return
;
+ })}
+
+
;
+ return fillPicker;
+ }
+
+ @computed get lineButton() {
+ const lineButton = <>
+
+
>;
+ return lineButton;
+ }
+ @computed get linePicker() {
+ const linePicker =
+ {this._palette.map(color => {
+ return
;
+ })}
+
+
;
+ return linePicker;
+ }
+ @computed get widthInput() {
+ const widthInput = <>
+ this.onChange(e.target.value, "width")}
+ autoFocus>
+
+ >;
+ return widthInput;
+ }
+ @computed get sizeHeightInput() {
+ const sizeHeightInput = <>
+ this.onChange(e.target.value, "sizeHeight")}
+ autoFocus>
+
+
+
+ >;
+ return sizeHeightInput;
+ }
+
+ @computed get sizeWidthInput() {
+ const sizeWidthInput = <>
+ this.onChange(e.target.value, "sizeWidth")}
+ autoFocus>
+
+
+ >;
+ return sizeWidthInput;
+ }
+
+ @computed get rotationInput() {
+ const rotationInput =
+ <>
+ this.onChange(e.target.value, "rotation")}
+ autoFocus>
+
+
+ >;
+ return rotationInput;
+ }
+
+ @computed get positionHorizontalInput() {
+ const positionHorizontalInput =
+ <> this.onChange(e.target.value, "positionHorizontal")}
+ autoFocus>
+
+
+ >;
+ return positionHorizontalInput;
+ }
+
+ @computed get positionVerticalInput() {
+ const positionVerticalInput =
+ <> this.onChange(e.target.value, "positionVertical")}
+ autoFocus>
+
+
+ >;
+ return positionVerticalInput;
+ }
+
+
+ @action
+ onChange = (val: string, property: string): void => {
+ if (!Number.isNaN(Number(val)) && Number(val) !== null && val !== " ") {
+
+ // if (val === "") {
+ // val = "0";
+ // }
+ switch (property) {
+ case "width":
+ this._currWidth = val;
+ if (val !== "") {
+ this.editProperties(this._currWidth, "width");
+ }
+ break;
+ case "sizeHeight":
+ this._currSizeHeight = val;
+ if (val !== "") {
+ this.editProperties(this._currSizeHeight, "heightSize");
+ }
+ break;
+ case "sizeWidth":
+ this._currSizeWidth = val;
+ if (val !== "") {
+
+ this.editProperties(this._currSizeWidth, "widthSize");
+ }
+ break;
+ case "rotation":
+
+ this._currRotation = val;
+ if (val !== "") {
+
+ this.rotate(Number(val));
+ }
+ break;
+ case "positionHorizontal":
+ this._currPositionHorizontal = val; if (val !== "") {
+
+ this.editProperties(this._currPositionHorizontal, "horizontal");
+ }
+
+ break;
+ case "positionVertical":
+ this._currPositionVertical = val;
+ if (val !== "") {
+
+ this.editProperties(this._currPositionVertical, "vertical");
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+
+
+ // @action
+ // changeWidth = (event: React.ChangeEvent) => {
+ // console.log(event.target.value);
+ // this._currWidth = NumCast(event.target.value);
+
+ // }
+
+ @computed get upDown() {
+ const upDown =
+
+
+
+
;
+ return upDown;
+ }
+
+
+ @computed get widthPicker() {
+ var widthPicker = ;
+ if (this._widthBtn) {
+ widthPicker =
+ {widthPicker}
+ {this._width.map(wid => {
+ return ;
+ })}
+
;
+ }
+ return widthPicker;
+ }
+
+
+
+ render() {
+ const buttons = [
+
+ this.close,
+ this.modes,
+ this.subMenu
+
+ ];
+
+ return this.getElementVert(buttons);
+ }
+}
+Scripting.addGlobal(function activatePen2(penBtn: any) {
+ if (penBtn) {
+ //no longer changes to inkmode
+ // Doc.SetSelectedTool(InkTool.Pen);
+ FormatShapePane.Instance.jumpTo(300, 300);
+ FormatShapePane.Instance.Pinned = true;
+
+ } else {
+ // Doc.SetSelectedTool(InkTool.None);
+ FormatShapePane.Instance.Pinned = false;
+ FormatShapePane.Instance.fadeOut(true);
+
+ }
+});
\ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
index 7329f4fc1..f739fcc8c 100644
--- a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
+++ b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.scss
@@ -32,7 +32,7 @@
}
.btn2-group {
- display: block;
+ display: grid;
background: #323232;
grid-template-columns: auto;
diff --git a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
index 7de70b8cd..e4f3248d0 100644
--- a/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
+++ b/src/client/views/collections/collectionFreeForm/InkOptionsMenu.tsx
@@ -36,14 +36,15 @@ export default class InkOptionsMenu extends AntimodeMenu {
// private _arrowEnd = ["none", "arrowEnd", "none", "dot", "none"];
// private _arrowIcons = ["→", "↔︎", "•", "••", " "];
private _draw = ["⎯", "→", "↔︎", "∿", "↝", "↭", "ロ", "O", "∆"];
- private _head = ["none", "arrowHead", "arrowHead", "none", "arrowHead", "arrowHead", "none", "none", "none"];
- private _end = ["none", "none", "arrowEnd", "none", "none", "arrowEnd", "none", "none", "none"];
+ private _head = ["none", "none", "arrowHead", "none", "none", "arrowHead", "none", "none", "none"];
+ private _end = ["none", "arrowEnd", "arrowEnd", "none", "arrowEnd", "arrowEnd", "none", "none", "none"];
private _shape = ["", "", "", "", "", "", "rectangle", "circle", "triangle"];
@observable _shapesNum = this._shape.length;
@observable _selected = this._shapesNum;
@observable private collapsed: boolean = false;
+ @observable _double = "";
@observable _colorBtn = false;
@observable _widthBtn = false;
@@ -155,7 +156,7 @@ export default class InkOptionsMenu extends AntimodeMenu {
className="antimodeMenu-button"
key={icon}
onPointerDown={action(() => {
- console.log(this._selected);
+ this._double = "";
if (this._selected !== i) {
this._selected = i;
@@ -177,6 +178,31 @@ export default class InkOptionsMenu extends AntimodeMenu {
}
console.log(this._selected);
+ })}
+ onDoubleClick={action(() => {
+ console.log("double");
+ this._double = this._draw[i];
+ if (this._selected !== i) {
+ this._selected = i;
+ Doc.SetSelectedTool(InkTool.Pen);
+ SetActiveArrowStart(this._head[i]);
+ SetActiveArrowEnd(this._end[i]);
+ SetActiveBezierApprox("300");
+
+ // this.editProperties(this._head[i], "arrowStart"), this.editProperties(this._end[i], "arrowEnd");
+ GestureOverlay.Instance.InkShape = this._shape[i];
+ } else {
+ this._selected = this._shapesNum;
+ Doc.SetSelectedTool(InkTool.None);
+ SetActiveArrowStart("none");
+ SetActiveArrowEnd("none");
+ GestureOverlay.Instance.InkShape = "";
+ SetActiveBezierApprox("0");
+
+ }
+
+
+
})}
style={{ backgroundColor: i === this._selected ? "121212" : "", fontSize: "20" }}>
{this._draw[i]}
@@ -235,7 +261,7 @@ export default class InkOptionsMenu extends AntimodeMenu {
className="antimodeMenu-button"
key={wid}
onPointerDown={action(() => { SetActiveInkWidth(wid); this._widthBtn = false; this.editProperties(wid, "width"); })}
- style={{ backgroundColor: this._widthBtn ? "121212" : "" }}>
+ style={{ backgroundColor: this._widthBtn ? "121212" : "", zIndex: 1001 }}>
{wid}
;
})}
@@ -265,7 +291,7 @@ export default class InkOptionsMenu extends AntimodeMenu {
className="antimodeMenu-button"
key={color}
onPointerDown={action(() => { this.changeColor(color, "color"); this._colorBtn = false; this.editProperties(color, "color"); })}
- style={{ backgroundColor: this._colorBtn ? "121212" : "" }}>
+ style={{ backgroundColor: this._colorBtn ? "121212" : "", zIndex: 1001 }}>
{/* */}
;
@@ -286,14 +312,14 @@ export default class InkOptionsMenu extends AntimodeMenu {
;
if (this._fillBtn) {
- fillPicker =
+ fillPicker =
{fillPicker}
{this._palette.map(color => {
return
;
})}
--
cgit v1.2.3-70-g09d2
From c8454d675a3081a83c56cf598b1b3637479b0459 Mon Sep 17 00:00:00 2001
From: yunahi <60233430+yunahi@users.noreply.github.com>
Date: Fri, 10 Jul 2020 05:22:06 +0900
Subject: added format shape
---
src/client/util/SelectionManager.ts | 3 +-
.../collectionFreeForm/FormatShapePane.tsx | 137 ++++-----------------
2 files changed, 24 insertions(+), 116 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index aea2c542b..af2f320d3 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -15,8 +15,7 @@ export namespace SelectionManager {
SelectedDocuments: ObservableMap
= new ObservableMap();
@action
SelectDoc(docView: DocumentView, ctrlPressed: boolean): void {
- console.log("select"
- );
+
// if doc is not in SelectedDocuments, add it
if (!manager.SelectedDocuments.get(docView)) {
if (!ctrlPressed) {
diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
index 7b47b7ca4..37ba805b6 100644
--- a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
+++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
@@ -3,12 +3,9 @@ import AntimodeMenu from "../../AntimodeMenu";
import { observer } from "mobx-react";
import { observable, action, computed } from "mobx";
import "./FormatShapePane.scss";
-import { ActiveInkColor, ActiveInkBezierApprox, ActiveFillColor, ActiveArrowStart, ActiveArrowEnd, SetActiveInkWidth, SetActiveInkColor, SetActiveBezierApprox, SetActiveFillColor, SetActiveArrowStart, SetActiveArrowEnd, ActiveDash, SetActiveDash } from "../../InkingStroke";
+import { SetActiveInkWidth } from "../../InkingStroke";
import { Scripting } from "../../../util/Scripting";
-import { InkTool, InkField } from "../../../../fields/InkField";
-import { ColorState } from "react-color";
-import { Utils } from "../../../../Utils";
-import GestureOverlay from "../../GestureOverlay";
+import { InkField } from "../../../../fields/InkField";
import { Doc } from "../../../../fields/Doc";
import { SelectionManager } from "../../../util/SelectionManager";
import { DocumentView } from "../../../views/nodes/DocumentView";
@@ -19,9 +16,6 @@ import { IconProp, library } from '@fortawesome/fontawesome-svg-core';
import { faRulerCombined, faFillDrip, faPenNib } from "@fortawesome/free-solid-svg-icons";
import { Cast, StrCast, BoolCast, NumCast } from "../../../../fields/Types";
import e = require("express");
-import { ChangeEvent } from "mongodb";
-import { black } from "colors";
-
library.add(faRulerCombined, faFillDrip, faPenNib);
@@ -33,63 +27,42 @@ export default class FormatShapePane extends AntimodeMenu {
private _width = ["1", "5", "10", "100"];
private _mode = ["fill-drip", "ruler-combined"];
private _subMenu = ["fill", "line", "size", "position"];
- private _headIcon = ["⎯", "←"];
- private _endIcon = ["⎯", "→"];
- private _head = ["none", "arrowHead"];
- private _end = ["none", "arrowEnd"];
-
@observable private _subOpen = [false, false, false, false];
-
@observable private collapsed: boolean = false;
@observable private currMode: string = "fill-drip";
@observable _fillBtn = false;
@observable _lineBtn = false;
-
@observable _selectDoc: DocumentView[] = [];
-
@observable _noFill = false;
@observable _solidFill = false;
@observable _noLine = false;
@observable _solidLine = false;
@observable _dashLine = false;
@observable _lock = false;
-
@observable _multiple = false;
-
@observable _widthBtn = false;
-
- @observable _currWidth = "10";
-
@observable _single = false;
- @observable _currFill = "#D0021B";
- @observable _currColor = "#D0021B";
-
@observable _arrowHead = false;
@observable _arrowEnd = false;
-
-
@observable _currSizeHeight = "10";
@observable _currSizeWidth = "10";
@observable _currRotation = "10";
-
@observable _currPositionHorizontal = "10";
@observable _currPositionVertical = "10";
-
+ @observable _currWidth = "10";
+ @observable _currFill = "#D0021B";
+ @observable _currColor = "#D0021B";
constructor(props: Readonly<{}>) {
super(props);
FormatShapePane.Instance = this;
- this._canFade = false; // don't let the inking menu fade away
+ this._canFade = false;
this.Pinned = BoolCast(Doc.UserDoc()["formatShapePane-pinned"]);
-
}
@action
toggleMenuPin = (e: React.MouseEvent) => {
Doc.UserDoc()["formatShapePane-pinned"] = this.Pinned = !this.Pinned;
- if (!this.Pinned) {
- // this.fadeOut(true);
- }
}
@action
@@ -105,9 +78,9 @@ export default class FormatShapePane extends AntimodeMenu {
closePane = () => {
this.jumpTo(-300, -300);
this.Pinned = false;
-
}
+ //if multiple inks are selected and do not share the same prop, leave blank
@action
checkSame = () => {
const docs = SelectionManager.SelectedDocuments();
@@ -117,18 +90,6 @@ export default class FormatShapePane extends AntimodeMenu {
inks.push(docs[i]);
}
}
- const firstWidth = Document(inks[0].rootDoc).strokeWidth;
- const firstColor = Document(inks[0].rootDoc).color;
- const firstFill = Document(inks[0].rootDoc).fillColor;
- // const firstBezier
- const firstRotation = Document(inks[0].rootDoc).rotation;
- const firstArrowStart = Document(inks[0].rootDoc).arrowStart;
- const firstArrowEnd = Document(inks[0].rootDoc).arrowEnd;
- const firstDash = Document(inks[0].rootDoc).dash;
- const firstWidthSize = Document(inks[0].rootDoc)._width;
- const firstHeightSize = Document(inks[0].rootDoc)._height;
- const firstHorizontal = Document(inks[0].rootDoc).x;
- const firstVertical = Document(inks[0].rootDoc).y;
this._noFill = Document(inks[0].rootDoc).fillColor === "none" ? true : false;
this._solidFill = Document(inks[0].rootDoc).fillColor === "none" ? false : true;
this._noLine = Document(inks[0].rootDoc).color === "none" ? true : false;
@@ -142,11 +103,7 @@ export default class FormatShapePane extends AntimodeMenu {
}
}
- // this._solidLine = (Document(inks[0].rootDoc).color === "none") ? false : Document(inks[0].rootDoc).dash === 0 ? true : false;
- // this._dashLine = (Document(inks[0].rootDoc).color === "none") ? false : Document(inks[0].rootDoc).dash !== 0 ? true : false;
- // // this._widthBtn = false;
this._currWidth = String(Document(inks[0].rootDoc).strokeWidth);
- // this._single = false;
this._currFill = String(Document(inks[0].rootDoc).fillColor);
this._currColor = String(Document(inks[0].rootDoc).color);
this._arrowHead = Document(inks[0].rootDoc).arrowStart === "none" ? false : true;
@@ -157,45 +114,43 @@ export default class FormatShapePane extends AntimodeMenu {
this._currPositionHorizontal = String(Document(inks[0].rootDoc).x);
this._currPositionVertical = String(Document(inks[0].rootDoc).y);
for (var i = 0; i < inks.length; i++) {
- if (Document(inks[i].rootDoc).strokeWidth !== firstWidth) {
+ if (Document(inks[i].rootDoc).strokeWidth !== Document(inks[0].rootDoc).strokeWidth) {
this._currWidth = "";
}
- if (Document(inks[i].rootDoc).color !== firstColor) {
+ if (Document(inks[i].rootDoc).color !== Document(inks[0].rootDoc).color) {
this._noLine = false;
this._solidLine = false;
this._dashLine = false;
}
- if (Document(inks[i].rootDoc).fillColor !== firstFill) {
+ if (Document(inks[i].rootDoc).fillColor !== Document(inks[0].rootDoc).fillColor) {
this._solidFill = false;
this._noFill = false;
}
- if (Document(inks[i].rootDoc).arrowStart !== firstArrowStart) {
+ if (Document(inks[i].rootDoc).arrowStart !== Document(inks[0].rootDoc).arrowStart) {
this._arrowHead = false;
}
- if (Document(inks[i].rootDoc).arrowEnd !== firstArrowEnd) {
+ if (Document(inks[i].rootDoc).arrowEnd !== Document(inks[0].rootDoc).arrowEnd) {
this._arrowEnd = false;
}
- if (Document(inks[i].rootDoc).x !== firstHorizontal) {
+ if (Document(inks[i].rootDoc).x !== Document(inks[0].rootDoc).x) {
this._currPositionHorizontal = "";
}
- if (Document(inks[i].rootDoc).y !== firstVertical) {
+ if (Document(inks[i].rootDoc).y !== Document(inks[0].rootDoc).y) {
this._currPositionVertical = "";
}
- if (Document(inks[i].rootDoc)._width !== firstWidthSize) {
+ if (Document(inks[i].rootDoc)._width !== Document(inks[0].rootDoc)._width) {
this._currSizeWidth = "";
}
- if (Document(inks[i].rootDoc)._height !== firstHeightSize) {
+ if (Document(inks[i].rootDoc)._height !== Document(inks[0].rootDoc)._height) {
this._currSizeHeight = "";
}
- if (Document(inks[i].rootDoc).rotation !== firstRotation) {
+ if (Document(inks[i].rootDoc).rotation !== Document(inks[0].rootDoc).rotation) {
this._currRotation = "";
}
}
-
-
-
}
+
@action
upDownButtons = (dirs: string, field: string) => {
SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
@@ -206,14 +161,12 @@ export default class FormatShapePane extends AntimodeMenu {
if (doc.strokeWidth) {
doc.strokeWidth = dirs === "up" ? doc.strokeWidth + 1 : doc.strokeWidth - 1;
SetActiveInkWidth(String(doc.strokeWidth));
-
}
break;
case "sizeWidth":
if (doc._width && doc._height) {
const oldWidth = doc._width;
const oldHeight = doc._height;
-
doc._width = dirs === "up" ? doc._width + 10 : doc._width - 10;
if (this._lock) {
doc._height = (doc._width * oldHeight) / oldWidth;
@@ -240,19 +193,17 @@ export default class FormatShapePane extends AntimodeMenu {
doc.y = dirs === "up" ? doc.y + 10 : doc.y - 10;
}
case "rotation":
-
this.rotate(dirs === "up" ? Number(doc.rotation) + Number(0.1) : Number(doc.rotation) - Number(0.1));
-
break;
default:
break;
}
this.selected();
-
}
}));
}
+
@action
editProperties = (value: any, field: string) => {
SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
@@ -270,7 +221,6 @@ export default class FormatShapePane extends AntimodeMenu {
doc.fillColor = String(value);
break;
case "bezier":
- // doc.strokeBezier === 300 ? doc.strokeBezier = 0 : doc.strokeBezier = 300;
break;
case "arrowStart":
doc.arrowStart = String(value);
@@ -285,7 +235,6 @@ export default class FormatShapePane extends AntimodeMenu {
if (doc._width && doc._height) {
const oldWidth = doc._width;
const oldHeight = doc._height;
-
doc._width = Number(value);
if (this._lock) {
doc._height = (doc._width * oldHeight) / oldWidth;
@@ -296,7 +245,6 @@ export default class FormatShapePane extends AntimodeMenu {
if (doc._width && doc._height) {
const oldWidth = doc._width;
const oldHeight = doc._height;
-
doc._height = Number(value);
if (this._lock) {
doc._width = (doc._height * oldWidth) / oldHeight;
@@ -308,7 +256,6 @@ export default class FormatShapePane extends AntimodeMenu {
break;
case "vertical":
doc.y = Number(value);
-
break;
default:
break;
@@ -331,13 +278,14 @@ export default class FormatShapePane extends AntimodeMenu {
return close;
}
+ //select either coor&fill or size&position
@computed get modes() {
const modes =
{this._mode.map(mode => {
return
;
@@ -346,6 +294,7 @@ export default class FormatShapePane extends AntimodeMenu {
return modes;
}
+ //detects currently selected document and change value in pane
@action
selected = () => {
this._selectDoc = SelectionManager.SelectedDocuments();
@@ -353,7 +302,6 @@ export default class FormatShapePane extends AntimodeMenu {
this._single = true;
const doc = Document(this._selectDoc[0].rootDoc);
if (doc.type === DocumentType.INK) {
- console.log(doc.fillColor);
if (doc.fillColor === "none") {
this._noFill = true;
this._solidFill = false;
@@ -382,11 +330,8 @@ export default class FormatShapePane extends AntimodeMenu {
this._arrowHead = doc.arrowStart === "none" ? false : true;
this._arrowEnd = doc.arrowEnd === "none" ? false : true;
-
-
this._currPositionHorizontal = String(doc.x);
this._currPositionVertical = String(doc.y);
- console.log(doc.rotation);
this._currRotation = String(doc.rotation);
this._currSizeHeight = String(doc._height);
this._currSizeWidth = String(doc._width);
@@ -418,8 +363,6 @@ export default class FormatShapePane extends AntimodeMenu {
SelectionManager.SelectedDocuments().forEach(action((element: DocumentView) => {
const doc = Document(element.rootDoc);
if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
- // doc.rotation = (Number(doc.rotation) + (Number(angle) * 180 / Math.PI));
- // console.log(doc.rotation);
const angle = Number(degrees) - Number(doc.rotation);
doc.rotation = Number(degrees);
const ink = Cast(doc.data, InkField)?.inkData;
@@ -446,10 +389,8 @@ export default class FormatShapePane extends AntimodeMenu {
const top2 = Math.min(...ys2);
const right2 = Math.max(...xs2);
const bottom2 = Math.max(...ys2);
-
doc._height = (bottom2 - top2) * element.props.ScreenToLocalTransform().Scale;
doc._width = (right2 - left2) * element.props.ScreenToLocalTransform().Scale;
-
}
}
}));
@@ -854,14 +795,11 @@ export default class FormatShapePane extends AntimodeMenu {
return positionVerticalInput;
}
-
+ //change inputs
@action
onChange = (val: string, property: string): void => {
if (!Number.isNaN(Number(val)) && Number(val) !== null && val !== " ") {
- // if (val === "") {
- // val = "0";
- // }
switch (property) {
case "width":
this._currWidth = val;
@@ -912,35 +850,6 @@ export default class FormatShapePane extends AntimodeMenu {
}
-
-
- // @action
- // changeWidth = (event: React.ChangeEvent
) => {
- // console.log(event.target.value);
- // this._currWidth = NumCast(event.target.value);
-
- // }
-
- @computed get upDown() {
- const upDown =
-
-
-
-
;
- return upDown;
- }
-
-
@computed get widthPicker() {
var widthPicker =
-
+
Math.min(350, NumCast(target._width, 350))}
- PanelHeight={() => Math.min(250, NumCast(target._height, 250))}
+ PanelWidth={() => 170} //Math.min(350, NumCast(target._width, 350))}
+ PanelHeight={() => 170} //Math.min(250, NumCast(target._height, 250))}
focus={emptyFunction}
whenActiveChanged={returnFalse}
bringToFront={returnFalse}
ContentScaling={returnOne}
- NativeWidth={returnZero}
- NativeHeight={returnZero}
+ NativeWidth={() => target._nativeWidth ? NumCast(target._nativeWidth) : 0}
+ NativeHeight={() => target._nativeHeight ? NumCast(target._nativeHeight) : 0}
/>
;
--
cgit v1.2.3-70-g09d2
From 3d0c64cf9979f739177b0efd9970ad0e0a9fa3d0 Mon Sep 17 00:00:00 2001
From: anika-ahluwalia
Date: Thu, 9 Jul 2020 17:00:12 -0500
Subject: small changes
---
src/client/documents/Documents.ts | 6 +-----
.../collections/collectionFreeForm/CollectionFreeFormView.tsx | 8 +++++---
src/client/views/linking/LinkMenuItem.tsx | 2 +-
src/client/views/nodes/formattedText/FormattedTextBox.tsx | 2 ++
4 files changed, 9 insertions(+), 9 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 565e7c25d..fa85d58f0 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -909,7 +909,7 @@ export namespace DocUtils {
DocUtils.ActiveRecordings.map(d => DocUtils.MakeLink({ doc: doc }, { doc: d }, "audio link", "audio timeline"));
}
- export function MakeLink(source: { doc: Doc }, target: { doc: Doc }, linkRelationship: string = "", description: string = "", id?: string, linkedText?: string) {
+ export function MakeLink(source: { doc: Doc }, target: { doc: Doc }, linkRelationship: string = "", description: string = "", id?: string) {
const sv = DocumentManager.Instance.getDocumentView(source.doc);
if (sv && sv.props.ContainingCollectionDoc === target.doc) return;
if (target.doc === Doc.UserDoc()) return undefined;
@@ -921,10 +921,6 @@ export namespace DocUtils {
Doc.GetProto(source.doc).links = ComputedField.MakeFunction("links(self)");
Doc.GetProto(target.doc).links = ComputedField.MakeFunction("links(self)");
- if (linkedText) {
- Doc.GetProto(linkDoc).linkedText = linkedText;
- }
-
return linkDoc;
}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 965bfdf24..9d79c0c89 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1181,17 +1181,19 @@ export class CollectionFreeFormView extends CollectionSubView {
this.props.destinationDoc.type === "screenshot" ? "photo-video" :
this.props.destinationDoc.type === "webcam" ? "video" :
this.props.destinationDoc.type === "audio" ? "microphone" :
- this.props.destinationDoc.type === "button" ? "lightning" :
+ this.props.destinationDoc.type === "button" ? "bolt" :
this.props.destinationDoc.type === "presentation" ? "tv" :
this.props.destinationDoc.type === "query" ? "search" :
this.props.destinationDoc.type === "script" ? "terminal" :
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index bff6f1c8c..4f6927d3d 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -176,9 +176,11 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
doLinkOnDeselect() {
console.log("link on deselect");
+
Array.from(this.linkOnDeselect.entries()).map(entry => {
const key = entry[0];
const value = entry[1];
+
const id = Utils.GenerateDeterministicGuid(this.dataDoc[Id] + key);
DocServer.GetRefField(value).then(doc => {
DocServer.GetRefField(id).then(linkDoc => {
--
cgit v1.2.3-70-g09d2
From 756a2d4e680bcdcc339e8f2493f699bb01e3fbb0 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Thu, 9 Jul 2020 18:37:03 -0400
Subject: fixed type errors.
---
.../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9d79c0c89..f2a39b240 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1172,7 +1172,7 @@ export class CollectionFreeFormView extends CollectionSubView
- _lastClientY = 0;
+ _lastClientY: number | undefined = 0;
@action
handleDragging = (e: CustomEvent, de: DragEvent) => {
if ((e as any).handlePan) return;
@@ -1233,7 +1233,7 @@ export class CollectionFreeFormView extends CollectionSubView {
setTimeout(() => {
const dragY = this._lastClientY;
- if (this._lastClientY !== undefined && this._marqueeRef.current) {
+ if (dragY !== undefined && this._marqueeRef.current) {
const bounds = this._marqueeRef.current.getBoundingClientRect()!;
this.Document._panY = NumCast(this.Document._panY) + delta;
(dragY - bounds.top < 25 || bounds.bottom - dragY < 25) && this.continueYPan(delta);
--
cgit v1.2.3-70-g09d2
From b9ba531c64fe7926a6794ab57e4989e1ea6c6992 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Fri, 10 Jul 2020 11:23:44 -0400
Subject: fixes for x/y panning on drag
---
.../collectionFreeForm/CollectionFreeFormView.tsx | 66 ++++++----------------
1 file changed, 16 insertions(+), 50 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index f2a39b240..3fdf6683e 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -84,6 +84,8 @@ export class CollectionFreeFormView extends CollectionSubView = new Map();
@@ -579,7 +581,7 @@ export class CollectionFreeFormView extends CollectionSubView {
- this._lastClientY = undefined;
+ this._lastClientY = this._lastClientX = undefined;
if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) return;
document.removeEventListener("pointermove", this.onPointerMove);
@@ -1172,76 +1174,40 @@ export class CollectionFreeFormView extends CollectionSubView
- _lastClientY: number | undefined = 0;
@action
handleDragging = (e: CustomEvent, de: DragEvent) => {
if ((e as any).handlePan) return;
(e as any).handlePan = true;
- const top = this.panX();
- const left = this.panY();
this._lastClientY = e.detail.clientY;
-
- console.log("draggg");
-
- const size = this.getTransform().transformDirection(this.props.PanelWidth(), this.props.PanelHeight());
- const scale = this.getLocalTransform().inverse().Scale;
+ this._lastClientX = e.detail.clientX;
if (this._marqueeRef?.current) {
-
- console.log("hellp");
-
const dragX = e.detail.clientX;
const dragY = e.detail.clientY;
const bounds = this._marqueeRef.current?.getBoundingClientRect();
- if (dragX - bounds.left < 25) {
- console.log("PAN left ");
-
- if (this.canPanX) {
- this.Document._panX = left - 5;
- setTimeout(action(() => {
- this.canPanX = true;
- this.panX();
- }), 250);
- this.canPanX = false;
- }
- } else if (bounds.right - dragX < 25) {
- console.log("PAN right ");
-
- if (this.canPanX) {
- this.Document._panX = left + 5;
- setTimeout(action(() => {
- this.panX();
- this.canPanX = true;
- }), 250);
- this.canPanX = false;
- }
-
- }
-
- if (dragY - bounds.top < 25) {
- console.log("PAN top ");
- this.continueYPan(-2);
- } else if (bounds.bottom - dragY < 25) {
- console.log("PAN bottom ");
- this.continueYPan(2);
- }
+ let deltaX = dragX - bounds.left < 25 ? -2 : bounds.right - dragX < 25 ? 2 : 0;
+ let deltaY = dragY - bounds.top < 25 ? -2 : bounds.bottom - dragY < 25 ? 2 : 0;
+ (deltaX !== 0 || deltaY !== 0) && this.continuePan(deltaX, deltaY);
}
e.stopPropagation();
}
- continueYPan = (delta: number) => {
+ continuePan = (deltaX: number, deltaY: number) => {
setTimeout(() => {
const dragY = this._lastClientY;
- if (dragY !== undefined && this._marqueeRef.current) {
+ const dragX = this._lastClientX;
+ if (dragY !== undefined && dragX !== undefined && this._marqueeRef.current) {
const bounds = this._marqueeRef.current.getBoundingClientRect()!;
- this.Document._panY = NumCast(this.Document._panY) + delta;
- (dragY - bounds.top < 25 || bounds.bottom - dragY < 25) && this.continueYPan(delta);
- } else this._lastClientY !== undefined && this.continueYPan(delta);
+ this.Document._panY = NumCast(this.Document._panY) + deltaY;
+ this.Document._panX = NumCast(this.Document._panX) + deltaX;
+ if (dragY - bounds.top < 25 || bounds.bottom - dragY < 25 || dragX - bounds.left < 25 || bounds.right - dragX < 25) {
+ this.continuePan(deltaX, deltaY);
+ }
+ } else this._lastClientY !== undefined && this._lastClientX !== undefined && this.continuePan(deltaX, deltaY);
}, 50);
}
-
promoteCollection = undoBatch(action(() => {
const childDocs = this.childDocs.slice();
childDocs.forEach(doc => {
--
cgit v1.2.3-70-g09d2
From d064024d9ab2cd8e836df5ba75e064d77617445b Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Fri, 10 Jul 2020 11:25:08 -0400
Subject: from last
---
.../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 3fdf6683e..2191021d2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1194,7 +1194,7 @@ export class CollectionFreeFormView extends CollectionSubView {
- setTimeout(() => {
+ setTimeout(action(() => {
const dragY = this._lastClientY;
const dragX = this._lastClientX;
if (dragY !== undefined && dragX !== undefined && this._marqueeRef.current) {
@@ -1205,7 +1205,7 @@ export class CollectionFreeFormView extends CollectionSubView {
--
cgit v1.2.3-70-g09d2
From 5a70fb56062d6a5ed45cf3cf4453089bc83f3c6b Mon Sep 17 00:00:00 2001
From: anika-ahluwalia
Date: Fri, 10 Jul 2020 18:11:09 -0500
Subject: added showing individual links with one bug
---
.../collectionFreeForm/CollectionFreeFormLinkView.tsx | 4 ++--
src/client/views/linking/LinkMenuItem.tsx | 13 ++++++++++---
src/client/views/nodes/DocumentLinksButton.tsx | 8 +++++++-
src/client/views/nodes/DocumentView.tsx | 18 ++++++++++++++----
4 files changed, 33 insertions(+), 10 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
index a24693c30..ae79c27e0 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
@@ -110,10 +110,10 @@ export class CollectionFreeFormLinkView extends React.Component
- {text !== "-ungrouped-" ? text : ""}
+ {text}
diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index f7d189b20..8fc1ea12f 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -177,11 +177,16 @@ export class LinkMenuItem extends React.Component {
DocumentLinksButton.EditLink = undefined;
}
+ @action
+ showLink = () => {
+ this.props.linkDoc.hidden = !this.props.linkDoc.hidden;
+ }
+
render() {
const keys = LinkManager.Instance.getMetadataKeysInGroup(this.props.groupType);//groupMetadataKeys.get(this.props.groupType);
const canExpand = keys ? keys.length > 0 : false;
- const eyeIcon = this.props.linkDoc.shown ? "eye-slash" : "eye";
+ const eyeIcon = this.props.linkDoc.hidden ? "eye-slash" : "eye";
const destinationIcon = this.props.destinationDoc.type === "image" ? "image" :
this.props.destinationDoc.type === "comparison" ? "columns" :
@@ -208,7 +213,9 @@ export class LinkMenuItem extends React.Component {
// from anika to bob: here's where the text that is specifically linked would show up (linkDoc.storedText)
// ...
const source = this.props.sourceDoc.type === "rtf" ? this.props.linkDoc.storedText ?
- "stored text would show up here" : undefined : undefined;
+ StrCast(this.props.linkDoc.storedText).length > 17 ?
+ StrCast(this.props.linkDoc.storedText).substr(0, 18)
+ : this.props.linkDoc.storedText : undefined : undefined;
return (
@@ -243,7 +250,7 @@ export class LinkMenuItem extends React.Component {
: <>>}
-
+
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx
index 22431117e..f07a2ea5a 100644
--- a/src/client/views/nodes/DocumentLinksButton.tsx
+++ b/src/client/views/nodes/DocumentLinksButton.tsx
@@ -95,6 +95,9 @@ export class DocumentLinksButton extends React.Component
{
LinkCreatedBox.popupX = e.screenX;
LinkCreatedBox.popupY = e.screenY - 133;
@@ -123,6 +126,9 @@ export class DocumentLinksButton extends React.Component {
LinkCreatedBox.popupX = e.screenX;
LinkCreatedBox.popupY = e.screenY - 133;
@@ -173,7 +179,7 @@ export class DocumentLinksButton extends React.Component : (null)}
;
- return (!links.length || links[0].hidden) && !this.props.AlwaysOn ? (null) :
+ return (!links.length) && !this.props.AlwaysOn ? (null) :
{linkButton}
;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 97e3bc01c..310260832 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -201,6 +201,8 @@ export class DocumentView extends DocComponent(Docu
this._mainCont.current && (this.multiTouchDisposer = InteractionUtils.MakeMultiTouchTarget(this._mainCont.current, this.onTouchStart.bind(this)));
// this._mainCont.current && (this.holdDisposer = InteractionUtils.MakeHoldTouchTarget(this._mainCont.current, this.handle1PointerHoldStart.bind(this)));
+ //this.layoutDoc.showAllLinks = true;
+
if (!this.props.dontRegisterView) {
DocumentManager.Instance.DocumentViews.push(this);
}
@@ -646,6 +648,8 @@ export class DocumentView extends DocComponent(Docu
const linkDoc = DocUtils.MakeLink({ doc: de.complete.annoDragData.annotationDocument }, { doc: this.props.Document }, "link");
LinkManager.currentLink = linkDoc;
+ linkDoc ? linkDoc.hidden = true : null;
+ linkDoc ? linkDoc.linkDisplay = true : null;
runInAction(() => {
LinkCreatedBox.popupX = de.x;
@@ -668,6 +672,8 @@ export class DocumentView extends DocComponent(Docu
const linkDoc = DocUtils.MakeLink({ doc: de.complete.linkDragData.linkSourceDocument },
{ doc: this.props.Document }, `link`);
LinkManager.currentLink = linkDoc;
+ linkDoc ? linkDoc.hidden = true : null;
+ linkDoc ? linkDoc.linkDisplay = true : null;
de.complete.linkDragData.linkSourceDocument !== this.props.Document &&
(de.complete.linkDragData.linkDocument = linkDoc); // TODODO this is where in text links get passed
@@ -783,9 +789,12 @@ export class DocumentView extends DocComponent(Docu
const optionItems: ContextMenuProps[] = options && "subitems" in options ? options.subitems : [];
const templateDoc = Cast(this.props.Document[StrCast(this.props.Document.layoutKey)], Doc, null);
templateDoc && optionItems.push({ description: "Open Template ", event: () => this.props.addDocTab(templateDoc, "onRight"), icon: "eye" });
- optionItems.push({ description: "Toggle Show Each Link Dot", event: () => this.layoutDoc.showLinks = !this.layoutDoc.showLinks, icon: "eye" });
+ optionItems.push({
+ description: "Toggle Show Each Link Dot", event: () => { this.layoutDoc.showAllLinks = !this.layoutDoc.showAllLinks; }, icon: "eye"
+ });
!options && cm.addItem({ description: "Options...", subitems: optionItems, icon: "compass" });
+
const existingOnClick = cm.findByDescription("OnClick...");
const onClicks: ContextMenuProps[] = existingOnClick && "subitems" in existingOnClick ? existingOnClick.subitems : [];
onClicks.push({ description: "Enter Portal", event: this.makeIntoPortal, icon: "window-restore" });
@@ -1084,7 +1093,7 @@ export class DocumentView extends DocComponent(Docu
select={this.select}
onClick={this.onClickHandler}
layoutKey={this.finalLayoutKey} />
- {this.layoutDoc.showLinks ? this.anchors : (null)}
+ {this.layoutDoc.showAllLinks ? this.allAnchors : null}
{this.props.forcedBackgroundColor?.(this.Document) === "transparent" || this.props.dontRegisterView ? (null) : }
);
@@ -1107,7 +1116,8 @@ export class DocumentView extends DocComponent
(Docu
hideLinkAnchor = (doc: Doc | Doc[]) => (doc instanceof Doc ? [doc] : doc).reduce((flg: boolean, doc) => flg && (doc.hidden = true), true)
anchorPanelWidth = () => this.props.PanelWidth() || 1;
anchorPanelHeight = () => this.props.PanelHeight() || 1;
- @computed get anchors() {
+
+ @computed get allAnchors() {
TraceMobx();
return (this.props.treeViewDoc && this.props.LayoutTemplateString) || // render nothing for: tree view anchor dots
this.layoutDoc.presBox || // presentationbox nodes
@@ -1133,7 +1143,7 @@ export class DocumentView extends DocComponent(Docu
if (this.props.treeViewDoc && !this.props.LayoutTemplateString) { // this happens when the document is a tree view label (but not an anchor dot)
return
{StrCast(this.props.Document.title)}
- {this.anchors}
+ {this.allAnchors}
;
}
--
cgit v1.2.3-70-g09d2
From 6b5c11a26e114f26f3907342f9afbd47b27cecf4 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik
Date: Sat, 11 Jul 2020 17:54:20 -0400
Subject: restructured ink to make more react-friendly
---
src/client/util/CurrentUserUtils.ts | 6 +-
src/client/util/InteractionUtils.tsx | 21 +-
src/client/util/SelectionManager.ts | 3 -
src/client/views/AntimodeMenu.tsx | 1 -
src/client/views/DocumentDecorations.tsx | 5 +-
src/client/views/InkingStroke.tsx | 18 +-
.../collectionFreeForm/FormatShapePane.tsx | 801 +++++++--------------
.../collectionFreeForm/InkOptionsMenu.tsx | 24 +-
src/client/views/nodes/ColorBox.tsx | 1 -
9 files changed, 299 insertions(+), 581 deletions(-)
(limited to 'src/client/views/collections/collectionFreeForm')
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index d0ca0e57e..0b644fa79 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -760,9 +760,9 @@ export class CurrentUserUtils {
doc.activeInkColor = StrCast(doc.activeInkColor, "rgb(0, 0, 0)");
doc.activeInkWidth = StrCast(doc.activeInkWidth, "1");
doc.activeInkBezier = StrCast(doc.activeInkBezier, "0");
- doc.activeFillColor = StrCast(doc.activeFillColor, "none");
- doc.activeArrowStart = StrCast(doc.activeArrowStart, "none");
- doc.activeArrowEnd = StrCast(doc.activeArrowEnd, "none");
+ doc.activeFillColor = StrCast(doc.activeFillColor, "");
+ doc.activeArrowStart = StrCast(doc.activeArrowStart, "");
+ doc.activeArrowEnd = StrCast(doc.activeArrowEnd, "");
doc.activeDash = StrCast(doc.activeDash, "0");
doc.fontSize = NumCast(doc.fontSize, 12);
doc["constants-snapThreshold"] = NumCast(doc["constants-snapThreshold"], 10); //
diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index 2883e2056..6ab7bcc87 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -3,7 +3,6 @@ import * as beziercurve from 'bezier-curve';
import * as fitCurve from 'fit-curve';
import "./InteractionUtils.scss";
import { Utils } from "../../Utils";
-import InkOptionsMenu from "../views/collections/collectionFreeForm/InkOptionsMenu";
export namespace InteractionUtils {
export const MOUSETYPE = "mouse";
@@ -96,12 +95,6 @@ export namespace InteractionUtils {
color: string, width: number, strokeWidth: number, bezier: string, fill: string, arrowStart: string, arrowEnd: string,
dash: string, scalex: number, scaley: number, shape: string, pevents: string, drawHalo: boolean, nodefs: boolean) {
- // if (InkOptionsMenu.Instance.Pinned) {
- // for (var i = 0; i < points.length; i++) {
- // points[i].Y -= 35;
- // }
- // }
-
let pts: { X: number; Y: number; }[] = [];
if (shape) { //if any of the shape are true
pts = makePolygon(shape, points);
@@ -127,15 +120,15 @@ export namespace InteractionUtils {
const dashArray = String(Number(width) * Number(dash));
const defGuid = Utils.GenerateGuid();
const arrowDim = Math.max(0.5, 8 / Math.log(Math.max(2, strokeWidth)));
- return (