From cf2c0e7045b3d7c117090abb994bd57e03b0edd3 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Thu, 24 Apr 2014 00:38:21 +0200 Subject: [PATCH] Enhancement : preview copied selection + paste only opaque --- .../drawingtools/selectiontools/BaseSelect.js | 28 +++++++++--- src/js/selection/SelectionManager.js | 43 +++++++++++++------ 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/js/drawingtools/selectiontools/BaseSelect.js b/src/js/drawingtools/selectiontools/BaseSelect.js index 896fac11..29bd9f85 100644 --- a/src/js/drawingtools/selectiontools/BaseSelect.js +++ b/src/js/drawingtools/selectiontools/BaseSelect.js @@ -76,18 +76,24 @@ */ ns.BaseSelect.prototype.moveUnactiveToolAt = function(col, row, color, frame, overlay, event) { if (overlay.containsPixel(col, row)) { - if(overlay.getPixel(col, row) != Constants.SELECTION_TRANSPARENT_COLOR) { + if(this.isInSelection(col, row)) { // We're hovering the selection, show the move tool: - this.BodyRoot.addClass(this.toolId); - this.BodyRoot.removeClass(this.secondaryToolId); - } else { - // We're not hovering the selection, show create selection tool: this.BodyRoot.addClass(this.secondaryToolId); this.BodyRoot.removeClass(this.toolId); + } else { + // We're not hovering the selection, show create selection tool: + this.BodyRoot.addClass(this.toolId); + this.BodyRoot.removeClass(this.secondaryToolId); } } }; + ns.BaseSelect.prototype.isInSelection = function (col, row) { + return this.selection && this.selection.pixels.some(function (pixel) { + return pixel.col === col && pixel.row === row; + }); + }; + ns.BaseSelect.prototype.hideHighlightedPixel = function() { // there is no highlighted pixel for selection tools, do nothing }; @@ -99,10 +105,20 @@ ns.BaseSelect.prototype.drawSelectionOnOverlay_ = function (overlay) { var pixels = this.selection.pixels; for(var i=0, l=pixels.length; i