UNPKG

@wcardinal/wcardinal-geditor

Version:

WebGL-based graphic editor, tester and viewer for supervisory systems

106 lines 3.71 kB
import { __extends } from "tslib"; import { DCommandBase } from "@wcardinal/wcardinal-ui"; import { EToolSelectSelectionUpdatedPart } from "../tool/e-tool-select-selection-updated-part"; var SHAPE_COMPARATOR = function (a, b) { return a.index - b.index; }; var ECommandShapeTreeSendToBack = /** @class */ (function (_super) { __extends(ECommandShapeTreeSendToBack, _super); /** * @param indices indices of moved children sorted in the "ascending" order * @param parent * @param selection */ function ECommandShapeTreeSendToBack(indices, parent, selection) { var _this = _super.call(this) || this; _this._indices = indices; _this._parent = parent; _this._selection = selection; return _this; } Object.defineProperty(ECommandShapeTreeSendToBack.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeTreeSendToBack.prototype, "parent", { get: function () { return this._parent; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeTreeSendToBack.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); ECommandShapeTreeSendToBack.prototype.execute = function () { return true; }; ECommandShapeTreeSendToBack.prototype.redo = function () { var indices = this._indices; var parent = this._parent; var children = parent.children; var offset = children.length; for (var i = 0; i < offset; ++i) { children[i].index = i; } for (var i = 0, imax = indices.length; i < imax; ++i) { var index = indices[i]; var child = children[index]; child.index = index - offset; } children.sort(SHAPE_COMPARATOR); parent.toDirty(); this._selection.update(EToolSelectSelectionUpdatedPart.TREE); return true; }; ECommandShapeTreeSendToBack.prototype.undo = function () { var indices = this._indices; var parent = this._parent; var children = parent.children; var indexSize = indices.length; for (var i = 0, imax = indexSize; i < imax; ++i) { var index = indices[i]; var child = children[i]; child.index = index; } var indexIndex = 0; var indexCurrent = indices[indexIndex]; var indexOffset = -indexSize; var offset = children.length; for (var i = indexSize; i < offset; ++i) { var child = children[i]; var index = i + indexOffset; if (index < indexCurrent) { child.index = index; } else { indexOffset += 1; indexIndex += 1; if (indexIndex < indexSize) { indexCurrent = indices[indexIndex]; } else { indexCurrent = Number.MAX_SAFE_INTEGER; } i -= 1; } } children.sort(SHAPE_COMPARATOR); parent.toDirty(); this._selection.update(EToolSelectSelectionUpdatedPart.TREE); return true; }; ECommandShapeTreeSendToBack.prototype.destroy = function () { this._indices.length = 0; }; return ECommandShapeTreeSendToBack; }(DCommandBase)); export { ECommandShapeTreeSendToBack }; //# sourceMappingURL=e-command-shape-tree-send-to-back.js.map