From 9b40b1170344aad40726c8ad4357e184c6d6fc2a Mon Sep 17 00:00:00 2001 From: jdescottes Date: Tue, 9 Apr 2013 07:24:07 +0200 Subject: [PATCH] Support secondary color for color picker --- js/Constants.js | 5 ++++- js/controller/DrawingController.js | 25 +++++++++++++++++++++---- js/controller/PaletteController.js | 26 +------------------------- js/drawingtools/ColorPicker.js | 8 ++++++-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/js/Constants.js b/js/Constants.js index ce0d8add..d4561db1 100644 --- a/js/Constants.js +++ b/js/Constants.js @@ -28,5 +28,8 @@ var Constants = { PISKEL_SERVICE_URL: 'http://3.piskel-app.appspot.com', GRID_STROKE_WIDTH: 1, - GRID_STROKE_COLOR: "lightgray" + GRID_STROKE_COLOR: "lightgray", + + LEFT_BUTTON : "left_button_1", + RIGHT_BUTTON : "right_button_2", }; \ No newline at end of file diff --git a/js/controller/DrawingController.js b/js/controller/DrawingController.js index 422fc4bc..d66269da 100644 --- a/js/controller/DrawingController.js +++ b/js/controller/DrawingController.js @@ -98,7 +98,8 @@ coords.col, coords.row, this.getCurrentColor_(), this.framesheet.getCurrentFrame(), - this.overlayFrame + this.overlayFrame, + this.wrapEvtInfo_(event) ); $.publish(Events.LOCALSTORAGE_REQUEST); @@ -118,7 +119,8 @@ coords.col, coords.row, this.getCurrentColor_(), this.framesheet.getCurrentFrame(), - this.overlayFrame + this.overlayFrame, + this.wrapEvtInfo_(event) ); // TODO(vincz): Find a way to move that to the model instead of being at the interaction level. @@ -131,7 +133,8 @@ coords.col, coords.row, this.getCurrentColor_(), this.framesheet.getCurrentFrame(), - this.overlayFrame + this.overlayFrame, + this.wrapEvtInfo_(event) ); } this.previousMousemoveTime = currentTime; @@ -157,13 +160,27 @@ coords.col, coords.row, this.getCurrentColor_(), this.framesheet.getCurrentFrame(), - this.overlayFrame + this.overlayFrame, + this.wrapEvtInfo_(event) ); $.publish(Events.TOOL_RELEASED); } }, + /** + * @private + */ + ns.DrawingController.prototype.wrapEvtInfo_ = function (event) { + var evtInfo = {}; + if (event.button == 0) { + evtInfo.button = Constants.LEFT_BUTTON; + } else if (event.button == 2) { + evtInfo.button = Constants.RIGHT_BUTTON; + } + return evtInfo; + }, + /** * @private */ diff --git a/js/controller/PaletteController.js b/js/controller/PaletteController.js index a1dd161a..8eb5a960 100644 --- a/js/controller/PaletteController.js +++ b/js/controller/PaletteController.js @@ -18,27 +18,7 @@ $.publish(Events.SECONDARY_COLOR_SELECTED, [inputPicker.val()]); } }; - - /** - * @private - */ - ns.PaletteController.prototype.createPaletteMarkup_ = function (colors) { - // Always adding transparent color - this.paletteRoot.html(''); - - for(var i=0, l=this.paletteColors.length; i