aboutsummaryrefslogtreecommitdiff
path: root/src/fields
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields')
-rw-r--r--src/fields/DimensionField.ts29
-rw-r--r--src/fields/Doc.ts25
2 files changed, 54 insertions, 0 deletions
diff --git a/src/fields/DimensionField.ts b/src/fields/DimensionField.ts
new file mode 100644
index 000000000..ffbb9a732
--- /dev/null
+++ b/src/fields/DimensionField.ts
@@ -0,0 +1,29 @@
+import { ObjectField } from "./ObjectField";
+import { Copy, ToJavascriptString, ToScriptString, ToString } from "./FieldSymbols";
+
+export class DimensionField extends ObjectField {
+ width: number;
+ height: number;
+
+ constructor(width: number, height: number) {
+ super();
+ this.width = width;
+ this.height = height;
+ }
+
+ [Copy](): DimensionField {
+ return new DimensionField(this.width, this.height);
+ }
+
+ [ToJavascriptString](): string {
+ return `{ width: ${this.width}, height: ${this.height} }`;
+ }
+
+ [ToScriptString](): string {
+ return `{ width: ${this.width}, height: ${this.height} }`;
+ }
+
+ [ToString](): string {
+ return `${this.width} x ${this.height}`;
+ }
+}
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index fc89dcbe7..dded8ce03 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -468,6 +468,10 @@ export class Doc extends RefField {
}
}
export namespace Doc {
+ export let SelectOnLoad: Doc | undefined;
+ export function SetSelectOnLoad(doc: Doc | undefined) {
+ SelectOnLoad = doc;
+ }
export let DocDragDataName: string = '';
export function SetDocDragDataName(name: string) {
DocDragDataName = name;
@@ -1177,6 +1181,27 @@ export namespace Doc {
const dheight = NumCast((dataDoc || doc)[Doc.LayoutFieldKey(doc) + '_nativeHeight'], useHeight ? NumCast(doc._height) : 0);
return NumCast(doc._nativeHeight, nheight || dheight);
}
+
+
+ export function OutpaintingWidth(doc?: Doc, dataDoc?: Doc, useWidth?: boolean) {
+ return !doc ? 0 : NumCast(doc._outpaintingWidth, NumCast((dataDoc || doc)[Doc.LayoutFieldKey(doc) + '_outpaintingWidth'], useWidth ? NumCast(doc._width) : 0));
+ }
+
+ export function OutpaintingHeight(doc?: Doc, dataDoc?: Doc, useHeight?: boolean) {
+ if (!doc) return 0;
+ const oheight = (Doc.OutpaintingWidth(doc, dataDoc, useHeight) / NumCast(doc._width)) * NumCast(doc._height);
+ const dheight = NumCast((dataDoc || doc)[Doc.LayoutFieldKey(doc) + '_outpaintingHeight'], useHeight ? NumCast(doc._height) : 0);
+ return NumCast(doc._outpaintingHeight, oheight || dheight);
+ }
+
+ export function SetOutpaintingWidth(doc: Doc, width: number | undefined, fieldKey?: string) {
+ doc[(fieldKey || Doc.LayoutFieldKey(doc)) + '_outpaintingWidth'] = width;
+ }
+
+ export function SetOutpaintingHeight(doc: Doc, height: number | undefined, fieldKey?: string) {
+ doc[(fieldKey || Doc.LayoutFieldKey(doc)) + '_outpaintingHeight'] = height;
+ }
+
export function SetNativeWidth(doc: Doc, width: number | undefined, fieldKey?: string) {
doc[(fieldKey || Doc.LayoutFieldKey(doc)) + '_nativeWidth'] = width;
}