2013-11-25 22:00:19 +04:00
|
|
|
/**
|
2013-04-09 03:32:30 +04:00
|
|
|
* @provide pskl.drawingtools.ColorPicker
|
|
|
|
*
|
|
|
|
* @require pskl.utils
|
|
|
|
*/
|
|
|
|
(function() {
|
2013-11-25 22:00:19 +04:00
|
|
|
var ns = $.namespace("pskl.drawingtools");
|
2013-04-09 03:32:30 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
ns.ColorPicker = function() {
|
|
|
|
this.toolId = "tool-colorpicker";
|
|
|
|
this.helpText = "Color picker";
|
|
|
|
};
|
2013-04-09 03:32:30 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
pskl.utils.inherit(ns.ColorPicker, ns.BaseTool);
|
|
|
|
|
2014-03-30 05:12:56 +04:00
|
|
|
|
2013-11-25 22:00:19 +04:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
2014-03-30 05:12:56 +04:00
|
|
|
ns.ColorPicker.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
2013-11-25 22:00:19 +04:00
|
|
|
if (frame.containsPixel(col, row)) {
|
|
|
|
var sampledColor = frame.getPixel(col, row);
|
2014-03-30 05:12:56 +04:00
|
|
|
if (event.button == Constants.LEFT_BUTTON) {
|
2013-11-25 22:00:19 +04:00
|
|
|
$.publish(Events.SELECT_PRIMARY_COLOR, [sampledColor]);
|
2014-03-30 05:12:56 +04:00
|
|
|
} else if (event.button == Constants.RIGHT_BUTTON) {
|
2013-11-25 22:00:19 +04:00
|
|
|
$.publish(Events.SELECT_SECONDARY_COLOR, [sampledColor]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2013-04-09 03:32:30 +04:00
|
|
|
})();
|