diff options
| author | Stanley Yip <stanley_yip@brown.edu> | 2019-10-19 15:38:50 -0400 |
|---|---|---|
| committer | Stanley Yip <stanley_yip@brown.edu> | 2019-10-19 15:38:50 -0400 |
| commit | fe673d8cc7073b5bbe94efde6ef3346364ad1c58 (patch) | |
| tree | 463781adc044a651643b043f58dafe021b491b92 /src/client/views/collections/CollectionStaffView.tsx | |
| parent | 462cd06a1bff6e510132a4434a72fd7b4245cfdf (diff) | |
staff view added
Diffstat (limited to 'src/client/views/collections/CollectionStaffView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionStaffView.tsx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/client/views/collections/CollectionStaffView.tsx b/src/client/views/collections/CollectionStaffView.tsx new file mode 100644 index 000000000..5b1224b96 --- /dev/null +++ b/src/client/views/collections/CollectionStaffView.tsx @@ -0,0 +1,65 @@ +import { CollectionSubView } from "./CollectionSubView"; +import { InkingCanvas } from "../InkingCanvas"; +import { Transform } from "../../util/Transform"; +import React = require("react") +import { computed, action, IReactionDisposer, reaction, runInAction, observable } from "mobx"; +import { Doc, HeightSym } from "../../../new_fields/Doc"; +import { NumCast } from "../../../new_fields/Types"; +import "./CollectionStaffView.scss"; +import { observer } from "mobx-react"; + +@observer +export class CollectionStaffView extends CollectionSubView(doc => doc) { + private getTransform = (): Transform => this.props.ScreenToLocalTransform().translate(0, -this._mainCont.current!.scrollTop); + private _mainCont = React.createRef<HTMLDivElement>(); + private _reactionDisposer: IReactionDisposer | undefined; + @observable private _staves = NumCast(this.props.Document.staves); + + componentDidMount = () => { + this._reactionDisposer = reaction( + () => NumCast(this.props.Document.staves), + (staves) => runInAction(() => this._staves = staves) + ); + + this.props.Document.staves = 5; + } + + @computed get fieldExtensionDoc() { + return Doc.fieldExtensionDoc(this.props.DataDoc || this.props.Document, this.props.fieldKey); + } + + @computed get addStaffButton() { + return <div onPointerDown={this.addStaff}>+</div>; + } + + @computed get staves() { + let staves = []; + for (let i = 0; i < this._staves; i++) { + let rows = []; + for (let j = 0; j < 5; j++) { + rows.push(<div key={`staff-${i}-${j}`} className="collectionStaffView-line"></div>) + } + staves.push(<div key={`staff-${i}`} className="collectionStaffView-staff"> + {rows} + </div>); + } + return staves; + } + + @action + addStaff = (e: React.PointerEvent) => { + this.props.Document.staves = this._staves + 1; + } + + render() { + return ( + <div className="collectionStaffView" ref={this._mainCont}> + <InkingCanvas getScreenTransform={this.getTransform} Document={this.props.Document} AnnotationDocument={this.fieldExtensionDoc} inkFieldKey={"ink"} > + {() => []} + </InkingCanvas> + {this.staves} + {this.addStaffButton} + </div> + ) + } +}
\ No newline at end of file |
