aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-01-29 14:43:42 -0500
committerbob <bcz@cs.brown.edu>2019-01-29 14:43:42 -0500
commitd8ff5b1effe0db563defc2a6e1391b9b0d160e67 (patch)
tree7f34bcd53a5732d644ccb8749da5d9258359d5b5
parent0a1264837da6de1bd73637307cc9c52678efa20f (diff)
intermediate state -- things don't resize properly yet.
-rw-r--r--src/DocumentDecorations.tsx2
-rw-r--r--src/views/collections/CollectionDockingView.tsx6
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx18
-rw-r--r--src/views/nodes/DocumentView.tsx6
4 files changed, 11 insertions, 21 deletions
diff --git a/src/DocumentDecorations.tsx b/src/DocumentDecorations.tsx
index d5a682b82..d71cda539 100644
--- a/src/DocumentDecorations.tsx
+++ b/src/DocumentDecorations.tsx
@@ -1,10 +1,8 @@
import { observable, computed } from "mobx";
import React = require("react");
-import { DocumentView } from "./views/nodes/DocumentView";
import { SelectionManager } from "./util/SelectionManager";
import { observer } from "mobx-react";
import './DocumentDecorations.scss'
-import { CollectionFreeFormView } from "./views/collections/CollectionFreeFormView";
@observer
export class DocumentDecorations extends React.Component {
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index b6fff6ba0..a59a40b33 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -132,13 +132,13 @@ export class CollectionDockingView extends React.Component<CollectionViewProps>
console.log("Gettting " + component);
const { fieldKey, Document: Document } = this.props;
const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
- if (component === "doc1") {
+ if (component === "doc1" && value.length > 0) {
return (<DocumentView key={value[ 0 ].Id} ContainingCollectionView={this} Document={value[ 0 ]} ContainingDocumentView={this.props.ContainingDocumentView} />);
}
- if (component === "doc2") {
+ if (component === "doc2" && value.length > 1) {
return (<DocumentView key={value[ 1 ].Id} ContainingCollectionView={this} Document={value[ 1 ]} ContainingDocumentView={this.props.ContainingDocumentView} />);
}
- if (component === "doc3") {
+ if (component === "doc3" && value.length > 2) {
return (<DocumentView key={value[ 2 ].Id} ContainingCollectionView={this} Document={value[ 2 ]} ContainingDocumentView={this.props.ContainingDocumentView} />);
}
if (component === "text") {
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index a1224f4da..c84b8e3e5 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -34,25 +34,17 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
}
drop = (e: Event, de: DragManager.DropEvent) => {
- const ele = this._canvasRef.current;
- if (!ele) {
- return;
- }
const doc = de.data[ "document" ];
- const xOffset = de.data[ "xOffset" ] as number || 0;
- const yOffset = de.data[ "yOffset" ] as number || 0;
if (doc instanceof DocumentView) {
if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this) {
doc.props.ContainingCollectionView.removeDocument(doc.props.Document);
this.addDocument(doc.props.Document);
}
- const { scale, translateX, translateY } = Utils.GetScreenTransform(ele);
- const screenX = de.x - xOffset;
- const screenY = de.y - yOffset;
- const docX = (screenX - translateX) / scale;
- const docY = (screenY - translateY) / scale;
- doc.x = docX;
- doc.y = docY;
+ const xOffset = de.data[ "xOffset" ] as number || 0;
+ const yOffset = de.data[ "yOffset" ] as number || 0;
+ let { LocalX, LocalY } = this.props.ContainingDocumentView!.TransformToLocalPoint(de.x - xOffset, de.y - yOffset);
+ doc.x = LocalX;
+ doc.y = LocalY;
}
e.stopPropagation();
}
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 0df97d62a..5ce64b347 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -193,9 +193,9 @@ export class DocumentView extends React.Component<DocumentViewProps> {
// Converts a point in the coordinate space of a document to a screen space coordinate.
//
public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): { ScreenX: Opt<number>, ScreenY: Opt<number> } {
- if (this.props.ContainingCollectionView != undefined && !(this.props.ContainingCollectionView instanceof CollectionFreeFormView)) {
- return { ScreenX: undefined, ScreenY: undefined };
- }
+ // if (this.props.ContainingCollectionView != undefined && !(this.props.ContainingCollectionView instanceof CollectionFreeFormView)) {
+ // return { ScreenX: undefined, ScreenY: undefined };
+ // }
let W = CollectionFreeFormView.BORDER_WIDTH; // this.props.Document.GetFieldValue(KeyStore.Width, NumberField, Number(0));
let H = CollectionFreeFormView.BORDER_WIDTH;
let Xx = this.props.Document.GetFieldValue(KeyStore.X, NumberField, Number(0));