From af52d9a96ab14c796798ac5902620db626921be6 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Wed, 23 Apr 2014 23:47:23 +0200 Subject: [PATCH] Enhancement : Selection tools various enhancements - can use BACKSPACE key to delete selection content when no selection, backspace retains the default behavior - cursor for rectangle selection has been changed to crosshair - fixed a bug where selection seemed to be cropped when released out of the visible canvas --- src/css/tools.css | 2 +- src/js/drawingtools/Eraser.js | 1 + .../drawingtools/selectiontools/BaseSelect.js | 37 ++++--------------- .../selectiontools/RectangleSelect.js | 35 ++++++++++-------- .../selectiontools/ShapeSelect.js | 12 +++--- src/js/selection/SelectionManager.js | 10 +++++ src/js/service/keyboard/KeycodeTranslator.js | 1 + src/js/service/keyboard/ShortcutService.js | 13 ++++++- 8 files changed, 58 insertions(+), 53 deletions(-) diff --git a/src/css/tools.css b/src/css/tools.css index 3b0dbcf2..6f38e313 100644 --- a/src/css/tools.css +++ b/src/css/tools.css @@ -130,7 +130,7 @@ } .tool-rectangle-select .drawing-canvas-container:hover { - cursor: url(../img/icons/select.png) 15 15, pointer; + cursor: crosshair; } .tool-shape-select .drawing-canvas-container:hover { diff --git a/src/js/drawingtools/Eraser.js b/src/js/drawingtools/Eraser.js index 57570fe9..27e169c7 100644 --- a/src/js/drawingtools/Eraser.js +++ b/src/js/drawingtools/Eraser.js @@ -8,6 +8,7 @@ var ns = $.namespace("pskl.drawingtools"); ns.Eraser = function() { + this.superclass.constructor.call(this); this.toolId = "tool-eraser"; this.helpText = "Eraser tool"; }; diff --git a/src/js/drawingtools/selectiontools/BaseSelect.js b/src/js/drawingtools/selectiontools/BaseSelect.js index 78cae0a3..896fac11 100644 --- a/src/js/drawingtools/selectiontools/BaseSelect.js +++ b/src/js/drawingtools/selectiontools/BaseSelect.js @@ -13,6 +13,8 @@ // Select's first point coordinates (set in applyToolAt) this.startCol = null; this.startRow = null; + + this.selection = null; }; pskl.utils.inherit(ns.BaseSelect, ns.BaseTool); @@ -50,8 +52,7 @@ ns.BaseSelect.prototype.moveToolAt = function(col, row, color, frame, overlay, event) { if(this.mode == "select") { this.onSelect_(col, row, color, frame, overlay); - } - else if(this.mode == "moveSelection") { + } else if(this.mode == "moveSelection") { this.onSelectionDrag_(col, row, color, frame, overlay); } }; @@ -95,31 +96,13 @@ * For each pixel in the selection draw it in white transparent on the tool overlay * @protected */ - ns.BaseSelect.prototype.drawSelectionOnOverlay_ = function (selection, overlay) { - var pixels = selection.pixels; + ns.BaseSelect.prototype.drawSelectionOnOverlay_ = function (overlay) { + var pixels = this.selection.pixels; for(var i=0, l=pixels.length; i