@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
50 lines • 2.03 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
import { EShapeButtonLayer } from "./e-shape-button-layer";
var ECommandShapeButtonLayerValueBringForward = /** @class */ (function (_super) {
__extends(ECommandShapeButtonLayerValueBringForward, _super);
function ECommandShapeButtonLayerValueBringForward(target, selection) {
var _this = _super.call(this) || this;
_this._selection = selection;
_this._target = target;
var indices = [];
var shapes = _this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
if (shape instanceof EShapeButtonLayer) {
var index = shape.button.indexOf(target);
indices.push(index);
if (0 < index) {
shape.button.swap(index - 1, index);
}
}
}
_this._indices = indices;
_this._selection.update("PROPERTY");
return _this;
}
ECommandShapeButtonLayerValueBringForward.prototype.execute = function () {
return true;
};
ECommandShapeButtonLayerValueBringForward.prototype.redo = function () {
var shapes = this._selection.get();
var indices = this._indices;
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
if (shape instanceof EShapeButtonLayer) {
var index = indices[i];
if (0 < index) {
shape.button.swap(index - 1, index);
}
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeButtonLayerValueBringForward.prototype.undo = function () {
return this.redo();
};
return ECommandShapeButtonLayerValueBringForward;
}(DCommandBase));
export { ECommandShapeButtonLayerValueBringForward };
//# sourceMappingURL=e-command-shape-button-layer-value-bring-forward.js.map