From f4df8204a57e1bc6021b651ebb2259f9931cf26f Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 22 May 2012 13:21:32 -0700 Subject: allow changes in the pen subtool in options to be seen by the pen tool code (can now select the pen plus, pen minus subtools) AND add keyboard shortcut for brush tool --- .../pen-properties.reel/pen-properties.js | 28 +++++++++++++++++++ js/data/tools-data.js | 4 +-- js/mediators/keyboard-mediator.js | 7 +++++ js/tools/PenTool.js | 31 ++++++++++++++++++++-- 4 files changed, 66 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/components/tools-properties/pen-properties.reel/pen-properties.js b/js/components/tools-properties/pen-properties.reel/pen-properties.js index cd205e07..aba6cb61 100755 --- a/js/components/tools-properties/pen-properties.reel/pen-properties.js +++ b/js/components/tools-properties/pen-properties.reel/pen-properties.js @@ -9,6 +9,17 @@ var ToolProperties = require("js/components/tools-properties/tool-properties").T var PenProperties = exports.PenProperties = Montage.create(ToolProperties, { addedColorChips: { value: false }, + _penToolRadio: { value: null, enumerable: false }, + _penPlusRadio: { value: null, enumerable: false }, + _penMinusRadio: { value: null, enumerable: false }, + + _subPrepare: { + value: function() { + this._penToolRadio.addEventListener("click", this, false); + this._penPlusRadio.addEventListener("click", this, false); + this._penMinusRadio.addEventListener("click", this, false); + } + }, _fill: { enumerable: false, @@ -50,6 +61,23 @@ var PenProperties = exports.PenProperties = Montage.create(ToolProperties, { } }, + _selectedSubtool: { + value: "pen", enumerable: false + }, + + selectedSubtool: { + get: function() { return this._selectedSubtool;}, + set: function(value) { this._selectedSubtool = value; } + }, + + handleClick: { + value: function(event) { + this._selectedSubtool = event._event.target.value; + console.log("handleClick changing pen tool subtool to "+this.selectedSubtool); + NJevent("penSubToolChange"); + } + }, + draw: { enumerable: false, value: function () { diff --git a/js/data/tools-data.js b/js/data/tools-data.js index 32eaf24d..179e8e81 100755 --- a/js/data/tools-data.js +++ b/js/data/tools-data.js @@ -100,7 +100,7 @@ exports.ToolsData = Montage.create(Montage, { "properties": "penProperties", "spriteSheet": true, "action": "PenTool", - "toolTip": "Pen Tool", + "toolTip": "Pen Tool (P)", "cursor": "auto", "lastInGroup": false, "container": false, @@ -159,7 +159,7 @@ exports.ToolsData = Montage.create(Montage, { "properties": "brushProperties", "spriteSheet": true, "action": "BrushTool", - "toolTip": "Brush Tool", + "toolTip": "Brush Tool (B)", "cursor": "url('images/tools/brush_down.png') 9 17, default", "lastInGroup": false, "container": false, diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 029c0916..5d5537d5 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -142,6 +142,13 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // shortcut for Brush tool is B + if (evt.keyCode === Keyboard.B){ + evt.preventDefault(); + this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.brushToolIndex] }); + return; + } + // Shortcut for Rectangle Tool is R // unless the user is pressing the command key. // If the user is pressing the command key, they want to refresh the browser. diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index cc8ec394..bbde7374 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -1468,8 +1468,8 @@ exports.PenTool = Montage.create(ShapeTool, { } this._isPickedEndPointInSelectPathMode = false; //only applies to the ENTRY_SELECT_PATH mode - this._subtool = this.SUBTOOL_NONE; - //this.SUBTOOL_PENMINUS; + this.handlePenSubToolChange(); + //this._subtool = this.SUBTOOL_NONE; //this.SUBTOOL_PENMINUS; if (this._trackMouseMoveWhenUp){ NJevent("enableStageMove"); @@ -1477,6 +1477,7 @@ exports.PenTool = Montage.create(ShapeTool, { this.eventManager.addEventListener("openDocument", this, false); this.eventManager.addEventListener("switchDocument", this, false); this.eventManager.addEventListener("closeDocument", this, false); + this.eventManager.addEventListener("penSubToolChange", this, false); } //if the pen tool was selected else { if (this._trackMouseMoveWhenUp){ @@ -1489,10 +1490,36 @@ exports.PenTool = Montage.create(ShapeTool, { this.eventManager.removeEventListener("openDocument", this, false); this.eventManager.removeEventListener("switchDocument", this, false); this.eventManager.removeEventListener("closeDocument", this, false); + this.eventManager.removeEventListener("penSubToolChange", this, false); } //if the pen tool was de-selected } }, + handlePenSubToolChange: { + value: function() { + switch (this.options.selectedSubtool){ + case "pen": + this._subtool = this.SUBTOOL_NONE; + console.log("Setting pen tool subtool to NONE"); + break; + + case "penPlus": + console.log("Setting pen tool subtool to PLUS"); + this._subtool = this.SUBTOOL_PENPLUS; + break; + + case "penMinus": + console.log("Setting pen tool subtool to MINUS"); + this._subtool = this.SUBTOOL_PENMINUS; + break; + + default: + console.log("Setting pen tool subtool to NONE"); + this._subtool = this.SUBTOOL_NONE; + break; + } + } + }, handleDelete:{ value: function(event){ //clear the selected subpath...the only new additions to this function w.r.t. ToolBase -- cgit v1.2.3