aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx47
-rw-r--r--src/views/nodes/DocumentView.tsx11
-rw-r--r--src/views/nodes/ImageBox.tsx11
3 files changed, 36 insertions, 33 deletions
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index 24daa2fbc..c77bd5820 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -20,6 +20,8 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
private _containerRef = React.createRef<HTMLDivElement>();
private _canvasRef = React.createRef<HTMLDivElement>();
private _nodeContainerRef = React.createRef<HTMLDivElement>();
+ private _lastX: number = 0;
+ private _lastY: number = 0;
constructor(props: CollectionViewProps) {
super(props);
@@ -35,6 +37,7 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
return isSelected || childSelected || topMost;
}
+ @action
drop = (e: Event, de: DragManager.DropEvent) => {
const doc = de.data["document"];
if (doc instanceof DocumentView) {
@@ -57,23 +60,6 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
e.stopPropagation();
}
- private bringToFront(doc: DocumentView) {
- const { fieldKey, Document: Document } = this.props;
-
- const value: Document[] = Document.GetListField<Document>(fieldKey, []);
- var topmost = value.reduce((topmost, d) => Math.max(d.GetNumberField(KeyStore.ZIndex, 0), topmost), -1000);
- value.map(d => {
- var zind = d.GetNumberField(KeyStore.ZIndex, 0);
- if (zind != topmost - 1 - (topmost - zind) && d != doc.props.Document) {
- d.SetFieldValue(KeyStore.ZIndex, topmost - 1 - (topmost - zind), NumberField);
- }
- })
-
- if (doc.props.Document.GetNumberField(KeyStore.ZIndex, 0) != 0) {
- doc.props.Document.SetFieldValue(KeyStore.ZIndex, 0, NumberField);
- }
- }
-
componentDidMount() {
if (this._containerRef.current) {
DragManager.MakeDropTarget(this._containerRef.current, {
@@ -84,8 +70,6 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
}
}
- _lastX: number = 0;
- _lastY: number = 0;
@action
onPointerDown = (e: React.PointerEvent): void => {
if (e.button === 2 && this.active) {
@@ -139,6 +123,7 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
this.props.Document.SetFieldValue(KeyStore.PanY, Panyy + dy, NumberField);
}
+ @action
onDrop = (e: React.DragEvent): void => {
e.stopPropagation()
e.preventDefault()
@@ -170,6 +155,9 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
}
}
+ onDragOver = (e: React.DragEvent): void => {
+ }
+
@action
addDocument = (doc: Document): void => {
//TODO This won't create the field if it doesn't already exist
@@ -189,16 +177,31 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps>
}
}
- onDragOver = (e: React.DragEvent): void => {
+ @action
+ bringToFront(doc: DocumentView) {
+ const { fieldKey, Document: Document } = this.props;
+
+ const value: Document[] = Document.GetListField<Document>(fieldKey, []);
+ var topmost = value.reduce((topmost, d) => Math.max(d.GetNumberField(KeyStore.ZIndex, 0), topmost), -1000);
+ value.map(d => {
+ var zind = d.GetNumberField(KeyStore.ZIndex, 0);
+ if (zind != topmost - 1 - (topmost - zind) && d != doc.props.Document) {
+ d.SetFieldValue(KeyStore.ZIndex, topmost - 1 - (topmost - zind), NumberField);
+ }
+ })
+
+ if (doc.props.Document.GetNumberField(KeyStore.ZIndex, 0) != 0) {
+ doc.props.Document.SetFieldValue(KeyStore.ZIndex, 0, NumberField);
+ }
}
+
render() {
const { fieldKey, Document: Document } = this.props;
-
const value: Document[] = Document.GetListField<Document>(fieldKey, []);
const panx: number = Document.GetNumberField(KeyStore.PanX, 0);
const pany: number = Document.GetNumberField(KeyStore.PanY, 0);
const currScale: number = Document.GetNumberField(KeyStore.Scale, 1);
- console.log("DocsR " + value.length);
+
return (
<div className="border" style={{
borderStyle: "solid",
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 560cc0ee0..ae5712182 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -172,6 +172,11 @@ export class DocumentView extends React.Component<DocumentViewProps> {
return SelectionManager.IsSelected(this) || this.props.ContainingCollectionView === undefined || this.props.ContainingCollectionView!.active;
}
+ @computed
+ get topMost(): boolean {
+ return this.props.ContainingCollectionView == undefined || this.props.ContainingCollectionView instanceof CollectionDockingView;
+ }
+
//
// returns the cumulative scaling between the document and the screen
@@ -281,7 +286,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3) {
this._contextMenuCanOpen = false;
- if (this._mainCont.current != null && this.props.ContainingCollectionView != null) {
+ if (this._mainCont.current != null && !this.topMost) {
this._contextMenuCanOpen = false;
const rect = this.screenRect;
let dragData: { [id: string]: any } = {};
@@ -340,9 +345,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
return;
}
- var topMost = this.props.ContainingCollectionView == undefined ||
- this.props.ContainingCollectionView instanceof CollectionDockingView;
- if (topMost) {
+ if (this.topMost) {
ContextMenu.Instance.clearItems()
ContextMenu.Instance.addItem({ description: "Full Screen", event: this.fullScreenClicked })
ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15)
diff --git a/src/views/nodes/ImageBox.tsx b/src/views/nodes/ImageBox.tsx
index ffdcbae05..1dfad462f 100644
--- a/src/views/nodes/ImageBox.tsx
+++ b/src/views/nodes/ImageBox.tsx
@@ -15,7 +15,9 @@ export class ImageBox extends React.Component<DocumentFieldViewProps, ImageBoxSt
public static LayoutString() { return "<ImageBox doc={Document} containingDocumentView={ContainingDocumentView} fieldKey={DataKey} />"; }
private _ref: React.RefObject<HTMLDivElement>;
- private _wasSelected: boolean = false;
+ private _downX: number = 0;
+ private _downY: number = 0;
+ private _lastTap: number = 0;
constructor(props: DocumentFieldViewProps) {
super(props);
@@ -33,14 +35,9 @@ export class ImageBox extends React.Component<DocumentFieldViewProps, ImageBoxSt
componentWillUnmount() {
}
- _downX: number = 0;
- _downY: number = 0;
- _singleTap = false;
- _lastTap: number = 0;
onPointerDown = (e: React.PointerEvent): void => {
- const { containingDocumentView } = this.props;
if (Date.now() - this._lastTap < 300) {
- if (e.buttons === 1 && SelectionManager.IsSelected(containingDocumentView)) {
+ if (e.buttons === 1 && SelectionManager.IsSelected(this.props.containingDocumentView)) {
e.stopPropagation();
this._downX = e.clientX;
this._downY = e.clientY;