mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
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:
@ -63,7 +63,8 @@
|
|||||||
ns.DrawingController.prototype.initMouseBehavior = function() {
|
ns.DrawingController.prototype.initMouseBehavior = function() {
|
||||||
var body = $('body');
|
var body = $('body');
|
||||||
this.container.mousedown($.proxy(this.onMousedown_, this));
|
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) {
|
if (pskl.utils.UserAgent.isChrome) {
|
||||||
this.container.on('mousewheel', $.proxy(this.onMousewheel_, this));
|
this.container.on('mousewheel', $.proxy(this.onMousewheel_, this));
|
||||||
@ -82,7 +83,7 @@
|
|||||||
window.clearInterval(this.resizeTimer);
|
window.clearInterval(this.resizeTimer);
|
||||||
}
|
}
|
||||||
this.resizeTimer = window.setTimeout($.proxy(this.afterWindowResize_, this), 200);
|
this.resizeTimer = window.setTimeout($.proxy(this.afterWindowResize_, this), 200);
|
||||||
},
|
};
|
||||||
|
|
||||||
ns.DrawingController.prototype.afterWindowResize_ = function () {
|
ns.DrawingController.prototype.afterWindowResize_ = function () {
|
||||||
var initialWidth = this.compositeRenderer.getDisplaySize().width;
|
var initialWidth = this.compositeRenderer.getDisplaySize().width;
|
||||||
@ -93,7 +94,7 @@
|
|||||||
this.compositeRenderer.setZoom(newZoom);
|
this.compositeRenderer.setZoom(newZoom);
|
||||||
|
|
||||||
$.publish(Events.ZOOM_CHANGED);
|
$.publish(Events.ZOOM_CHANGED);
|
||||||
},
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -102,7 +103,7 @@
|
|||||||
if(settingsName == pskl.UserSettings.SHOW_GRID) {
|
if(settingsName == pskl.UserSettings.SHOW_GRID) {
|
||||||
console.warn('DrawingController:onUserSettingsChange_ not implemented !');
|
console.warn('DrawingController:onUserSettingsChange_ not implemented !');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
ns.DrawingController.prototype.onFrameSizeChanged_ = function () {
|
ns.DrawingController.prototype.onFrameSizeChanged_ = function () {
|
||||||
this.compositeRenderer.setDisplaySize(this.getContainerWidth_(), this.getContainerHeight_());
|
this.compositeRenderer.setDisplaySize(this.getContainerWidth_(), this.getContainerHeight_());
|
||||||
@ -111,6 +112,21 @@
|
|||||||
$.publish(Events.ZOOM_CHANGED);
|
$.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
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -124,6 +140,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.isClicked = true;
|
this.isClicked = true;
|
||||||
|
this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame);
|
||||||
|
|
||||||
this.currentToolBehavior.applyToolAt(
|
this.currentToolBehavior.applyToolAt(
|
||||||
coords.x,
|
coords.x,
|
||||||
|
@ -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) {};
|
ns.BaseTool.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user