2013-09-28 23:10:12 +04:00
|
|
|
/**
|
2013-04-09 03:32:30 +04:00
|
|
|
* @provide pskl.drawingtools.ColorPicker
|
|
|
|
*
|
|
|
|
* @require pskl.utils
|
|
|
|
*/
|
|
|
|
(function() {
|
2013-08-10 14:11:16 +04:00
|
|
|
var ns = $.namespace("pskl.drawingtools");
|
2013-04-09 03:32:30 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
ns.ColorPicker = function() {
|
|
|
|
this.toolId = "tool-colorpicker";
|
|
|
|
this.helpText = "Color picker";
|
|
|
|
};
|
2013-04-09 03:32:30 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
pskl.utils.inherit(ns.ColorPicker, ns.BaseTool);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
ns.ColorPicker.prototype.applyToolAt = function(col, row, color, frame, overlay, context) {
|
|
|
|
if (frame.containsPixel(col, row)) {
|
|
|
|
var sampledColor = frame.getPixel(col, row);
|
|
|
|
if (context.button == Constants.LEFT_BUTTON) {
|
|
|
|
$.publish(Events.PRIMARY_COLOR_SELECTED, [sampledColor]);
|
|
|
|
} else if (context.button == Constants.RIGHT_BUTTON) {
|
|
|
|
$.publish(Events.SECONDARY_COLOR_SELECTED, [sampledColor]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2013-04-09 03:32:30 +04:00
|
|
|
})();
|