UNPKG

@aurigma/design-atoms-model

Version:

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

90 lines 3.81 kB
import { RgbColors } from "../../Colors"; import { RectangleItem } from "./RectangleItem"; import { SurfaceContainer } from "../Container"; import * as Math from "../../Math/index"; import { equals, isString } from "../../Utils/Utils"; export class ContentItem extends RectangleItem { constructor() { super(); this._maskOpacity = 0.45; this._parentPlaceholder = null; this.type = ContentItem.type; this.borderWidth = 0; this.fillColor = RgbColors.transparent; this._ignorePermissionsChange = true; this.itemPermissions.itemToolbarPermissions.showEditButton = true; this._ignorePermissionsChange = false; } get maskOpacity() { return this._maskOpacity; } set maskOpacity(value) { if (!Math.EqualsOfFloatNumbers(this._maskOpacity, value)) { this._maskOpacity = value; this._propertyChanged.notify(this, "maskOpacity"); } } get parentPlaceholder() { return this._parentPlaceholder; } set parentPlaceholder(value) { this._parentPlaceholder = value; this._propertyChanged.notify(this, "parentPlaceholder"); } applyPermissionsConstrain() { if (this.parentPlaceholder != null) { if (this.parentPlaceholder.isCoverMode) { this.manipulationPermissions.resizeGrips.edgeConstraint = false; this.manipulationPermissions.resizeGrips.setCornerArbitraryConstraint(false); this.manipulationPermissions.allowRotateConstraint = false; } else { this.manipulationPermissions.resizeGrips.edgeConstraint = null; this.manipulationPermissions.resizeGrips.setCornerArbitraryConstraint(null); this.manipulationPermissions.allowRotateConstraint = null; } this.parentPlaceholder.applyPermissionsConstrain(); } if (this.isRenderTypeIsNormal) return; this.itemPermissions.allowOpacityChange = false; this.shapePermissions.allowChangeBorderColor = false; this.shapePermissions.allowChangeFillColor = false; } getSimplifiedObject(omitProperties) { if (!Array.isArray(omitProperties) && !isString(omitProperties)) omitProperties = []; return super.getSimplifiedObject(["parentPlaceholder"].concat(omitProperties)); } _canSetIsVariable() { return true; } _getPrintAreaBounds() { const parentContainer = this.parentContainer != null ? this.parentContainer : this.parentPlaceholder != null ? this.parentPlaceholder.parentContainer : null; if (parentContainer instanceof SurfaceContainer) return parentContainer.parentComponent.bounds; return null; } _getParentContainer() { if (this.parentPlaceholder != null) return this.parentPlaceholder.parentContainer; return null; } _copy(source, destination, generateNewIds, appropriateParentContainer) { super._copy(source, destination, generateNewIds, appropriateParentContainer); destination._maskOpacity = source._maskOpacity; destination.isVariable = source.isVariable; } equals(other) { return super.equals(other) && equals(this._maskOpacity, other._maskOpacity) && equals(this.isVariable, other.isVariable); } clone(generateNewIds = false, appropriateParentContainer = false) { const item = new ContentItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; } } ContentItem.type = "ContentItem"; //# sourceMappingURL=ContentItem.js.map