From 5d4002b7a920a53ea02b0e8caeaec80b804995e4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 8 Feb 2012 15:12:16 -0800 Subject: Merging fix for marquee selection that accounts for 3d values. Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'js/tools') 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, { var box = []; selectedItems = []; - box[0] = this.downPoint.x - this.application.ninja.stage.documentOffsetLeft + this.application.ninja.stage.scrollLeft; - box[1] = this.downPoint.y - this.application.ninja.stage.documentOffsetTop + this.application.ninja.stage.scrollTop; - box[2] = box[0] + (point.x - this.downPoint.x); - box[3] = box[1] + (point.y - this.downPoint.y); - box = this.absoluteRectangle(box[0], box[1],box[2],box[3]); - + box[0] = this.downPoint.x; + box[1] = this.downPoint.y; + box[2] = point.x; + box[3] = point.y; //selectionManagerModule.selectionManager.marqueeSelection(box); var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1 && SelectionTool._simpleCollisionDetection(item, box)) { + if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { selectedItems.push(item); } }); @@ -802,6 +800,34 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } }, + // TODO : Use the new element mediator to get element offsets + _complicatedCollisionDetection: + { + value: function(elt, box) + { + var left, top, width, height; + + left = box[0]; + width = box[2] - left; + if (width < 0) + { + left = box[2]; + width = -width; + } + top = box[1]; + height = box[3] - top; + if (height < 0) + { + top = box[3]; + height = -height; + } + + var rtnVal = MathUtils.rectsOverlap( [left,top], width, height, elt ); + + return rtnVal; + } + }, + // TODO : Use the new element mediator to get element offsets _simpleCollisionDetection: { value: function(ele, box){ -- cgit v1.2.3 From 4bd8b5ce3286d472fd852dc53ef07e90aadfb7e9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 08:47:33 -0800 Subject: Fixed runtime error when using 3d tools without any items selected. Signed-off-by: Nivesh Rajbhandari --- js/tools/Rotate3DToolBase.js | 2 +- js/tools/RotateStage3DTool.js | 2 +- js/tools/modifier-tool-base.js | 35 +++++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'js/tools') 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, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = null; + this._targets = []; this._startOriginArray = null; 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, { captureSelectionDrawn: { value: function(event){ this._origin = null; - this._targets = null; + this._targets = []; this._startOriginArray = null; var stage = this.application.ninja.currentDocument.documentRoot; 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, { startDraw: { value: function(event) { - this.isDrawing = true; - this.application.ninja.stage.showSelectionBounds = false; - - if(this._canSnap) - { - this.initializeSnapping(event); - } - else + if(this._target) { - this.drawWithoutSnapping(event); + this.isDrawing = true; + this.application.ninja.stage.showSelectionBounds = false; + + if(this._canSnap) + { + this.initializeSnapping(event); + } + else + { + this.drawWithoutSnapping(event); + } } } }, @@ -674,11 +677,15 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { return this._targets; }, set: function (value) { - this._target = value; - if (value === null) + this._targets = value; + if (value !== null && value.length) { - return; + this.target = value[0]; } + else + { + this.target = null; + } } }, @@ -723,7 +730,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { } else { this.eventManager.removeEventListener("selectionChange", this, true); this.application.ninja.stage._iframeContainer.removeEventListener("scroll", this, false); - this._targets = null; + this._targets = []; // Clean up NJevent("disableStageMove"); @@ -749,7 +756,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { captureSelectionDrawn: { value: function(event){ - this._targets = null; + this._targets = []; var len = this.application.ninja.selectedElements.length; if(len) -- cgit v1.2.3