aboutsummaryrefslogtreecommitdiff
path: root/js/tools/SelectionTool.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-12 17:06:05 -0700
committerNivesh Rajbhandari2012-03-12 17:06:05 -0700
commit9d885aae7a17b4fc731a41f6b1ac8840092b83ac (patch)
tree4e2fd901492df729cac529ca5fa924d90582fd4e /js/tools/SelectionTool.js
parent5fb358d9e80a364d5f300d60b7a9fe0f773741e7 (diff)
downloadninja-9d885aae7a17b4fc731a41f6b1ac8840092b83ac.tar.gz
Fixing snapping bugs in Selection, translate and rotate tools.
We should show snap marker on mouse move for selection tool prior to mousing down as well. We should create drag plane parallel to the view and where the user moused down. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools/SelectionTool.js')
-rwxr-xr-xjs/tools/SelectionTool.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 6d8ff175..13a04944 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -16,6 +16,7 @@ var Montage = require("montage/core/core").Montage,
16var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { 16var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
17 drawingFeedback: { value: { mode: "Draw2D", type: "" } }, 17 drawingFeedback: { value: { mode: "Draw2D", type: "" } },
18 18
19 _inLocalMode: { value: false}, // This tool should always use global mode for translations
19 _canOperateOnStage: { value: true}, 20 _canOperateOnStage: { value: true},
20 _isSelecting: {value: false, writable:true}, 21 _isSelecting: {value: false, writable:true},
21 _shiftMove: { value: 10}, 22 _shiftMove: { value: 10},
@@ -34,14 +35,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
34 value: function () { 35 value: function () {
35 if(this._targets && this._targets.length) 36 if(this._targets && this._targets.length)
36 { 37 {
37 // TODO - drawUtils's elementPlanes check in drawSelectionBounds doesn't seem to work,
38 // so temporary workaround to simply check if all elements have identity matrix
39 // TODO - Eventually, this should instead check if all the selected items are on the view plane
40 var len = this._targets.length; 38 var len = this._targets.length;
39 var plane = this.application.ninja.stage.stageDeps.snapManager.getDragPlane();
41 for(var i = 0; i < len; i++) 40 for(var i = 0; i < len; i++)
42 { 41 {
43 var mat = this._targets[i].mat; 42 var elt = this._targets[i].elt;
44 if(!MathUtils.isIdentityMatrix(mat)) 43 if(!this.application.ninja.stage.stageDeps.snapManager.elementIsOnPlane(elt, plane))
45 { 44 {
46 return false; 45 return false;
47 } 46 }
@@ -123,14 +122,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
123 this.doDraw(event); 122 this.doDraw(event);
124 } else { 123 } else {
125 this._showFeedbackOnMouseMove(event); 124 this._showFeedbackOnMouseMove(event);
126 // if(this._canSnap) 125 if(this._canSnap)
127 // { 126 {
128 // this.doSnap(event); 127 this.doSnap(event);
129 // } 128 }
130 } 129 }
131 130
132 this.DrawHandles(this._delta); 131 this.DrawHandles(this._delta);
133 if(this._canSnap && this._isDrawing) 132 if(this._canSnap)
134 { 133 {
135 this.application.ninja.stage.stageDeps.snapManager.drawLastHit(); 134 this.application.ninja.stage.stageDeps.snapManager.drawLastHit();
136 } 135 }
@@ -704,6 +703,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
704 */ 703 */
705 _showFeedbackOnMouseMove : { 704 _showFeedbackOnMouseMove : {
706 value: function (event) { 705 value: function (event) {
706 if(!this._showTransformHandles)
707 {
708 return;
709 }
707 if(this._target && this._handles) 710 if(this._target && this._handles)
708 { 711 {
709 var len = this._handles.length; 712 var len = this._handles.length;