Files
piskel/dev/js/tools/drawing/selection/RectangleSelect.js
Julian Descottes dbf8072343 deploy dev version
2017-05-22 09:56:42 +02:00

45 lines
1.3 KiB
JavaScript

/**
* @provide pskl.tools.drawing.selection.RectangleSelect
*
* @require pskl.utils
*/
(function() {
var ns = $.namespace('pskl.tools.drawing.selection');
ns.RectangleSelect = function() {
ns.AbstractDragSelect.call(this);
this.toolId = 'tool-rectangle-select';
this.helpText = 'Rectangle selection';
this.shortcut = pskl.service.keyboard.Shortcuts.TOOL.RECTANGLE_SELECT;
};
pskl.utils.inherit(ns.RectangleSelect, ns.AbstractDragSelect);
/** @override */
ns.RectangleSelect.prototype.onDragSelectStart_ = function (col, row) {
$.publish(Events.DRAG_START, [col, row]);
};
/**
* When creating the rectangle selection, we clear the current overlayFrame and
* redraw the current rectangle based on the orgin coordinate and
* the current mouse coordiinate in sprite.
* @override
*/
ns.RectangleSelect.prototype.onDragSelect_ = function (col, row, frame, overlay) {
overlay.clear();
this.selection = new pskl.selection.RectangularSelection(this.startCol, this.startRow, col, row);
$.publish(Events.SELECTION_CREATED, [this.selection]);
this.drawSelectionOnOverlay_(overlay);
};
/** @override */
ns.RectangleSelect.prototype.onDragSelectEnd_ = function (col, row, frame, overlay) {
this.onSelect_(col, row, frame, overlay);
$.publish(Events.DRAG_END);
};
})();