aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ImageBox.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-02-22 12:14:27 -0500
committerBob Zeleznik <zzzman@gmail.com>2020-02-22 12:14:27 -0500
commit59e947ad4bd885c4bbf511a19eba64f672a3d76d (patch)
treee58ce78c58a9c0144e24b225c0ea9e0639883be4 /src/client/views/nodes/ImageBox.tsx
parent14a357133b223ecb9a156e6b8b6dfbbe72f14dc5 (diff)
added option to update image native size
Diffstat (limited to 'src/client/views/nodes/ImageBox.tsx')
-rw-r--r--src/client/views/nodes/ImageBox.tsx13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index bb421d315..99000a0a9 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -160,6 +160,19 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum
const funcs: ContextMenuProps[] = [];
funcs.push({ description: "Copy path", event: () => Utils.CopyText(field.url.href), icon: "expand-arrows-alt" });
funcs.push({ description: "Rotate", event: this.rotate, icon: "expand-arrows-alt" });
+ funcs.push({
+ description: "Reset Native Dimensions", event: action(() => {
+ const curNW = NumCast(this.dataDoc[this.props.fieldKey + "-nativeWidth"]);
+ const curNH = NumCast(this.dataDoc[this.props.fieldKey + "-nativeHeight"]);
+ if (this.props.PanelWidth() / this.props.PanelHeight() > curNW / curNH) {
+ this.dataDoc[this.props.fieldKey + "-nativeWidth"] = this.props.PanelHeight() * curNW / curNH;
+ this.dataDoc[this.props.fieldKey + "-nativeHeight"] = this.props.PanelHeight();
+ } else {
+ this.dataDoc[this.props.fieldKey + "-nativeWidth"] = this.props.PanelWidth();
+ this.dataDoc[this.props.fieldKey + "-nativeHeight"] = this.props.PanelWidth() * curNH / curNW;
+ }
+ }), icon: "expand-arrows-alt"
+ });
const existingAnalyze = ContextMenu.Instance.findByDescription("Analyzers...");
const modes: ContextMenuProps[] = existingAnalyze && "subitems" in existingAnalyze ? existingAnalyze.subitems : [];