uicore-ts 1.0.158 → 1.0.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,6 +42,7 @@ export declare class UIRectangle extends UIObject {
|
|
|
42
42
|
rectangleWithY(y: number, centeredOnPosition?: number): UIRectangle;
|
|
43
43
|
rectangleByAddingX(x: number): UIRectangle;
|
|
44
44
|
rectangleByAddingY(y: number): UIRectangle;
|
|
45
|
+
rectangleWithRelativeValues(relativeXPosition: number, widthMultiplier: number, relativeYPosition: number, heightMultiplier: number): UIRectangle;
|
|
45
46
|
rectanglesBySplittingWidth(weights: number[], paddings?: number | number[], absoluteWidths?: number | number[]): UIRectangle[];
|
|
46
47
|
rectanglesBySplittingHeight(weights: number[], paddings?: number | number[], absoluteHeights?: number | number[]): UIRectangle[];
|
|
47
48
|
rectanglesByEquallySplittingWidth(numberOfFrames: number, padding?: number): UIRectangle[];
|
|
@@ -260,6 +260,18 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
260
260
|
result.y = this.y + y;
|
|
261
261
|
return result;
|
|
262
262
|
}
|
|
263
|
+
rectangleWithRelativeValues(relativeXPosition, widthMultiplier, relativeYPosition, heightMultiplier) {
|
|
264
|
+
const result = this.copy();
|
|
265
|
+
const width = result.width;
|
|
266
|
+
const height = result.height;
|
|
267
|
+
result.width = widthMultiplier * width;
|
|
268
|
+
result.height = heightMultiplier * height;
|
|
269
|
+
result.center = new import_UIPoint.UIPoint(
|
|
270
|
+
relativeXPosition * width,
|
|
271
|
+
relativeYPosition * height
|
|
272
|
+
);
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
263
275
|
rectanglesBySplittingWidth(weights, paddings = 0, absoluteWidths = import_UIObject.nil) {
|
|
264
276
|
if ((0, import_UIObject.IS_NIL)(paddings)) {
|
|
265
277
|
paddings = 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIRectangle.ts"],
|
|
4
|
-
"sourcesContent": ["import { FIRST_OR_NIL, IS, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange: (b: any) => void = nil\n max: UIPoint\n min: UIPoint\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n return new UIRectangle(this.x, this.y, this.height, this.width)\n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectanglesBySplittingWidth(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteWidths: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = absoluteWidths[i] || 0\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteHeights: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n var previousCellMaxY = this.y\n \n for (var i = 0; i < weights.length; i++) {\n var resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = absoluteHeights[i] || 0\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n var padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteWidths?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteHeights?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n rectangleForNextRow(padding: number = 0, height = this.height) {\n const result = this.rectangleWithY(this.max.y + padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width = this.width) {\n const result = this.rectangleWithX(this.max.x + padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0) {\n return this.rectangleWithY(this.min.y - this.height - padding)\n }\n \n rectangleForPreviousColumn(padding: number = 0) {\n return this.rectangleWithX(this.min.x - this.width - padding)\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6E;AAC7E,qBAAwB;AAIjB,MAAM,oBAAoB,yBAAS;AAAA,EAQtC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAPV,mCAA4C;AASxC,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,WAAK,yBAAyB;AAAA,IAClC;AACA,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,WAAK,yBAAyB;AAAA,IAClC;AAEA,SAAK,kBAAkB;AAEvB,SAAK,MAAM,IAAI,uBAAQ,GAAG,CAAC;AAC3B,SAAK,MAAM,IAAI,uBAAQ,IAAI,OAAO,IAAI,MAAM;AAE5C,YAAI,wBAAO,MAAM,GAAG;AAChB,WAAK,IAAI,IAAI;AAAA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AA,EAEA,2BAA2B;AACvB,QAAI,CAAC,KAAK,iBAAiB;AACvB,WAAK,UAAU;AAAA,IACnB;AAAA,EACJ;AAGJ;",
|
|
4
|
+
"sourcesContent": ["import { FIRST_OR_NIL, IS, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange: (b: any) => void = nil\n max: UIPoint\n min: UIPoint\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n return new UIRectangle(this.x, this.y, this.height, this.width)\n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectangleWithRelativeValues(\n relativeXPosition: number,\n widthMultiplier: number,\n relativeYPosition: number,\n heightMultiplier: number\n ) {\n \n const result = this.copy()\n \n const width = result.width\n const height = result.height\n \n result.width = widthMultiplier * width\n result.height = heightMultiplier * height\n \n result.center = new UIPoint(\n relativeXPosition * width,\n relativeYPosition * height\n )\n \n return result\n \n }\n \n \n rectanglesBySplittingWidth(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteWidths: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = absoluteWidths[i] || 0\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteHeights: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n var previousCellMaxY = this.y\n \n for (var i = 0; i < weights.length; i++) {\n var resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = absoluteHeights[i] || 0\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n var padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteWidths?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteHeights?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n rectangleForNextRow(padding: number = 0, height = this.height) {\n const result = this.rectangleWithY(this.max.y + padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width = this.width) {\n const result = this.rectangleWithX(this.max.x + padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0) {\n return this.rectangleWithY(this.min.y - this.height - padding)\n }\n \n rectangleForPreviousColumn(padding: number = 0) {\n return this.rectangleWithX(this.min.x - this.width - padding)\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6E;AAC7E,qBAAwB;AAIjB,MAAM,oBAAoB,yBAAS;AAAA,EAQtC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAPV,mCAA4C;AASxC,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,W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;AAAA,IACnB;AACA,WAAO;AAAA,EACX;AAAA,EAEA,wBAAwB,UAAkB,GAAG;AACzC,WAAO,KAAK,eAAe,KAAK,IAAI,IAAI,KAAK,SAAS,OAAO;AAAA,EACjE;AAAA,EAEA,2BAA2B,UAAkB,GAAG;AAC5C,WAAO,KAAK,eAAe,KAAK,IAAI,IAAI,KAAK,QAAQ,OAAO;AAAA,EAChE;AAAA,EAIA,OAAO,qBAAqB,QAAwB;AAChD,UAAM,SAAS,IAAI,YAAY;AAC/B,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,oBAAoB,OAAO,EAAE;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAGA,eAAe;AACX,SAAK,kBAAkB;AAAA,EAC3B;AAAA,EAEA,gBAAgB;AACZ,SAAK,kBAAkB;AACvB,SAAK,UAAU;AAAA,EACnB;AAAA,EAGA,YAAY;AAAA,EAIZ;AAAA,EAEA,2BAA2B;AACvB,QAAI,CAAC,KAAK,iBAAiB;AACvB,WAAK,UAAU;AAAA,IACnB;AAAA,EACJ;AAGJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.172",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
package/scripts/UIRectangle.ts
CHANGED
|
@@ -12,12 +12,12 @@ export class UIRectangle extends UIObject {
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
super()
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)
|
|
19
19
|
this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
this.min.didChange = (point) => {
|
|
22
22
|
this.rectanglePointDidChange(point)
|
|
23
23
|
this._rectanglePointDidChange()
|
|
@@ -26,12 +26,12 @@ export class UIRectangle extends UIObject {
|
|
|
26
26
|
this.rectanglePointDidChange(point)
|
|
27
27
|
this._rectanglePointDidChange()
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
this._isBeingUpdated = NO
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
this.min = new UIPoint(x, y)
|
|
33
33
|
this.max = new UIPoint(x + width, y + height)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
if (IS_NIL(height)) {
|
|
36
36
|
this.max.y = height
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ export class UIRectangle extends UIObject {
|
|
|
39
39
|
if (IS_NIL(width)) {
|
|
40
40
|
this.max.x = width
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
@@ -67,7 +67,7 @@ export class UIRectangle extends UIObject {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
this.beginUpdates()
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
const min = this.min.copy()
|
|
72
72
|
if (min.x === nil) {
|
|
73
73
|
min.x = this.max.x
|
|
@@ -75,7 +75,7 @@ export class UIRectangle extends UIObject {
|
|
|
75
75
|
if (min.y === nil) {
|
|
76
76
|
min.y = this.max.y
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
const max = this.max.copy()
|
|
80
80
|
if (max.x === nil) {
|
|
81
81
|
max.x = this.min.x
|
|
@@ -133,7 +133,7 @@ export class UIRectangle extends UIObject {
|
|
|
133
133
|
set x(x: number) {
|
|
134
134
|
|
|
135
135
|
this.beginUpdates()
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
const width = this.width
|
|
138
138
|
this.min.x = x
|
|
139
139
|
this.max.x = this.min.x + width
|
|
@@ -151,7 +151,7 @@ export class UIRectangle extends UIObject {
|
|
|
151
151
|
set y(y: number) {
|
|
152
152
|
|
|
153
153
|
this.beginUpdates()
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
const height = this.height
|
|
156
156
|
this.min.y = y
|
|
157
157
|
this.max.y = this.min.y + height
|
|
@@ -203,11 +203,11 @@ export class UIRectangle extends UIObject {
|
|
|
203
203
|
|
|
204
204
|
|
|
205
205
|
intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
const result = this.copy()
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
result.beginUpdates()
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
const min = result.min
|
|
212
212
|
if (min.x === nil) {
|
|
213
213
|
min.x = rectangle.max.x - Math.min(result.width, rectangle.width)
|
|
@@ -215,7 +215,7 @@ export class UIRectangle extends UIObject {
|
|
|
215
215
|
if (min.y === nil) {
|
|
216
216
|
min.y = rectangle.max.y - Math.min(result.height, rectangle.height)
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
const max = result.max
|
|
220
220
|
if (max.x === nil) {
|
|
221
221
|
max.x = rectangle.min.x + Math.min(result.width, rectangle.width)
|
|
@@ -231,7 +231,7 @@ export class UIRectangle extends UIObject {
|
|
|
231
231
|
|
|
232
232
|
|
|
233
233
|
if (result.height < 0) {
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
const averageY = (this.center.y + rectangle.center.y) * 0.5
|
|
236
236
|
result.min.y = averageY
|
|
237
237
|
result.max.y = averageY
|
|
@@ -239,7 +239,7 @@ export class UIRectangle extends UIObject {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
if (result.width < 0) {
|
|
242
|
-
|
|
242
|
+
|
|
243
243
|
const averageX = (this.center.x + rectangle.center.x) * 0.5
|
|
244
244
|
result.min.x = averageX
|
|
245
245
|
result.max.x = averageX
|
|
@@ -282,7 +282,7 @@ export class UIRectangle extends UIObject {
|
|
|
282
282
|
if (isNaN(centeredOnPosition)) {
|
|
283
283
|
centeredOnPosition = nil
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
const result = this.copy()
|
|
287
287
|
result.height = height
|
|
288
288
|
|
|
@@ -300,7 +300,7 @@ export class UIRectangle extends UIObject {
|
|
|
300
300
|
if (isNaN(centeredOnPosition)) {
|
|
301
301
|
centeredOnPosition = nil
|
|
302
302
|
}
|
|
303
|
-
|
|
303
|
+
|
|
304
304
|
const result = this.copy()
|
|
305
305
|
result.width = width
|
|
306
306
|
|
|
@@ -322,7 +322,7 @@ export class UIRectangle extends UIObject {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
rectangleWithX(x: number, centeredOnPosition: number = 0) {
|
|
325
|
-
|
|
325
|
+
|
|
326
326
|
const result = this.copy()
|
|
327
327
|
result.x = x - result.width * centeredOnPosition
|
|
328
328
|
|
|
@@ -331,7 +331,7 @@ export class UIRectangle extends UIObject {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
rectangleWithY(y: number, centeredOnPosition: number = 0) {
|
|
334
|
-
|
|
334
|
+
|
|
335
335
|
const result = this.copy()
|
|
336
336
|
result.y = y - result.height * centeredOnPosition
|
|
337
337
|
|
|
@@ -341,7 +341,7 @@ export class UIRectangle extends UIObject {
|
|
|
341
341
|
|
|
342
342
|
|
|
343
343
|
rectangleByAddingX(x: number) {
|
|
344
|
-
|
|
344
|
+
|
|
345
345
|
const result = this.copy()
|
|
346
346
|
result.x = this.x + x
|
|
347
347
|
|
|
@@ -350,7 +350,7 @@ export class UIRectangle extends UIObject {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
rectangleByAddingY(y: number) {
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
const result = this.copy()
|
|
355
355
|
result.y = this.y + y
|
|
356
356
|
|
|
@@ -359,12 +359,37 @@ export class UIRectangle extends UIObject {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
|
|
362
|
+
rectangleWithRelativeValues(
|
|
363
|
+
relativeXPosition: number,
|
|
364
|
+
widthMultiplier: number,
|
|
365
|
+
relativeYPosition: number,
|
|
366
|
+
heightMultiplier: number
|
|
367
|
+
) {
|
|
368
|
+
|
|
369
|
+
const result = this.copy()
|
|
370
|
+
|
|
371
|
+
const width = result.width
|
|
372
|
+
const height = result.height
|
|
373
|
+
|
|
374
|
+
result.width = widthMultiplier * width
|
|
375
|
+
result.height = heightMultiplier * height
|
|
376
|
+
|
|
377
|
+
result.center = new UIPoint(
|
|
378
|
+
relativeXPosition * width,
|
|
379
|
+
relativeYPosition * height
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
return result
|
|
383
|
+
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
362
387
|
rectanglesBySplittingWidth(
|
|
363
388
|
weights: number[],
|
|
364
389
|
paddings: number | number[] = 0,
|
|
365
390
|
absoluteWidths: number | number[] = nil
|
|
366
391
|
) {
|
|
367
|
-
|
|
392
|
+
|
|
368
393
|
if (IS_NIL(paddings)) {
|
|
369
394
|
paddings = 1
|
|
370
395
|
}
|
|
@@ -375,7 +400,7 @@ export class UIRectangle extends UIObject {
|
|
|
375
400
|
if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {
|
|
376
401
|
absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)
|
|
377
402
|
}
|
|
378
|
-
|
|
403
|
+
|
|
379
404
|
const result: UIRectangle[] = []
|
|
380
405
|
const sumOfWeights = weights.reduce(
|
|
381
406
|
(a, b, index) => {
|
|
@@ -390,9 +415,9 @@ export class UIRectangle extends UIObject {
|
|
|
390
415
|
const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue
|
|
391
416
|
const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths
|
|
392
417
|
let previousCellMaxX = this.x
|
|
393
|
-
|
|
394
|
-
for (let i = 0; i < weights.length; i++) {
|
|
395
418
|
|
|
419
|
+
for (let i = 0; i < weights.length; i++) {
|
|
420
|
+
|
|
396
421
|
let resultWidth: number
|
|
397
422
|
if (IS_NOT_NIL(absoluteWidths[i])) {
|
|
398
423
|
resultWidth = absoluteWidths[i] || 0
|
|
@@ -400,18 +425,18 @@ export class UIRectangle extends UIObject {
|
|
|
400
425
|
else {
|
|
401
426
|
resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)
|
|
402
427
|
}
|
|
403
|
-
|
|
428
|
+
|
|
404
429
|
const rectangle = this.rectangleWithWidth(resultWidth)
|
|
405
|
-
|
|
430
|
+
|
|
406
431
|
let padding = 0
|
|
407
432
|
if (paddings.length > i && paddings[i]) {
|
|
408
433
|
padding = paddings[i]
|
|
409
434
|
}
|
|
410
|
-
|
|
435
|
+
|
|
411
436
|
rectangle.x = previousCellMaxX
|
|
412
437
|
previousCellMaxX = rectangle.max.x + padding
|
|
413
438
|
result.push(rectangle)
|
|
414
|
-
|
|
439
|
+
|
|
415
440
|
}
|
|
416
441
|
|
|
417
442
|
return result
|
|
@@ -423,7 +448,7 @@ export class UIRectangle extends UIObject {
|
|
|
423
448
|
paddings: number | number[] = 0,
|
|
424
449
|
absoluteHeights: number | number[] = nil
|
|
425
450
|
) {
|
|
426
|
-
|
|
451
|
+
|
|
427
452
|
if (IS_NIL(paddings)) {
|
|
428
453
|
paddings = 1
|
|
429
454
|
}
|
|
@@ -434,7 +459,7 @@ export class UIRectangle extends UIObject {
|
|
|
434
459
|
if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {
|
|
435
460
|
absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)
|
|
436
461
|
}
|
|
437
|
-
|
|
462
|
+
|
|
438
463
|
const result: UIRectangle[] = []
|
|
439
464
|
const sumOfWeights = weights.reduce(
|
|
440
465
|
(a, b, index) => {
|
|
@@ -449,11 +474,11 @@ export class UIRectangle extends UIObject {
|
|
|
449
474
|
const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue
|
|
450
475
|
const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights
|
|
451
476
|
var previousCellMaxY = this.y
|
|
452
|
-
|
|
477
|
+
|
|
453
478
|
for (var i = 0; i < weights.length; i++) {
|
|
454
479
|
var resultHeight: number
|
|
455
480
|
if (IS_NOT_NIL(absoluteHeights[i])) {
|
|
456
|
-
|
|
481
|
+
|
|
457
482
|
resultHeight = absoluteHeights[i] || 0
|
|
458
483
|
|
|
459
484
|
}
|
|
@@ -462,9 +487,9 @@ export class UIRectangle extends UIObject {
|
|
|
462
487
|
resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)
|
|
463
488
|
|
|
464
489
|
}
|
|
465
|
-
|
|
490
|
+
|
|
466
491
|
const rectangle = this.rectangleWithHeight(resultHeight)
|
|
467
|
-
|
|
492
|
+
|
|
468
493
|
var padding = 0
|
|
469
494
|
if (paddings.length > i && paddings[i]) {
|
|
470
495
|
padding = paddings[i]
|