UNPKG

@wcardinal/wcardinal-geditor

Version:

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

107 lines 3.77 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 ECommandShapeTreeBringToFront = /** @class */ (function (_super) { __extends(ECommandShapeTreeBringToFront, _super); /** * * @param indices indices of moved children sorted in the "descending" order * @param parent * @param selection */ function ECommandShapeTreeBringToFront(indices, parent, selection) { var _this = _super.call(this) || this; _this._indices = indices; _this._parent = parent; _this._selection = selection; return _this; } Object.defineProperty(ECommandShapeTreeBringToFront.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeTreeBringToFront.prototype, "parent", { get: function () { return this._parent; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeTreeBringToFront.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); ECommandShapeTreeBringToFront.prototype.execute = function () { return true; }; ECommandShapeTreeBringToFront.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 = offset + index; } children.sort(SHAPE_COMPARATOR); parent.toDirty(); this._selection.update(EToolSelectSelectionUpdatedPart.TREE); return true; }; ECommandShapeTreeBringToFront.prototype.undo = function () { var indices = this._indices; var parent = this._parent; var children = parent.children; var offset = children.length; var indexSize = indices.length; for (var i = 0, imax = indexSize; i < imax; ++i) { var index = indices[i]; var child = children[offset - 1 - i]; child.index = index; } var indexIndex = indexSize - 1; var indexCurrent = indices[indexIndex]; var indexOffset = 0; for (var i = 0, imax = offset - indexSize; i < imax; ++i) { var child = children[i]; var index = i + indexOffset; if (index < indexCurrent) { child.index = index; } else { indexOffset += 1; indexIndex -= 1; if (0 <= indexIndex) { indexCurrent = indices[indexIndex]; } else { indexCurrent = Number.MAX_SAFE_INTEGER; } i -= 1; } } children.sort(SHAPE_COMPARATOR); parent.toDirty(); this._selection.update(EToolSelectSelectionUpdatedPart.TREE); return true; }; ECommandShapeTreeBringToFront.prototype.destroy = function () { this._indices.length = 0; }; return ECommandShapeTreeBringToFront; }(DCommandBase)); export { ECommandShapeTreeBringToFront }; //# sourceMappingURL=e-command-shape-tree-bring-to-front.js.map