aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-03-11 15:27:20 -0400
committerbob <bcz@cs.brown.edu>2019-03-11 15:27:20 -0400
commit6e66622439eff11e69c8fa71c477ce0f8f5cc104 (patch)
tree7243a0e2adc606993745c06a2eabbe7f4f6d1a24 /src
parente0d33c6092e5fb62343ef38d8734fa342e6dff84 (diff)
cleaned up drag/drop interactions to be more consistent and complete.
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx2
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx18
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx2
-rw-r--r--src/client/views/nodes/DocumentView.tsx38
4 files changed, 34 insertions, 26 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 70549099e..6a0404663 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -44,7 +44,7 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
(window as any).ReactDOM = ReactDOM;
}
public StartOtherDrag(dragDoc: Document, e: any) {
- this.AddRightSplit(dragDoc, true).contentItems[0].tab._dragListener.onMouseDown({ pageX: e.pageX, pageY: e.pageY, preventDefault: () => { }, button: e.button })
+ this.AddRightSplit(dragDoc, true).contentItems[0].tab._dragListener.onMouseDown({ pageX: e.pageX, pageY: e.pageY, preventDefault: () => { }, button: 0 })
}
@action
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 1d1a748e4..ab6b9d533 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -25,6 +25,7 @@ import "./CollectionFreeFormView.scss";
import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
import { CollectionViewBase } from "./CollectionViewBase";
import React = require("react");
+import { SelectionManager } from "../../util/SelectionManager";
const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
@observer
@@ -74,7 +75,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
onPointerDown = (e: React.PointerEvent): void => {
- if (((e.button === 2 && this.props.active()) || !e.defaultPrevented) &&
+ if (((e.button === 2 && this.props.active()) || !e.defaultPrevented) && !e.shiftKey &&
(!this.isAnnotationOverlay || this.zoomScaling != 1 || e.button == 0)) {
document.removeEventListener("pointermove", this.onPointerMove);
document.addEventListener("pointermove", this.onPointerMove);
@@ -84,11 +85,6 @@ export class CollectionFreeFormView extends CollectionViewBase {
this._lastY = e.pageY;
this._downX = e.pageX;
this._downY = e.pageY;
- this._marquee = e.button != 2 && e.shiftKey;
- if (this._marquee) {
- e.stopPropagation();
- e.preventDefault();
- }
}
}
@@ -99,6 +95,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
e.stopPropagation();
if (this._marquee) {
+ if (!e.shiftKey) {
+ SelectionManager.DeselectAll();
+ }
this.marqueeSelect();
this._marquee = false;
}
@@ -123,12 +122,12 @@ export class CollectionFreeFormView extends CollectionViewBase {
@action
marqueeSelect() {
+ this.props.CollectionView.SelectedDocs.length = 0;
var curPage = this.props.Document.GetNumber(KeyStore.CurPage, 1);
let p = this.getTransform().transformPoint(this._downX, this._downY);
let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
let selRect = { left: p[0], top: p[1], right: p[0] + v[0], bottom: p[1] + v[1] }
- this.props.CollectionView.SelectedDocs.length = 0;
var curPage = this.props.Document.GetNumber(KeyStore.CurPage, 1);
const lvalue = this.props.Document.GetT<ListField<Document>>(this.props.fieldKey, ListField);
if (lvalue && lvalue != FieldWaiting) {
@@ -151,6 +150,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
if (!e.cancelBubble && this.props.active()) {
e.stopPropagation();
e.preventDefault();
+ this._marquee = e.buttons != 2;
if (!this._marquee) {
let x = this.props.Document.GetNumber(KeyStore.PanX, 0);
@@ -341,9 +341,9 @@ export class CollectionFreeFormView extends CollectionViewBase {
cursor = <div id="prevCursor" onKeyPress={this.onKeyDown} style={{ color: "black", position: "absolute", transformOrigin: "left top", transform: `translate(${x}px, ${y}px)` }}>I</div>
}
- let p = this.getTransform().transformPoint(this._downX, this._downY);
+ let p = this.getTransform().transformPoint(this._downX < this._lastX ? this._downX : this._lastX, this._downY < this._lastY ? this._downY : this._lastY);
let v = this.getTransform().transformDirection(this._lastX - this._downX, this._lastY - this._downY);
- var marquee = this._marquee ? <div className="collectionfreeformview-marquee" style={{ transform: `translate(${p[0]}px, ${p[1]}px)`, width: `${v[0]}`, height: `${v[1]}` }}></div> : (null);
+ var marquee = this._marquee ? <div className="collectionfreeformview-marquee" style={{ transform: `translate(${p[0]}px, ${p[1]}px)`, width: `${Math.abs(v[0])}`, height: `${Math.abs(v[1])}` }}></div> : (null);
let [dx, dy] = [this.centeringShiftX, this.centeringShiftY];
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 59fa61800..b126b40a9 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -47,7 +47,7 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
protected drop(e: Event, de: DragManager.DropEvent) {
const docView: DocumentView = de.data["documentView"];
const doc: Document = de.data["document"];
- if (docView && docView.props.ContainingCollectionView && docView.props.ContainingCollectionView !== this.props.CollectionView) {
+ if (docView && (!docView.props.ContainingCollectionView || docView.props.ContainingCollectionView !== this.props.CollectionView)) {
if (docView.props.RemoveDocument) {
docView.props.RemoveDocument(docView.props.Document);
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index ee19c2b80..dc793c16d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -100,8 +100,11 @@ export class DocumentView extends React.Component<DocumentViewProps> {
onPointerDown = (e: React.PointerEvent): void => {
this._downX = e.clientX;
this._downY = e.clientY;
- if (e.shiftKey && e.buttons === 1) {
- CollectionDockingView.Instance.StartOtherDrag(this.props.Document, e);
+ if (e.shiftKey && e.buttons === 2) {
+ if (this.props.isTopMost) {
+ this.startDragging(e.pageX, e.pageY);
+ }
+ else CollectionDockingView.Instance.StartOtherDrag(this.props.Document, e);
e.stopPropagation();
} else {
if (this.active && !e.isDefaultPrevented()) {
@@ -156,6 +159,21 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
}
+ startDragging(x: number, y: number) {
+ if (this._mainCont.current) {
+ const [left, top] = this.props.ScreenToLocalTransform().inverse().transformPoint(0, 0);
+ let dragData: { [id: string]: any } = {};
+ dragData["documentView"] = this;
+ dragData["xOffset"] = x - left;
+ dragData["yOffset"] = y - top;
+ DragManager.StartDrag(this._mainCont.current, dragData, {
+ handlers: {
+ dragComplete: action(() => { }),
+ },
+ hideSource: true
+ })
+ }
+ }
onPointerMove = (e: PointerEvent): void => {
if (e.cancelBubble) {
@@ -163,19 +181,9 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3) {
document.removeEventListener("pointermove", this.onPointerMove)
- document.removeEventListener("pointerup", this.onPointerUp)
- if (this._mainCont.current != null && !this.topMost) {
- const [left, top] = this.props.ScreenToLocalTransform().inverse().transformPoint(0, 0);
- let dragData: { [id: string]: any } = {};
- dragData["documentView"] = this;
- dragData["xOffset"] = e.x - left;
- dragData["yOffset"] = e.y - top;
- DragManager.StartDrag(this._mainCont.current, dragData, {
- handlers: {
- dragComplete: action(() => { }),
- },
- hideSource: true
- })
+ document.removeEventListener("pointerup", this.onPointerUp);
+ if (!this.topMost || e.buttons == 2) {
+ this.startDragging(e.x, e.y);
}
}
e.stopPropagation();