aboutsummaryrefslogtreecommitdiff
path: root/js/tools/modifier-tool-base.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-04-24 10:06:53 -0700
committerJose Antonio Marquez2012-04-24 10:06:53 -0700
commit4c15e77bdb7f4e0558f3749994a8a37b207b97ae (patch)
tree593ab4917fb5cc3ef8ee36822b56c6edd30c33a5 /js/tools/modifier-tool-base.js
parent36d50b6599ab98559c76e1fe57b1bb131c4433da (diff)
parent55e6d621b9555abac06ab4adff44dfe29a78ec4e (diff)
downloadninja-4c15e77bdb7f4e0558f3749994a8a37b207b97ae.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/tools/modifier-tool-base.js')
-rwxr-xr-xjs/tools/modifier-tool-base.js53
1 files changed, 24 insertions, 29 deletions
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index de73c861..2e006c35 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -125,8 +125,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
125// } 125// }
126// } 126// }
127 127
128 128 if(this.application.ninja.selectedElements.length)
129 if(this._targets)
130 { 129 {
131 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, 130 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
132 new WebKitPoint(event.pageX, event.pageY)); 131 new WebKitPoint(event.pageX, event.pageY));
@@ -142,11 +141,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
142 } 141 }
143 142
144 // we don't want to snap to selected objects during the drag 143 // we don't want to snap to selected objects during the drag
145 var len = this._targets.length; 144 this.application.ninja.selectedElements.forEach(function(element) {
146 for(var i=0; i<len; i++) 145 snapManager.addToAvoidList(element);
147 { 146 });
148 snapManager.addToAvoidList( this._targets[i].elt ); 147
149 }
150 if (hitRec) 148 if (hitRec)
151 { 149 {
152 // disable snap attributes 150 // disable snap attributes
@@ -404,7 +402,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
404 { 402 {
405 var index = this._snapIndex; 403 var index = this._snapIndex;
406 var pt0; 404 var pt0;
407 var useViewPoint = (this._inLocalMode && (this._targets.length === 1)); 405 var useViewPoint = this.rotateStage || (this._inLocalMode && (this.application.ninja.selectedElements.length === 1));
408 if (this._useQuadPt) 406 if (this._useQuadPt)
409 { 407 {
410 pt0 = this.GetQuadrantPoint(useViewPoint); 408 pt0 = this.GetQuadrantPoint(useViewPoint);
@@ -427,6 +425,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
427 pt1 = MathUtils.transformPoint( pt1, this._startMat ); 425 pt1 = MathUtils.transformPoint( pt1, this._startMat );
428 } 426 }
429 427
428 //console.log( "getMousePoints, useViewPoint: " + useViewPoint + ", " + pt0 + " => " + pt1 );
430 return {pt0:pt0, pt1:pt1}; 429 return {pt0:pt0, pt1:pt1};
431 } 430 }
432 else 431 else
@@ -564,6 +563,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
564 var pt = hitRec.getScreenPoint(); 563 var pt = hitRec.getScreenPoint();
565 this.upPoint.x = pt[0]; 564 this.upPoint.x = pt[0];
566 this.upPoint.y = pt[1]; 565 this.upPoint.y = pt[1];
566 this.upPoint.z = pt[2];
567 } 567 }
568 } 568 }
569 } 569 }
@@ -691,25 +691,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
691 }, 691 },
692 692
693 _startMat: { value: Matrix.I(4) }, 693 _startMat: { value: Matrix.I(4) },
694
695 _targets: { value: null },
696 targets:
697 {
698 get: function () {
699 return this._targets;
700 },
701 set: function (value) {
702 this._targets = value;
703 if (value !== null && value.length)
704 {
705 this.target = value[0];
706 }
707 else
708 {
709 this.target = null;
710 }
711 }
712 },
713 694
714 _undoArray: { value: [] }, 695 _undoArray: { value: [] },
715 696
@@ -752,7 +733,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
752 } else { 733 } else {
753 this.eventManager.removeEventListener("selectionChange", this, true); 734 this.eventManager.removeEventListener("selectionChange", this, true);
754 this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false); 735 this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false);
755 this._targets = [];
756 736
757 // Clean up 737 // Clean up
758 NJevent("disableStageMove"); 738 NJevent("disableStageMove");
@@ -783,7 +763,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
783 763
784 captureSelectionDrawn: { 764 captureSelectionDrawn: {
785 value: function(event){ 765 value: function(event){
786 this._targets = [];
787 this._origin = null; 766 this._origin = null;
788 this._delta = null; 767 this._delta = null;
789 768
@@ -832,7 +811,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
832 if(!this._activateOriginHandle) 811 if(!this._activateOriginHandle)
833 { 812 {
834 this.application.ninja.stage.drawNow = true; 813 this.application.ninja.stage.drawNow = true;
814 var canSnap = this._canSnap;
815 this._canSnap = true;
835 this.doSelection(event); 816 this.doSelection(event);
817 this._canSnap = canSnap;
836 } 818 }
837 } 819 }
838 820
@@ -858,7 +840,9 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
858 } 840 }
859 } 841 }
860 842
843 if (!this._isDrawing || (this.application.ninja.selectedElements.length == 1))
861 this.DrawHandles(this._delta); 844 this.DrawHandles(this._delta);
845
862 if(this._canSnap) 846 if(this._canSnap)
863 { 847 {
864 snapManager.drawLastHit(); 848 snapManager.drawLastHit();
@@ -898,10 +882,21 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
898 this._delta = null; 882 this._delta = null;
899 } 883 }
900 this.endDraw(event); 884 this.endDraw(event);
885
886 this.application.ninja.stage.draw();
887 if (this.application.ninja.selectedElements.length > 1)
888 {
889 //this._origin = null;
890 this._updateHandlesOrigin();
891 }
901 this.DrawHandles(); 892 this.DrawHandles();
902 } 893 }
903 }, 894 },
904 895
896 _updateHandlesOrigin: {
897 value: function () { }
898 },
899
905 handleToolDoubleClick: { 900 handleToolDoubleClick: {
906 value: function(event) { 901 value: function(event) {
907 if(!this._target) 902 if(!this._target)