aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPushkar Joshi2012-05-22 13:21:32 -0700
committerPushkar Joshi2012-05-22 13:21:32 -0700
commitf4df8204a57e1bc6021b651ebb2259f9931cf26f (patch)
tree629352d8c01214a0fa1a08be1f4a4961aa64aa32
parent11cfa9ef2871002b600f1c18f4e06e55a826163c (diff)
downloadninja-f4df8204a57e1bc6021b651ebb2259f9931cf26f.tar.gz
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
-rwxr-xr-xjs/components/tools-properties/pen-properties.reel/pen-properties.js28
-rwxr-xr-xjs/data/tools-data.js4
-rwxr-xr-xjs/mediators/keyboard-mediator.js7
-rwxr-xr-xjs/tools/PenTool.js31
4 files changed, 66 insertions, 4 deletions
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
9 9
10var PenProperties = exports.PenProperties = Montage.create(ToolProperties, { 10var PenProperties = exports.PenProperties = Montage.create(ToolProperties, {
11 addedColorChips: { value: false }, 11 addedColorChips: { value: false },
12 _penToolRadio: { value: null, enumerable: false },
13 _penPlusRadio: { value: null, enumerable: false },
14 _penMinusRadio: { value: null, enumerable: false },
15
16 _subPrepare: {
17 value: function() {
18 this._penToolRadio.addEventListener("click", this, false);
19 this._penPlusRadio.addEventListener("click", this, false);
20 this._penMinusRadio.addEventListener("click", this, false);
21 }
22 },
12 23
13 _fill: { 24 _fill: {
14 enumerable: false, 25 enumerable: false,
@@ -50,6 +61,23 @@ var PenProperties = exports.PenProperties = Montage.create(ToolProperties, {
50 } 61 }
51 }, 62 },
52 63
64 _selectedSubtool: {
65 value: "pen", enumerable: false
66 },
67
68 selectedSubtool: {
69 get: function() { return this._selectedSubtool;},
70 set: function(value) { this._selectedSubtool = value; }
71 },
72
73 handleClick: {
74 value: function(event) {
75 this._selectedSubtool = event._event.target.value;
76 console.log("handleClick changing pen tool subtool to "+this.selectedSubtool);
77 NJevent("penSubToolChange");
78 }
79 },
80
53 draw: { 81 draw: {
54 enumerable: false, 82 enumerable: false,
55 value: function () { 83 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, {
100 "properties": "penProperties", 100 "properties": "penProperties",
101 "spriteSheet": true, 101 "spriteSheet": true,
102 "action": "PenTool", 102 "action": "PenTool",
103 "toolTip": "Pen Tool", 103 "toolTip": "Pen Tool (P)",
104 "cursor": "auto", 104 "cursor": "auto",
105 "lastInGroup": false, 105 "lastInGroup": false,
106 "container": false, 106 "container": false,
@@ -159,7 +159,7 @@ exports.ToolsData = Montage.create(Montage, {
159 "properties": "brushProperties", 159 "properties": "brushProperties",
160 "spriteSheet": true, 160 "spriteSheet": true,
161 "action": "BrushTool", 161 "action": "BrushTool",
162 "toolTip": "Brush Tool", 162 "toolTip": "Brush Tool (B)",
163 "cursor": "url('images/tools/brush_down.png') 9 17, default", 163 "cursor": "url('images/tools/brush_down.png') 9 17, default",
164 "lastInGroup": false, 164 "lastInGroup": false,
165 "container": false, 165 "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, {
142 return; 142 return;
143 } 143 }
144 144
145 // shortcut for Brush tool is B
146 if (evt.keyCode === Keyboard.B){
147 evt.preventDefault();
148 this.application.ninja.handleSelectTool({ "detail": this.application.ninja.toolsData.defaultToolsData[this.application.ninja.toolsData.brushToolIndex] });
149 return;
150 }
151
145 // Shortcut for Rectangle Tool is R 152 // Shortcut for Rectangle Tool is R
146 // unless the user is pressing the command key. 153 // unless the user is pressing the command key.
147 // If the user is pressing the command key, they want to refresh the browser. 154 // 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, {
1468 } 1468 }
1469 this._isPickedEndPointInSelectPathMode = false; //only applies to the ENTRY_SELECT_PATH mode 1469 this._isPickedEndPointInSelectPathMode = false; //only applies to the ENTRY_SELECT_PATH mode
1470 1470
1471 this._subtool = this.SUBTOOL_NONE; 1471 this.handlePenSubToolChange();
1472 //this.SUBTOOL_PENMINUS; 1472 //this._subtool = this.SUBTOOL_NONE; //this.SUBTOOL_PENMINUS;
1473 1473
1474 if (this._trackMouseMoveWhenUp){ 1474 if (this._trackMouseMoveWhenUp){
1475 NJevent("enableStageMove"); 1475 NJevent("enableStageMove");
@@ -1477,6 +1477,7 @@ exports.PenTool = Montage.create(ShapeTool, {
1477 this.eventManager.addEventListener("openDocument", this, false); 1477 this.eventManager.addEventListener("openDocument", this, false);
1478 this.eventManager.addEventListener("switchDocument", this, false); 1478 this.eventManager.addEventListener("switchDocument", this, false);
1479 this.eventManager.addEventListener("closeDocument", this, false); 1479 this.eventManager.addEventListener("closeDocument", this, false);
1480 this.eventManager.addEventListener("penSubToolChange", this, false);
1480 } //if the pen tool was selected 1481 } //if the pen tool was selected
1481 else { 1482 else {
1482 if (this._trackMouseMoveWhenUp){ 1483 if (this._trackMouseMoveWhenUp){
@@ -1489,10 +1490,36 @@ exports.PenTool = Montage.create(ShapeTool, {
1489 this.eventManager.removeEventListener("openDocument", this, false); 1490 this.eventManager.removeEventListener("openDocument", this, false);
1490 this.eventManager.removeEventListener("switchDocument", this, false); 1491 this.eventManager.removeEventListener("switchDocument", this, false);
1491 this.eventManager.removeEventListener("closeDocument", this, false); 1492 this.eventManager.removeEventListener("closeDocument", this, false);
1493 this.eventManager.removeEventListener("penSubToolChange", this, false);
1492 } //if the pen tool was de-selected 1494 } //if the pen tool was de-selected
1493 } 1495 }
1494 }, 1496 },
1495 1497
1498 handlePenSubToolChange: {
1499 value: function() {
1500 switch (this.options.selectedSubtool){
1501 case "pen":
1502 this._subtool = this.SUBTOOL_NONE;
1503 console.log("Setting pen tool subtool to NONE");
1504 break;
1505
1506 case "penPlus":
1507 console.log("Setting pen tool subtool to PLUS");
1508 this._subtool = this.SUBTOOL_PENPLUS;
1509 break;
1510
1511 case "penMinus":
1512 console.log("Setting pen tool subtool to MINUS");
1513 this._subtool = this.SUBTOOL_PENMINUS;
1514 break;
1515
1516 default:
1517 console.log("Setting pen tool subtool to NONE");
1518 this._subtool = this.SUBTOOL_NONE;
1519 break;
1520 }
1521 }
1522 },
1496 handleDelete:{ 1523 handleDelete:{
1497 value: function(event){ 1524 value: function(event){
1498 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase 1525 //clear the selected subpath...the only new additions to this function w.r.t. ToolBase