diff options
author | Eric Guzman | 2012-05-17 17:43:05 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-17 17:43:05 -0700 |
commit | 458a4598ed64e3d8c6010a216fb7fb4b3c3c87e7 (patch) | |
tree | ee329e409fe28ae54c894b9e27e82e1f85aefc85 /js/helper-classes | |
parent | 82954f400f7f8609aef0d2bc1f44c9d960907be6 (diff) | |
parent | 52394cdd71bd62c8c109fd135fa146b7183fbd1f (diff) | |
download | ninja-458a4598ed64e3d8c6010a216fb7fb4b3c3c87e7.tar.gz |
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into CSSPanelUpdates
Conflicts:
js/document/templates/montage-html/default_html.css
js/lib/NJUtils.js
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 94 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 20 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 15 |
3 files changed, 85 insertions, 44 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 88830964..a6d2d899 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -119,19 +119,43 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
119 | 119 | ||
120 | initializeFromDocument:{ | 120 | initializeFromDocument:{ |
121 | value:function(){ | 121 | value:function(){ |
122 | var documentRootChildren = null, i; | 122 | var documentRootChildren = null, i, stage = this.application.ninja.stage; |
123 | //initialize with current document | 123 | //initialize with current document |
124 | this._eltArray = []; | 124 | this._eltArray = []; |
125 | this._planesArray = []; | 125 | this._planesArray = []; |
126 | this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); | 126 | this.setDrawingSurfaceElement(stage.canvas); |
127 | this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); | 127 | this.setSourceSpaceElement( stage.stageDeps.currentStage ); |
128 | this.setWorkingPlane( [0,0,1,0] ); | 128 | this.setWorkingPlane( [0,0,1,0] ); |
129 | 129 | ||
130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them | 130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them |
131 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ | 131 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ |
132 | documentRootChildren = this.application.ninja.currentDocument._liveNodeList; | 132 | documentRootChildren = this.application.ninja.currentDocument._liveNodeList; |
133 | for(i=0;i<documentRootChildren.length;i++){ | 133 | var len = documentRootChildren.length, |
134 | this.addElement(documentRootChildren[i]); | 134 | minLeft = stage.userPaddingLeft, |
135 | minTop = stage.userPaddingTop, | ||
136 | docLeft = stage.documentOffsetLeft, | ||
137 | docTop = stage.documentOffsetTop, | ||
138 | l, | ||
139 | t, | ||
140 | plane, | ||
141 | elt | ||
142 | for(i=0; i<len; i++) { | ||
143 | elt = documentRootChildren[i]; | ||
144 | plane = this.addElement(elt); | ||
145 | l = plane._rect.m_left - docLeft; | ||
146 | t = plane._rect.m_top - docTop; | ||
147 | if(l < minLeft) { | ||
148 | minLeft = l; | ||
149 | } | ||
150 | if(t < minTop) { | ||
151 | minTop = t; | ||
152 | } | ||
153 | } | ||
154 | if(minLeft !== stage.userPaddingLeft) { | ||
155 | stage.userPaddingLeft = minLeft; | ||
156 | } | ||
157 | if(minTop !== stage.userPaddingTop) { | ||
158 | stage.userPaddingTop = minTop; | ||
135 | } | 159 | } |
136 | } | 160 | } |
137 | } | 161 | } |
@@ -245,16 +269,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
245 | } | 269 | } |
246 | var els = event.detail.data.els; | 270 | var els = event.detail.data.els; |
247 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { | 271 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { |
248 | var len = els.length; | 272 | var len = els.length, |
273 | stage = this.application.ninja.stage, | ||
274 | minLeft = stage.userPaddingLeft, | ||
275 | minTop = stage.userPaddingTop, | ||
276 | docLeft = stage.documentOffsetLeft, | ||
277 | docTop = stage.documentOffsetTop, | ||
278 | l, | ||
279 | t, | ||
280 | plane, | ||
281 | changed = false; | ||
249 | for(var i=0; i < len; i++) { | 282 | for(var i=0; i < len; i++) { |
250 | if(els[i].elementModel.props3D.elementPlane) { | 283 | plane = els[i].elementModel.props3D.elementPlane; |
251 | els[i].elementModel.props3D.elementPlane.init(); | 284 | if(plane) { |
285 | plane.init(); | ||
286 | l = plane._rect.m_left - docLeft; | ||
287 | t = plane._rect.m_top - docTop; | ||
288 | if(l < minLeft) { | ||
289 | minLeft = l; | ||
290 | } | ||
291 | if(t < minTop) { | ||
292 | minTop = t; | ||
293 | } | ||
252 | } | 294 | } |
253 | } | 295 | } |
254 | 296 | ||
255 | this.application.ninja.stage.layout.draw(); | 297 | if(minLeft !== stage.userPaddingLeft) { |
256 | this.drawWorkingPlane(); | 298 | stage.userPaddingLeft = minLeft; |
257 | this.draw3DCompass(); | 299 | changed = true; |
300 | } | ||
301 | if(minTop !== stage.userPaddingTop) { | ||
302 | stage.userPaddingTop = minTop; | ||
303 | changed = true; | ||
304 | } | ||
305 | |||
306 | if(!changed) { | ||
307 | stage.layout.draw(); | ||
308 | this.drawWorkingPlane(); | ||
309 | this.draw3DCompass(); | ||
310 | } | ||
258 | } | 311 | } |
259 | } | 312 | } |
260 | }, | 313 | }, |
@@ -281,6 +334,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
281 | plane.init(); | 334 | plane.init(); |
282 | this._planesArray.push( plane ); | 335 | this._planesArray.push( plane ); |
283 | elt.elementModel.props3D.elementPlane = plane; | 336 | elt.elementModel.props3D.elementPlane = plane; |
337 | return plane; | ||
284 | } | 338 | } |
285 | }, | 339 | }, |
286 | 340 | ||
@@ -584,18 +638,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
584 | var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); | 638 | var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); |
585 | 639 | ||
586 | // define the grid parameters | 640 | // define the grid parameters |
587 | var width, | 641 | var width = this.snapManager.getStageWidth(), |
588 | height, | 642 | height = this.snapManager.getStageHeight(), |
589 | nLines = 10; | 643 | nLines = 10; |
590 | 644 | ||
591 | // if(this.application.ninja.documentController.webTemplate) { | ||
592 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { | ||
593 | width = this.application.ninja.currentDocument.documentRoot.scrollWidth; | ||
594 | height = this.application.ninja.currentDocument.documentRoot.scrollHeight; | ||
595 | } else { | ||
596 | width = this.snapManager.getStageWidth(); | ||
597 | height = this.snapManager.getStageHeight(); | ||
598 | } | ||
599 | // get a matrix from working plane space to the world | 645 | // get a matrix from working plane space to the world |
600 | var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); | 646 | var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); |
601 | var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] ); | 647 | var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] ); |
@@ -1178,8 +1224,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1178 | var saveColor = this._lineColor; | 1224 | var saveColor = this._lineColor; |
1179 | var saveLineWidth = this._lineWidth; | 1225 | var saveLineWidth = this._lineWidth; |
1180 | 1226 | ||
1181 | var origLeft = 50; | 1227 | var origLeft = 60; |
1182 | var origTop = 50; | 1228 | var origTop = this.snapManager.getStageHeight() - 60; |
1183 | 1229 | ||
1184 | var mat = this.viewUtils.getMatrixFromElement( this._sourceSpaceElt ); | 1230 | var mat = this.viewUtils.getMatrixFromElement( this._sourceSpaceElt ); |
1185 | var tMat = Matrix.Translation([origLeft,origTop,0]); | 1231 | var tMat = Matrix.Translation([origLeft,origTop,0]); |
@@ -1211,7 +1257,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1211 | this.setDrawingSurfaceElement(this.application.ninja.stage.layoutCanvas); | 1257 | this.setDrawingSurfaceElement(this.application.ninja.stage.layoutCanvas); |
1212 | // clear just the 3d compass area | 1258 | // clear just the 3d compass area |
1213 | this._drawingContext.save(); | 1259 | this._drawingContext.save(); |
1214 | this._drawingContext.rect(0, 0, 100, 100); | 1260 | this._drawingContext.rect(10, origTop-60, 100, 110); |
1215 | this._drawingContext.clip(); | 1261 | this._drawingContext.clip(); |
1216 | 1262 | ||
1217 | this._drawingContext.lineWidth = 2.0; | 1263 | this._drawingContext.lineWidth = 2.0; |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 6766ac7f..2e8020d3 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -130,10 +130,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
130 | 130 | ||
131 | bindSnap: { | 131 | bindSnap: { |
132 | value: function() { | 132 | value: function() { |
133 | this.addEventListener("change@appModel.snap", this.toggleSnap, false); | 133 | this.addPropertyChangeListener("appModel.snap", this.toggleSnap, false); |
134 | this.addEventListener("change@appModel.snapGrid", this.toggleSnapGrid, false); | 134 | this.addPropertyChangeListener("appModel.snapGrid", this.toggleSnapGrid, false); |
135 | this.addEventListener("change@appModel.snapObjects", this.toggleSnapObjects, false); | 135 | this.addPropertyChangeListener("appModel.snapObjects", this.toggleSnapObjects, false); |
136 | this.addEventListener("change@appModel.snapAlign", this.toggleSnapAlign, false); | 136 | this.addPropertyChangeListener("appModel.snapAlign", this.toggleSnapAlign, false); |
137 | } | 137 | } |
138 | }, | 138 | }, |
139 | 139 | ||
@@ -1617,11 +1617,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1617 | if (x > y) { | 1617 | if (x > y) { |
1618 | if (x > z) { | 1618 | if (x > z) { |
1619 | plane[0] = 1; | 1619 | plane[0] = 1; |
1620 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { | 1620 | plane[3] = this.getStageWidth() / 2.0; |
1621 | plane[3] = stage.scrollWidth / 2.0; | ||
1622 | } else { | ||
1623 | plane[3] = this.getStageWidth() / 2.0; | ||
1624 | } | ||
1625 | if (dir[0] > 0) plane[3] = -plane[3]; | 1621 | if (dir[0] > 0) plane[3] = -plane[3]; |
1626 | change = !drawUtils.drawYZ; | 1622 | change = !drawUtils.drawYZ; |
1627 | drawUtils.drawXY = drawUtils.drawXZ = false; | 1623 | drawUtils.drawXY = drawUtils.drawXZ = false; |
@@ -1639,11 +1635,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1639 | else { | 1635 | else { |
1640 | if (y > z) { | 1636 | if (y > z) { |
1641 | plane[1] = 1; | 1637 | plane[1] = 1; |
1642 | if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { |