aboutsummaryrefslogtreecommitdiff
path: root/js/tools/drawing-tool-base.js
diff options
context:
space:
mode:
authorEric Guzman2012-05-02 17:13:38 -0700
committerEric Guzman2012-05-02 17:13:38 -0700
commit39ab9e427086c83661b07287328c254e0b5ba053 (patch)
tree3fc0925d2f8c5ef1322f084b6a2ed7def223ab80 /js/tools/drawing-tool-base.js
parenta183eff03cef60840ed360b3c9fc750b923a0a6b (diff)
parent691beb1c39fc0baa683f1fc56cbc519fe58f306d (diff)
downloadninja-39ab9e427086c83661b07287328c254e0b5ba053.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/tools/drawing-tool-base.js')
-rwxr-xr-xjs/tools/drawing-tool-base.js63
1 files changed, 36 insertions, 27 deletions
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 0b51aa28..7d97f105 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -24,6 +24,9 @@ exports.DrawingToolBase = Montage.create(Montage, {
24 value: null 24 value: null
25 }, 25 },
26 26
27 dragPlane: {
28 value: null
29 },
27 /** 30 /**
28 * Used on the initial MouseDown for Drawing Tools 31 * Used on the initial MouseDown for Drawing Tools
29 * 32 *
@@ -33,28 +36,30 @@ exports.DrawingToolBase = Montage.create(Montage, {
33 * 2 - Y value converted to screen point 36 * 2 - Y value converted to screen point
34 */ 37 */
35 getInitialSnapPoint: { 38 getInitialSnapPoint: {
36 value: function(x,y) { 39 value: function(x, y, shapeCanvas) {
40 snapManager.clearDragPlane();
41
37 // update the snap settings 42 // update the snap settings
38 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 43 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
39 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 44 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
40 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 45 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
41 46
42 // do the snap 47 // do the snap
43 var hitRec = snapManager.snap(x, y, true); 48 this.dragPlane = null;
44 var dragPlane; 49 var hitRec = snapManager.snap(x, y, true);
45 if (hitRec) { 50 if (hitRec) {
46 // set up the working plane and convert the hit record to be working plane relative 51 if (shapeCanvas)
47 if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer)
48 { 52 {
49 dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); 53 this.dragPlane = viewUtils.getUnprojectedElementPlane( shapeCanvas );
50 snapManager.setupDragPlaneFromPlane( dragPlane ); 54 snapManager.setupDragPlaneFromPlane( this.dragPlane );
51 } 55 }
52 else 56 else
53 { 57 {
54 dragPlane = snapManager.setupDragPlanes( hitRec ); 58 this.dragPlane = snapManager.setupDragPlanes( hitRec, true );
55 } 59 }
60// console.log( "drag plane: " + this.dragPlane );
56 61
57 var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); 62 var wpHitRec = hitRec.convertToWorkingPlane( this.dragPlane );
58 var pt = hitRec.getScreenPoint(); 63 var pt = hitRec.getScreenPoint();
59 64
60 return( [wpHitRec, pt[0], pt[1]] ); 65 return( [wpHitRec, pt[0], pt[1]] );
@@ -72,28 +77,32 @@ exports.DrawingToolBase = Montage.create(Montage, {
72 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() ); 77 snapManager.enableElementSnap( snapManager.elementSnapEnabledAppLevel() );
73 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() ); 78 snapManager.enableGridSnap( snapManager.gridSnapEnabledAppLevel() );
74 79
75
76 // do the first snap
77 var hitRec = snapManager.snap(x, y, snap3d ); 80 var hitRec = snapManager.snap(x, y, snap3d );
78 if (hitRec) { 81 if (hitRec) {
79 if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) { 82// if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
80 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() ); 83// hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
81 } 84// }
82 85//
83 if(downHitRec !== null) { 86// if(downHitRec !== null) {
84 // if we are working off-plane, do a snap to the projected locations of the geometry 87// // if we are working off-plane, do a snap to the projected locations of the geometry
85 var thePlane = workingPlane; 88// var thePlane = workingPlane;
86 if (snapManager.hasDragPlane()) 89// if (snapManager.hasDragPlane())
87 { 90// {
88 thePlane = snapManager.getDragPlane(); 91// thePlane = snapManager.getDragPlane();
89 } 92// }
90 93//
91 // Return the up HitRec 94// // Return the up HitRec
92 return hitRec; 95// return hitRec;
93 } else { 96// } else {
94 return null; 97// return null;
98// }
99 if(downHitRec) {
100 hitRec = hitRec.convertToWorkingPlane(this.dragPlane);
101 } else if ((hitRec.getType() !== hitRec.SNAP_TYPE_STAGE) && !hitRec.isSomeGridTypeSnap()) {
102 hitRec = hitRec.convertToWorkingPlane( snapManager.getDragPlane() );
95 } 103 }
96 } 104 }
105 return hitRec;
97 } 106 }
98 }, 107 },
99 108