UNPKG

@daign/2d-graphics

Version:

Two dimensional graphics library that implements the daign-2d-pipeline.

63 lines (62 loc) 2.58 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectionManager = void 0; var observable_1 = require("@daign/observable"); /** * Class that manages the current selected control object and control point. */ var SelectionManager = /** @class */ (function (_super) { __extends(SelectionManager, _super); /** * Constructor. */ function SelectionManager() { var _this = _super.call(this) || this; // The currently active control object or null. _this.activeObject = null; // The currently active control point vector or null. _this.activePoint = null; return _this; } /** * Set the current selection. * @param activeObject - The currently active control object or null. * @param activePoint - The currently active control point vector or null. */ SelectionManager.prototype.setSelection = function (activeObject, activePoint) { // Setting a point without an object is not a valid option. if (activeObject === null && activePoint !== null) { return; } /* When setting an object and a point, the point must be part of the object's point elements. * Otherwise not a valid option. */ if (activeObject !== null && activePoint !== null) { var points = activeObject.points.elements; if (points.indexOf(activePoint) === -1) { return; } } if (this.activeObject !== activeObject || this.activePoint !== activePoint) { this.activeObject = activeObject; this.activePoint = activePoint; this.notifyObservers(); } }; return SelectionManager; }(observable_1.Observable)); exports.SelectionManager = SelectionManager;