aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-09 13:42:59 -0800
committerPushkar Joshi2012-02-09 13:42:59 -0800
commit6bb00e69713bd7131b2bc0a15e4e0cb6071d616c (patch)
tree08d43d3c3a6777032ce51c503947874c02bf3947 /js/tools
parent5f42bd1f7723483d374cdd3fe51ef8298c86a1a2 (diff)
parent666ae3e9119410cbf7fa974274d95336aaff091c (diff)
downloadninja-6bb00e69713bd7131b2bc0a15e4e0cb6071d616c.tar.gz
Merge branch 'master' into brushtool
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/Rotate3DToolBase.js2
-rw-r--r--js/tools/RotateStage3DTool.js2
-rw-r--r--js/tools/SelectionTool.js40
-rw-r--r--js/tools/modifier-tool-base.js35
4 files changed, 56 insertions, 23 deletions
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index 6e17864b..aa91b2f4 100644
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -254,7 +254,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
254 captureSelectionDrawn: { 254 captureSelectionDrawn: {
255 value: function(event){ 255 value: function(event){
256 this._origin = null; 256 this._origin = null;
257 this._targets = null; 257 this._targets = [];
258 this._startOriginArray = null; 258 this._startOriginArray = null;
259 259
260 var len = this.application.ninja.selectedElements.length; 260 var len = this.application.ninja.selectedElements.length;
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js
index 6f07adae..ca2a8bf3 100644
--- a/js/tools/RotateStage3DTool.js
+++ b/js/tools/RotateStage3DTool.js
@@ -83,7 +83,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
83 captureSelectionDrawn: { 83 captureSelectionDrawn: {
84 value: function(event){ 84 value: function(event){
85 this._origin = null; 85 this._origin = null;
86 this._targets = null; 86 this._targets = [];
87 this._startOriginArray = null; 87 this._startOriginArray = null;
88 88
89 var stage = this.application.ninja.currentDocument.documentRoot; 89 var stage = this.application.ninja.currentDocument.documentRoot;
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 862b2e88..48548271 100644
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -135,18 +135,16 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
135 var box = []; 135 var box = [];
136 selectedItems = []; 136 selectedItems = [];
137 137
138 box[0] = this.downPoint.x - this.application.ninja.stage.documentOffsetLeft + this.application.ninja.stage.scrollLeft; 138 box[0] = this.downPoint.x;
139 box[1] = this.downPoint.y - this.application.ninja.stage.documentOffsetTop + this.application.ninja.stage.scrollTop; 139 box[1] = this.downPoint.y;
140 box[2] = box[0] + (point.x - this.downPoint.x); 140 box[2] = point.x;
141 box[3] = box[1] + (point.y - this.downPoint.y); 141 box[3] = point.y;
142 box = this.absoluteRectangle(box[0], box[1],box[2],box[3]);
143
144 142
145 //selectionManagerModule.selectionManager.marqueeSelection(box); 143 //selectionManagerModule.selectionManager.marqueeSelection(box);
146 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; 144 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes;
147 childNodes = Array.prototype.slice.call(childNodes, 0); 145 childNodes = Array.prototype.slice.call(childNodes, 0);
148 childNodes.forEach(function(item) { 146 childNodes.forEach(function(item) {
149 if(item.nodeType == 1 && SelectionTool._simpleCollisionDetection(item, box)) { 147 if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) {
150 selectedItems.push(item); 148 selectedItems.push(item);
151 } 149 }
152 }); 150 });
@@ -803,6 +801,34 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
803 }, 801 },
804 802
805 // TODO : Use the new element mediator to get element offsets 803 // TODO : Use the new element mediator to get element offsets
804 _complicatedCollisionDetection:
805 {
806 value: function(elt, box)
807 {
808 var left, top, width, height;
809
810 left = box[0];
811 width = box[2] - left;
812 if (width < 0)
813 {
814 left = box[2];
815 width = -width;
816 }
817 top = box[1];
818 height = box[3] - top;
819 if (height < 0)
820 {
821 top = box[3];
822 height = -height;
823 }
824
825 var rtnVal = MathUtils.rectsOverlap( [left,top], width, height, elt );
826
827 return rtnVal;
828 }
829 },
830
831 // TODO : Use the new element mediator to get element offsets
806 _simpleCollisionDetection: { 832 _simpleCollisionDetection: {
807 value: function(ele, box){ 833 value: function(ele, box){
808 var left1, left2, right1, right2, top1, top2, bottom1, bottom2; 834 var left1, left2, right1, right2, top1, top2, bottom1, bottom2;
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index f78e99c8..67b217c4 100644
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -437,16 +437,19 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
437 437
438 startDraw: { 438 startDraw: {
439 value: function(event) { 439 value: function(event) {
440 this.isDrawing = true; 440 if(this._target)
441 this.application.ninja.stage.showSelectionBounds = false;
442
443 if(this._canSnap)
444 {
445 this.initializeSnapping(event);
446 }
447 else
448 { 441 {
449 this.drawWithoutSnapping(event); 442 this.isDrawing = true;
443 this.application.ninja.stage.showSelectionBounds = false;
444
445 if(this._canSnap)
446 {
447 this.initializeSnapping(event);
448 }
449 else
450 {
451 this.drawWithoutSnapping(event);
452 }
450 } 453 }
451 } 454 }
452 }, 455 },
@@ -674,11 +677,15 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
674 return this._targets; 677 return this._targets;
675 }, 678 },
676 set: function (value) { 679 set: function (value) {
677 this._target = value; 680 this._targets = value;
678 if (value === null) 681 if (value !== null && value.length)
679 { 682 {
680 return; 683 this.target = value[0];
681 } 684 }
685 else
686 {
687 this.target = null;
688 }
682 } 689 }
683 }, 690 },
684 691
@@ -723,7 +730,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
723 } else { 730 } else {
724 this.eventManager.removeEventListener("selectionChange", this, true); 731 this.eventManager.removeEventListener("selectionChange", this, true);
725 this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false); 732 this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false);
726 this._targets = null; 733 this._targets = [];
727 734
728 // Clean up 735 // Clean up
729 NJevent("disableStageMove"); 736 NJevent("disableStageMove");
@@ -749,7 +756,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
749 756
750 captureSelectionDrawn: { 757 captureSelectionDrawn: {
751 value: function(event){ 758 value: function(event){
752 this._targets = null; 759 this._targets = [];
753 760
754 var len = this.application.ninja.selectedElements.length; 761 var len = this.application.ninja.selectedElements.length;
755 if(len) 762 if(len)