Issue#145 : Hide highlighted pixel

+ BaseTool : added new method hideHighlightedPixel
+ DrawingController : mousemove event plugged on mousenter
  and unplugged on mouseleave
+ DrawingController : tool.hideHighlightPixel called on mouseleave and
  when switching the current tool to active (i.e. when user starts
  clicking)
This commit is contained in:
jdescottes 2013-12-18 23:37:17 +01:00
parent e4cf2ac40b
commit 4056142b97
2 changed files with 28 additions and 4 deletions

View File

@ -63,7 +63,8 @@
ns.DrawingController.prototype.initMouseBehavior = function() {
var body = $('body');
this.container.mousedown($.proxy(this.onMousedown_, this));
this.container.mousemove($.proxy(this.onMousemove_, this));
this.container.mouseenter($.proxy(this.onMouseenter_, this));
this.container.mouseleave($.proxy(this.onMouseleave_, this));
if (pskl.utils.UserAgent.isChrome) {
this.container.on('mousewheel', $.proxy(this.onMousewheel_, this));
@ -82,7 +83,7 @@
window.clearInterval(this.resizeTimer);
}
this.resizeTimer = window.setTimeout($.proxy(this.afterWindowResize_, this), 200);
},
};
ns.DrawingController.prototype.afterWindowResize_ = function () {
var initialWidth = this.compositeRenderer.getDisplaySize().width;
@ -93,7 +94,7 @@
this.compositeRenderer.setZoom(newZoom);
$.publish(Events.ZOOM_CHANGED);
},
};
/**
* @private
@ -102,7 +103,7 @@
if(settingsName == pskl.UserSettings.SHOW_GRID) {
console.warn('DrawingController:onUserSettingsChange_ not implemented !');
}
},
};
ns.DrawingController.prototype.onFrameSizeChanged_ = function () {
this.compositeRenderer.setDisplaySize(this.getContainerWidth_(), this.getContainerHeight_());
@ -111,6 +112,21 @@
$.publish(Events.ZOOM_CHANGED);
};
/**
* @private
*/
ns.DrawingController.prototype.onMouseenter_ = function (event) {
this.container.bind('mousemove', $.proxy(this.onMousemove_, this));
};
/**
* @private
*/
ns.DrawingController.prototype.onMouseleave_ = function (event) {
this.container.unbind('mousemove');
this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame);
};
/**
* @private
*/
@ -124,6 +140,7 @@
}
} else {
this.isClicked = true;
this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame);
this.currentToolBehavior.applyToolAt(
coords.x,

View File

@ -31,6 +31,13 @@
}
};
ns.BaseTool.prototype.hideHighlightedPixel = function(overlay) {
overlay.setPixel(this.highlightedPixelCol, this.highlightedPixelRow, Constants.TRANSPARENT_COLOR);
this.highlightedPixelRow = null;
this.highlightedPixelCol = null;
};
ns.BaseTool.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {};
/**