UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

691 lines 33.6 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; import { EventWithAutoSenderArg, EventWithSenderArg } from "@aurigma/design-atoms-model/EventObject"; import { ItemHandler } from "./ItemHandler"; import { ContentType } from "./ContentType"; import { Graphics } from "../Graphics"; import { WrappingMode } from "@aurigma/design-atoms-model/Product/Items"; import { RotatedRectangleF, PointF, RectangleF, EqualsOfFloatNumbers, Path } from "@aurigma/design-atoms-model/Math"; import { PathHandler } from "./PathHandler"; var BaseRectangleItemHandler = /** @class */ (function (_super) { __extends(BaseRectangleItemHandler, _super); function BaseRectangleItemHandler(left, top, width, height, item, _textWhizz, colorPreviewService) { if (_textWhizz === void 0) { _textWhizz = null; } var _this = _super.call(this, item) || this; _this._textWhizz = _textWhizz; _this._transformChanging = new EventWithAutoSenderArg(_this); _this._violationWarningButtonClickEvent = new EventWithSenderArg(); _this._violationWarningButtonClick = new EventWithSenderArg(); _this._doubleClickEvent = new EventWithSenderArg(); _this._clickEvent = new EventWithSenderArg(); _this._onColorPreviewLoaded = function (args) { var _a; _this._colorPreviewService.unsubscribeFromPreviewLoaded(args.color, _this._onColorPreviewLoaded); (_a = _this.canvas) === null || _a === void 0 ? void 0 : _a.redraw(); _this._dispatchReadyEvent(); }; _this._applyMatrix = function (matrix, finished, newAngle) { if (newAngle === void 0) { newAngle = null; } _this.setRectangle(_this.rectangle.transformByMatrix(matrix, newAngle), !finished); }; var l = (left) ? left : 0; var t = (top) ? top : 0; var w = (width) ? width : 0; var h = (height) ? height : 0; _this._controlPoints = [new PointF(l, t), new PointF(l + w, t + h)]; _this._allowNegativeResize = false; _this._selectionTolerance = 0; _this._violationWarningButton = null; _this._violationWarningButtonClickHandler = _this._onViolationWarningButtonClick.bind(_this); _this._colorPreviewService = colorPreviewService; _this._violationContainer = null; _this._updateVectorMaskCenterSync(); return _this; } Object.defineProperty(BaseRectangleItemHandler.prototype, "allowNegativeResize", { get: function () { return this._allowNegativeResize; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "transformChanging", { get: function () { return this._transformChanging; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "rectangle", { get: function () { return this._getRectangle(); }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "bounds", { get: function () { var r = this.rectangle; var margin = this._getBoundsMargin(); r.width += r.width > 0 ? margin : -margin; r.height += r.height > 0 ? margin : -margin; return r.bounds; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "drawingRectangle", { get: function () { return this.rectangle; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "angle", { get: function () { return this.item.transform.angle; }, set: function (angle) { this.item.transform.setAngle(angle); }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "height", { get: function () { return this.rectangle.height; }, set: function (height) { var r = this.rectangle; r.height = height; this.setRectangle(r); }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "width", { get: function () { return this.rectangle.width; }, set: function (width) { var r = this.rectangle; r.width = width; this.setRectangle(r); }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "startRectangle", { get: function () { return this._startRectangle != null ? this._startRectangle : null; }, enumerable: true, configurable: true }); BaseRectangleItemHandler.transformRectangleByTwoRectanglesDiff = function (rectangle, startRectangle, endRectangle) { var transform = endRectangle.getTransform(startRectangle); var angle = transform.angle; var scaleX = transform.scaleX; var scaleY = transform.scaleY; if (!EqualsOfFloatNumbers(endRectangle.angle, 0)) rectangle.rotateAt(-endRectangle.angle, startRectangle.center); if (!EqualsOfFloatNumbers(scaleX, 1) || !EqualsOfFloatNumbers(scaleY, 1)) { //Swap scales if the angle is 90 or 270 //TODO FIXIT var swapScales = false; rectangle.width = rectangle.width * (swapScales ? scaleY : scaleX); rectangle.height = rectangle.height * (swapScales ? scaleX : scaleY); rectangle.centerX = endRectangle.centerX + (rectangle.centerX - startRectangle.centerX) * scaleX; rectangle.centerY = endRectangle.centerY + (rectangle.centerY - startRectangle.centerY) * scaleY; } else { rectangle.centerX += transform.translateX; rectangle.centerY += transform.translateY; } if (!EqualsOfFloatNumbers(endRectangle.angle, 0)) rectangle.rotateAt(endRectangle.angle, endRectangle.center); if (!EqualsOfFloatNumbers(angle, 0)) { var center = rectangle.center; center.rotateAt(angle, startRectangle.center); rectangle.angle = rectangle.angle + angle; rectangle.center = center; } return rectangle; }; BaseRectangleItemHandler.prototype.setRectangle = function (rectangle, supressOnChanged) { var controlBounds = RotatedRectangleF.fromRectangleF(this.getControlBounds()); var transform = rectangle.getTransform(controlBounds); this.item.setTransform(transform, supressOnChanged); }; BaseRectangleItemHandler.prototype.getControlBounds = function () { var maxX = Math.max(this._controlPoints[0].x, this._controlPoints[1].x); var maxY = Math.max(this._controlPoints[0].y, this._controlPoints[1].y); var minX = Math.min(this._controlPoints[0].x, this._controlPoints[1].x); var minY = Math.min(this._controlPoints[0].y, this._controlPoints[1].y); var width = maxX - minX; var height = maxY - minY; return new RectangleF(minX, minY, width, height); }; BaseRectangleItemHandler.prototype.getControlCenter = function () { var r = this.getControlBounds(); var centerX = r.left + (r.width / 2); var centerY = r.top + (r.height / 2); return new PointF(centerX, centerY); }; BaseRectangleItemHandler.prototype.transformByMatrix = function (matrix, finished, newAngle) { if (newAngle === void 0) { newAngle = null; } if (!finished && this._startRectangle == null) { this.startTransform(); } this._applyMatrix(matrix, finished, newAngle); this.transformChanged(); if (finished && this._startRectangle != null) { var rectangle = this.rectangle; var changed = !rectangle.equals(this._startRectangle); var resized = !EqualsOfFloatNumbers(rectangle.width, this._startRectangle.width) || !EqualsOfFloatNumbers(rectangle.height, this._startRectangle.height); if (resized) this.onResized(); this._endTransform(changed, resized, true); this._startRectangle = null; } var canvas = this.canvas; if (canvas != null) { this.updateViolationContainerPosition(); canvas.redraw(); } if (this.item.parentGroupItem != null) this.raiseChanging(this.item); else this._throttleSizeChanging(); }; BaseRectangleItemHandler.prototype.getTransformedRectangle = function (relativeToPrintArea, withMargins) { if (relativeToPrintArea === void 0) { relativeToPrintArea = true; } var transformedRectangle = this.rectangle; var printAreaBounds = this._getPrintAreaBounds(); if (printAreaBounds != null && relativeToPrintArea) transformedRectangle.location = transformedRectangle.location.translate(-printAreaBounds.left, -printAreaBounds.top); if (withMargins) { var margin = this.getBorderMargin(); transformedRectangle.width += margin * 2; transformedRectangle.height += margin * 2; } return transformedRectangle; }; BaseRectangleItemHandler.prototype.setTransformedRectangle = function (value, suppressOnChanged) { this.setRectangle(value, suppressOnChanged); }; BaseRectangleItemHandler.prototype.getTextWrappingPath = function () { return this.item.textWrappingMode !== WrappingMode.None ? Path.rotatedRectangle(this.rectangle) : null; }; BaseRectangleItemHandler.prototype.setLocation = function (location) { var r = this.rectangle; r.location = location; this.setRectangle(r); }; BaseRectangleItemHandler.prototype.onTextWhizzInit = function () { this._updateVectorMaskCenter(); }; BaseRectangleItemHandler.prototype.hitTest = function (point) { return this.canvas.hitTestManager.hitTestSelection(this._getHighlightRectangle(), point); }; BaseRectangleItemHandler.prototype.addViolationWarningButtonClick = function (handler) { this._violationWarningButtonClick.add(handler); }; BaseRectangleItemHandler.prototype.removeViolationWarningButtonClick = function (handler) { this._violationWarningButtonClick.remove(handler); }; BaseRectangleItemHandler.prototype.getViolationWarningButton = function () { return this._violationWarningButton; }; BaseRectangleItemHandler.prototype.setViolationWarningButton = function (value) { this._violationWarningButton = value; }; BaseRectangleItemHandler.prototype.getViolationWarningButtonClickHandler = function () { return this._violationWarningButtonClickHandler; }; BaseRectangleItemHandler.prototype.getViolationContainer = function () { return this._violationContainer; }; BaseRectangleItemHandler.prototype.setViolationContainer = function (value) { this._violationContainer = value; }; BaseRectangleItemHandler.prototype.getViolationWarningButtonElement = function () { return this._violationWarningButton; }; BaseRectangleItemHandler.prototype.transformRectangle = function (startRectangle, endRectangle, highlightOnly) { if (highlightOnly === void 0) { highlightOnly = false; } this._onTransformRectangle(startRectangle, endRectangle, highlightOnly); this.updateViolationContainerPosition(); if (this.item.parentGroupItem != null) this.raiseChanging(this.item); else this._throttleSizeChanging(); }; BaseRectangleItemHandler.prototype.startTransform = function (operation) { _super.prototype.startTransform.call(this, operation); this._startRectangle = this.rectangle; if (this.canvas != null) this.canvas.updateViolationContainer(this, false); }; BaseRectangleItemHandler.prototype.endTransform = function (changed, resized, supressOnChanged) { if (supressOnChanged === void 0) { supressOnChanged = false; } _super.prototype.endTransform.call(this, changed, resized, supressOnChanged); this._endTransform(changed, resized, supressOnChanged); }; BaseRectangleItemHandler.prototype.transformChanged = function () { _super.prototype.transformChanged.call(this); this.updateViolationContainerPosition(); }; BaseRectangleItemHandler.prototype.onResized = function () { delete this._startRectangle; return true; }; BaseRectangleItemHandler.prototype.dispatchDoubleClickEvent = function (e) { this._doubleClickEvent.notify(this, e); }; BaseRectangleItemHandler.prototype.addDoubleClick = function (handler) { this._doubleClickEvent.add(handler); }; BaseRectangleItemHandler.prototype.removeDoubleClick = function (handler) { this._doubleClickEvent.remove(handler); }; BaseRectangleItemHandler.prototype.dispatchClickEvent = function (e) { this._clickEvent.notify(e); }; BaseRectangleItemHandler.prototype.addClick = function (handler) { this._clickEvent.add(handler); }; BaseRectangleItemHandler.prototype.removeClick = function (handler) { this._clickEvent.remove(handler); }; BaseRectangleItemHandler.prototype.getHighlightRectangles = function (options) { if (options === void 0) { options = { includeChildren: true, includeParent: true }; } return [this._getHighlightRectangle()]; }; BaseRectangleItemHandler.prototype.getSelectionRectangle = function () { if (!this.isVisible()) return null; return this.rectangle; }; BaseRectangleItemHandler.prototype.getBorderMargin = function () { return this._getBoundsMargin() / 2; }; BaseRectangleItemHandler.prototype.getSelectionTolerance = function () { return this._selectionTolerance; }; BaseRectangleItemHandler.prototype.showDeleteToolbarButton = function () { return this.getPermissions().allowDelete && this.getPermissions().showDeleteToolbarButton; }; BaseRectangleItemHandler.prototype.showHandleToolbarButton = function () { return false; }; BaseRectangleItemHandler.prototype.showEditToolbarButton = function () { return this.getPermissions().showEditToolbarButton; }; BaseRectangleItemHandler.prototype.showSelectToolbarButton = function () { return this.getPermissions().showSelectToolbarButton; }; BaseRectangleItemHandler.prototype.updateViolationContainerPosition = function () { var _a; (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.updateViolationContainerPosition(this); }; BaseRectangleItemHandler.prototype.isGoodViolationIcon = function () { if (this._violationWarningButton == null) return false; var goodIconCssClass = this.canvas.goodViolationIconCssClass; return this._violationWarningButton.classList.contains(goodIconCssClass); }; BaseRectangleItemHandler.prototype.setGoodViolationIcon = function (title) { if (this._violationWarningButton == null) return false; this._showViolationButton(); if (title != null) this._violationWarningButton.title = title; if (this.isGoodViolationIcon()) return; var canvas = this.canvas; var goodIconCssClass = canvas.goodViolationIconCssClass; var warningIconCssClass = canvas.warningViolationIconCssClass; var badIconCssClass = canvas.badViolationIconCssClass; this._violationWarningButton.classList.remove(warningIconCssClass); this._violationWarningButton.classList.remove(badIconCssClass); this._violationWarningButton.classList.add(goodIconCssClass); this._violationWarningButton.classList.toggle("active", canvas.isOnlyThisItemHandlerSelected(this)); }; BaseRectangleItemHandler.prototype.isWarningViolationIcon = function () { if (this._violationWarningButton == null) return false; var warningIconCssClass = this.canvas.warningViolationIconCssClass; return this._violationWarningButton.classList.contains(warningIconCssClass); }; BaseRectangleItemHandler.prototype.setWarningViolationIcon = function (title) { if (this._violationWarningButton == null) return; this._showViolationButton(); if (title != null) this._violationWarningButton.title = title; if (this.isWarningViolationIcon()) return; var canvas = this.canvas; var goodIconCssClass = canvas.goodViolationIconCssClass; var warningIconCssClass = canvas.warningViolationIconCssClass; var badIconCssClass = canvas.badViolationIconCssClass; this._violationWarningButton.classList.remove(goodIconCssClass); this._violationWarningButton.classList.remove(badIconCssClass); this._violationWarningButton.classList.add(warningIconCssClass); this._violationWarningButton.classList.toggle("active", canvas.isOnlyThisItemHandlerSelected(this)); }; BaseRectangleItemHandler.prototype.isBadViolationIcon = function () { if (this._violationWarningButton == null) return false; var badIconCssClass = this.canvas.badViolationIconCssClass; return this._violationWarningButton.classList.contains(badIconCssClass); }; BaseRectangleItemHandler.prototype.setBadViolationIcon = function (title) { if (this._violationWarningButton == null) return; this._showViolationButton(); if (title != null) this._violationWarningButton.title = title; if (this.isBadViolationIcon()) return; var canvas = this.canvas; var goodIconCssClass = canvas.goodViolationIconCssClass; var warningIconCssClass = canvas.warningViolationIconCssClass; var badIconCssClass = canvas.badViolationIconCssClass; this._violationWarningButton.classList.remove(goodIconCssClass); this._violationWarningButton.classList.remove(warningIconCssClass); this._violationWarningButton.classList.add(badIconCssClass); this._violationWarningButton.classList.toggle("active", canvas.isOnlyThisItemHandlerSelected(this)); }; BaseRectangleItemHandler.prototype.isNoneViolationIcon = function () { if (this._violationWarningButton == null) return false; var canvas = this.canvas; var goodIconCssClass = canvas.goodViolationIconCssClass; var warningIconCssClass = canvas.warningViolationIconCssClass; var badIconCssClass = canvas.badViolationIconCssClass; var isButtonHasViClass = this._violationWarningButton.classList.contains(goodIconCssClass) || this._violationWarningButton.classList.contains(warningIconCssClass) || this._violationWarningButton.classList.contains(badIconCssClass); return this._violationWarningButton.style.visibility === "hidden" || !isButtonHasViClass; }; BaseRectangleItemHandler.prototype.setNoneViolationIcon = function () { if (this._violationWarningButton == null) return; var canvas = this.canvas; var goodIconCssClass = canvas.goodViolationIconCssClass; var warningIconCssClass = canvas.warningViolationIconCssClass; var badIconCssClass = canvas.badViolationIconCssClass; this._violationWarningButton.classList.remove(goodIconCssClass); this._violationWarningButton.classList.remove(warningIconCssClass); this._violationWarningButton.classList.remove(badIconCssClass); this._violationWarningButton.style.visibility = "hidden"; }; BaseRectangleItemHandler.prototype._isReady = function () { return this._areColorPreviewsReady; }; Object.defineProperty(BaseRectangleItemHandler.prototype, "_areColorPreviewsReady", { get: function () { return true; }, enumerable: true, configurable: true }); Object.defineProperty(BaseRectangleItemHandler.prototype, "_isReadyToDraw", { get: function () { return true; }, enumerable: true, configurable: true }); BaseRectangleItemHandler.prototype._updateImpl = function (beforeUpdate, afterUpdate) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { this._updateViolationContainersVisibility(); return [2 /*return*/]; }); }); }; BaseRectangleItemHandler.prototype._getItemColorPreviews = function () { return {}; }; BaseRectangleItemHandler.prototype._getHighlightRectangle = function () { var rect = this.rectangle; var margin = parseInt(this._getBoundsMargin().toString()); rect.width += rect.width >= 0 ? margin : -margin; rect.height += rect.height >= 0 ? margin : -margin; return rect; }; BaseRectangleItemHandler.prototype._updateVisibility = function () { this._updateViolationContainersVisibility(); }; BaseRectangleItemHandler.prototype._onViolationWarningButtonClick = function (e) { this._violationWarningButtonClick.notify(this, e); e.preventDefault(); }; BaseRectangleItemHandler.prototype._updateViolationContainersVisibility = function () { var _a; (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.updateViolationContainer(this, false); }; BaseRectangleItemHandler.prototype._endTransform = function (changed, resized, supressOnChanged) { if (supressOnChanged === void 0) { supressOnChanged = false; } if (!supressOnChanged && changed && (resized || this._startRectangle != null)) this._itemPropertyChangedEvent.notify(this, "transform"); if (!changed || !resized) delete this._startRectangle; var canvas = this.canvas; if (canvas != null) { canvas.updateViolationContainer(this, true); } }; BaseRectangleItemHandler.prototype._calculateTransformedRectangle = function (startRectangle, endRectangle) { var newRectangle; if (this._startRectangle.equals(startRectangle)) { newRectangle = endRectangle.clone(); } else { var rectangle = this._startRectangle.clone(); newRectangle = BaseRectangleItemHandler.transformRectangleByTwoRectanglesDiff(rectangle, startRectangle, endRectangle); } return newRectangle; }; BaseRectangleItemHandler.prototype._onTransformRectangle = function (startRectangle, endRectangle, highlightOnly) { //Transform rectangle relatively global start and end rectangles if (startRectangle == null || endRectangle == null || this._startRectangle == null) return; var newRectangle = this._calculateTransformedRectangle(startRectangle, endRectangle); this.setRectangle(newRectangle, true); }; BaseRectangleItemHandler.prototype._onAddedOnCanvas = function (canvas, supressUpdate) { //TODO: fix and move to descendants _super.prototype._onAddedOnCanvas.call(this, canvas, supressUpdate); if (canvas == null) return; if (this["_contentType"] == null || this["_contentType"] === ContentType.NotContent) { canvas.addViolationContainer(this); } this._updateVectorMaskCenter(); }; BaseRectangleItemHandler.prototype._onRemovedFromCanvas = function (canvas) { _super.prototype._onRemovedFromCanvas.call(this, canvas); if (canvas != null) { canvas.removeViolationContainer(this); } }; BaseRectangleItemHandler.prototype._getRectangle = function () { var rectangle = RotatedRectangleF.fromRectangleF(this.getControlBounds()); rectangle.setTransform(this.item.transform); return rectangle; }; BaseRectangleItemHandler.prototype._getBoundsMargin = function () { return 0; }; BaseRectangleItemHandler.prototype._clip = function (itemHandlerCtx) { if (this._hasVectorMask()) { var clippingPath = this._getTransformedClippingPath(); if (clippingPath != null) Graphics.clipPath(itemHandlerCtx, clippingPath); } }; BaseRectangleItemHandler.prototype._onItemPropertyChanged = function (sender, propertyName) { switch (propertyName) { case "opacity": case "transform": break; case "locked": this._updateVisibility(); break; case "textWrappingMode": if (this.canvas != null) this.canvas.updateTexts(); break; case "mask": this._updateVectorMaskCenter(); break; case "violationSettings": this.canvas.updateViolationContainer(this); break; default: } _super.prototype._onItemPropertyChanged.call(this, sender, propertyName); }; BaseRectangleItemHandler.prototype._onItemVisibilityChanged = function () { _super.prototype._onItemVisibilityChanged.call(this); this._updateVisibility(); }; BaseRectangleItemHandler.prototype._updateVectorMaskCenter = function () { return __awaiter(this, void 0, void 0, function () { var bounds; return __generator(this, function (_a) { switch (_a.label) { case 0: if (!this._hasVectorMask()) return [3 /*break*/, 2]; return [4 /*yield*/, PathHandler.getBounds(this.item.mask.vectorMask)]; case 1: bounds = _a.sent(); this._vectorMaskCenter = RotatedRectangleF.fromRectangleF(bounds).center; return [3 /*break*/, 3]; case 2: this._vectorMaskCenter = null; _a.label = 3; case 3: return [2 /*return*/]; } }); }); }; BaseRectangleItemHandler.prototype._updateVectorMaskCenterSync = function () { if (this._hasVectorMask()) { var bounds = PathHandler.getBoundsSync(this.item.mask.vectorMask); if (bounds == null) return; this._vectorMaskCenter = RotatedRectangleF.fromRectangleF(bounds).center; } else { this._vectorMaskCenter = null; } }; BaseRectangleItemHandler.prototype._getTransformedClippingPath = function (transform) { if (!this._hasVectorMask() || this._vectorMaskCenter == null) return null; if (transform == null) transform = this.item.transform.clone(); var mask = this.item.mask; var path = mask.vectorMask.clone(); var center = this._vectorMaskCenter; var controlCenter = this.getControlCenter(); if (transform.angle !== 0) { path.rotateAt(transform.angle, controlCenter); transform.setAngle(0, true); } if (!EqualsOfFloatNumbers(transform.scaleX, 1) || !EqualsOfFloatNumbers(transform.scaleY, 1)) { var centerXDelta = center.x - controlCenter.x; var centerYDelta = center.y - controlCenter.y; controlCenter.translate(transform.translateX, transform.translateY); transform.setTranslateX(controlCenter.x + centerXDelta * transform.scaleX - center.x); transform.setTranslateY(controlCenter.y + centerYDelta * transform.scaleY - center.y); } path.transform(transform, center); return path; }; BaseRectangleItemHandler.prototype._hasVectorMask = function () { return this.item.mask != null && this.item.mask.vectorMask != null; }; BaseRectangleItemHandler.prototype._refreshState = function () { _super.prototype._refreshState.call(this); if (!this._isIgnorePermissionsMode() || this.canvas == null) { return; } if (!this.visible || this.locked) { this.canvas.removeSelectedItemHandler(this); } this.canvas.updateViolationContainer(this, true); this.canvas.redraw(); }; BaseRectangleItemHandler.prototype._showViolationButton = function () { var _a; var isVisible = this.isVisible() && ((_a = this.canvas) === null || _a === void 0 ? void 0 : _a.previewMode) != true; this._violationWarningButton.style.visibility = isVisible ? "visible" : "hidden"; }; BaseRectangleItemHandler.prototype._getPrintAreaBounds = function () { if (this.layer == null || this.layer.container.parentComponent == null) return null; var surface = this.layer.container.parentComponent; if (surface.printAreas == null || surface.printAreas.length < 1) return null; return surface.printAreas.get(0).bounds; }; BaseRectangleItemHandler.typeName = "BaseRectangleItemHandler"; return BaseRectangleItemHandler; }(ItemHandler)); export { BaseRectangleItemHandler }; //# sourceMappingURL=BaseRectangleItemHandler.js.map