aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-02-26 16:33:53 -0500
committeryipstanley <stanley_yip@brown.edu>2019-02-26 16:33:53 -0500
commit59cc888c8bf0559c50e12fd2774ea5ac4ebb3059 (patch)
tree01c88fb348d4431c017d9546f0840f37235dd1ba /src/client/views/collections
parent8d2dc530854517830dc55d7f7a0f02828bd7f8f6 (diff)
basic implementation of prototype/delegate stuff
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx25
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx14
2 files changed, 26 insertions, 13 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index cb6668634..4cdd0d554 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -44,17 +44,20 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
drop = (e: Event, de: DragManager.DropEvent) => {
super.drop(e, de);
- const doc: DocumentView = de.data["document"];
- const xOffset = de.data["xOffset"] as number || 0;
- const yOffset = de.data["yOffset"] as number || 0;
- //this should be able to use translate and scale methods on an Identity transform, no?
- const transform = this.getTransform();
- const screenX = de.x - xOffset;
- const screenY = de.y - yOffset;
- const [x, y] = transform.transformPoint(screenX, screenY);
- doc.props.Document.SetNumber(KeyStore.X, x);
- doc.props.Document.SetNumber(KeyStore.Y, y);
- this.bringToFront(doc);
+
+ if (!de.data["alias"]) {
+ const doc: DocumentView = de.data["document"];
+ const xOffset = de.data["xOffset"] as number || 0;
+ const yOffset = de.data["yOffset"] as number || 0;
+ //this should be able to use translate and scale methods on an Identity transform, no?
+ const transform = this.getTransform();
+ const screenX = de.x - xOffset;
+ const screenY = de.y - yOffset;
+ const [x, y] = transform.transformPoint(screenX, screenY);
+ doc.props.Document.SetNumber(KeyStore.X, x);
+ doc.props.Document.SetNumber(KeyStore.Y, y);
+ this.bringToFront(doc);
+ }
}
@action
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 7e269caf1..be3cb0d5f 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -43,11 +43,21 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
@action
protected drop(e: Event, de: DragManager.DropEvent) {
const doc: DocumentView = de.data["document"];
+ if (de.data["alias"]) {
+ let newDoc = doc.props.Document.CreateAlias()
+ const xOffset = de.data["xOffset"] as number || 0
+ const yOffset = de.data["yOffset"] as number || 0
+ newDoc.SetNumber(KeyStore.X, de.x - xOffset)
+ newDoc.SetNumber(KeyStore.Y, de.y - yOffset)
+ newDoc.SetNumber(KeyStore.Width, doc.props.Document.GetNumber(KeyStore.Width, 100))
+ newDoc.SetNumber(KeyStore.Height, doc.props.Document.GetNumber(KeyStore.Height, 100))
+ this.props.addDocument(newDoc)
+ }
if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this.props.CollectionView) {
- if (doc.props.RemoveDocument) {
+ if (!de.data["alias"] && doc.props.RemoveDocument) {
doc.props.RemoveDocument(doc.props.Document);
}
- this.props.addDocument(doc.props.Document);
+ this.props.addDocument(de.data["alias"] ? doc.props.Document.CreateAlias() : doc.props.Document);
}
e.stopPropagation();
}