@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
55 lines • 2.22 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
import { EShapeButtonLayer } from "./e-shape-button-layer";
var ECommandShapeButtonLayerValueSendBackward = /** @class */ (function (_super) {
__extends(ECommandShapeButtonLayerValueSendBackward, _super);
function ECommandShapeButtonLayerValueSendBackward(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 button = shape.button;
var index = button.indexOf(target);
indices.push(index);
if (0 <= index && index < button.size() - 1) {
button.swap(index + 1, index);
}
}
else {
indices.push(-1);
}
}
_this._indices = indices;
_this._selection.update("PROPERTY");
return _this;
}
ECommandShapeButtonLayerValueSendBackward.prototype.execute = function () {
return true;
};
ECommandShapeButtonLayerValueSendBackward.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 button = shape.button;
var index = indices[i];
if (0 <= index && index < button.size() - 1) {
button.swap(index + 1, index);
}
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeButtonLayerValueSendBackward.prototype.undo = function () {
return this.redo();
};
return ECommandShapeButtonLayerValueSendBackward;
}(DCommandBase));
export { ECommandShapeButtonLayerValueSendBackward };
//# sourceMappingURL=e-command-shape-button-layer-value-send-backward.js.map