diff options
author | Armen Kesablyan | 2012-05-25 11:22:58 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-05-25 11:22:58 -0700 |
commit | 81239571c538f72e398fafa5b07725bf1bbb2d5d (patch) | |
tree | d31c876f5af61565eff8c934c9e5f119696d46e0 /js/tools | |
parent | e8c4e98c24092a360eb2f637983fd104fbb67f66 (diff) | |
parent | 9c8d724dd1605ee2e5257591e0bfaad575cbc906 (diff) | |
download | ninja-81239571c538f72e398fafa5b07725bf1bbb2d5d.tar.gz |
Merge branch 'refs/heads/dom-architecture' into binding
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/PanTool.js | 16 | ||||
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 12 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 20 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 6 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 4 | ||||
-rwxr-xr-x | js/tools/ZoomTool.js | 2 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 12 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 8 |
8 files changed, 41 insertions, 39 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 5cfeec75..39f89d17 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -47,8 +47,8 @@ exports.PanTool = Montage.create(toolBase, | |||
47 | HandleLeftButtonDown: { | 47 | HandleLeftButtonDown: { |
48 | value : function ( event ) { | 48 | value : function ( event ) { |
49 | // Determine the maximum horizontal and vertical scroll values | 49 | // Determine the maximum horizontal and vertical scroll values |
50 | this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; | 50 | this._maxHorizontalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; |
51 | this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; | 51 | this._maxVerticalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; |
52 | if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) | 52 | if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) |
53 | { | 53 | { |
54 | this._isDrawing = true; | 54 | this._isDrawing = true; |
@@ -121,7 +121,7 @@ exports.PanTool = Montage.create(toolBase, | |||
121 | { | 121 | { |
122 | value: function () | 122 | value: function () |
123 | { | 123 | { |
124 | var uc = this.application.ninja.currentDocument.documentRoot; | 124 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
125 | //var uc = documentManagerModule.DocumentManager.activeDocument | 125 | //var uc = documentManagerModule.DocumentManager.activeDocument |
126 | var ucMat = viewUtils.getMatrixFromElement(uc); | 126 | var ucMat = viewUtils.getMatrixFromElement(uc); |
127 | 127 | ||
@@ -152,7 +152,7 @@ exports.PanTool = Montage.create(toolBase, | |||
152 | 152 | ||
153 | delta *= zoom; | 153 | delta *= zoom; |
154 | 154 | ||
155 | var uc = this.application.ninja.currentDocument.documentRoot; | 155 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
156 | var ucMat = viewUtils.getMatrixFromElement(uc); | 156 | var ucMat = viewUtils.getMatrixFromElement(uc); |
157 | var offset = viewUtils.getElementOffset( uc ); | 157 | var offset = viewUtils.getElementOffset( uc ); |
158 | //console.log( "uc offset: " + offset[0] ); | 158 | //console.log( "uc offset: " + offset[0] ); |
@@ -224,7 +224,7 @@ exports.PanTool = Montage.create(toolBase, | |||
224 | if (elt) | 224 | if (elt) |
225 | { | 225 | { |
226 | // get the userContent object (stage) and its matrix | 226 | // get the userContent object (stage) and its matrix |
227 | var userContent = this.application.ninja.currentDocument.documentRoot; | 227 | var userContent = this.application.ninja.currentDocument.model.documentRoot; |
228 | var ucMat = viewUtils.getMatrixFromElement(userContent); | 228 | var ucMat = viewUtils.getMatrixFromElement(userContent); |
229 | 229 | ||
230 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); | 230 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); |
@@ -358,7 +358,7 @@ exports.PanTool = Montage.create(toolBase, | |||
358 | delta[2] = 0; | 358 | delta[2] = 0; |
359 | 359 | ||
360 | // limit the change | 360 | // limit the change |
361 | var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); | 361 | var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.model.documentRoot); |
362 | var tooMuch = false; | 362 | var tooMuch = false; |
363 | if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; | 363 | if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; |
364 | if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; | 364 | if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; |
@@ -397,7 +397,7 @@ exports.PanTool = Montage.create(toolBase, | |||
397 | value: function( transMat ) | 397 | value: function( transMat ) |
398 | { | 398 | { |
399 | // update the user content matrix | 399 | // update the user content matrix |
400 | var uc = this.application.ninja.currentDocument.documentRoot; | 400 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
401 | var ucMat = viewUtils.getMatrixFromElement(uc); | 401 | var ucMat = viewUtils.getMatrixFromElement(uc); |
402 | var newUCMat = glmat4.multiply( transMat, ucMat, [] ); | 402 | var newUCMat = glmat4.multiply( transMat, ucMat, [] ); |
403 | viewUtils.setMatrixForElement( uc, newUCMat ); | 403 | viewUtils.setMatrixForElement( uc, newUCMat ); |
@@ -412,7 +412,7 @@ exports.PanTool = Montage.create(toolBase, | |||
412 | value: function() | 412 | value: function() |
413 | { | 413 | { |
414 | // get the userContent object | 414 | // get the userContent object |
415 | var userContent = this.application.ninja.currentDocument.documentRoot; | 415 | var userContent = this.application.ninja.currentDocument.model.documentRoot; |
416 | 416 | ||
417 | // get a matrix from user content world space to the screen | 417 | // get a matrix from user content world space to the screen |
418 | viewUtils.pushViewportObj( userContent ); | 418 | viewUtils.pushViewportObj( userContent ); |
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 4fa8657e..bf9537dd 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js | |||
@@ -32,7 +32,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
32 | 32 | ||
33 | var selectedElements = this.application.ninja.selectedElements; | 33 | var selectedElements = this.application.ninja.selectedElements; |
34 | if(this.rotateStage) { | 34 | if(this.rotateStage) { |
35 | selectedElements = [this.application.ninja.currentDocument.documentRoot]; | 35 | selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; |
36 | } | 36 | } |
37 | 37 | ||
38 | this._mouseDownHitRec = null; | 38 | this._mouseDownHitRec = null; |
@@ -225,7 +225,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
225 | 225 | ||
226 | var selectedElements = this.application.ninja.selectedElements; | 226 | var selectedElements = this.application.ninja.selectedElements; |
227 | if(this.rotateStage) { | 227 | if(this.rotateStage) { |
228 | selectedElements = [this.application.ninja.currentDocument.documentRoot]; | 228 | selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; |
229 | } | 229 | } |
230 | 230 | ||
231 | if(this._handleMode !== null) | 231 | if(this._handleMode !== null) |
@@ -345,7 +345,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
345 | var selectedElements = this.application.ninja.selectedElements; | 345 | var selectedElements = this.application.ninja.selectedElements; |
346 | 346 | ||
347 | if(this.rotateStage) { | 347 | if(this.rotateStage) { |
348 | selectedElements = [this.application.ninja.currentDocument.documentRoot]; | 348 | selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; |
349 | } | 349 | } |
350 | var len = selectedElements.length; | 350 | var len = selectedElements.length; |
351 | for(var i = 0; i < len; i++) { | 351 | for(var i = 0; i < len; i++) { |
@@ -481,7 +481,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
481 | } | 481 | } |
482 | else | 482 | else |
483 | { | 483 | { |
484 | this.target = this.application.ninja.currentDocument.documentRoot; | 484 | this.target = this.application.ninja.currentDocument.model.documentRoot; |
485 | //this._origin = drawUtils._selectionCtr.slice(0); | 485 | //this._origin = drawUtils._selectionCtr.slice(0); |
486 | //this._origin[0] += this.application.ninja.stage.userContentLeft; | 486 | //this._origin[0] += this.application.ninja.stage.userContentLeft; |
487 | //this._origin[1] += this.application.ninja.stage.userContentTop; | 487 | //this._origin[1] += this.application.ninja.stage.userContentTop; |
@@ -609,7 +609,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
609 | 609 | ||
610 | if(this.rotateStage || (this.application.ninja.selectedElements.length === 1)) { | 610 | if(this.rotateStage || (this.application.ninja.selectedElements.length === 1)) { |
611 | if(this.rotateStage) { | 611 | if(this.rotateStage) { |
612 | element = this.application.ninja.currentDocument.documentRoot; | 612 | element = this.application.ninja.currentDocument.model.documentRoot; |
613 | } else { | 613 | } else { |
614 | element = this.application.ninja.selectedElements[0]; | 614 | element = this.application.ninja.selectedElements[0]; |
615 | } | 615 | } |
@@ -851,7 +851,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { | |||
851 | else | 851 | else |
852 | { | 852 | { |
853 | lMode = false; | 853 | lMode = false; |
854 | viewUtils.pushViewportObj( this.application.ninja.currentDocument.documentRoot ); | 854 | viewUtils.pushViewportObj( this.application.ninja.currentDocument.model.documentRoot ); |
855 | } | 855 | } |
856 | var base = this._origin; | 856 | var base = this._origin; |
857 | //console.log( "Rotate3DToolBase.DrawHandles, base: " + base ); | 857 | //console.log( "Rotate3DToolBase.DrawHandles, base: " + base ); |
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js index c8818021..12b21a64 100755 --- a/js/tools/RotateStage3DTool.js +++ b/js/tools/RotateStage3DTool.js | |||
@@ -90,7 +90,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
90 | this._origin = null; | 90 | this._origin = null; |
91 | this._startOriginArray = null; | 91 | this._startOriginArray = null; |
92 | 92 | ||
93 | var stage = this.application.ninja.currentDocument.documentRoot; | 93 | var stage = this.application.ninja.currentDocument.model.documentRoot; |
94 | this.target = stage; | 94 | this.target = stage; |
95 | 95 | ||
96 | viewUtils.pushViewportObj( stage ); | 96 | viewUtils.pushViewportObj( stage ); |
@@ -119,7 +119,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
119 | 119 | ||
120 | captureElementChange: { | 120 | captureElementChange: { |
121 | value: function(event) { | 121 | value: function(event) { |
122 | if(event._event.item === this.application.ninja.currentDocument.documentRoot) | 122 | if(event._event.item === this.application.ninja.currentDocument.model.documentRoot) |
123 | { | 123 | { |
124 | this.captureSelectionDrawn(null); | 124 | this.captureSelectionDrawn(null); |
125 | } | 125 | } |
@@ -130,20 +130,22 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, { | |||
130 | value : function() | 130 | value : function() |
131 | { | 131 | { |
132 | // Reset stage to identity matrix | 132 | // Reset stage to identity matrix |
133 | var iMat = Matrix.I(4); | 133 | var iMat = Matrix.I(4), |
134 | stage = this.application.ninja.stage; | ||
134 | 135 | ||
135 | ElementsMediator.setMatrix(this.application.ninja.currentDocument.documentRoot, | 136 | ElementsMediator.setMatrix(this.application.ninja.currentDocument.model.documentRoot, |
136 | iMat, false, "rotateStage3DTool"); | 137 | iMat, false, "rotateStage3DTool"); |
137 | this.application.ninja.currentDocument.documentRoot.elementModel.props3D.m_transformCtr = null; | 138 | this.application.ninja.currentDocument.model.documentRoot.elementModel.props3D.m_transformCtr = null; |
138 | 139 | ||
139 | // let the document and stage manager know about the zoom change | 140 | // let the document and stage manager know about the zoom change |
140 | this.application.ninja.stage._firstDraw = true; | 141 | stage._firstDraw = true; |
141 | this.application.ninja.documentBar.zoomFactor = 100; | 142 | this.application.ninja.documentBar.zoomFactor = 100; |
142 | this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; | 143 | this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0; |
143 | this.application.ninja.stage._firstDraw = false; | 144 | stage._firstDraw = false; |
144 | 145 | ||
145 | // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? | 146 | viewUtils.clearStageTranslation(); |
146 | this.application.ninja.stage.updatedStage = true; | 147 | stage.centerStage(); |
148 | stage.draw(); | ||
147 | 149 | ||
148 | this.isDrawing = false; | 150 | this.isDrawing = false; |
149 | this.endDraw(event); |