aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/ContextMenu.scss1
-rw-r--r--src/client/views/MainView.tsx6
-rw-r--r--src/client/views/animationtimeline/Keyframe.scss94
-rw-r--r--src/client/views/animationtimeline/Keyframe.tsx552
-rw-r--r--src/client/views/animationtimeline/Timeline.scss122
-rw-r--r--src/client/views/animationtimeline/Timeline.tsx390
-rw-r--r--src/client/views/animationtimeline/TimelineMenu.scss94
-rw-r--r--src/client/views/animationtimeline/TimelineMenu.tsx86
-rw-r--r--src/client/views/animationtimeline/Track.scss15
-rw-r--r--src/client/views/animationtimeline/Track.tsx285
-rw-r--r--src/client/views/collections/CollectionSubView.tsx16
-rw-r--r--src/client/views/collections/CollectionViewChromes.scss12
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx8
-rw-r--r--src/client/views/graph/Graph.tsx32
-rw-r--r--src/client/views/graph/GraphManager.ts45
-rw-r--r--src/client/views/graph/GraphMenu.tsx0
-rw-r--r--src/client/views/nodes/DocumentView.tsx3
-rw-r--r--src/client/views/nodes/FormattedTextBox.tsx2
-rw-r--r--src/new_fields/Doc.ts3
-rw-r--r--src/new_fields/RichTextField.ts1
21 files changed, 1762 insertions, 9 deletions
diff --git a/src/client/views/ContextMenu.scss b/src/client/views/ContextMenu.scss
index e2c0de8af..6c619fbe1 100644
--- a/src/client/views/ContextMenu.scss
+++ b/src/client/views/ContextMenu.scss
@@ -7,6 +7,7 @@
box-shadow: $intermediate-color 0.2vw 0.2vw 0.4vw;
flex-direction: column;
background: whitesmoke;
+ padding-top: 10px;
padding-bottom: 10px;
border-radius: 15px;
border: solid #BBBBBBBB 1px;
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 031478477..8f68f7c0d 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -39,6 +39,7 @@ import { FilterBox } from './search/FilterBox';
import { CollectionTreeView } from './collections/CollectionTreeView';
import { ClientUtils } from '../util/ClientUtils';
import { SchemaHeaderField, RandomPastel } from '../../new_fields/SchemaHeaderField';
+import { TimelineMenu } from './animationtimeline/TimelineMenu';
import { DictationManager } from '../util/DictationManager';
@observer
@@ -205,6 +206,9 @@ export class MainView extends React.Component {
if (targets && targets.length && targets[0].className.toString().indexOf("contextMenu") === -1) {
ContextMenu.Instance.closeMenu();
}
+ // if (targets && targets.length && targets[0].className.toString().indexOf("timeline-menu-container") === -1) {
+ // TimelineMenu.Instance.closeMenu();
+ // }
});
globalPointerUp = () => this.isPointerDown = false;
@@ -484,6 +488,7 @@ export class MainView extends React.Component {
<ul id="add-options-list">
<li key="search"><button className="add-button round-button" title="Search" onClick={this.toggleSearch}><FontAwesomeIcon icon="search" size="sm" /></button></li>
<li key="presentation"><button className="add-button round-button" title="Open Presentation View" onClick={() => PresentationView.Instance.toggle(undefined)}><FontAwesomeIcon icon="table" size="sm" /></button></li>
+ <li key="timeline"><button className="add-button round-button" title="Add Timeline"><FontAwesomeIcon icon="times" size="sm"/></button></li>
<li key="undo"><button className="add-button round-button" title="Undo" style={{ opacity: UndoManager.CanUndo() ? 1 : 0.5, transition: "0.4s ease all" }} onClick={() => UndoManager.Undo()}><FontAwesomeIcon icon="undo-alt" size="sm" /></button></li>
<li key="redo"><button className="add-button round-button" title="Redo" style={{ opacity: UndoManager.CanRedo() ? 1 : 0.5, transition: "0.4s ease all" }} onClick={() => UndoManager.Redo()}><FontAwesomeIcon icon="redo-alt" size="sm" /></button></li>
{btns.map(btn =>
@@ -577,6 +582,7 @@ export class MainView extends React.Component {
{this.nodesMenu()}
{this.miscButtons}
<PDFMenu />
+ <TimelineMenu/>
<MainOverlayTextBox firstinstance={true} />
<OverlayView />
</div >
diff --git a/src/client/views/animationtimeline/Keyframe.scss b/src/client/views/animationtimeline/Keyframe.scss
new file mode 100644
index 000000000..b1e8b0b65
--- /dev/null
+++ b/src/client/views/animationtimeline/Keyframe.scss
@@ -0,0 +1,94 @@
+@import "./../globalCssVariables.scss";
+
+.bar {
+ height: 100%;
+ width: 5px;
+ position: absolute;
+
+ // pointer-events: none;
+ .menubox {
+ width: 200px;
+ height:200px;
+ top: 50%;
+ position: relative;
+ background-color: $light-color;
+ .menutable{
+ tr:nth-child(odd){
+ background-color:$light-color-secondary;
+ }
+ }
+ }
+
+ .leftResize{
+ left:-12.5px;
+ height:25px;
+ width:25px;
+ border-radius: 50%;
+ background-color: white;
+ border:3px solid black;
+ top: calc(50% - 12.5px);
+ z-index: 1000;
+ position:absolute;
+ }
+ .rightResize{
+ right:-12.5px;
+ height:25px;
+ width:25px;
+ border-radius: 50%;
+ top:calc(50% - 12.5px);
+ background-color:white;
+ border:3px solid black;
+ z-index: 1000;
+ position:absolute;
+ }
+ .fadeLeft{
+ left:0px;
+ height:100%;
+ position:absolute;
+ pointer-events: none;
+ background: linear-gradient(to left, #4d9900 10%, $light-color);
+ }
+
+ .fadeRight{
+ right:0px;
+ height:100%;
+ position:absolute;
+ pointer-events: none;
+ background: linear-gradient(to right, #4d9900 10%, $light-color);
+ }
+ .divider{
+ height:100%;
+ width: 1px;
+ position: absolute;
+ background-color:black;
+ cursor: col-resize;
+ pointer-events:none;
+ }
+ .keyframe{
+ height:100%;
+ position:absolute;
+ }
+ .keyframeCircle{
+ left:-15px;
+ height:30px;
+ width:30px;
+ border-radius: 50%;
+ top:calc(50% - 15px);
+ background-color:white;
+ border:3px solid green;
+ z-index: 1000;
+ position:absolute;
+ }
+
+ .fadeIn-container, .fadeOut-container, .body-container{
+ position:absolute;
+ height:100%;
+ background-color: rgba(0, 0, 0, 0.5);
+ opacity: 0;
+ }
+
+
+}
+
+
+
diff --git a/src/client/views/animationtimeline/Keyframe.tsx b/src/client/views/animationtimeline/Keyframe.tsx
new file mode 100644
index 000000000..dbc26e3d4
--- /dev/null
+++ b/src/client/views/animationtimeline/Keyframe.tsx
@@ -0,0 +1,552 @@
+import * as React from "react";
+import "./Keyframe.scss";
+import "./Timeline.scss";
+import "../globalCssVariables.scss";
+import { observer, Observer } from "mobx-react";
+import { observable, reaction, action, IReactionDisposer, observe, IObservableArray, computed, toJS, isComputedProp, runInAction } from "mobx";
+import { Doc, DocListCast, DocListCastAsync } from "../../../new_fields/Doc";
+import { Cast, FieldValue, StrCast, NumCast } from "../../../new_fields/Types";
+import { List } from "../../../new_fields/List";
+import { createSchema, defaultSpec, makeInterface, listSpec } from "../../../new_fields/Schema";
+import { FlyoutProps } from "./Timeline";
+import { Transform } from "../../util/Transform";
+import { InkField, StrokeData } from "../../../new_fields/InkField";
+import { TimelineMenu } from "./TimelineMenu";
+import { Docs } from "../../documents/Documents";
+import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
+import { CollectionDockingView } from "../collections/CollectionDockingView";
+
+export namespace KeyframeFunc {
+ export enum KeyframeType {
+ fade = "fade",
+ default = "default",
+ }
+ export enum Direction {
+ left = "left",
+ right = "right"
+ }
+ export const findAdjacentRegion = (dir: KeyframeFunc.Direction, currentRegion: Doc, regions: List<Doc>): (RegionData | undefined) => {
+ let leftMost: (RegionData | undefined) = undefined;
+ let rightMost: (RegionData | undefined) = undefined;
+ DocListCast(regions).forEach(region => {
+ let neighbor = RegionData(region as Doc);
+ if (currentRegion.position! > neighbor.position) {
+ if (!leftMost || neighbor.position > leftMost.position) {
+ leftMost = neighbor;
+ }
+ } else if (currentRegion.position! < neighbor.position) {
+ if (!rightMost || neighbor.position < rightMost.position) {
+ rightMost = neighbor;
+ }
+ }
+ });
+ if (dir === Direction.left) {
+ return leftMost;
+ } else if (dir === Direction.right) {
+ return rightMost;
+ }
+ };
+
+ export const calcMinLeft = async (region: Doc, currentBarX: number, ref?: Doc) => { //returns the time of the closet keyframe to the left
+ let leftKf: (Doc | undefined) = undefined;
+ let time: number = 0;
+ let keyframes = await DocListCastAsync(region.keyframes!);
+ keyframes!.forEach((kf) => {
+ let compTime = currentBarX;
+ if (ref) {
+ compTime = NumCast(ref.time);
+ }
+ if (NumCast(kf.time) < compTime && NumCast(kf.time) >= time) {
+ leftKf = kf;
+ time = NumCast(kf.time);
+ }
+ });
+ return leftKf;
+ };
+
+
+ export const calcMinRight = async (region: Doc, currentBarX: number, ref?: Doc) => { //returns the time of the closest keyframe to the right
+ let rightKf: (Doc | undefined) = undefined;
+ let time: number = Infinity;
+ let keyframes = await DocListCastAsync(region.keyframes!);
+ keyframes!.forEach((kf) => {
+ let compTime = currentBarX;
+ if (ref) {
+ compTime = NumCast(ref.time);
+ }
+ if (NumCast(kf.time) > compTime && NumCast(kf.time) <= NumCast(time)) {
+ rightKf = kf;
+ time = NumCast(kf.time);
+ }
+ });
+ return rightKf;
+ };
+
+ export const defaultKeyframe = () => {
+ let regiondata = new Doc(); //creating regiondata
+ regiondata.duration = 200;
+ regiondata.position = 0;
+ regiondata.fadeIn = 20;
+ regiondata.fadeOut = 20;
+ regiondata.functions = new List<Doc>();
+ return regiondata;
+ };
+}
+
+export const RegionDataSchema = createSchema({
+ position: defaultSpec("number", 0),
+ duration: defaultSpec("number", 0),
+ keyframes: listSpec(Doc),
+ fadeIn: defaultSpec("number", 0),
+ fadeOut: defaultSpec("number", 0),
+ functions: listSpec(Doc)
+});
+export type RegionData = makeInterface<[typeof RegionDataSchema]>;
+export const RegionData = makeInterface(RegionDataSchema);
+
+interface IProps {
+ node: Doc;
+ RegionData: Doc;
+ collection: Doc;
+ changeCurrentBarX: (x: number) => void;
+ setFlyout: (props: FlyoutProps) => any;
+ transform: Transform;
+}
+
+@observer
+export class Keyframe extends React.Component<IProps> {
+
+ @observable private _bar = React.createRef<HTMLDivElement>();
+ @observable private _gain = 20; //default
+
+ @computed
+ private get regiondata() {
+ let index = this.regions.indexOf(this.props.RegionData);
+ return RegionData(this.regions[index] as Doc);
+ }
+
+ @computed
+ private get regions() {
+ return Cast(this.props.node.regions, listSpec(Doc)) as List<Doc>;
+ }
+
+ @computed
+ private get firstKeyframe() {
+ let first: (Doc | undefined) = undefined;
+ DocListCast(this.regiondata.keyframes!).forEach(kf => {
+ if (kf.type !== KeyframeFunc.KeyframeType.fade) {
+ if (!first || first && NumCast(kf.time) < NumCast(first.time)) {
+ first = kf;
+ }
+ }
+ });
+ return first;
+ }
+
+ @computed
+ private get lastKeyframe() {
+ let last: (Doc | undefined) = undefined;
+ DocListCast(this.regiondata.keyframes!).forEach(kf => {
+ if (kf.type !== KeyframeFunc.KeyframeType.fade) {
+ if (!last || last && NumCast(kf.time) > NumCast(last.time)) {
+ last = kf;
+ }
+ }
+ });
+ return last;
+ }
+ @computed
+ private get keyframes(){
+ return DocListCast(this.regiondata.keyframes);
+ }
+
+ @computed
+ private get inks() {
+ if (this.props.collection.data_ext) {
+ let data_ext = Cast(this.props.collection.data_ext, Doc) as Doc;
+ let ink = Cast(data_ext.ink, InkField) as InkField;
+ if (ink) {
+ return ink.inkData;
+ }
+ }
+ }
+
+ async componentWillMount() {
+ if (!this.regiondata.keyframes) {
+ this.regiondata.keyframes = new List<Doc>();
+ }
+ let fadeIn = await this.makeKeyData(this.regiondata.position + this.regiondata.fadeIn, KeyframeFunc.KeyframeType.fade)!;
+ let fadeOut = await this.makeKeyData(this.regiondata.position + this.regiondata.duration - this.regiondata.fadeOut, KeyframeFunc.KeyframeType.fade)!;
+ let start = await this.makeKeyData(this.regiondata.position, KeyframeFunc.KeyframeType.fade)!;
+ let finish = await this.makeKeyData(this.regiondata.position + this.regiondata.duration, KeyframeFunc.KeyframeType.fade)!;
+ (fadeIn.key! as Doc).opacity = 1;
+ (fadeOut.key! as Doc).opacity = 1;
+ (start.key! as Doc).opacity = 0.1;
+ (finish.key! as Doc).opacity = 0.1;
+
+ observe(this.regiondata, change => {
+ if (change.type === "update") {
+ fadeIn.time = this.regiondata.position + this.regiondata.fadeIn;
+ fadeOut.time = this.regiondata.position + this.regiondata.duration - this.regiondata.fadeOut;
+ start.time = this.regiondata.position;
+ finish.time = this.regiondata.position + this.regiondata.duration;
+ this.regiondata.keyframes![this.regiondata.keyframes!.indexOf(fadeIn)] = fadeIn;
+ this.regiondata.keyframes![this.regiondata.keyframes!.indexOf(fadeOut)] = fadeOut;
+ this.regiondata.keyframes![this.regiondata.keyframes!.indexOf(start)] = start;
+ this.regiondata.keyframes![this.regiondata.keyframes!.indexOf(finish)] = finish;
+ this.forceUpdate();
+ }
+ });
+ }
+
+ @action
+ makeKeyData = async (kfpos: number, type: KeyframeFunc.KeyframeType = KeyframeFunc.KeyframeType.default) => { //Kfpos is mouse offsetX, representing time
+ let doclist = (await DocListCastAsync(this.regiondata.keyframes))!;
+ let existingkf: (Doc | undefined) = undefined;
+ doclist.forEach(TK => {
+ TK = TK as Doc;
+ if (TK.time === kfpos) existingkf = TK;
+ });
+ if (existingkf) return existingkf;
+ let TK: Doc = new Doc();
+ TK.time = kfpos;
+ TK.key = Doc.MakeCopy(this.props.node, true);
+ TK.type = type;
+ this.regiondata.keyframes!.push(TK);
+
+ let interpolationFunctions = new Doc();
+ interpolationFunctions.interpolationX = new List<number>([0, 1]);
+ interpolationFunctions.interpolationY = new List<number>([0,100]);
+ interpolationFunctions.pathX = new List<number>();
+ interpolationFunctions.pathY = new List<number>();
+
+ this.regiondata.functions!.push(interpolationFunctions);
+ let found:boolean = false;
+ this.regiondata.keyframes!.forEach(compkf => {
+ compkf = compkf as Doc;
+ if (kfpos < NumCast(compkf.time) && !found) {
+ runInAction(() => {
+ this.regiondata.keyframes!.splice(doclist.indexOf(compkf as Doc), 0, TK);
+ this.regiondata.keyframes!.pop();
+ found = true;
+ });
+ return;
+ }
+ });
+ return TK;
+ }
+
+ @action
+ onBarPointerDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onBarPointerMove);
+ document.addEventListener("pointerup", (e: PointerEvent) => {
+ document.removeEventListener("pointermove", this.onBarPointerMove);
+ });
+ }
+
+
+ @action
+ onBarPointerMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let left = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.left, this.regiondata, this.regions)!;
+ let right = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.right, this.regiondata, this.regions!);
+ let prevX = this.regiondata.position;
+ let futureX = this.regiondata.position + e.movementX;
+ if (futureX <= 0) {
+ this.regiondata.position = 0;
+ } else if ((left && left.position + left.duration >= futureX)) {
+ this.regiondata.position = left.position + left.duration;
+ } else if ((right && right.position <= futureX + this.regiondata.duration)) {
+ this.regiondata.position = right.position - this.regiondata.duration;
+ } else {
+ this.regiondata.position = futureX;
+ }
+ for (let i = 0; i < this.regiondata.keyframes!.length; i++) {
+ if ((this.regiondata.keyframes![i] as Doc).type !== KeyframeFunc.KeyframeType.fade) {
+ let movement = this.regiondata.position - prevX;
+ (this.regiondata.keyframes![i] as Doc).time = NumCast((this.regiondata.keyframes![i] as Doc).time) + movement;
+ }
+ }
+ this.forceUpdate();
+ }
+
+ @action
+ onResizeLeft = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onDragResizeLeft);
+ document.addEventListener("pointerup", () => {
+ document.removeEventListener("pointermove", this.onDragResizeLeft);
+ });
+ }
+
+ @action
+ onResizeRight = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onDragResizeRight);
+ document.addEventListener("pointerup", () => {
+ document.removeEventListener("pointermove", this.onDragResizeRight);
+ });
+ }
+
+ @action
+ onDragResizeLeft = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let bar = this._bar.current!;
+ let offset = Math.round((e.clientX - bar.getBoundingClientRect().left) * this.props.transform.Scale);
+ let leftRegion = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.left, this.regiondata, this.regions);
+ let firstkf: (Doc | undefined) = this.firstKeyframe;
+ if (firstkf && this.regiondata.position + this.regiondata.fadeIn + offset >= NumCast(firstkf!.time)) {
+ let dif = NumCast(firstkf!.time) - (this.regiondata.position + this.regiondata.fadeIn);
+ this.regiondata.position = NumCast(firstkf!.time) - this.regiondata.fadeIn;
+ this.regiondata.duration -= dif;
+ } else if (this.regiondata.duration - offset < this.regiondata.fadeIn + this.regiondata.fadeOut) { // no keyframes, just fades
+ this.regiondata.position -= (this.regiondata.fadeIn + this.regiondata.fadeOut - this.regiondata.duration);
+ this.regiondata.duration = this.regiondata.fadeIn + this.regiondata.fadeOut;
+ } else if (leftRegion && this.regiondata.position + offset <= leftRegion.position + leftRegion.duration) {
+ let dif = this.regiondata.position - (leftRegion.position + leftRegion.duration);
+ this.regiondata.position = leftRegion.position + leftRegion.duration;
+ this.regiondata.duration += dif;
+ } else {
+ this.regiondata.duration -= offset;
+ this.regiondata.position += offset;
+ }
+ }
+
+
+ @action
+ onDragResizeRight = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let bar = this._bar.current!;
+ let offset = Math.round((e.clientX - bar.getBoundingClientRect().right) * this.props.transform.Scale);
+ let rightRegion = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.right, this.regiondata, this.regions);
+ if (this.lastKeyframe! && this.regiondata.position + this.regiondata.duration - this.regiondata.fadeOut + offset <= NumCast((this.lastKeyframe! as Doc).time)) {
+ let dif = this.regiondata.position + this.regiondata.duration - this.regiondata.fadeOut - NumCast((this.lastKeyframe! as Doc).time);
+ this.regiondata.duration -= dif;
+ } else if (this.regiondata.duration + offset < this.regiondata.fadeIn + this.regiondata.fadeOut) { // nokeyframes, just fades
+ this.regiondata.duration = this.regiondata.fadeIn + this.regiondata.fadeOut;
+ } else if (rightRegion && this.regiondata.position + this.regiondata.duration + offset >= rightRegion.position) {
+ let dif = rightRegion.position - (this.regiondata.position + this.regiondata.duration);
+ this.regiondata.duration += dif;
+ } else {
+ this.regiondata.duration += offset;
+ }
+ }
+
+ createDivider = (type?: KeyframeFunc.Direction): JSX.Element => {
+ if (type === "left") {
+ return <div className="divider" style={{ right: "0px" }}></div>;
+ } else if (type === "right") {
+ return <div className="divider" style={{ left: "0px" }}> </div>;
+ }
+ return <div className="divider"></div>;
+ }
+
+ @action
+ createKeyframe = async (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let bar = this._bar.current!;
+ let offset = Math.round((e.clientX - bar.getBoundingClientRect().left) * this.props.transform.Scale);
+ if (offset > this.regiondata.fadeIn && offset < this.regiondata.duration - this.regiondata.fadeOut) { //make sure keyframe is not created inbetween fades and ends
+ let position = NumCast(this.regiondata.position);
+ await this.makeKeyData(Math.round(position + offset));
+ console.log(this.regiondata.keyframes!.length);
+ this.props.changeCurrentBarX(NumCast(Math.round(position + offset))); //first move the keyframe to the correct location and make a copy so the correct file gets coppied
+ }
+ }
+
+
+ @action
+ moveKeyframe = async (e: React.MouseEvent, kf: Doc) => {
+ e.preventDefault();
+ e.stopPropagation();
+ this.props.changeCurrentBarX(NumCast(kf.time!));
+ }
+
+
+ @action
+ onKeyframeOver = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ this.props.node.backgroundColor = "#000000";
+
+ }
+ @action
+ private createKeyframeJSX = (kf: Doc, type = KeyframeFunc.KeyframeType.default) => {
+ if (type === KeyframeFunc.KeyframeType.default) {
+ return (
+ <div className="keyframe" style={{ left: `${NumCast(kf.time) - this.regiondata.position}px` }}>
+ {this.createDivider()}
+ <div className="keyframeCircle" onPointerDown={(e) => { this.moveKeyframe(e, kf as Doc); }} onContextMenu={(e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let items = [
+ TimelineMenu.Instance.addItem("button", "Show Data", () => {
+ runInAction(() => {let kvp = Docs.Create.KVPDocument(Cast(kf.key, Doc) as Doc, { width: 300, height: 300 });
+ CollectionDockingView.Instance.AddRightSplit(kvp, (kf.key as Doc).data as Doc); });
+ }),
+ TimelineMenu.Instance.addItem("button", "Delete", () => {}),
+ TimelineMenu.Instance.addItem("input", "Move", (val) => {kf.time = parseInt(val, 10);})
+ ];
+ TimelineMenu.Instance.addMenu("Keyframe", items);
+ TimelineMenu.Instance.openMenu(e.clientX, e.clientY);
+ }}></div>
+ </div>);
+ }
+ return (
+ <div className="keyframe" style={{ left: `${NumCast(kf.time) - this.regiondata.position}px` }}>
+ {this.createDivider()}
+ </div>
+ );
+ }
+
+ onContainerOver = (e: React.PointerEvent, ref: React.RefObject<HTMLDivElement>) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let div = ref.current!;
+ div.style.opacity = "1";
+ }
+
+ onContainerOut = (e: React.PointerEvent, ref: React.RefObject<HTMLDivElement>) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let div = ref.current!;
+ div.style.opacity = "0";
+ }
+
+
+ private _reac: (undefined | IReactionDisposer) = undefined;
+ private _plotList: ([string, StrokeData] | undefined) = undefined;
+ private _interpolationKeyframe: (Doc | undefined) = undefined;
+ private _type: string = "";
+
+ @action
+ onContainerDown = (kf: Doc, type: string) => {
+ let listenerCreated = false;
+ this._type = type;
+ this.props.collection.backgroundColor = "rgb(0,0,0)";
+ this._reac = reaction(() => {
+ return this.inks;
+ }, data => {
+ if (!listenerCreated) {
+ this._plotList = Array.from(data!)[data!.size - 1]!;
+ this._interpolationKeyframe = kf;
+ document.addEventListener("pointerup", this.onReactionListen);
+ listenerCreated = true;
+ }
+ });
+
+
+ }
+
+
+
+
+ @action
+ onReactionListen = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let message = prompt("GRAPHING MODE: Enter gain");
+ if (message) {
+ let messageContent = parseInt(message, 10);
+ if (messageContent === NaN) {
+ this._gain = Infinity;
+ } else {
+ this._gain = messageContent;
+ }
+
+ }
+ if (this._reac && this._plotList && this._interpolationKeyframe) {
+ this.props.collection.backgroundColor = "#FFF";
+ this._reac();
+ let xPlots = new List<number>();
+ let yPlots = new List<number>();
+ let maxY = 0;
+ let minY = Infinity;
+ let pathData = this._plotList![1].pathData;
+ for (let i = 0; i < pathData.length - 1;) {
+ let val = pathData[i];
+ if (val.y > maxY) {
+ maxY = val.y;
+ }
+ if (val.y < minY) {
+ minY = val.y;
+ }
+ xPlots.push(val.x);
+ yPlots.push(val.y);
+ let increment = Math.floor(pathData.length / this._gain);
+ if (pathData.length > this._gain) {
+ if (i + increment < pathData.length) {
+ i = i + increment;
+ } else {
+ i = pathData.length - 1;
+ }
+ } else {
+ i++;
+ }
+ }
+ let index = this.keyframes.indexOf(this._interpolationKeyframe!);
+ if (this._type === "interpolate"){
+ (Cast(this.regiondata.functions![index], Doc) as Doc).interpolationX = xPlots;
+ (Cast(this.regiondata.functions![index], Doc) as Doc).interpolationY = yPlots;
+ } else if (this._type === "path") {
+ (Cast(this.regiondata.functions![index], Doc) as Doc).pathX = xPlots;
+ (Cast(this.regiondata.functions![index], Doc) as Doc).pathY = yPlots;
+ }
+
+ this._reac = undefined;
+ this._interpolationKeyframe = undefined;
+ this._plotList = undefined;
+ this._type = "";
+ document.removeEventListener("pointerup", this.onReactionListen);
+ }
+ }
+ render() {
+ return (
+ <div>
+ <div className="bar" ref={this._bar} style={{ transform: `translate(${this.regiondata.position}px)`, width: `${this.regiondata.duration}px`, background: `linear-gradient(90deg, rgba(77, 153, 0, 0) 0%, rgba(77, 153, 0, 1) ${this.regiondata.fadeIn / this.regiondata.duration * 100}%, rgba(77, 153, 0, 1) ${(this.regiondata.duration - this.regiondata.fadeOut) / this.regiondata.duration * 100}%, rgba(77, 153, 0, 0) 100% )` }}
+ onPointerDown={this.onBarPointerDown}
+ onDoubleClick={this.createKeyframe}>
+ <div className="leftResize" onPointerDown={this.onResizeLeft} ></div>
+ <div className="rightResize" onPointerDown={this.onResizeRight}></div>
+ {this.regiondata.keyframes!.map(kf => {
+ return this.createKeyframeJSX(kf as Doc, (kf! as Doc).type as KeyframeFunc.KeyframeType);
+ })}
+ {this.keyframes.map( kf => {
+ if(this.keyframes.indexOf(kf ) !== this.keyframes.length - 1) {
+ let left = this.keyframes[this.keyframes.indexOf(kf) + 1];
+ let bodyRef = React.createRef<HTMLDivElement>();
+ return (
+ <div ref={bodyRef}className="body-container" style={{left: `${NumCast(kf.time) - this.regiondata.position}px`, width:`${NumCast(left!.time) - NumCast(kf.time)}px`}}
+ onPointerOver={(e) => { this.onContainerOver(e, bodyRef); }}
+ onPointerOut={(e) => { this.onContainerOut(e, bodyRef); }}
+ onPointerDown={(e) => { this.props.changeCurrentBarX(NumCast(kf.time) + (e.clientX - bodyRef.current!.getBoundingClientRect().left) * this.props.transform.Scale);}}
+ onContextMenu={(e) => {
+ let items = [
+ TimelineMenu.Instance.addItem("button", "Add Ease", () => {this.onContainerDown(kf, "interpolate");}),
+ TimelineMenu.Instance.addItem("button", "Add Path", () => {this.onContainerDown(kf, "path");}),
+ TimelineMenu.Instance.addItem("input", "fadeIn", (val) => {this.regiondata.fadeIn = parseInt(val, 10);}),
+ TimelineMenu.Instance.addItem("input", "fadeOut", (val) => {this.regiondata.fadeOut = parseInt(val, 10);}),
+ TimelineMenu.Instance.addItem("input", "position", (val) => {this.regiondata.position = parseInt(val, 10);}),
+ TimelineMenu.Instance.addItem("input", "duration", (val) => {this.regiondata.duration = parseInt(val, 10);}),
+ ];
+ TimelineMenu.Instance.addMenu("Region", items);
+ TimelineMenu.Instance.openMenu(e.clientX, e.clientY);
+ }}>
+ </div>
+ );
+ }
+ })}
+
+ </div>
+ </div>
+ );
+ }
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/Timeline.scss b/src/client/views/animationtimeline/Timeline.scss
new file mode 100644
index 000000000..e5d898502
--- /dev/null
+++ b/src/client/views/animationtimeline/Timeline.scss
@@ -0,0 +1,122 @@
+@import "./../globalCssVariables.scss";
+
+.minimize{
+ position:relative;
+ z-index: 1000;
+ height: 30px;
+ width: 100px;
+}
+
+.timeline-toolbox{
+ position:absolute;
+ display:flex;
+ align-items: flex-start;
+ flex-direction: row;
+ top: 10px;
+ div{
+ margin-left:10px;
+ }
+}
+.timeline-container{
+ width:100%;
+ height:300px;
+ position:absolute;
+ background-color: $light-color-secondary;
+ box-shadow: 0px 10px 20px;
+
+ .info-container{
+ margin-top: 50px;
+ right:20px;
+ position:absolute;
+ height: calc(100% - 100px);
+ width: calc(100% - 140px);
+ overflow: hidden;
+
+ .scrubberbox{
+ position:absolute;
+ background-color: transparent;
+ height: 30px;
+ width:100%;
+
+ .tick{
+ height:100%;
+ width: 1px;
+ background-color:black;
+
+ }
+ }
+ .scrubber{
+ top:30px;
+ height: 100%;
+ width: 2px;
+ position:absolute;
+ z-index: 1001;
+ background-color:black;
+ .scrubberhead{
+ top: -30px;
+ height: 30px;
+ width: 30px;
+ background-color:transparent;
+ border-radius: 50%;
+ border: 5px solid black;
+ left: -15px;
+ position:absolute;
+ }
+ }
+
+ .trackbox{
+ top: 30px;
+ height:calc(100% - 30px);
+ width:100%;
+ border:1px;
+ overflow:hidden;
+ background-color:white;
+ position:absolute;
+ box-shadow: -10px 0px 10px 10px grey;
+ }
+
+ }
+ .title-container{
+ margin-top: 80px;
+ margin-left: 20px;
+ height: calc(100% - 100px - 30px);
+ width: 100px;
+ background-color:white;
+ overflow: hidden;
+ .datapane{
+ top:0px;
+ width: 100px;
+ height: 75px;
+ border: 1px solid $dark-color;
+ background-color: $intermediate-color;
+ color: white;
+ position:relative;
+ float:left;
+ border-style:solid;
+ }
+ }
+ .resize{
+ bottom: 5px;
+ position:absolute;
+ height: 30px;
+ width: 50px;
+ left: calc(50% - 25px);
+ }
+}
+
+
+
+.overview{
+ position: absolute;
+ height: 50px;
+ width: 200px;
+ background-color: black;
+ .container{
+ position: absolute;
+ float: left 0px;
+ top: 25%;
+ height: 75%;
+ width: 100%;
+ background-color: grey;
+ }
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/Timeline.tsx b/src/client/views/animationtimeline/Timeline.tsx
new file mode 100644
index 000000000..c8f11db5b
--- /dev/null
+++ b/src/client/views/animationtimeline/Timeline.tsx
@@ -0,0 +1,390 @@
+import * as React from "react";
+import "./Timeline.scss";
+import { CollectionSubView } from "../collections/CollectionSubView";
+import { Document, listSpec } from "../../../new_fields/Schema";
+import { observer } from "mobx-react";
+import { Track } from "./Track";
+import { observable, reaction, action, IReactionDisposer, observe, IObservableArray, computed, toJS, Reaction, IObservableObject, trace, autorun, runInAction } from "mobx";
+import { Cast, NumCast, FieldValue, StrCast, BoolCast } from "../../../new_fields/Types";
+import { List } from "../../../new_fields/List";
+import { Doc, DocListCast } from "../../../new_fields/Doc";
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faPlayCircle, faBackward, faForward, faGripLines, faArrowUp, faArrowDown, faClock, faPauseCircle } from "@fortawesome/free-solid-svg-icons";
+import { ContextMenuProps } from "../ContextMenuItem";
+import { ContextMenu } from "../ContextMenu";
+import { DocumentManager } from "../../util/DocumentManager";
+import { VideoBox } from "../nodes/VideoBox";
+import { VideoField } from "../../../new_fields/URLField";
+import { CollectionVideoView } from "../collections/CollectionVideoView";
+import { Transform } from "../../util/Transform";
+import { faGrinTongueSquint } from "@fortawesome/free-regular-svg-icons";
+import { InkField } from "../../../new_fields/InkField";
+import { AddComparisonParameters } from "../../northstar/model/idea/idea";
+import { keepAlive } from "mobx-utils";
+
+
+export interface FlyoutProps {
+ x?: number;
+ y?: number;
+ display?: string;
+ regiondata?: Doc;
+ regions?: List<Doc>;
+}
+
+
+@observer
+export class Timeline extends CollectionSubView(Document) {
+ static Instance:Timeline;
+
+
+ private readonly DEFAULT_CONTAINER_HEIGHT: number = 300;
+ private readonly DEFAULT_TICK_SPACING: number = 50;
+ private readonly MIN_CONTAINER_HEIGHT: number = 205;
+ private readonly MAX_CONTAINER_HEIGHT: number = 800;
+ private readonly DEFAULT_TICK_INCREMENT: number = 1000;
+
+ @observable private _isMinimized = false;
+ @observable private _tickSpacing = this.DEFAULT_TICK_SPACING;
+ @observable private _tickIncrement = this.DEFAULT_TICK_INCREMENT;
+
+ @observable private _scrubberbox = React.createRef<HTMLDivElement>();
+ @observable private _scrubber = React.createRef<HTMLDivElement>();
+ @observable private _trackbox = React.createRef<HTMLDivElement>();
+ @observable private _titleContainer = React.createRef<HTMLDivElement>();
+ @observable private _timelineContainer = React.createRef<HTMLDivElement>();
+
+ @observable private _timelineWrapper = React.createRef<HTMLDivElement>();
+ @observable private _infoContainer = React.createRef<HTMLDivElement>();
+
+
+ @observable private _currentBarX: number = 0;
+ @observable private _windSpeed: number = 1;
+ @observable private _isPlaying: boolean = false; //scrubber playing
+ @observable private _isFrozen: boolean = false; //timeline freeze
+ @observable private _boxLength: number = 0;
+ @observable private _containerHeight: number = this.DEFAULT_CONTAINER_HEIGHT;
+ @observable private _time = 100000; //DEFAULT
+ @observable private _ticks: number[] = [];
+ @observable private _playButton = faPlayCircle;
+ @observable private flyoutInfo: FlyoutProps = { x: 0, y: 0, display: "none", regiondata: new Doc(), regions: new List<Doc>() };
+
+ @computed
+ private get children(): List<Doc> {
+ let extendedDocument = ["image", "video", "pdf"].includes(StrCast(this.props.Document.type));
+
+ if (extendedDocument) {
+ if (this.props.Document.data_ext) {
+ return Cast((Cast(this.props.Document.data_ext, Doc) as Doc).annotations, listSpec(Doc)) as List<Doc>;
+ } else {
+ return new List<Doc>();
+ }
+ }
+ return Cast(this.props.Document[this.props.fieldKey], listSpec(Doc)) as List<Doc>;
+ }
+
+ componentWillMount() {
+ this.props.Document.isAnimating ? this.props.Document.isAnimating = true : this.props.Document.isAnimating = false;
+ }
+
+ componentDidMount() {
+ if (StrCast(this.props.Document.type) === "video") {
+ console.log("ran");
+ console.log(this.props.Document.duration);
+ if (this.props.Document.duration) {
+ this._time = Math.round(NumCast(this.props.Document.duration)) * 1000;
+ reaction(() => {
+ return NumCast(this.props.Document.curPage);
+ }, curPage => {
+ this.changeCurrentBarX(curPage * this._tickIncrement / this._tickSpacing);
+ });
+ }
+
+ }
+ runInAction(() => {
+ reaction(() => {
+ return this.props.Document.isAnimating;
+ }, async isAnimating => {
+ if (isAnimating){
+ this._ticks = [];
+ for (let i = 0; i < this._time;) {
+ this._ticks.push(i);
+ i += this._tickIncrement;
+ }
+ observe(this._trackbox, change => {if (change.type === "update"){
+ if (this.props.Document.isAnimating){
+ let trackbox = this._trackbox.current!;
+ this._boxLength = this._tickIncrement / 1000 * this._tickSpacing * this._ticks.length;
+ trackbox.style.width = `${this._boxLength}`;
+ this._scrubberbox.current!.style.width = `${this._boxLength}`;
+ }
+ }});
+ }
+
+ });
+ });
+ }
+
+
+ @action
+ changeCurrentBarX = (x: number) => {
+ this._currentBarX = x;
+ }
+
+ //for playing
+ @action
+ onPlay = async (e: React.MouseEvent) => {
+ if (this._isPlaying) {
+ this._isPlaying = false;
+ this._playButton = faPlayCircle;
+ } else {
+ this._isPlaying = true;
+ this._playButton = faPauseCircle;
+ this.changeCurrentX();
+ }
+ }
+
+ @action
+ changeCurrentX = () => {
+ if (this._currentBarX === this._boxLength && this._isPlaying) {
+ this._currentBarX = 0;
+ }
+ if (this._currentBarX <= this._boxLength && this._isPlaying) {
+ this._currentBarX = this._currentBarX + this._windSpeed;
+ setTimeout(this.changeCurrentX, 15);
+ }
+ }
+
+ @action
+ windForward = (e: React.MouseEvent) => {
+ if (this._windSpeed < 64) { //max speed is 32
+ this._windSpeed = this._windSpeed * 2;
+ }
+ }
+
+ @action
+ windBackward = (e: React.MouseEvent) => {
+ if (this._windSpeed > 1 / 16) { // min speed is 1/8
+ this._windSpeed = this._windSpeed / 2;
+ }
+ }
+
+ //for scrubber action
+ @action
+ onScrubberDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onScrubberMove);
+ document.addEventListener("pointerup", () => {
+ document.removeEventListener("pointermove", this.onScrubberMove);
+ });
+ }
+
+ @action
+ onScrubberMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let scrubberbox = this._scrubberbox.current!;
+ let left = scrubberbox.getBoundingClientRect().left;
+ let offsetX = Math.round(e.clientX - left) * this.props.ScreenToLocalTransform().Scale;
+ this._currentBarX = offsetX;
+ }
+
+ @action
+ onScrubberClick = (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let scrubberbox = this._scrubberbox.current!;
+ let offset = (e.clientX - scrubberbox.getBoundingClientRect().left) * this.props.ScreenToLocalTransform().Scale;
+ this._currentBarX = offset;
+ }
+
+
+
+ @action
+ onPanDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onPanMove);
+ document.addEventListener("pointerup", () => {
+ document.removeEventListener("pointermove", this.onPanMove);
+ });
+ }
+
+ @action
+ onPanMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let infoContainer = this._infoContainer.current!;
+ let trackbox = this._trackbox.current!;
+ let titleContainer = this._titleContainer.current!;
+ infoContainer.scrollLeft = infoContainer.scrollLeft - e.movementX;
+ trackbox.scrollTop = trackbox.scrollTop - e.movementY;
+ titleContainer.scrollTop = titleContainer.scrollTop - e.movementY;
+ }
+
+
+ @action
+ onResizeDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.addEventListener("pointermove", this.onResizeMove);
+ document.addEventListener("pointerup", () => {
+ document.removeEventListener("pointermove", this.onResizeMove);
+ });
+ }
+
+ @action
+ onResizeMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let offset = e.clientY - this._timelineContainer.current!.getBoundingClientRect().bottom;
+ if (this._containerHeight + offset <= this.MIN_CONTAINER_HEIGHT) {
+ this._containerHeight = this.MIN_CONTAINER_HEIGHT;
+ } else if (this._containerHeight + offset >= this.MAX_CONTAINER_HEIGHT) {
+ this._containerHeight = this.MAX_CONTAINER_HEIGHT;
+ } else {
+ this._containerHeight += offset;
+ }
+ }
+
+ @action
+ onTimelineDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ if (e.nativeEvent.which === 1 && !this._isFrozen) {
+ document.addEventListener("pointermove", this.onTimelineMove);
+ document.addEventListener("pointerup", () => { document.removeEventListener("pointermove", this.onTimelineMove); });
+ }
+ }
+
+ @action
+ onTimelineMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let timelineContainer = this._timelineWrapper.current!;
+ let left = parseFloat(timelineContainer.style.left!);
+ let top = parseFloat(timelineContainer.style.top!);
+ timelineContainer.style.left = `${left + e.movementX}px`;
+ timelineContainer.style.top = `${top + e.movementY}px`;
+ }
+
+ @action
+ minimize = (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ let timelineContainer = this._timelineContainer.current!;
+ if (this._isMinimized) {
+ this._isMinimized = false;
+ timelineContainer.style.visibility = "visible";
+ } else {
+ this._isMinimized = true;
+ timelineContainer.style.visibility = "hidden";
+ }
+ }
+
+ @action
+ toTime = (time: number): string => {
+ const inSeconds = time / 1000;
+ let min: (string | number) = Math.floor(inSeconds / 60);
+ let sec: (string | number) = inSeconds % 60;
+
+ if (Math.floor(sec / 10) === 0) {
+ sec = "0" + sec;
+ }
+ return `${min}:${sec}`;
+ }
+
+
+ private _freezeText = "Freeze Timeline";
+
+ timelineContextMenu = (e: React.MouseEvent): void => {
+ let subitems: ContextMenuProps[] = [];
+ let timelineContainer = this._timelineWrapper.current!;
+ subitems.push({
+ description: "Pin to Top", event: action(() => {
+ if (!this._isFrozen) {
+ timelineContainer.style.transition = "top 1000ms ease-in, left 1000ms ease-in"; //?????
+ timelineContainer.style.left = "0px";
+ timelineContainer.style.top = "0px";
+ timelineContainer.style.transition = "none";
+ }
+ }), icon: faArrowUp
+ });
+ subitems.push({
+ description: "Pin to Bottom", event: action(() => {
+ console.log(this.props.Document.y);
+
+ if (!this._isFrozen) {
+ timelineContainer.style.transform = `translate(0px, ${e.pageY - this._containerHeight}px)`;
+ }
+ }), icon: faArrowDown
+ });
+ subitems.push({
+ description: this._freezeText, event: action(() => {
+ if (this._isFrozen) {
+ this._isFrozen = false;
+ this._freezeText = "Freeze Timeline";
+ } else {
+ this._isFrozen = true;
+ this._freezeText = "Unfreeze Timeline";
+ }
+ }), icon: "thumbtack"
+ });
+ ContextMenu.Instance.addItem({ description: "Timeline Funcs...", subitems: subitems, icon: faClock });
+ }
+
+
+
+ @action
+ getFlyout = (props: FlyoutProps) => {
+ for (const [k, v] of Object.entries(props)) {
+ (this.flyoutInfo as any)[k] = v;
+ }
+ console.log(this.flyoutInfo);
+ }
+
+ render() {
+ let timeline:JSX.Element[] = [];
+ BoolCast(this.props.Document.isAnimating) ? timeline = [
+ <div key="timeline_wrapper" style={{ left: "0px", top: "0px", position: "absolute", width: "100%", transform: "translate(0px, 0px)" }} ref={this._timelineWrapper}>
+ <button key="timeline_minimize" className="minimize" onClick={this.minimize}>Minimize</button>
+ <div key="timeline_container" className="timeline-container" style={{ height: `${this._containerHeight}px`, left: "0px", top: "30px" }} ref={this._timelineContainer} onPointerDown={this.onTimelineDown} onContextMenu={this.timelineContextMenu}>
+ <div key ="timeline_toolbox" className="timeline-toolbox">
+ <div key ="timeline_windBack" onClick={this.windBackward}> <FontAwesomeIcon icon={faBackward} size="2x" /> </div>
+ <div key ="timeline_play" onClick={this.onPlay}> <FontAwesomeIcon icon={this._playButton} size="2x" /> </div>
+ <div key = "timeline_windForward" onClick={this.windForward}> <FontAwesomeIcon icon={faForward} size="2x" /> </div>
+ </div>
+ <div key ="timeline_info"className="info-container" ref={this._infoContainer}>
+ <div key="timeline_scrubberbox" className="scrubberbox" ref={this._scrubberbox} onClick={this.onScrubberClick}>
+ {this._ticks.map(element => {
+ return <div className="tick" style={{ transform: `translate(${element / 1000 * this._tickSpacing}px)`, position: "absolute", pointerEvents: "none" }}> <p>{this.toTime(element)}</p></div>;
+ })}
+ </div>
+ <div key="timeline_scrubber" className="scrubber" ref={this._scrubber} onPointerDown={this.onScrubberDown} style={{ transform: `translate(${this._currentBarX}px)` }}>
+ <div key="timeline_scrubberhead" className="scrubberhead"></div>
+ </div>
+ <div key="timeline_trackbox" className="trackbox" ref={this._trackbox} onPointerDown={this.onPanDown}>
+ {DocListCast(this.children).map(doc => <Track node={doc} currentBarX={this._currentBarX} changeCurrentBarX={this.changeCurrentBarX} setFlyout={this.getFlyout} transform={this.props.ScreenToLocalTransform()} collection = {this.props.Document}/>)}
+ </div>
+ </div>
+ <div key="timeline_title"className="title-container" ref={this._titleContainer}>
+ {DocListCast(this.children).map(doc => <div className="datapane"><p>{doc.title}</p></div>)}
+ </div>
+ <div key="timeline_resize" onPointerDown={this.onResizeDown}>
+ <FontAwesomeIcon className="resize" icon={faGripLines} />
+ </div>
+ </div>
+ </div>
+ ] : timeline = [
+ <div key="timeline_toolbox" className="timeline-toolbox">
+ <div key="timeline_windBack" onClick={this.windBackward}> <FontAwesomeIcon icon={faBackward} size="2x" /> </div>
+ <div key =" timeline_play" onClick={this.onPlay}> <FontAwesomeIcon icon={this._playButton} size="2x" /> </div>
+ <div key="timeline_windForward" onClick={this.windForward}> <FontAwesomeIcon icon={faForward} size="2x" /> </div>
+ </div>];
+
+ return (
+ <div>
+ {timeline}
+ </div>
+ );
+ }
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/TimelineMenu.scss b/src/client/views/animationtimeline/TimelineMenu.scss
new file mode 100644
index 000000000..90cc53b4c
--- /dev/null
+++ b/src/client/views/animationtimeline/TimelineMenu.scss
@@ -0,0 +1,94 @@
+@import "./../globalCssVariables.scss";
+
+
+.timeline-menu-container{
+ position: absolute;
+ display: flex;
+ box-shadow: $intermediate-color 0.2vw 0.2vw 0.4vw;
+ flex-direction: column;
+ background: whitesmoke;
+ z-index: 10000;
+ width: 150px;
+ padding-bottom: 10px;
+ border-radius: 15px;
+
+ border: solid #BBBBBBBB 1px;
+
+
+
+ .timeline-menu-input{
+ font: $sans-serif;
+ font-size: 13px;
+ width:100%;
+ text-transform: uppercase;
+ letter-spacing: 2px;
+ margin-left: 10px;
+ background-color: transparent;
+ border-width: 0px;
+ transition: border-width 500ms;
+ }
+
+ .timeline-menu-input:hover{
+ border-width: 2px;
+ }
+
+
+
+
+ .timeline-menu-header{
+ border-top-left-radius: 15px;
+ border-top-right-radius: 15px;
+ text-transform: uppercase;
+ background: $dark-color;
+ letter-spacing: 2px;
+
+ .timeline-menu-header-desc{
+ font:$sans-serif;
+ font-size: 13px;
+ text-align: center;
+ color: whitesmoke;
+ }
+ }
+
+
+ .timeline-menu-item {
+ // width: 11vw; //10vw
+ height: 30px; //2vh
+ background: whitesmoke;
+ display: flex; //comment out to allow search icon to be inline with search text
+ justify-content: left;
+ align-items: center;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ transition: all .1s;
+ border-style: none;
+ // padding: 10px 0px 10px 0px;
+ white-space: nowrap;
+ font-size: 13px;
+ color: grey;
+ letter-spacing: 2px;
+ text-transform: uppercase;
+ padding-right: 20px;
+ padding-left: 10px;
+ }
+
+ .timeline-menu-item:hover {
+ border-width: .11px;
+ border-style: none;
+ border-color: $intermediate-color;
+ border-bottom-style: solid;
+ border-top-style: solid;
+ background: $darker-alt-accent;
+ }
+
+ .timeline-menu-desc {
+ padding-left: 10px;
+ font:$sans-serif;
+ font-size: 13px;
+ }
+
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/TimelineMenu.tsx b/src/client/views/animationtimeline/TimelineMenu.tsx
new file mode 100644
index 000000000..4223ee099
--- /dev/null
+++ b/src/client/views/animationtimeline/TimelineMenu.tsx
@@ -0,0 +1,86 @@
+import * as React from "react";
+import {observable, action, runInAction} from "mobx";
+import {observer} from "mobx-react";
+import "./TimelineMenu.scss";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faChartLine, faRoad, faClipboard, faPen, faTrash, faTable } from "@fortawesome/free-solid-svg-icons";
+
+
+@observer
+export class TimelineMenu extends React.Component {
+ public static Instance:TimelineMenu;
+
+ @observable private _opacity = 0;
+ @observable private _x = 0;
+ @observable private _y = 0;
+ @observable private _currentMenu:JSX.Element[] = [];
+
+ constructor (props:Readonly<{}>){
+ super(props);
+ TimelineMenu.Instance = this;
+ }
+
+ @action
+ pointerDown = (e: React.PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ document.removeEventListener("pointerup", this.pointerUp);
+ document.addEventListener("pointerup", this.pointerUp);
+ document.removeEventListener("pointermove", this.pointerMove);
+ document.addEventListener("pointermove", this.pointerMove);
+ }
+
+ @action
+ pointerMove = (e: PointerEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+
+ @action
+ pointerUp = (e: PointerEvent) => {
+ document.removeEventListener("pointermove", this.pointerMove);
+ document.removeEventListener("pointerup", this.pointerUp);
+ }
+
+ @action
+ openMenu = (x?:number, y?:number) => {
+ this._opacity = 1;
+ x ? this._x = x : this._x = 0;
+ y ? this._y = y : this._y = 0;
+ }
+
+ @action
+ closeMenu = () => {
+ this._opacity = 0;
+ }
+
+ addItem = (type: "input" | "button", title: string, event: (e:any) => void) => {
+ if (type === "input"){
+ let ref = React.createRef<HTMLInputElement>();
+ let text = "";
+ return <div className="timeline-menu-item"><FontAwesomeIcon icon={faClipboard} size="lg"/><input className="timeline-menu-input" ref = {ref} placeholder={title} onChange={(e) => {text = e.target.value;}} onKeyDown={(e:React.KeyboardEvent) => {
+ if(e.keyCode === 13){
+ event(text);
+ }}}/></div>;
+ } else if (type === "button") {
+ let ref = React.createRef<HTMLDivElement>();
+ return <div className="timeline-menu-item"><FontAwesomeIcon icon={faChartLine}size="lg"/><p className="timeline-menu-desc" onClick={event}>{title}</p></div>;
+ }
+ return <div></div>;
+ }
+
+ @action
+ addMenu = (title:string, items: JSX.Element[]) => {
+ items.unshift(<div className="timeline-menu-header"><p className="timeline-menu-header-desc">{title}</p></div>);
+ this._currentMenu = items;
+ }
+
+ render() {
+ return (
+ <div className="timeline-menu-container" style={{opacity: this._opacity, left: this._x, top: this._y}} >
+ {this._currentMenu}
+ </div>
+ );
+ }
+
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/Track.scss b/src/client/views/animationtimeline/Track.scss
new file mode 100644
index 000000000..c8d56edf6
--- /dev/null
+++ b/src/client/views/animationtimeline/Track.scss
@@ -0,0 +1,15 @@
+@import "./../globalCssVariables.scss";
+
+.track-container{
+
+ .track {
+ .inner {
+ top:0px;
+ height: 75px;
+ width: calc(100%);
+ background-color: $light-color;
+ border: 1px solid $dark-color;
+ position:relative;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/client/views/animationtimeline/Track.tsx b/src/client/views/animationtimeline/Track.tsx
new file mode 100644
index 000000000..64e94f0f1
--- /dev/null
+++ b/src/client/views/animationtimeline/Track.tsx
@@ -0,0 +1,285 @@
+import * as React from "react";
+import { observer } from "mobx-react";
+import { observable, reaction, action, IReactionDisposer, observe, IObservableArray, computed, toJS, IObservableObject, runInAction, autorun } from "mobx";
+import "./Track.scss";
+import { Doc, DocListCastAsync, DocListCast, Field } from "../../../new_fields/Doc";
+import { listSpec } from "../../../new_fields/Schema";
+import { FieldValue, Cast, NumCast, BoolCast, StrCast } from "../../../new_fields/Types";
+import { List } from "../../../new_fields/List";
+import { Keyframe, KeyframeFunc, RegionData } from "./Keyframe";
+import { FlyoutProps } from "./Timeline";
+import { Transform } from "../../util/Transform";
+import { RichTextField } from "../../../new_fields/RichTextField";
+
+interface IProps {
+ node: Doc;
+ currentBarX: number;
+ transform: Transform;
+ collection: Doc;
+ changeCurrentBarX: (x: number) => void;
+ setFlyout: (props: FlyoutProps) => any;
+}
+
+@observer
+export class Track extends React.Component<IProps> {
+ @observable private _inner = React.createRef<HTMLDivElement>();
+ @observable private _reactionDisposers: IReactionDisposer[] = [];
+ @observable private _currentBarXReaction: any;
+ @observable private _isOnKeyframe: boolean = false;
+ @observable private _onKeyframe: (Doc | undefined) = undefined;
+ @observable private _onRegionData : ( Doc | undefined) = undefined;
+ @observable private _leftCurrKeyframe: (Doc | undefined) = undefined;
+
+ @computed
+ private get regions() {
+ return Cast(this.props.node.regions, listSpec(Doc)) as List<Doc>;
+ }
+
+ componentWillMount() {
+ if (!this.props.node.regions) {
+ this.props.node.regions = new List<Doc>();
+ }
+ this.props.node.opacity = 1;
+ }
+
+ componentDidMount() {
+ runInAction(() => {
+ this._currentBarXReaction = this.currentBarXReaction();
+ if (this.regions.length === 0) this.createRegion(this.props.currentBarX);
+ this.props.node.hidden = false;
+ });
+ }
+
+ componentWillUnmount() {
+ runInAction(() => {
+ if (this._currentBarXReaction) this._currentBarXReaction();
+ });
+ }
+
+ @action
+ saveKeyframe = async (ref:Doc, regiondata:Doc) => {
+ let keyframes:List<Doc> = (Cast(regiondata.keyframes, listSpec(Doc)) as List<Doc>);
+ let kfIndex:number = keyframes.indexOf(ref);
+ let kf = keyframes[kfIndex] as Doc;
+ if (kf.type === KeyframeFunc.KeyframeType.default) { // only save for non-fades
+ kf.key = Doc.MakeCopy(this.props.node, true);
+ let leftkf: (Doc | undefined) = await KeyframeFunc.calcMinLeft(regiondata!, this.props.currentBarX, kf); // lef keyframe, if it exists
+ let rightkf: (Doc | undefined) = await KeyframeFunc.calcMinRight(regiondata!, this.props.currentBarX, kf); //right keyframe, if it exists
+ if (leftkf!.type === KeyframeFunc.KeyframeType.fade) { //replicating this keyframe to fades
+ let edge:(Doc | undefined) = await KeyframeFunc.calcMinLeft(regiondata!, this.props.currentBarX, leftkf!);
+ edge!.key = Doc.MakeCopy(kf.key as Doc, true);
+ leftkf!.key = Doc.MakeCopy(kf.key as Doc, true);
+ (Cast(edge!.key, Doc)! as Doc).opacity = 0.1;
+ (Cast(leftkf!.key, Doc)! as Doc).opacity = 1;
+ }
+ if (rightkf!.type === KeyframeFunc.KeyframeType.fade) {
+ let edge:(Doc | undefined) = await KeyframeFunc.calcMinRight(regiondata!,this.props.currentBarX, rightkf!);
+ edge!.key = Doc.MakeCopy(kf.key as Doc, true);
+ rightkf!.key = Doc.MakeCopy(kf.key as Doc, true);
+ (Cast(edge!.key, Doc)! as Doc).opacity = 0.1;
+ (Cast(rightkf!.key, Doc)! as Doc).opacity = 1;
+ }
+ }
+ keyframes[kfIndex] = kf;
+ this._onKeyframe = undefined;
+ this._onRegionData = undefined;
+ this._isOnKeyframe = false;
+ }
+
+ @action
+ currentBarXReaction = () => {
+ return reaction(() => this.props.currentBarX, async () => {
+ let regiondata: (Doc | undefined) = await this.findRegion(this.props.currentBarX);
+ if (regiondata) {
+ this.props.node.hidden = false;
+ await this.timeChange(this.props.currentBarX);
+ } else {
+ this.props.node.hidden = true;
+ }
+ }, { fireImmediately: true });
+ }
+
+
+ @action
+ timeChange = async (time: number) => {
+ if (this._isOnKeyframe && this._onKeyframe && this._onRegionData) {
+ await this.saveKeyframe(this._onKeyframe, this._onRegionData);
+ }
+ let regiondata = await this.findRegion(Math.round(time)); //finds a region that the scrubber is on
+ if (regiondata) {
+ let leftkf: (Doc | undefined) = await KeyframeFunc.calcMinLeft(regiondata, this.props.currentBarX); // lef keyframe, if it exists
+ let rightkf: (Doc | undefined) = await KeyframeFunc.calcMinRight(regiondata, this.props.currentBarX); //right keyframe, if it exists
+ let currentkf: (Doc | undefined) = await this.calcCurrent(regiondata); //if the scrubber is on top of the keyframe
+ if (currentkf) {
+ await this.applyKeys(currentkf);
+ this._leftCurrKeyframe = currentkf;
+ this._isOnKeyframe = true;
+ this._onKeyframe = currentkf;
+ this._onRegionData = regiondata;
+ } else if (leftkf && rightkf) {
+ await this.interpolate(leftkf, rightkf, regiondata);
+ }
+ }
+ }
+
+ @action
+ private applyKeys = async (kf: Doc) => {
+ let kfNode = await Cast(kf.key, Doc) as Doc;
+ let docFromApply = kfNode;
+ console.log(Doc.allKeys(docFromApply));
+ if (this.filterKeys(Doc.allKeys(this.props.node)).length > this.filterKeys(Doc.allKeys(kfNode)).length) docFromApply = this.props.node;
+ this.filterKeys(Doc.allKeys(docFromApply)).forEach(key => {
+ console.log(key);
+ if (!kfNode[key]) {
+ this.props.node[key] = undefined;
+ } else {
+ if (key === "data") {
+ if (this.props.node.type === "text"){
+ let nodeData = (kfNode[key] as RichTextField).Data;
+ this.props.node[key] = new RichTextField(nodeData);
+ }
+ } else if (key === "creationDate") {
+ } else {
+ this.props.node[key] = kfNode[key];
+ }
+
+ }
+
+ });
+ }
+
+
+ @action
+ private filterKeys = (keys: string[]): string[] => {
+ return keys.reduce((acc: string[], key: string) => {
+ if (key !== "regions" && key !== "cursors" && key !== "hidden" && key !== "nativeHeight" && key !== "nativeWidth" && key !== "schemaColumns") acc.push(key);
+ return acc;
+ }, []) as string[];
+ }
+
+ @action
+ calcCurrent = async (region: Doc) => {
+ let currentkf: (Doc | undefined) = undefined;
+ let keyframes = await DocListCastAsync(region.keyframes!);
+ keyframes!.forEach((kf) => {
+ if (NumCast(kf.time) === Math.round(this.props.currentBarX)) currentkf = kf;
+ });
+ return currentkf;
+ }
+
+
+ @action
+ interpolate = async (left: Doc, right: Doc, regiondata:Doc) => {
+ let leftNode = left.key as Doc;
+ let rightNode = right.key as Doc;
+ const dif_time = NumCast(right.time) - NumCast(left.time);
+ const timeratio = (this.props.currentBarX - NumCast(left.time)) / dif_time; //linear
+ let keyframes = (await DocListCastAsync(regiondata.keyframes!))!;
+ let indexLeft = keyframes.indexOf(left);
+ let interY:List<number> = await ((regiondata.functions as List<Doc>)[indexLeft] as Doc).interpolationY as List<number>;
+ let realIndex = (interY.length - 1) * timeratio;
+ let xIndex = Math.floor(realIndex);
+ let yValue = interY[xIndex];
+ let secondYOffset:number = yValue;
+ let minY = interY[0]; // for now
+ let maxY = interY[interY.length - 1]; //for now
+ if (interY.length !== 1) {
+ secondYOffset = interY[xIndex] + ((realIndex - xIndex) / 1) * (interY[xIndex + 1] - interY[xIndex]) - minY;
+ }
+ let finalRatio = secondYOffset / (maxY - minY);
+ let pathX:List<number> = await ((regiondata.functions as List<Doc>)[indexLeft] as Doc).pathX as List<number>;
+ let pathY:List<number> = await ((regiondata.functions as List<Doc>)[indexLeft] as Doc).pathY as List<number>;
+ let proposedX = 0;
+ let proposedY = 0;
+ if (pathX.length !== 0) {
+ let realPathCorrespondingIndex = finalRatio * (pathX.length - 1);
+ let pathCorrespondingIndex = Math.floor(realPathCorrespondingIndex);
+ if (pathCorrespondingIndex >= pathX.length - 1) {
+ proposedX = pathX[pathX.length - 1];
+ proposedY = pathY[pathY.length - 1];
+ } else if (pathCorrespondingIndex < 0){
+ proposedX = pathX[0];
+ proposedY = pathY[0];
+ } else {
+ proposedX = pathX[pathCorrespondingIndex] + ((realPathCorrespondingIndex - pathCorrespondingIndex) / 1) * (pathX[pathCorrespondingIndex + 1] - pathX[pathCorrespondingIndex]);
+ proposedY = pathY[pathCorrespondingIndex] + ((realPathCorrespondingIndex - pathCorrespondingIndex) / 1) * (pathY[pathCorrespondingIndex + 1] - pathY[pathCorrespondingIndex]);
+ }
+
+ }
+ this.filterKeys(Doc.allKeys(leftNode)).forEach(key => {
+ if (leftNode[key] && rightNode[key] && typeof (leftNode[key]) === "number" && typeof (rightNode[key]) === "number") { //if it is number, interpolate
+ if ((key === "x" || key === "y") && pathX.length !== 0){
+ if (key === "x") this.props.node[key] = proposedX;
+ if (key === "y") this.props.node[key] = proposedY;
+ } else {
+ const diff = NumCast(rightNode[key]) - NumCast(leftNode[key]);
+ const adjusted = diff * finalRatio;
+ this.props.node[key] = NumCast(leftNode[key]) + adjusted;
+ }
+ } else {
+ if (key === "data") {
+ if (this.props.node.type === "text"){
+ let nodeData = StrCast((leftNode[key] as RichTextField).Data);
+ let currentNodeData = StrCast((this.props.node[key] as RichTextField).Data);
+ if (nodeData !== currentNodeData) {
+ this.props.node[key] = new RichTextField(nodeData);
+ }
+ }
+ } else if (key === "creationDate") {
+
+ } else {
+ this.props.node[key] = leftNode[key];
+ }
+ }
+ });
+ }
+
+ @action
+ findRegion = async (time: number) => {
+ let foundRegion:(Doc | undefined) = undefined;
+ let regions = await DocListCastAsync(this.regions);
+ regions!.forEach(region => {
+ region = region as RegionData;
+ if (time >= NumCast(region.position) && time <= (NumCast(region.position) + NumCast(region.duration))) {
+ foundRegion = region;
+ }
+ });
+ return foundRegion;
+ }
+
+ @action
+ onInnerDoubleClick = (e: React.MouseEvent) => {
+ let inner = this._inner.current!;
+ let offsetX = Math.round((e.clientX - inner.getBoundingClientRect().left) * this.props.transform.Scale);
+ this.createRegion(offsetX);
+ }
+
+ createRegion = (position: number) => {
+ let regiondata = KeyframeFunc.defaultKeyframe();
+ regiondata.position = position;
+ let leftRegion = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.left, regiondata, this.regions);
+ let rightRegion = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.right, regiondata, this.regions);
+ if ((rightRegion && leftRegion && rightRegion.position - (leftRegion.position + leftRegion.duration) < NumCast(regiondata.fadeIn) + NumCast(regiondata.fadeOut)) || (rightRegion && rightRegion.position - regiondata.position < NumCast(regiondata.fadeIn) + NumCast(regiondata.fadeOut))) {
+ return;
+ } else if (rightRegion && rightRegion.position - regiondata.position >= NumCast(regiondata.fadeIn) + NumCast(regiondata.fadeOut)) {
+ regiondata.duration = rightRegion.position - regiondata.position;
+ }
+ this.regions.push(regiondata);
+ return regiondata;
+ }
+
+
+ render() {
+ return (
+ <div className="track-container">
+ <div className="track">
+ <div className="inner" ref={this._inner} onDoubleClick={this.onInnerDoubleClick}>
+ {DocListCast(this.regions).map((region) => {
+ return <Keyframe node={this.props.node} RegionData={region} changeCurrentBarX={this.props.changeCurrentBarX} setFlyout={this.props.setFlyout} transform={this.props.transform} collection={this.props.collection}/>;
+ })}
+ </div>
+ </div>
+ </div>
+ );
+ }
+} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 077f3f941..7482f5665 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -14,13 +14,13 @@ import { DocServer } from "../../DocServer";
import { Docs, DocumentOptions, DocumentType } from "../../documents/Documents";
import { DragManager } from "../../util/DragManager";
import { undoBatch, UndoManager } from "../../util/UndoManager";
-import { DocComponent } from "../DocComponent";
import { FieldViewProps } from "../nodes/FieldView";
import { FormattedTextBox } from "../nodes/FormattedTextBox";
import { CollectionPDFView } from "./CollectionPDFView";
import { CollectionVideoView } from "./CollectionVideoView";
import { CollectionView } from "./CollectionView";
import React = require("react");
+import { DocComponent } from "../DocComponent";
export interface CollectionViewProps extends FieldViewProps {
addDocument: (document: Doc, allowDuplicates?: boolean) => boolean;
@@ -35,7 +35,7 @@ export interface SubCollectionViewProps extends CollectionViewProps {
CollectionView: CollectionView | CollectionPDFView | CollectionVideoView;
}
-export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
+export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
class CollectionSubView extends DocComponent<SubCollectionViewProps, T>(schemaCtor) {
private dropDisposer?: DragManager.DragDropDisposer;
protected createDropTarget = (ele: HTMLDivElement) => {
@@ -56,7 +56,7 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
//TODO tfs: This might not be what we want?
//This linter error can't be fixed because of how js arguments work, so don't switch this to filter(FieldValue)
let docs = DocListCast(this.extensionDoc[this.props.fieldExt ? this.props.fieldExt : this.props.fieldKey]);
- let viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
+ let viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
if (viewSpecScript) {
let script = viewSpecScript.script;
docs = docs.filter(d => {
@@ -122,13 +122,19 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
}
let added = false;
if (de.data.dropAction || de.data.userDropAction) {
- added = de.data.droppedDocuments.reduce((added: boolean, d) => this.props.addDocument(d) || added, false);
+ added = de.data.droppedDocuments.reduce((added: boolean, d) => {
+ let moved = this.props.addDocument(d);
+ return moved || added;
+ }, false);
} else if (de.data.moveDocument) {
let movedDocs = de.data.options === this.props.Document[Id] ? de.data.draggedDocuments : de.data.droppedDocuments;
added = movedDocs.reduce((added: boolean, d) =>
de.data.moveDocument(d, this.props.Document, this.props.addDocument) || added, false);
} else {
- added = de.data.droppedDocuments.reduce((added: boolean, d) => this.props.addDocument(d) || added, false);
+ added = de.data.droppedDocuments.reduce((added: boolean, d) => {
+ let moved = this.props.addDocument(d);
+ return moved || added;
+ }, false);
}
e.stopPropagation();
return added;
diff --git a/src/client/views/collections/CollectionViewChromes.scss b/src/client/views/collections/CollectionViewChromes.scss
index 793cb7a8b..74f0dffd4 100644
--- a/src/client/views/collections/CollectionViewChromes.scss
+++ b/src/client/views/collections/CollectionViewChromes.scss
@@ -35,6 +35,18 @@
outline-color: black;
}
+ .collectionViewBaseChrome-button{
+ font-size: 75%;
+ text-transform: uppercase;
+ letter-spacing: 2px;
+ background: rgb(238, 238, 238);
+ color: purple;
+ outline-color: black;
+ border: none;
+ padding: 12px 10px 11px 10px;
+ margin-left: 10px;
+ }
+
.collectionViewBaseChrome-collapse {
transition: all .5s, opacity 0.3s;
position: absolute;
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 52c47e7e8..694bfbe4f 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -288,9 +288,13 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
<button className="collectonViewBaseChrome-viewSpecsMenu-lastRowButton" onClick={this.applyFilter}>
APPLY FILTER
</button>
+
</div>
</div>
</div>
+ {/* <button className="collectionViewBaseChrome-button" >
+ SHOW TIMELINE
+ </button> */}
</div>
{this.subChrome()}
</div>
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index ba8dcff98..32c181557 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -36,6 +36,9 @@ import { CollectionFreeFormRemoteCursors } from "./CollectionFreeFormRemoteCurso
import "./CollectionFreeFormView.scss";
import { MarqueeView } from "./MarqueeView";
import React = require("react");
+import v5 = require("uuid/v5");
+import { Timeline } from "../../animationtimeline/Timeline";
+import { number } from "prop-types";
import { DocumentType, Docs } from "../../../documents/Documents";
import { RouteStore } from "../../../../server/RouteStore";
import { string, number, elementType } from "prop-types";
@@ -919,7 +922,9 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
addOverlay("arrangeScript", { x: 400, y: 500, width: 400, height: 300, title: "Layout Script" }, { doc: "Doc", index: "number", collection: "Doc", state: "any", docs: "Doc[]" }, "{x: number, y: number, width?: number, height?: number}");
};
}
-
+ private _timeline = <Timeline {...this.props}/>;
+ se = () => {
+ }
render() {
const easing = () => this.props.Document.panTransformType === "Ease";
Doc.UpdateDocumentExtensionForField(this.props.DataDoc ? this.props.DataDoc : this.props.Document, this.props.fieldKey);
@@ -939,6 +944,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
<CollectionFreeFormRemoteCursors {...this.props} key="remoteCursors" />
</CollectionFreeFormViewPannableContents>
</MarqueeView>
+ <Timeline {...this.props} />
{this.overlayChildViews()}
<CollectionFreeFormOverlayView {...this.props} {...this.getDocumentViewProps(this.props.Document)} />
</div>
diff --git a/src/client/views/graph/Graph.tsx b/src/client/views/graph/Graph.tsx
new file mode 100644
index 000000000..d925cc32c
--- /dev/null
+++ b/src/client/views/graph/Graph.tsx
@@ -0,0 +1,32 @@
+import * as React from "react";
+import {observable} from "mobx";
+import { observer } from "mobx-react";
+import { Document, listSpec } from "../../../new_fields/Schema";
+import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
+import { CollectionSubView, CollectionViewProps, SubCollectionViewProps } from "../collections/CollectionSubView";
+
+
+
+
+export class Graph extends CollectionSubView(Document) {
+ static Instance:Graph;
+
+ private constructor(props:SubCollectionViewProps) {
+ super(props);
+ Graph.Instance = this;
+ }
+
+
+
+
+ render() {
+ let collection = <CollectionFreeFormView {...this.props}/>;
+
+ return (
+ <div>
+ </div>
+
+ );
+ }
+
+} \ No newline at end of file
diff --git a/src/client/views/graph/GraphManager.ts b/src/client/views/graph/GraphManager.ts
new file mode 100644
index 000000000..9d62b1ef8
--- /dev/null
+++ b/src/client/views/graph/GraphManager.ts
@@ -0,0 +1,45 @@
+
+
+import {Graph} from "./Graph";
+import {observable, computed} from 'mobx';
+import { Dictionary } from "typescript-collections";
+import { string } from "prop-types";
+import { Doc } from "../../../new_fields/Doc";
+
+
+export class GraphManager {
+ @observable public Graphs: Graph[] = [];
+
+ @observable public GraphData: Doc = new Doc();
+
+ private static _instance: GraphManager;
+
+ @computed
+ public static get Instance():GraphManager {
+ return this._instance || (this._instance = new this());
+ }
+
+ private constructor(){
+
+ }
+
+
+
+
+ public set addGraph(graph:Graph){
+ this.Graphs.push(graph);
+ }
+
+
+ defaultGraphs = () => {
+ this.GraphData.linear = ;
+ }
+
+
+
+
+
+
+
+
+} \ No newline at end of file
diff --git a/src/client/views/graph/GraphMenu.tsx b/src/client/views/graph/GraphMenu.tsx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/client/views/graph/GraphMenu.tsx
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index c8eab85c2..5a7e96522 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -109,7 +109,7 @@ const schema = createSchema({
nativeHeight: "number",
backgroundColor: "string",
opacity: "number",
- hidden: "boolean"
+ hidden: "boolean",
});
export const positionSchema = createSchema({
@@ -567,6 +567,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
cm.addItem({ description: "Pin to Presentation", event: () => PresentationView.Instance.PinDoc(this.props.Document), icon: "map-pin" });
cm.addItem({ description: BoolCast(this.props.Document.lockedPosition) ? "Unlock Position" : "Lock Position", event: this.toggleLockPosition, icon: BoolCast(this.props.Document.lockedPosition) ? "unlock" : "lock" });
cm.addItem({ description: "Transcribe Speech", event: this.listen, icon: "microphone" });
+ cm.addItem({ description: BoolCast(this.props.Document.isAnimating) ? "Enter Play Mode" : "Enter Authoring Mode", event: () => {BoolCast(this.props.Document.isAnimating) ? this.props.Document.isAnimating = false : this.props.Document.isAnimating = true;}, icon:BoolCast(this.props.Document.isAnimating) ? "play" : "edit"});
let makes: ContextMenuProps[] = [];
makes.push({ description: this.props.Document.isBackground ? "Remove Background" : "Make Background", event: this.makeBackground, icon: BoolCast(this.props.Document.lockedPosition) ? "unlock" : "lock" });
makes.push({ description: this.props.Document.isButton ? "Remove Button" : "Make Button", event: this.makeBtnClicked, icon: "concierge-bell" });
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 44b5d2c21..c5f4490a0 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -182,7 +182,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
const fieldkey = "preview";
if (this.extensionDoc) this.extensionDoc.text = state.doc.textBetween(0, state.doc.content.size, "\n\n");
if (this.extensionDoc) this.extensionDoc.lastModified = new DateField(new Date(Date.now()));
- this.dataDoc[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON()));
+ this.dataDoc[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON()));
this._applyingChange = false;
let title = StrCast(this.dataDoc.title);
if (title && title.startsWith("-") && this._editorView && !this.Document.customTitle) {
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 543ee46cc..3a90824df 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -467,12 +467,13 @@ export namespace Doc {
export function MakeCopy(doc: Doc, copyProto: boolean = false): Doc {
const copy = new Doc;
Object.keys(doc).forEach(key => {
- const field = ProxyField.WithoutProxy(() => doc[key]);
if (key === "proto" && copyProto) {
+ const field = doc[key];
if (field instanceof Doc) {
copy[key] = Doc.MakeCopy(field);
}
} else {
+ const field = ProxyField.WithoutProxy(() => doc[key]);
if (field instanceof RefField) {
copy[key] = field;
} else if (field instanceof ObjectField) {
diff --git a/src/new_fields/RichTextField.ts b/src/new_fields/RichTextField.ts
index 89799b2af..dcd8658ab 100644
--- a/src/new_fields/RichTextField.ts
+++ b/src/new_fields/RichTextField.ts
@@ -15,6 +15,7 @@ export class RichTextField extends ObjectField {
this.Data = data;
}
+
[Copy]() {
return new RichTextField(this.Data);
}