aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/CollectionLinearView.tsx
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-10-26 15:35:56 -0400
committeryipstanley <stanley_yip@brown.edu>2019-10-26 15:35:56 -0400
commit24031b32402f19932d293bdc3eb483235cff820a (patch)
treeab1cb93f50eafeb1a4cf07e588aed971700c96b5 /src/client/views/CollectionLinearView.tsx
parent3cff8e7d101a528e392d885420de118cccca6ae5 (diff)
parent2786a2e4b33ff874f320697b89fecec3105df201 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into interaction_stanley
Diffstat (limited to 'src/client/views/CollectionLinearView.tsx')
-rw-r--r--src/client/views/CollectionLinearView.tsx35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/client/views/CollectionLinearView.tsx b/src/client/views/CollectionLinearView.tsx
index eb3c768d0..7c6d33d36 100644
--- a/src/client/views/CollectionLinearView.tsx
+++ b/src/client/views/CollectionLinearView.tsx
@@ -2,19 +2,17 @@ import { action, IReactionDisposer, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { Doc, HeightSym, WidthSym } from '../../new_fields/Doc';
-import { ObjectField } from '../../new_fields/ObjectField';
import { makeInterface } from '../../new_fields/Schema';
-import { ScriptField } from '../../new_fields/ScriptField';
import { BoolCast, NumCast, StrCast } from '../../new_fields/Types';
import { emptyFunction, returnEmptyString, returnOne, returnTrue, Utils } from '../../Utils';
-import { Docs } from '../documents/Documents';
import { DragManager } from '../util/DragManager';
import { Transform } from '../util/Transform';
import "./CollectionLinearView.scss";
-import { CollectionViewType } from './collections/CollectionBaseView';
+import { CollectionViewType } from './collections/CollectionView';
import { CollectionSubView } from './collections/CollectionSubView';
-import { documentSchema, DocumentView } from './nodes/DocumentView';
-import { translate } from 'googleapis/build/src/apis/translate';
+import { DocumentView } from './nodes/DocumentView';
+import { documentSchema } from '../../new_fields/documentSchemas';
+import { Id } from '../../new_fields/FieldSymbols';
type LinearDocument = makeInterface<[typeof documentSchema,]>;
@@ -25,6 +23,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
@observable public addMenuToggle = React.createRef<HTMLInputElement>();
private _dropDisposer?: DragManager.DragDropDisposer;
private _heightDisposer?: IReactionDisposer;
+ private _spacing = 20;
componentWillUnmount() {
this._dropDisposer && this._dropDisposer();
@@ -45,23 +44,6 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
}
}
- drop = action((e: Event, de: DragManager.DropEvent) => {
- (de.data as DragManager.DocumentDragData).draggedDocuments.map((doc, i) => {
- let dbox = doc;
- if (!doc.onDragStart && !doc.onClick && this.props.Document.convertToButtons && doc.viewType !== CollectionViewType.Linear) {
- dbox = Docs.Create.FontIconDocument({ nativeWidth: 100, nativeHeight: 100, width: 100, height: 100, backgroundColor: StrCast(doc.backgroundColor), title: "Custom", icon: "bolt" });
- dbox.dragFactory = doc;
- dbox.removeDropProperties = doc.removeDropProperties instanceof ObjectField ? ObjectField.MakeCopy(doc.removeDropProperties) : undefined;
- dbox.onDragStart = ScriptField.MakeFunction('getCopy(this.dragFactory, true)');
- } else if (doc.viewType === CollectionViewType.Linear) {
- dbox.ignoreClick = true;
- }
- (de.data as DragManager.DocumentDragData).droppedDocuments[i] = dbox;
- });
- e.stopPropagation();
- return super.drop(e, de);
- });
-
public isCurrent(doc: Doc) { return !doc.isMinimized && (Math.abs(NumCast(doc.displayTimecode, -1) - NumCast(this.Document.currentTimecode, -1)) < 1.5 || NumCast(doc.displayTimecode, -1) === -1); }
dimension = () => NumCast(this.props.Document.height); // 2 * the padding
@@ -69,8 +51,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
if (!ele.current) return Transform.Identity();
let { scale, translateX, translateY } = Utils.GetScreenTransform(ele.current);
return new Transform(-translateX, -translateY, 1 / scale);
- };
- _spacing = 20;
+ }
render() {
let guid = Utils.GenerateGuid();
return <div className="collectionLinearView-outer">
@@ -87,7 +68,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
let scalingContent = nested ? 1 : this.dimension() / (this._spacing + nativeWidth);
let scalingBox = nested ? 1 : this.dimension() / nativeWidth;
let deltaSize = nativeWidth * scalingBox - nativeWidth * scalingContent;
- return <div className={`collectionLinearView-docBtn` + (pair.layout.onClick || pair.layout.onDragStart ? "-scalable" : "")} key={StrCast(pair.layout.title)} ref={dref}
+ return <div className={`collectionLinearView-docBtn` + (pair.layout.onClick || pair.layout.onDragStart ? "-scalable" : "")} key={pair.layout[Id]} ref={dref}
style={{
width: nested ? pair.layout[WidthSym]() : this.dimension(),
height: nested && pair.layout.isExpanded ? pair.layout[HeightSym]() : this.dimension(),
@@ -118,7 +99,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
zoomToScale={emptyFunction}
getScale={returnOne}>
</DocumentView>
- </div>
+ </div>;
})}
{/* <li key="undoTest"><button className="add-button round-button" title="Click if undo isn't working" onClick={() => UndoManager.TraceOpenBatches()}><FontAwesomeIcon icon="exclamation" size="sm" /></button></li> */}