aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/document-html.js2
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js76
-rwxr-xr-xjs/stage/stage.reel/stage.js41
3 files changed, 102 insertions, 17 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 87c776d5..a26b74d5 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -41,7 +41,7 @@ exports.HtmlDocument = Montage.create(Component, {
41 //////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////
42 // 42 //
43 exclusionList: { 43 exclusionList: {
44 value: ["HTML", "BODY"] //TODO: Update to correct list 44 value: ["HTML", "BODY", "NINJA-CONTENT"] //TODO: Update to correct list
45 }, 45 },
46 //////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////
47 // 47 //
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index b53ac4ad..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
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 93270561..cac99326 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -187,6 +187,37 @@ exports.Stage = Montage.create(Component, {
187 enumerable : false 187 enumerable : false
188 }, 188 },
189 189
190 _userPaddingLeft: { value: 0 },
191 _userPaddingTop: { value: 0 },
192
193 userPaddingLeft: {
194 get: function() { return this._userPaddingLeft; },
195 set: function(value) {
196 this._userPaddingLeft = value;
197 this._documentOffsetLeft = -value;
198 if(!this._documentRoot) {
199 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
200 }
201 this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px";
202 this.userContentLeft = this._documentOffsetLeft;
203 this.updatedStage = true;
204 }
205 },
206
207 userPaddingTop: {
208 get: function() { return this._userPaddingTop; },
209 set: function(value) {
210 this._userPaddingTop = value;
211 this._documentOffsetTop = -value;
212 if(!this._documentRoot) {
213 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
214 }
215 this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px";
216 this.userContentTop = this._documentOffsetTop;
217 this.updatedStage = true;
218 }
219 },
220
190 willDraw: { 221 willDraw: {
191 value: function() { 222 value: function() {
192 if(this.resizeCanvases) { 223 if(this.resizeCanvases) {
@@ -287,8 +318,8 @@ exports.Stage = Montage.create(Component, {
287 318
288 this._scrollLeft = 0; 319 this._scrollLeft = 0;
289 this._scrollTop = 0; 320 this._scrollTop = 0;
290 this._userContentLeft = 0; 321 this._userContentLeft = this._documentOffsetLeft;
291 this._userContentTop = 0; 322 this._userContentTop = this._documentOffsetTop;
292 323
293 this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; 324 this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11;
294 this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; 325 this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11;
@@ -489,8 +520,8 @@ exports.Stage = Montage.create(Component, {
489 this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; 520 this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft;
490 this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; 521 this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop;
491 522
492 this.userContentLeft = -this._scrollLeft; 523 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft;
493 this.userContentTop = -this._scrollTop; 524 this.userContentTop = this._documentOffsetTop - this._scrollTop;
494 525
495 // TODO - scroll events are not dependable. We may need to use a timer to simulate 526 // TODO - scroll events are not dependable. We may need to use a timer to simulate
496 // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values 527 // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values
@@ -581,7 +612,7 @@ exports.Stage = Montage.create(Component, {
581 var point, element, 612 var point, element,
582 docView = this.application.ninja.currentDocument.model.views.design; 613 docView = this.application.ninja.currentDocument.model.views.design;
583 614
584 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset, position.pageY - docView.iframe.contentWindow.pageYOffset)); 615 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop));
585 element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); 616 element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop);
586 617
587 if(!element) debugger; 618 if(!element) debugger;