diff options
-rwxr-xr-x | js/stage/stage.reel/stage.js | 30 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 5 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 111 | ||||
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 40 | ||||
-rwxr-xr-x | js/tools/drawing-tool.js | 2 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 25 |
6 files changed, 159 insertions, 54 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index e139af97..00b72490 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -519,6 +519,36 @@ exports.Stage = Montage.create(Component, { | |||
519 | }, | 519 | }, |
520 | 520 | ||
521 | /** | 521 | /** |
522 | * GetSelectableElement: Returns a selectable object (direct child of current container) at clicked point | ||
523 | * | ||
524 | * @param: X,Y | ||
525 | * @return: Returns the current container if the the X,Y hits an element in the exclusion list | ||
526 | */ | ||
527 | GetSelectableElement: { | ||
528 | value: function(pos) { | ||
529 | var item = this.GetElement(pos); | ||
530 | if(this.application.ninja.currentDocument.inExclusion(item) !== -1) { | ||
531 | return this.application.ninja.currentSelectedContainer; | ||
532 | } | ||
533 | var activeContainerId = this.application.ninja.currentSelectedContainer.uuid; | ||
534 | if(item.parentNode.uuid === activeContainerId) { | ||
535 | return item; | ||
536 | } else { | ||
537 | var outerElement = item.parentNode; | ||
538 | |||
539 | while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) { | ||
540 | // If element is higher up than current container then return | ||
541 | if(outerElement.id === "UserContent") return; | ||
542 | // else keep going up the chain | ||
543 | outerElement = outerElement.parentNode; | ||
544 | } | ||
545 | |||
546 | return outerElement; | ||
547 | } | ||
548 | } | ||
549 | }, | ||
550 | |||
551 | /** | ||
522 | * GetElement: Returns the object under the X,Y coordinates passed as an obj with x,y | 552 | * GetElement: Returns the object under the X,Y coordinates passed as an obj with x,y |
523 | * | 553 | * |
524 | * @param: X,Y | 554 | * @param: X,Y |
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, | |||
18 | exports.Translate3DToolBase = Montage.create(ModifierToolBase, | 18 | exports.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 |