diff options
| author | andrewdkim <adkim414@gmail.com> | 2019-11-23 16:30:45 -0500 |
|---|---|---|
| committer | andrewdkim <adkim414@gmail.com> | 2019-11-23 16:30:45 -0500 |
| commit | b5b45c7d8eb9e3056c71d9ca213cca7f2d9c792a (patch) | |
| tree | e6a04ae7ea36d085607a90109e2698db8ac2e034 /src/client/views/InkSelectDecorations.tsx | |
| parent | 8af45ed7f376981ce8f8b1c6d1b2fd3b1546a00e (diff) | |
| parent | 3b37cc31bb09b11238868c34a38a8e99f508479f (diff) | |
merge from master
Diffstat (limited to 'src/client/views/InkSelectDecorations.tsx')
| -rw-r--r-- | src/client/views/InkSelectDecorations.tsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/client/views/InkSelectDecorations.tsx b/src/client/views/InkSelectDecorations.tsx new file mode 100644 index 000000000..d40df9b75 --- /dev/null +++ b/src/client/views/InkSelectDecorations.tsx @@ -0,0 +1,55 @@ +import React = require("react"); +import { Touchable } from "./Touchable"; +import { PointData } from "../../new_fields/InkField"; +import { observer } from "mobx-react"; +import { computed, observable, action, runInAction } from "mobx"; +import "./InkSelectDecorations.scss"; + +@observer +export default class InkSelectDecorations extends Touchable { + static Instance: InkSelectDecorations; + + @observable private _selectedInkNodes: Map<any, any> = new Map(); + + constructor(props: Readonly<{}>) { + super(props); + + InkSelectDecorations.Instance = this; + } + + @action + public SetSelected = (inkNodes: Map<any, any>, keepOld: boolean = false) => { + if (!keepOld) { + this._selectedInkNodes = new Map(); + } + inkNodes.forEach((value: any, key: any) => { + runInAction(() => this._selectedInkNodes.set(key, value)); + }); + } + + @computed + get Bounds(): { x: number, y: number, b: number, r: number } { + let left = Number.MAX_VALUE; + let top = Number.MAX_VALUE; + let right = -Number.MAX_VALUE; + let bottom = -Number.MAX_VALUE; + this._selectedInkNodes.forEach((value: PointData, key: string) => { + // value.pathData.map(val => { + // left = Math.min(val.x, left); + // top = Math.min(val.y, top); + // right = Math.max(val.x, right); + // bottom = Math.max(val.y, bottom); + // }); + }); + return { x: left, y: top, b: bottom, r: right }; + } + + render() { + let bounds = this.Bounds; + return <div style={{ + top: bounds.y, left: bounds.x, + height: bounds.b - bounds.y, + width: bounds.r - bounds.x + }} />; + } +}
\ No newline at end of file |
