diff options
author | bob <bcz@cs.brown.edu> | 2019-04-18 15:57:25 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-04-18 15:57:25 -0400 |
commit | 80c7baeaa82697428730a24382f660d82ca209b6 (patch) | |
tree | 65c8a8ede9ab067b1d0babb127554e204128b888 /src/client/views/nodes/DocumentView.tsx | |
parent | 95dff75290edc9b13e9741eefe2bc5851a60dde6 (diff) |
icons
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index af52e44e1..3ada3252c 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -222,11 +222,12 @@ export class DocumentView extends React.Component<DocumentViewProps> { } @action - public minimize = (): void => { + public minimize = (where: number[]): void => { this.props.Document.SetBoolean(KeyStore.Minimized, true); - this.props.Document.SetNumber(KeyStore.MinimizedX, 0); - this.props.Document.SetNumber(KeyStore.MinimizedY, 0); - SelectionManager.DeselectAll(); + if (where[0] !== 0 || where[1] !== 0) + this.props.Document.SetNumber(KeyStore.MinimizedX, where[0]); + if (where[1] !== 0 || where[0] !== 0) + this.props.Document.SetNumber(KeyStore.MinimizedY, where[1]); } @undoBatch @@ -294,7 +295,7 @@ export class DocumentView extends React.Component<DocumentViewProps> { } e.preventDefault(); - !this.isMinimized() && ContextMenu.Instance.addItem({ description: "Minimize", event: this.minimize }); + !this.isMinimized() && ContextMenu.Instance.addItem({ description: "Minimize", event: () => this.minimize([0, 0]) }); ContextMenu.Instance.addItem({ description: "Full Screen", event: this.fullScreenClicked }); ContextMenu.Instance.addItem({ description: "Fields", event: this.fieldsClicked }); ContextMenu.Instance.addItem({ description: "Center", event: () => this.props.focus(this.props.Document) }); @@ -309,7 +310,7 @@ export class DocumentView extends React.Component<DocumentViewProps> { } @action - expand = () => this.props.Document.SetBoolean(KeyStore.Minimized, false) + expand = (e: React.MouseEvent) => { this.props.Document.SetBoolean(KeyStore.Minimized, false); SelectionManager.SelectDoc(this, e.ctrlKey); } isMinimized = () => this.props.Document.GetBoolean(KeyStore.Minimized, false); isSelected = () => SelectionManager.IsSelected(this); select = (ctrlPressed: boolean) => SelectionManager.SelectDoc(this, ctrlPressed); @@ -318,20 +319,26 @@ export class DocumentView extends React.Component<DocumentViewProps> { @computed get nativeHeight() { return this.props.Document.GetNumber(KeyStore.NativeHeight, 0); } @computed get contents() { return (<DocumentContentsView {...this.props} isSelected={this.isSelected} select={this.select} layoutKey={KeyStore.Layout} />); } + @computed get minimizedIcon() { + let button = this.layout.indexOf("PDFBox") !== -1 ? faFilePdf : + this.layout.indexOf("ImageBox") !== -1 ? faImage : + this.layout.indexOf("Formatted") !== -1 ? faStickyNote : + this.layout.indexOf("Video") !== -1 ? faFilm : + this.layout.indexOf("Collection") !== -1 ? faObjectGroup : + faCaretUp; + return <FontAwesomeIcon icon={button} style={{ width: MINIMIZED_ICON_SIZE, height: MINIMIZED_ICON_SIZE }} className="documentView-minimizedIcon" /> + } + render() { var scaling = this.props.ContentScaling(); var nativeHeight = this.nativeHeight > 0 ? this.nativeHeight.toString() + "px" : "100%"; var nativeWidth = this.nativeWidth > 0 ? this.nativeWidth.toString() + "px" : "100%"; if (this.isMinimized()) { - let button = this.layout.indexOf("PDFBox") !== -1 ? faFilePdf : - this.layout.indexOf("ImageBox") !== -1 ? faImage : - this.layout.indexOf("Formatted") !== -1 ? faStickyNote : - this.layout.indexOf("Collection") !== -1 ? faObjectGroup : - faCaretUp; - return <div className="minimized-box" ref={this._mainCont} onClick={this.expand} onDrop={this.onDrop} onPointerDown={this.onPointerDown} > - <FontAwesomeIcon icon={button} style={{ width: MINIMIZED_ICON_SIZE, height: MINIMIZED_ICON_SIZE }} className="documentView-minimizedIcon" /> - </div> + return ( + <div className="minimized-box" ref={this._mainCont} onClick={this.expand} onDrop={this.onDrop} onPointerDown={this.onPointerDown} > + {this.minimizedIcon} + </div>); } return ( <div className={`documentView-node${this.props.isTopMost ? "-topmost" : ""}`} |