aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorhwc4872012-03-21 15:26:24 -0700
committerhwc4872012-03-21 15:26:24 -0700
commit3f6c49bff64a9a765c16d2bd21994f57b557a94b (patch)
tree3a658595917a82aa67b9fc0de2916d5d7502feab /js/tools
parenteb59a523258cad3351cba9bf8de986e90a8e5b1c (diff)
parent57cc00a5ef3ab525e54a030d7692b2d9eefaa68b (diff)
downloadninja-3f6c49bff64a9a765c16d2bd21994f57b557a94b.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into integration
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/SelectionTool.js5
-rwxr-xr-xjs/tools/Translate3DToolBase.js111
-rwxr-xr-xjs/tools/TranslateObject3DTool.js40
-rwxr-xr-xjs/tools/drawing-tool.js2
-rwxr-xr-xjs/tools/modifier-tool-base.js25
5 files changed, 129 insertions, 54 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 5f48f74d..f9411f48 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -205,12 +205,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
205 { 205 {
206 this._handleMode = null; 206 this._handleMode = null;
207 this._delta = null; 207 this._delta = null;
208 this.DrawHandles();
209 } 208 }
210 209
211 this.endDraw(event); 210 this.endDraw(event);
212 this._canSnap = true; 211 this._canSnap = true;
213 this._use3DMode = false; 212 this._use3DMode = false;
213 this.DrawHandles();
214 } 214 }
215 }, 215 },
216 216
@@ -577,6 +577,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
577 { 577 {
578 // form the translation vector and post translate the matrix by it. 578 // form the translation vector and post translate the matrix by it.
579 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); 579 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 );
580 delta[2] = 0;
580 var transMat = Matrix.Translation( delta ); 581 var transMat = Matrix.Translation( delta );
581 this._moveElements(transMat); 582 this._moveElements(transMat);
582 } 583 }
@@ -710,7 +711,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
710 { 711 {
711 return; 712 return;
712 } 713 }
713 if(this._target && this._handles) 714 if(this._target && this._handles && (this._targets.length === 1))
714 { 715 {
715 var len = this._handles.length; 716 var len = this._handles.length;
716 var i = 0, 717 var i = 0,
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 24a68ad1..07b6d04d 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -18,6 +18,7 @@ var Montage = require("montage/core/core").Montage,
18exports.Translate3DToolBase = Montage.create(ModifierToolBase, 18exports.Translate3DToolBase = Montage.create(ModifierToolBase,
19{ 19{
20 _inLocalMode: { value: true, enumerable: true }, 20 _inLocalMode: { value: true, enumerable: true },
21 _clickedOnStage: { value: false },
21 22
22 HandleDoubleClick : { 23 HandleDoubleClick : {
23 value : function() 24 value : function()
@@ -47,17 +48,33 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
47 delta[1] = 0; 48 delta[1] = 0;
48 break; 49 break;
49 } 50 }
51 if( (this.application.ninja.selectedElements.length > 1) && this._clickedOnStage )
52 {
53 this._delta = ~~(delta[this._handleMode]);
54 }
55 else
56 {
57 this._delta += ~~(delta[this._handleMode]);
58 }
50 59
51 this._updateDelta(delta, this._handleMode);
52 } 60 }
53 else if(this._mode === 1) 61 else
54 { 62 {
55 delta[2] = delta[1]; 63 if(this._mode === 1)
56 delta[0] = 0; 64 {
57 delta[1] = 0; 65 delta[2] = delta[1];
66 delta[0] = 0;
67 delta[1] = 0;
68 }
69 else
70 {
71 delta[2] = 0;
72 }
73 this._delta = delta.slice(0);
58 } 74 }
59 75
60 var transMat = Matrix.Translation( delta ); 76 var transMat = Matrix.Translation( delta );
77
61 if(this._inLocalMode && (this._targets.length === 1) ) 78 if(this._inLocalMode && (this._targets.length === 1) )
62 { 79 {
63 this._translateLocally(transMat); 80 this._translateLocally(transMat);
@@ -139,7 +156,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
139 156
140 var shouldUpdateStartMat = true; 157 var shouldUpdateStartMat = true;
141 158
142 if(this._clickedObject === this.application.ninja.currentDocument.documentRoot) 159 if(this._clickedOnStage)
143 { 160 {
144 shouldUpdateStartMat = false; 161 shouldUpdateStartMat = false;
145 } 162 }
@@ -152,11 +169,15 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
152 { 169 {
153 item = this._targets[i]; 170 item = this._targets[i];
154 elt = item.elt; 171 elt = item.elt;
155 curMat = item.mat; 172 curMat = item.mat.slice(0);
156
157 glmat4.multiply(curMat, qMat, curMat);
158 173
159 viewUtils.setMatrixForElement( elt, curMat, true); 174// glmat4.multiply(curMat, qMat, curMat);
175//
176// viewUtils.setMatrixForElement( elt, curMat, true);
177 curMat[12] += transMat[12];
178 curMat[13] += transMat[13];
179 curMat[14] += transMat[14];
180 viewUtils.setMatrixForElement( elt, curMat, true);
160 181
161 if(shouldUpdateStartMat) 182 if(shouldUpdateStartMat)
162 { 183 {
@@ -198,6 +219,19 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
198 "translateTool", 219 "translateTool",
199 previousStyles 220 previousStyles
200 ); 221 );
222 if(this._origin && this._delta)
223 {
224 if(this._handleMode !== null)
225 {
226 this._origin[this._handleMode] += this._delta;
227 }
228 else
229 {
230 this._origin[0] += this._delta[0];
231 this._origin[1] += this._delta[1];
232 }
233 }
234 this._delta = null;
201 } 235 }
202 // Save previous value for undo/redo 236 // Save previous value for undo/redo
203 this._undoArray = []; 237 this._undoArray = [];
@@ -232,7 +266,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
232 } 266 }
233 }, 267 },
234 268
235 _getHandlesOrigin: { 269 _updateHandlesOrigin: {
236 value: function () { 270 value: function () {
237 var ctr; 271 var ctr;
238 272
@@ -243,30 +277,43 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
243 { 277 {
244 var item = this._target; 278 var item = this._target;
245 viewUtils.pushViewportObj( item ); 279 viewUtils.pushViewportObj( item );
246 var ctr = viewUtils.getCenterOfProjection(); 280 ctr = viewUtils.getCenterOfProjection();
247 viewUtils.popViewportObj(); 281 viewUtils.popViewportObj();
248 ctr[2] = 0; 282 ctr[2] = 0;
249 283
250 var ctrOffset = item.elementModel.props3D.m_transformCtr; 284// var ctrOffset = item.elementModel.props3D.m_transformCtr;
251 if(ctrOffset) 285// if(ctrOffset)
252 { 286// {
253 ctr = vecUtils.vecAdd(3, ctr, ctrOffset); 287// ctr = vecUtils.vecAdd(3, ctr, ctrOffset);
254 } 288// }
255 289
256 ctr = viewUtils.localToGlobal(ctr, item); 290 this._origin = viewUtils.localToGlobal(ctr, item);
257 } 291 }
258 else 292 else
259 { 293 {
260 ctr = drawUtils._selectionCtr.slice(0); 294 if(this._origin)
261 ctr[0] += this.application.ninja.stage.userContentLeft; 295 {
262 ctr[1] += this.application.ninja.stage.userContentTop; 296 if(this._delta)
263 297 {
264// ctr[0] += this.m_deltaPoint[0]; 298 if(this._handleMode !== null)
265// ctr[1] += this.m_deltaPoint[1]; 299 {
300// this._origin[this._handleMode] = this._delta;
301 }
302 else
303 {
304 this._origin[0] += this._delta[0];
305 this._origin[1] += this._delta[1];
306 }
307 }
308 }
309 else
310 {
311 this._origin = drawUtils._selectionCtr.slice(0);
312 this._origin[0] += this.application.ninja.stage.userContentLeft;
313 this._origin[1] += this.application.ninja.stage.userContentTop;
314 }
266 } 315 }
267 } 316 }