diff options
| author | bob <bcz@cs.brown.edu> | 2020-02-28 17:26:57 -0500 | 
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2020-02-28 17:26:57 -0500 | 
| commit | 64dbb375652338f5d6ddf3f3bcd3d8908aa681ae (patch) | |
| tree | 7ed235f4f42f0cf2b1329385b53c9cc1d8632f1c /src/client/views/DocumentDecorations.tsx | |
| parent | fc945bcf674efe62aad67be8c1f337cd9b8c83e2 (diff) | |
added ctrl-drag to set size of annotation text by changing native size of document
Diffstat (limited to 'src/client/views/DocumentDecorations.tsx')
| -rw-r--r-- | src/client/views/DocumentDecorations.tsx | 21 | 
1 files changed, 16 insertions, 5 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 9c69e6083..4922411e8 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -1,12 +1,12 @@  import { IconProp, library } from '@fortawesome/fontawesome-svg-core';  import { faCaretUp, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faTextHeight, faArrowAltCircleDown, faArrowAltCircleUp, faCheckCircle, faCloudUploadAlt, faLink, faShare, faStopCircle, faSyncAlt, faTag, faTimes } from '@fortawesome/free-solid-svg-icons';  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { action, computed, observable, reaction } from "mobx"; +import { action, computed, observable, reaction, runInAction } from "mobx";  import { observer } from "mobx-react"; -import { Doc } from "../../new_fields/Doc"; +import { Doc, DataSym } from "../../new_fields/Doc";  import { PositionDocument } from '../../new_fields/documentSchemas';  import { ScriptField } from '../../new_fields/ScriptField'; -import { Cast, StrCast } from "../../new_fields/Types"; +import { Cast, StrCast, NumCast } from "../../new_fields/Types";  import { CurrentUserUtils } from '../../server/authentication/models/current_user_utils';  import { Utils, setupMoveUpEvents } from "../../Utils";  import { DocUtils } from "../documents/Documents"; @@ -324,12 +324,23 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>                  const actualdH = Math.max(height + (dH * scale), 20);                  doc.x = (doc.x || 0) + dX * (actualdW - width);                  doc.y = (doc.y || 0) + dY * (actualdH - height); -                const fixedAspect = e.ctrlKey || (nwidth && nheight); +                const fixedAspect = (nwidth && nheight);                  if (fixedAspect && (!nwidth || !nheight)) {                      layoutDoc._nativeWidth = nwidth = layoutDoc._width || 0;                      layoutDoc._nativeHeight = nheight = layoutDoc._height || 0;                  } -                if (nwidth > 0 && nheight > 0) { +                const anno = Cast(doc.annotationOn, Doc, null); +                if (e.ctrlKey && anno) { +                    dW !== 0 && runInAction(() => { +                        const dataDoc = anno[DataSym]; +                        const fieldKey = Doc.LayoutFieldKey(anno); +                        const nw = NumCast(dataDoc[fieldKey + "-nativeWidth"]); +                        const nh = NumCast(dataDoc[fieldKey + "-nativeHeight"]); +                        dataDoc[fieldKey + "-nativeWidth"] = nw + (dW > 0 ? 10 : -10); +                        dataDoc[fieldKey + "-nativeHeight"] = nh + (dW > 0 ? 10 : -10) * nh / nw; +                    }); +                } +                else if (nwidth > 0 && nheight > 0) {                      if (Math.abs(dW) > Math.abs(dH)) {                          if (!fixedAspect) {                              layoutDoc._nativeWidth = actualdW / (layoutDoc._width || 1) * (layoutDoc._nativeWidth || 0);  | 
