aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/DocumentManager.tsx267
-rw-r--r--src/client/views/Main.tsx4
-rw-r--r--src/client/views/TempTreeView.tsx5
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx4
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx10
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx4
-rw-r--r--src/client/views/collections/CollectionView.tsx2
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx1
-rw-r--r--src/client/views/nodes/DocumentView.tsx6
9 files changed, 210 insertions, 93 deletions
diff --git a/src/client/views/DocumentManager.tsx b/src/client/views/DocumentManager.tsx
index bd3c4abfd..750b7aecf 100644
--- a/src/client/views/DocumentManager.tsx
+++ b/src/client/views/DocumentManager.tsx
@@ -53,7 +53,27 @@ export class DocumentManager {
return (toReturn);
}
- public getDocumentViewFreeform(toFind: Document): DocumentView | null {
+ // public getDocumentViewFreeform2(toFind: Document): DocumentView | null {
+
+ // let toReturn: DocumentView | null;
+ // toReturn = null;
+
+ // //gets document view that is in a freeform canvas collection
+ // DocumentManager.Instance.DocumentViews.map(view => {
+ // let doc = view.props.Document;
+ // if (view.props.ContainingCollectionView && view.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
+ // if (Object.is(doc, toFind)) {
+ // console.log("finding view")
+ // toReturn = view;
+ // return;
+ // }
+ // }
+ // })
+
+ // return (toReturn);
+ // }
+
+ public getCollectionView(toFind: Document): DocumentView | null {
let toReturn: DocumentView | null;
toReturn = null;
@@ -61,7 +81,8 @@ export class DocumentManager {
//gets document view that is in a freeform canvas collection
DocumentManager.Instance.DocumentViews.map(view => {
let doc = view.props.Document;
- if (view.props.ContainingCollectionView && view.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
+ if (view instanceof CollectionView) {
+ console.log("finding view")
if (Object.is(doc, toFind)) {
toReturn = view;
return;
@@ -72,113 +93,189 @@ export class DocumentManager {
return (toReturn);
}
- @action
- public centerNode2(doc: Document | DocumentView): any {
- //console.log(doc.Title)
- //gets document view that is in freeform collection
-
- let docView: DocumentView | null;
-
- if (doc instanceof Document) {
- docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
- }
- else {
- docView = doc
- }
-
- let scale: number;
- let XView: number;
- let YView: number;
-
- //if the view exists in a freeform collection
- if (docView) {
- let { width, height } = docView.size();
-
- //base case: parent of parent does not exist
- if (!docView.props.ContainingCollectionView) {
- scale = docView.props.ScreenToLocalTransform().Scale
- let doc = docView.props.Document;
- console.log("hello")
- XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2)
- YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2)
- //set x and y view of parent
- if (docView instanceof CollectionView) {
- console.log("here")
- DocumentManager.Instance.setViewportXY(docView, XView, YView)
- }
- }
- //parent is not main, parent is centered and calls itself
- else {
- if (true) {
- //view of parent
- let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
- let doc = docView.props.Document
-
- //TODO: make sure to test if the parent view is a freeform view. if not, just skip to the next level
- if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- //scale of parent
- console.log("scale: " + scale)
- XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
- YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
- // //node.Parent.setViewportXY(XView, YView);
- DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
- return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
- }
- else { return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document) }
- }
- else {
- // return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
- }
- }
- }
- }
+ // @action
+ // public centerNode2(doc: Document | DocumentView): any {
+ // //console.log(doc.Title)
+ // //gets document view that is in freeform collection
+
+ // let docView: DocumentView | null;
+
+ // if (doc instanceof Document) {
+ // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
+ // }
+ // else {
+ // docView = doc
+ // }
+
+ // let scale: number;
+ // let XView: number;
+ // let YView: number;
+
+ // //if the view exists in a freeform collection
+ // if (docView) {
+ // let { width, height } = docView.size();
+
+ // //base case: parent of parent does not exist
+ // if (!docView.props.ContainingCollectionView) {
+ // scale = docView.props.ScreenToLocalTransform().Scale
+ // let doc = docView.props.Document;
+ // console.log("hello")
+ // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2)
+ // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2)
+ // //set x and y view of parent
+ // if (docView instanceof CollectionView) {
+ // console.log("here")
+ // DocumentManager.Instance.setViewportXY(docView, XView, YView)
+ // }
+ // }
+ // //parent is not main, parent is centered and calls itself
+ // else {
+ // if (true) {
+ // //view of parent
+ // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
+ // let doc = docView.props.Document
+
+ // //TODO: make sure to test if the parent view is a freeform view. if not, just skip to the next level
+ // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
+ // //scale of parent
+ // console.log("scale: " + scale)
+ // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
+ // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
+ // // //node.Parent.setViewportXY(XView, YView);
+ // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
+ // return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
+ // }
+ // else { return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document) }
+ // }
+ // else {
+ // // return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
+ // }
+ // }
+ // }
+ // }
+
+ // @action
+ // public centerNode4(doc: Document | DocumentView): any {
+ // //console.log(doc.Title)
+ // //gets document view that is in freeform collection
+
+ // console.log("things are happening")
+
+ // let docView: DocumentView | null;
+
+ // if (doc instanceof Document) {
+ // console.log(doc.Title)
+ // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
+ // }
+ // else {
+ // docView = doc
+ // console.log(docView.props.Document.Title)
+ // }
+
+ // let scale: number;
+ // let XView: number;
+ // let YView: number;
+
+ // //if the view exists in a freeform collection
+ // if (docView) {
+ // let { width, height } = docView.size();
+
+ // if (docView.props.ContainingCollectionView) {
+ // //view of parent
+ // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
+ // let doc = docView.props.Document
+
+ // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
+ // //scale of parent
+ // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
+ // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
+ // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
+ // return DocumentManager.Instance.centerNode4(docView.props.ContainingCollectionView.props.Document)
+ // }
+ // else { return DocumentManager.Instance.centerNode4(docView.props.ContainingCollectionView.props.Document) }
+ // }
+ // }
+ // }
@action
- public centerNode(doc: Document | DocumentView): any {
+ public centerNode(doc: Document | DocumentView, x: number, y: number): any {
//console.log(doc.Title)
- //gets document view that is in freeform collection
-
+ //gets document view that is in freeform collection
let docView: DocumentView | null;
if (doc instanceof Document) {
- docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
+ console.log(doc.Title)
+ docView = DocumentManager.Instance.getDocumentView(doc)
}
else {
docView = doc
+ console.log(docView.props.Document.Title)
}
let scale: number;
let XView: number;
let YView: number;
- //if the view exists in a freeform collection
if (docView) {
let { width, height } = docView.size();
+ let scale = docView.props.Document.GetNumber(KeyStore.Scale, 1)
+ let doc = docView.props.Document
- //parent is not main, parent is centered and calls itself
- if (docView.props.ContainingCollectionView) {
- //view of parent
- let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
- let doc = docView.props.Document
-
- if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- //scale of parent
- XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
- YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
- DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
- return DocumentManager.Instance.centerNode(docView.props.ContainingCollectionView.props.Document)
- }
- else { return DocumentManager.Instance.centerNode(docView.props.ContainingCollectionView.props.Document) }
+ if (x && y) {
+ XView = (-x * scale) - (width * scale / 2);
+ YView = (-y * scale) - (height * scale / 2);
+ DocumentManager.Instance.setViewportXY(docView, XView, YView)
}
+
}
}
+ // @action
+ // public centerNode3(doc: Document | DocumentView): any {
+ // //console.log(doc.Title)
+ // //gets document view that is in freeform collection
+
+ // let docView: DocumentView | null;
+
+ // if (doc instanceof Document) {
+ // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
+ // }
+ // else {
+ // docView = doc
+ // }
+
+ // let scale: number;
+ // let XView: number;
+ // let YView: number;
+
+ // //if the view exists in a freeform collection
+ // if (docView) {
+ // let { width, height } = docView.size();
+
+ // //parent is not main, parent is centered and calls itself
+ // if (docView.props.ContainingCollectionView) {
+ // //view of parent
+ // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
+ // let doc = docView.props.Document
+
+ // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
+ // //scale of parent
+ // XView = doc.GetNumber(KeyStore.X, 0) - width / 2
+ // YView = doc.GetNumber(KeyStore.Y, 0) - height / 2
+ // // console.log("X location: " + XView)
+ // // console.log("Y location: " + YView)
+ // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
+ // return DocumentManager.Instance.centerNode3(docView.props.ContainingCollectionView.props.Document)
+ // }
+ // else { return DocumentManager.Instance.centerNode3(docView.props.ContainingCollectionView.props.Document) }
+ // }
+ // }
+ // }
+
@action
- private setViewportXY(collection: CollectionView, x: number, y: number) {
- if (collection.collectionViewType !== CollectionViewType.Freeform) {
- return
- }
+ private setViewportXY(collection: DocumentView, x: number, y: number) {
+ console.log("setting")
let doc = collection.props.Document;
doc.SetNumber(KeyStore.PanX, x);
doc.SetNumber(KeyStore.PanY, y);
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 64bcbc24f..da78dcfba 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -131,7 +131,9 @@ Documents.initProtos(() => {
PanelWidth={() => 0}
PanelHeight={() => 0}
isTopMost={true}
- ContainingCollectionView={undefined} />
+ ContainingCollectionView={undefined}
+ focus={(doc, x, y) => { }}
+ />
<DocumentDecorations />
<TempTreeView />
<ContextMenu />
diff --git a/src/client/views/TempTreeView.tsx b/src/client/views/TempTreeView.tsx
index f852224e9..bd73ef887 100644
--- a/src/client/views/TempTreeView.tsx
+++ b/src/client/views/TempTreeView.tsx
@@ -5,6 +5,7 @@ import { Document } from "../../fields/Document";
import { ListField } from "../../fields/ListField";
import "./TempTreeView.scss"
import { DocumentManager } from "./DocumentManager";
+import { KeyStore } from "../../fields/KeyStore";
@observer
@@ -15,7 +16,9 @@ export class TempTreeView extends React.Component {
let view = DocumentManager.Instance.getDocumentView(doc);
if (view != null) {
- DocumentManager.Instance.centerNode(view);
+ // DocumentManager.Instance.centerNode(view);
+ doc = view.props.Document
+ view.props.focus(doc, doc.GetNumber(KeyStore.X, 0), doc.GetNumber(KeyStore.Y, 0))
}
}
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 5393ac06e..9c1f1a56d 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -298,7 +298,9 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
PanelHeight={this._nativeHeight}
ScreenToLocalTransform={this.ScreenToLocalTransform}
isTopMost={true}
- ContainingCollectionView={undefined} />
+ ContainingCollectionView={undefined}
+ focus={(doc: Document, x: number, y: number) => { }}
+ />
</div>
return <Measure onResize={action((r: any) => { this._panelWidth = r.entry.width; this._panelHeight = r.entry.height; })}>
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index ac14811a5..fe2fc42ad 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -21,6 +21,7 @@ import "./CollectionFreeFormView.scss";
import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
import { CollectionViewBase } from "./CollectionViewBase";
import React = require("react");
+import { DocumentManager } from "../DocumentManager";
const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
@observer
@@ -191,7 +192,14 @@ export class CollectionFreeFormView extends CollectionViewBase {
ContentScaling={this.noScaling}
PanelWidth={doc.Width}
PanelHeight={doc.Height}
- ContainingCollectionView={this.props.CollectionView} />);
+ ContainingCollectionView={this.props.CollectionView}
+ focus={(doc: Document, x: number, y: number) => {
+ //set pan of colleciton freeform and then call parent
+ console.log("calling...")
+ DocumentManager.Instance.centerNode(doc, doc.GetNumber(KeyStore.X, 0), doc.GetNumber(KeyStore.Y, 0))
+ this.props.focus(this.props.Document, doc.GetNumber(KeyStore.X, 0), doc.GetNumber(KeyStore.Y, 0))
+ }}
+ />);
})
}
return null;
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 38217d7c4..4eaf585ce 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -211,7 +211,9 @@ export class CollectionSchemaView extends CollectionViewBase {
ContentScaling={this.getContentScaling}
PanelWidth={this.getPanelWidth}
PanelHeight={this.getPanelHeight}
- ContainingCollectionView={this.props.CollectionView} />
+ ContainingCollectionView={this.props.CollectionView}
+ focus={(doc, x, y) => this.props.focus(this.props.Document, x, y)}
+ />
</div>
}
</Measure>
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 03e1f1fa4..e6a8d2448 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -30,7 +30,7 @@ export class CollectionView extends React.Component<CollectionViewProps> {
public static LayoutString(fieldKey: string = "DataKey") {
return `<CollectionView Document={Document}
ScreenToLocalTransform={ScreenToLocalTransform} fieldKey={${fieldKey}} panelWidth={PanelWidth} panelHeight={PanelHeight} isSelected={isSelected} select={select} bindings={bindings}
- isTopMost={isTopMost} BackgroundView={BackgroundView} />`;
+ isTopMost={isTopMost} BackgroundView={BackgroundView} focus={focus}/>`;
}
public active = () => {
var isSelected = this.props.isSelected();
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index e38258e0b..d9e43c0dc 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -23,6 +23,7 @@ export interface CollectionViewProps {
bindings: any;
panelWidth: () => number;
panelHeight: () => number;
+ focus: (doc: Document, x: number, y: number) => void;
}
export interface SubCollectionViewProps extends CollectionViewProps {
active: () => boolean;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 21f64ef35..90699cd2e 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -36,6 +36,7 @@ export interface DocumentViewProps {
ContentScaling: () => number;
PanelWidth: () => number;
PanelHeight: () => number;
+ focus: (doc: Document, x: number, y: number) => void;
}
export interface JsxArgs extends DocumentViewProps {
Keys: { [name: string]: Key }
@@ -184,7 +185,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
//TODO Monika
@action
Center = (e: React.MouseEvent): void => {
- DocumentManager.Instance.centerNode(this)
+ this.props.focus(this.props.Document, this.props.Document.GetNumber(KeyStore.X, 0), this.props.Document.GetNumber(KeyStore.Y, 0))
}
@action
@@ -265,7 +266,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
...this.props,
isSelected: this.isSelected,
select: this.select,
- documentSize: this.size
+ documentSize: this.size,
+ focus: this.props.focus
};
for (const key of this.layoutKeys) {
this._documentBindings[key.Name + "Key"] = key; // this maps string values of the form <keyname>Key to an actual key Kestore.keyname e.g, "DataKey" => KeyStore.Data