aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-19 10:03:14 -0700
committerPushkar Joshi2012-04-19 10:03:14 -0700
commitd703eeb01afa818a02538ec4efa66ac7350bac06 (patch)
tree65ac6463edf44ed375adc97714881447fb8732ba /js
parentb1013db1b1a44d5fcd2e1a244d3c21c013d23e6e (diff)
downloadninja-d703eeb01afa818a02538ec4efa66ac7350bac06.tar.gz
for subpaths that have not been initialized with a canvas yet (i.e. no local coordinates), use stage world mouse positions to translate the anchor points while dragging
Diffstat (limited to 'js')
-rwxr-xr-xjs/tools/PenTool.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 765d4589..8ac48d55 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -405,14 +405,7 @@ exports.PenTool = Montage.create(ShapeTool, {
405 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) 405 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2)
406 return; 406 return;
407 } 407 }
408 408
409 if (!this._selectedSubpath ){
410 return; //nothing to do in case no subpath is selected
411 }
412 //clear the canvas before we draw anything else
413 this.application.ninja.stage.clearDrawingCanvas();
414 this._hoveredAnchorIndex = -1;
415
416 //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) 409 //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet)
417 if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ 410 if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){
418 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; 411 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
@@ -423,13 +416,29 @@ exports.PenTool = Montage.create(ShapeTool, {
423 "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default"; 416 "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default";
424 } 417 }
425 418
419 if (!this._selectedSubpath ){
420 return; //nothing to do in case no subpath is selected
421 }
422
423 //clear the canvas before we draw anything else
424 this.application.ninja.stage.clearDrawingCanvas();
425 this._hoveredAnchorIndex = -1;
426
426 var hitRec = this.getHitRecord(event.pageX, event.pageY, false); 427 var hitRec = this.getHitRecord(event.pageX, event.pageY, false);
428 var globalMousePos=null, localMousePos=null, stageWorldMousePos = null;
427 var drawingCanvas = this._selectedSubpath.getCanvas(); 429 var drawingCanvas = this._selectedSubpath.getCanvas();
428 if (!drawingCanvas){ 430 if (!drawingCanvas){
429 drawingCanvas = ViewUtils.getStageElement(); 431 drawingCanvas = ViewUtils.getStageElement();
432 stageWorldMousePos = hitRec.calculateStageWorldPoint();
433 stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5;
434 stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5;
435 localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well
430 } 436 }
431 var globalMousePos = hitRec.getScreenPoint(); 437 else {
432 var localMousePos = ViewUtils.globalToLocal(globalMousePos, drawingCanvas); 438 globalMousePos = hitRec.getScreenPoint();
439 localMousePos = ViewUtils.globalToLocal(globalMousePos, drawingCanvas);
440 }
441
433 442
434 if (this._isDrawing) { 443 if (this._isDrawing) {
435 //if there is a selected subpath with a selected anchor point 444 //if there is a selected subpath with a selected anchor point