aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/tools/PenTool.js43
1 files changed, 27 insertions, 16 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 14ea3563..2974d37b 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -190,10 +190,11 @@ exports.PenTool = Montage.create(ShapeTool, {
190 if (removeSelectedSubpath){ 190 if (removeSelectedSubpath){
191 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary 191 this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary
192 this._selectedSubpath = null; 192 this._selectedSubpath = null;
193 if (this._entryEditMode === this.ENTRY_SELECT_PATH){ 193 if (this._subtool === this.SUBTOOL_NONE){
194 this._entryEditMode = this.ENTRY_SELECT_NONE; 194 if (this._entryEditMode === this.ENTRY_SELECT_PATH){
195 this._entryEditMode = this.ENTRY_SELECT_NONE;
196 }
195 } 197 }
196 this._subtool = this.SUBTOOL_NONE;
197 } else { 198 } else {
198 this._selectedSubpath.setCanvas(null); 199 this._selectedSubpath.setCanvas(null);
199 } 200 }
@@ -274,7 +275,7 @@ exports.PenTool = Montage.create(ShapeTool, {
274 value: function (event) { 275 value: function (event) {
275 //ignore any right or middle clicks 276 //ignore any right or middle clicks
276 if (event.button !== 0) { 277 if (event.button !== 0) {
277 //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) 278 //todo NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2)
278 return; 279 return;
279 } 280 }
280 281
@@ -448,22 +449,24 @@ exports.PenTool = Montage.create(ShapeTool, {
448 } 449 }
449 450
450 //if we hit the prev handle 451 //if we hit the prev handle
451 else if (whichPoint & this._selectedSubpath.SEL_PREV){ 452 else if (whichPoint & this._selectedSubpath.SEL_PREV && this._subtool===this.SUBTOOL_NONE){
452 this._editMode = this.EDIT_PREV; 453 this._editMode = this.EDIT_PREV;
453 } 454 }
454 455
455 //if we hit the next handle 456 //if we hit the next handle
456 else if (whichPoint & this._selectedSubpath.SEL_NEXT){ 457 else if (whichPoint & this._selectedSubpath.SEL_NEXT && this._subtool===this.SUBTOOL_NONE){
457 this._editMode = this.EDIT_NEXT; 458 this._editMode = this.EDIT_NEXT;
458 } 459 }
459 460
460 //if no anchor or handles 461 //if no anchor or handles
461 else if (whichPoint & this._selectedSubpath.SEL_PATH) { 462 else if (whichPoint & this._selectedSubpath.SEL_PATH) {
462 //the click point is close enough to insert point in bezier segment after selected anchor at selParam 463 //the click point is close enough to insert point in bezier segment after selected anchor at selParam
463 if (selParam > 0 && selParam < 1) { 464 if ((selParam > 0 && selParam < 1) && this._subtool!==this.SUBTOOL_PENMINUS) {
464 this._selectedSubpath.insertAnchorAtParameter(this._selectedSubpath.getSelectedAnchorIndex(), selParam); 465 this._selectedSubpath.insertAnchorAtParameter(this._selectedSubpath.getSelectedAnchorIndex(), selParam);
465 //set the mode so that dragging will update anchor point positions 466 //set the mode so that dragging will update anchor point positions
466 //this._editMode = this.EDIT_ANCHOR; 467 //this._editMode = this.EDIT_ANCHOR;
468 } else {
469 this._selectedSubpath.deselectAnchorPoint(); //set that no anchor is selected since the path was not hit anywhere useful
467 } 470 }
468 } 471 }
469 472
@@ -473,7 +476,10 @@ exports.PenTool = Montage.create(ShapeTool, {
473 else { 476 else {
474 //add an anchor point to end of the open selected subpath (in local space), and make it the selected anchor point 477 //add an anchor point to end of the open selected subpath (in local space), and make it the selected anchor point
475 // ONLY if we were not in SELECT_PATH entry mode or we are in SELECT_PATH entry mode and we have picked one of the endpoints 478 // ONLY if we were not in SELECT_PATH entry mode or we are in SELECT_PATH entry mode and we have picked one of the endpoints
476 if (this._entryEditMode !== this.ENTRY_SELECT_PATH || (this._entryEditMode === this.ENTRY_SELECT_PATH && this._isPickedEndPointInSelectPathMode)) { 479 if (this._subtool===this.SUBTOOL_NONE &&
480 (this._entryEditMode !== this.ENTRY_SELECT_PATH ||
481 (this._entryEditMode === this.ENTRY_SELECT_PATH && this._isPickedEndPointInSelectPathMode))
482 ) {
477 if (!this._selectedSubpath.getIsClosed()) { //todo this test is probably unnecessary, but doing it to be safe 483 if (!this._selectedSubpath.getIsClosed()) { //todo this test is probably unnecessary, but doing it to be safe
478 this._selectedSubpath.addAnchor(new AnchorPoint()); 484 this._selectedSubpath.addAnchor(new AnchorPoint());
479 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 485 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex());
@@ -513,16 +519,21 @@ exports.PenTool = Montage.create(ShapeTool, {
513 } 519 }
514 520
515 //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) 521 //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet)
516 if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ 522 if (this._subtool===this.SUBTOOL_NONE){
517 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; 523 if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){
518 "url('images/cursors/penCursors/Pen_.png') 5 1, default"; 524 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
519 } 525 "url('images/cursors/penCursors/Pen_.png') 5 1, default";
520 else { 526 }
527 else {
528 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
529 "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default";
530 }
531 } else {
532 //use the standard pen cursor for Pen Plus and Pen Minus
521 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; 533 this.application.ninja.stage.drawingCanvas.style.cursor = //"auto";
522 "url('images/cursors/penCursors/Pen_newPath.png') 5 1, default"; 534 "url('images/cursors/penCursors/Pen_.png') 5 1, default";
523 } 535 }
524 536
525
526 if (!this._selectedSubpath ){ 537 if (!this._selectedSubpath ){
527 return; //nothing to do in case no subpath is selected 538 return; //nothing to do in case no subpath is selected
528 } 539 }
@@ -625,7 +636,7 @@ exports.PenTool = Montage.create(ShapeTool, {
625 cursor = "url('images/cursors/penCursors/Pen_closePath.png') 5 1, default"; 636 cursor = "url('images/cursors/penCursors/Pen_closePath.png') 5 1, default";
626 } 637 }
627 } //if path is not closed 638 } //if path is not closed
628 } else if (this._subtool === this.SUBTOOL_PENMINUS){ 639 } else if (this._subtool === this.SUBTOOL_PENMINUS && selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_ANCHOR){
629 cursor = "url('images/cursors/penCursors/Pen_minus.png') 5 1, default"; 640 cursor = "url('images/cursors/penCursors/Pen_minus.png') 5 1, default";
630 } 641 }
631 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 642 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;