aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Utils.ts4
-rw-r--r--src/client/views/CollectionMulticolumnView.scss7
-rw-r--r--src/client/views/CollectionMulticolumnView.tsx39
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
-rw-r--r--src/new_fields/Doc.ts6
5 files changed, 48 insertions, 10 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 562d9d83f..f50655f6c 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -329,7 +329,7 @@ export function timenow() {
}
export function aggregateBounds(boundsList: { x: number, y: number, width: number, height: number }[], xpad: number, ypad: number) {
- let bounds = boundsList.reduce((bounds, b) => {
+ const bounds = boundsList.reduce((bounds, b) => {
const [sptX, sptY] = [b.x, b.y];
const [bptX, bptY] = [sptX + b.width, sptY + b.height];
return {
@@ -337,7 +337,7 @@ export function aggregateBounds(boundsList: { x: number, y: number, width: numbe
r: Math.max(bptX, bounds.r), b: Math.max(bptY, bounds.b)
};
}, { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: -Number.MAX_VALUE, b: -Number.MAX_VALUE });
- return { x: bounds.x !== Number.MAX_VALUE ? bounds.x - xpad : bounds.x, y: bounds.y !== Number.MAX_VALUE ? bounds.y - ypad : bounds.y, r: bounds.r !== -Number.MAX_VALUE ? bounds.r + 2 * xpad : bounds.r, b: bounds.b !== -Number.MAX_VALUE ? bounds.b + 2 * ypad : bounds.b }
+ return { x: bounds.x !== Number.MAX_VALUE ? bounds.x - xpad : bounds.x, y: bounds.y !== Number.MAX_VALUE ? bounds.y - ypad : bounds.y, r: bounds.r !== -Number.MAX_VALUE ? bounds.r + 2 * xpad : bounds.r, b: bounds.b !== -Number.MAX_VALUE ? bounds.b + 2 * ypad : bounds.b };
}
export function intersectRect(r1: { left: number, top: number, width: number, height: number },
r2: { left: number, top: number, width: number, height: number }) {
diff --git a/src/client/views/CollectionMulticolumnView.scss b/src/client/views/CollectionMulticolumnView.scss
new file mode 100644
index 000000000..84e80da4a
--- /dev/null
+++ b/src/client/views/CollectionMulticolumnView.scss
@@ -0,0 +1,7 @@
+.collectionMulticolumnView_outer,
+.collectionMulticolumnView_contents {
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+}
+
diff --git a/src/client/views/CollectionMulticolumnView.tsx b/src/client/views/CollectionMulticolumnView.tsx
index ea1f0c189..0aa615ffc 100644
--- a/src/client/views/CollectionMulticolumnView.tsx
+++ b/src/client/views/CollectionMulticolumnView.tsx
@@ -1,12 +1,16 @@
import { observer } from 'mobx-react';
import { makeInterface, listSpec } from '../../new_fields/Schema';
import { documentSchema } from '../../new_fields/documentSchemas';
-import { CollectionSubView, SubCollectionViewProps } from './collections/CollectionSubView';
+import { CollectionSubView } from './collections/CollectionSubView';
import { DragManager } from '../util/DragManager';
import * as React from "react";
import { Doc, DocListCast } from '../../new_fields/Doc';
-import { NumCast, Cast } from '../../new_fields/Types';
+import { NumCast, Cast, StrCast } from '../../new_fields/Types';
import { List } from '../../new_fields/List';
+import { ContentFittingDocumentView } from './nodes/ContentFittingDocumentView';
+import { Utils } from '../../Utils';
+import { Transform } from '../util/Transform';
+import "./collectionMulticolumnView.scss";
type MulticolumnDocument = makeInterface<[typeof documentSchema]>;
const MulticolumnDocument = makeInterface(documentSchema);
@@ -29,14 +33,41 @@ export default class CollectionMulticolumnView extends CollectionSubView(Multico
}
}
+ getTransform = (ele: React.RefObject<HTMLDivElement>) => () => {
+ if (!ele.current) return Transform.Identity();
+ const { scale, translateX, translateY } = Utils.GetScreenTransform(ele.current);
+ return new Transform(-translateX, -translateY, 1 / scale);
+ }
+
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); }
render() {
+ const { PanelWidth } = this.props;
return (
<div className={"collectionMulticolumnView_outer"}>
<div className={"collectionMulticolumnView_contents"}>
- {this.configuration.map(config => ).filter(pair => this.isCurrent(pair.layout)).map(({ layout, data }) => {
-
+ {this.configuration.map(config => {
+ const { target } = config;
+ if (target instanceof Doc) {
+ let computedWidth: number = 0;
+ const widthSpecifier = Cast(config.columnWidth, "number");
+ let matches: RegExpExecArray | null;
+ if (widthSpecifier !== undefined) {
+ computedWidth = widthSpecifier;
+ } else if ((matches = /([\d.]+)\%/.exec(StrCast(config.columnWidth))) !== null) {
+ computedWidth = Number(matches[1]) / 100 * PanelWidth();
+ }
+ return (!computedWidth ? (null) :
+ <ContentFittingDocumentView
+ {...this.props}
+ Document={target}
+ DataDocument={undefined}
+ PanelWidth={() => computedWidth}
+ getTransform={this.props.ScreenToLocalTransform}
+ />
+ );
+ }
+ return (null);
})}
</div>
</div>
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index e45c19533..8f3fa4530 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -196,7 +196,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY);
} else if (this.props.Document.isButton === "Selector") { // this should be moved to an OnClick script
FormattedTextBoxComment.Hide();
- this.Document.links?.[0] instanceof Doc && (Doc.UserDoc().SelectedDocs = new List([Doc.LinkOtherAnchor(this.Document.links[0]!, this.props.Document)]));
+ this.Document.links?.[0] instanceof Doc && (Doc.UserDoc().SelectedDocs = new List([Doc.LinkOtherAnchor(this.Document.links[0], this.props.Document)]));
} else if (this.Document.isButton) {
SelectionManager.SelectDoc(this, e.ctrlKey); // don't think this should happen if a button action is actually triggered.
this.buttonClick(e.altKey, e.ctrlKey);
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index d4634ba4b..26acfa9c3 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -405,7 +405,7 @@ export namespace Doc {
}
export function MakeAlias(doc: Doc) {
const alias = !GetT(doc, "isPrototype", "boolean", true) ? Doc.MakeCopy(doc) : Doc.MakeDelegate(doc);
- let layout = Doc.Layout(alias);
+ const layout = Doc.Layout(alias);
if (layout instanceof Doc && layout !== alias) {
Doc.SetLayout(alias, Doc.MakeAlias(layout));
}
@@ -755,7 +755,7 @@ export namespace Doc {
const modifiers = docFilters[i + 2];
const scriptText = `${modifiers === "x" ? "!" : ""}matchFieldValue(doc, "${key}", "${value}")`;
docFilterText = docFilterText ? docFilterText + " || " + scriptText : scriptText;
- };
+ }
return docFilterText ? "(" + docFilterText + ")" : "";
}
}
@@ -781,7 +781,7 @@ Scripting.addGlobal(function matchFieldValue(doc: Doc, key: string, value: any)
if (StrCast(fieldVal, null) !== undefined) return StrCast(fieldVal) === value;
if (NumCast(fieldVal, null) !== undefined) return NumCast(fieldVal) === value;
if (Cast(fieldVal, listSpec("string"), []).length) {
- let vals = Cast(fieldVal, listSpec("string"), []);
+ const vals = Cast(fieldVal, listSpec("string"), []);
return vals.some(v => v === value);
}
return false;