aboutsummaryrefslogtreecommitdiff
path: root/js/tools/PenTool.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-27 10:47:42 -0700
committerPushkar Joshi2012-04-27 10:47:42 -0700
commited7d22edf3cbca82ae43a4e3373a93a8666ba4a1 (patch)
treec68a2437948bcb1625347c7562122b03ef66349a /js/tools/PenTool.js
parent40a4d9dbc12e802e2d0a7c3acd69bc7e394d4529 (diff)
downloadninja-ed7d22edf3cbca82ae43a4e3373a93a8666ba4a1.tar.gz
add event handlers for open, close, and switch document to pen tool, fixes:
1532 Pen: Anchor points get carried over to the new document
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-xjs/tools/PenTool.js47
1 files changed, 43 insertions, 4 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 8cc32536..016d6ded 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -1278,10 +1278,45 @@ exports.PenTool = Montage.create(ShapeTool, {
1278 } //value: function() { 1278 } //value: function() {
1279 }, //DrawSubpathAnchors { 1279 }, //DrawSubpathAnchors {
1280 1280
1281 deselectPenTool:{
1282 value: function() {
1283 this._selectedSubpath = null;
1284 this._selectedSubpathCanvas = null;
1285 this._selectedSubpathPlaneMat = null;
1286 this._snapTargetIndex = -1;
1287 }
1288 },
1289 //if the document is opened with the pen tool being active, we do the same thing as when configure(false) is called
1290 handleOpenDocument: {
1291 value: function() {
1292 this.deselectPenTool();
1293 //clear the canvas
1294 this.application.ninja.stage.clearDrawingCanvas();
1295 }
1296 },
1297 //if the document is switched with the pen tool being active, we do the same thing as when configure(false) is called
1298 handleSwitchDocument: {
1299 value: function() {
1300 this.deselectPenTool();
1301 //clear the canvas
1302 this.application.ninja.stage.clearDrawingCanvas();
1303 }
1304 },
1305 //if the document is closed with the pen tool being active, we do the same thing as when configure(false) is called
1306 handleCloseDocument: {
1307 value: function() {
1308 this.deselectPenTool();
1309 //clear the canvas
1310 this.application.ninja.stage.clearDrawingCanvas();
1311 }
1312 },
1281 1313
1282 Configure: { 1314 Configure: {
1283 value: function (wasSelected) { 1315 value: function (wasSelected) {
1284 if (wasSelected) { 1316 if (wasSelected) {
1317 //first nullify any set values
1318 this.deselectPenTool();
1319
1285 defaultEventManager.addEventListener("resetPenTool", this, false); 1320 defaultEventManager.addEventListener("resetPenTool", this, false);
1286 this.application.ninja.elementMediator.deleteDelegate = this; 1321 this.application.ninja.elementMediator.deleteDelegate = this;
1287 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; 1322 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
@@ -1335,17 +1370,21 @@ exports.PenTool = Montage.create(ShapeTool, {
1335 if (this._trackMouseMoveWhenUp){ 1370 if (this._trackMouseMoveWhenUp){
1336 NJevent("enableStageMove"); 1371 NJevent("enableStageMove");
1337 } 1372 }
1373 this.eventManager.addEventListener("openDocument", this, false);
1374 this.eventManager.addEventListener("switchDocument", this, false);
1375 this.eventManager.addEventListener("closeDocument", this, false);
1338 } //if the pen tool was selected 1376 } //if the pen tool was selected
1339 else { 1377 else {
1340 if (this._trackMouseMoveWhenUp){ 1378 if (this._trackMouseMoveWhenUp){
1341 NJevent("disableStageMove"); 1379 NJevent("disableStageMove");
1342 } 1380 }
1343 this._selectedSubpath = null; 1381 this.deselectPenTool();
1344 this._selectedSubpathCanvas = null;
1345 this._selectedSubpathPlaneMat = null;
1346 this._snapTargetIndex = -1;
1347 defaultEventManager.removeEventListener("resetPenTool", this, false); 1382 defaultEventManager.removeEventListener("resetPenTool", this, false);
1348 this.application.ninja.elementMediator.deleteDelegate = null; 1383 this.application.ninja.elementMediator.deleteDelegate = null;
1384
1385 this.eventManager.removeEventListener("openDocument", this, false);
1386 this.eventManager.removeEventListener("switchDocument", this, false);
1387 this.eventManager.removeEventListener("closeDocument", this, false);
1349 } //if the pen tool was de-selected 1388 } //if the pen tool was de-selected
1350 } 1389 }
1351 }, 1390 },