aboutsummaryrefslogtreecommitdiff
path: root/src/views/collections
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-01-30 13:36:03 -0500
committerbob <bcz@cs.brown.edu>2019-01-30 13:36:03 -0500
commitf9d241406c62b6aba1a84b5947d339c1a4c28a6d (patch)
treebd989211548534470f7dbaa088ee847d2522e013 /src/views/collections
parent8866e324bd7ea8dd03814a840662ca7c3b1a8e0f (diff)
fixed dragging and doc decorations for all docking locations I think.
Diffstat (limited to 'src/views/collections')
-rw-r--r--src/views/collections/CollectionDockingView.tsx52
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx19
2 files changed, 30 insertions, 41 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index fd492503d..f08bdaab4 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -4,7 +4,7 @@ import React = require("react");
import FlexLayout from "flexlayout-react";
import { action, observable, computed } from "mobx";
import { Document } from "../../fields/Document";
-import { DocumentView, CollectionViewProps } from "../nodes/DocumentView";
+import { DocumentView, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "../nodes/DocumentView";
import { ListField } from "../../fields/ListField";
import { NumberField } from "../../fields/NumberField";
import { SSL_OP_SINGLE_DH_USE } from "constants";
@@ -52,9 +52,6 @@ export class CollectionDockingView extends React.Component<CollectionViewProps>
super(props);
}
- public static BORDER_WIDTH = 2;
- public static TAB_HEADER_HEIGHT = 20;
-
@computed
public get active(): boolean {
var isSelected = (this.props.ContainingDocumentView != undefined && SelectionManager.IsSelected(this.props.ContainingDocumentView));
@@ -169,35 +166,24 @@ export class CollectionDockingView extends React.Component<CollectionViewProps>
var w = Document.GetFieldValue(KeyStore.Width, NumberField, Number(0)) / s;
var h = Document.GetFieldValue(KeyStore.Height, NumberField, Number(0)) / s;
- if (CollectionDockingView.UseGoldenLayout) {
- return (
- <div className="border" style={{
- borderStyle: "solid",
- borderWidth: `${CollectionDockingView.BORDER_WIDTH}px`,
- }}>
- <div className="collectiondockingview-container" onPointerDown={this.onPointerDown} onContextMenu={(e) => e.preventDefault()} ref={this._containerRef}
- style={{
- width: "100%",
- height: "100%"
- }} >
- </div>
- </div>
- );
- } else {
- return (
- <div className="border" style={{
- borderStyle: "solid",
- borderWidth: `${CollectionDockingView.BORDER_WIDTH}px`,
- }}>
- <div className="collectiondockingview-container" onPointerDown={this.onPointerDown} onContextMenu={(e) => e.preventDefault()} ref={this._containerRef}
- style={{
- width: s > 1 ? "100%" : w - 2 * CollectionDockingView.BORDER_WIDTH,
- height: s > 1 ? "100%" : h - 2 * CollectionDockingView.BORDER_WIDTH
- }} >
- <FlexLayout.Layout model={this.modelForFlexLayout} factory={this.flexLayoutFactory} />
- </div>
- </div>
- );
+ var chooseLayout = () => {
+ if (!CollectionDockingView.UseGoldenLayout)
+ return <FlexLayout.Layout model={this.modelForFlexLayout} factory={this.flexLayoutFactory} />;
}
+
+ return (
+ <div className="border" style={{
+ borderStyle: "solid",
+ borderWidth: `${COLLECTION_BORDER_WIDTH}px`,
+ }}>
+ <div className="collectiondockingview-container" onPointerDown={this.onPointerDown} onContextMenu={(e) => e.preventDefault()} ref={this._containerRef}
+ style={{
+ width: CollectionDockingView.UseGoldenLayout || s > 1 ? "100%" : w - 2 * COLLECTION_BORDER_WIDTH,
+ height: CollectionDockingView.UseGoldenLayout || s > 1 ? "100%" : h - 2 * COLLECTION_BORDER_WIDTH
+ }} >
+ {chooseLayout()}
+ </div>
+ </div>
+ );
}
} \ No newline at end of file
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index 736bcb786..58e694698 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -3,7 +3,7 @@ import { Key, KeyStore } from "../../fields/Key";
import React = require("react");
import { action, observable, computed } from "mobx";
import { Document } from "../../fields/Document";
-import { DocumentView, CollectionViewProps } from "../nodes/DocumentView";
+import { DocumentView, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "../nodes/DocumentView";
import { ListField } from "../../fields/ListField";
import { NumberField } from "../../fields/NumberField";
import { SSL_OP_SINGLE_DH_USE } from "constants";
@@ -24,8 +24,6 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
super(props);
}
- public static BORDER_WIDTH = 2;
-
@computed
public get active(): boolean {
var isSelected = (this.props.ContainingDocumentView != undefined && SelectionManager.IsSelected(this.props.ContainingDocumentView));
@@ -45,9 +43,14 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
}
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;
+ const { scale, translateX, translateY } = Utils.GetScreenTransform(this._canvasRef.current!);
+ let sscale = this.props.ContainingDocumentView!.props.Document.GetFieldValue(KeyStore.Scale, NumberField, Number(1))
+ const screenX = de.x - xOffset;
+ const screenY = de.y - yOffset;
+ const docX = (screenX - translateX) / sscale / scale;
+ const docY = (screenY - translateY) / sscale / scale;
+ doc.x = docX;
+ doc.y = docY;
}
e.stopPropagation();
}
@@ -181,11 +184,11 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
return (
<div className="border" style={{
borderStyle: "solid",
- borderWidth: `${CollectionFreeFormView.BORDER_WIDTH}px`,
+ borderWidth: `${COLLECTION_BORDER_WIDTH}px`,
}}>
<div className="collectionfreeformview-container" onPointerDown={this.onPointerDown} onWheel={this.onPointerWheel} onContextMenu={(e) => e.preventDefault()} style={{
width: "100%",
- height: `calc(100% - 2*${CollectionFreeFormView.BORDER_WIDTH}px)`,
+ height: `calc(100% - 2*${COLLECTION_BORDER_WIDTH}px)`,
}} onDrop={this.onDrop} onDragOver={this.onDragOver} ref={this._containerRef}>
<div className="collectionfreeformview" style={{ transform: `translate(${panx}px, ${pany}px) scale(${currScale}, ${currScale})`, transformOrigin: `left, top` }} ref={this._canvasRef}>