diff options
author | hwc487 | 2012-05-02 17:00:46 -0700 |
---|---|---|
committer | hwc487 | 2012-05-02 17:00:46 -0700 |
commit | 571e4518d9550113d5696a61bbc07be8379ff4ac (patch) | |
tree | d8e4fc5964ec005b0c75e414c6eb80a3b04b09f4 /js/tools | |
parent | 8eac5582b72115969a9f915f4303535c22018033 (diff) | |
parent | 691beb1c39fc0baa683f1fc56cbc519fe58f306d (diff) | |
download | ninja-571e4518d9550113d5696a61bbc07be8379ff4ac.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 18 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 3 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 63 | ||||
-rwxr-xr-x | js/tools/drawing-tool.js | 3 |
4 files changed, 57 insertions, 30 deletions
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index d1701304..2a9c63db 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js | |||
@@ -96,6 +96,12 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
96 | viewUtils.pushViewportObj( stage ); | 96 | viewUtils.pushViewportObj( stage ); |
97 | var eltCtr = viewUtils.getCenterOfProjection(); | 97 | var eltCtr = viewUtils.getCenterOfProjection(); |
98 | viewUtils.popViewportObj(); | 98 | viewUtils.popViewportObj(); |
99 | // if(this.application.ninja.documentController.webTemplate) | ||
100 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") | ||
101 | { | ||
102 | eltCtr[0] = stage.scrollWidth/2; | ||
103 | eltCtr[1] = stage.scrollHeight/2; | ||
104 | } | ||
99 | 105 | ||
100 | var curMat = viewUtils.getMatrixFromElement(stage); | 106 | var curMat = viewUtils.getMatrixFromElement(stage); |
101 | var curMatInv = glmat4.inverse(curMat, []); | 107 | var curMatInv = glmat4.inverse(curMat, []); |
@@ -113,8 +119,16 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
113 | 119 | ||
114 | this._origin = viewUtils.localToGlobal(eltCtr, stage); | 120 | this._origin = viewUtils.localToGlobal(eltCtr, stage); |
115 | 121 | ||
116 | this._setTransformOrigin(false); | 122 | // if(this.application.ninja.documentController.webTemplate) |
117 | 123 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") | |
124 | { | ||
125 | this._startOriginArray = []; | ||
126 | this._startOriginArray.push(this._origin.slice()); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | this._setTransformOrigin(false); | ||
131 | } | ||
118 | this.DrawHandles(); | 132 | this.DrawHandles(); |
119 | } | 133 | } |
120 | }, | 134 | }, |
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 8f45891d..d2337000 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -106,6 +106,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
106 | if(wasSelected) { | 106 | if(wasSelected) { |
107 | this.AddCustomFeedback(); | 107 | this.AddCustomFeedback(); |
108 | this.application.ninja.elementMediator.addDelegate = this; | 108 | this.application.ninja.elementMediator.addDelegate = this; |
109 | if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") { | ||
110 | this._targetedElement = this.application.ninja.currentSelectedContainer; | ||
111 | } | ||
109 | } else { | 112 | } else { |
110 | this.RemoveCustomFeedback(); | 113 | this.RemoveCustomFeedback(); |
111 | this.application.ninja.elementMediator.addDelegate = null; | 114 | this.application.ninja.elementMediator.addDelegate = null; |
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 | ||
diff --git a/js/tools/drawing-tool.js b/js/tools/drawing-tool.js index dc5f7996..d906fdf9 100755 --- a/js/tools/drawing-tool.js +++ b/js/tools/drawing-tool.js | |||
@@ -72,10 +72,11 @@ exports.DrawingTool = Montage.create(ToolBase, { | |||
72 | var snapData, point; | 72 | var snapData, point; |
73 | 73 | ||
74 | this._isDrawing = true; | 74 | this._isDrawing = true; |
75 | this.mouseDownHitRec = null; | ||
75 | this.mouseUpHitRec = null; | 76 | this.mouseUpHitRec = null; |
76 | 77 | ||
77 | point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); | 78 | point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); |
78 | snapData = DrawingToolBase.getInitialSnapPoint(point.x, point.y); //event.layerX, event.layerY); | 79 | snapData = DrawingToolBase.getInitialSnapPoint(point.x, point.y, this._targetedElement); //event.layerX, event.layerY); |
79 | this.mouseDownHitRec = snapData[0]; | 80 | this.mouseDownHitRec = snapData[0]; |
80 | this.downPoint.x = snapData[1]; | 81 | this.downPoint.x = snapData[1]; |
81 | this.downPoint.y = snapData[2]; | 82 | this.downPoint.y = snapData[2]; |