diff options
author | Valerio Virgillito | 2012-05-30 10:33:16 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-30 10:33:16 -0700 |
commit | 0c2f181ca565f9c3b68fcfdc7124416e2e2fa647 (patch) | |
tree | f6d5300c528a69305abd30ffea1beee016241375 /js/stage/stage.reel/stage.js | |
parent | 31b094ee21102f99a4021d505bc3a28527c9e23d (diff) | |
parent | d4f2df2a7b3ec79fc54e17f09195dbc37331f051 (diff) | |
download | ninja-0c2f181ca565f9c3b68fcfdc7124416e2e2fa647.tar.gz |
Merge branch 'Dom-Architecture' of github.com:mqg734/ninja-internal into document-bindings-fix
Conflicts:
js/stage/stage-deps.js
js/stage/stage.reel/stage.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-x | js/stage/stage.reel/stage.js | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index da5a4f76..4505ff66 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -97,6 +97,12 @@ exports.Stage = Montage.create(Component, { | |||
97 | _layoutCanvas: { value: null }, | 97 | _layoutCanvas: { value: null }, |
98 | layoutCanvas: { get: function() { return this._layoutCanvas; } }, | 98 | layoutCanvas: { get: function() { return this._layoutCanvas; } }, |
99 | 99 | ||
100 | _gridCanvas: { value: null }, | ||
101 | gridCanvas: { get: function() { return this._gridCanvas; } }, | ||
102 | |||
103 | _gridContext: { value: null }, | ||
104 | gridContext: { get: function() { return this._gridContext; } }, | ||
105 | |||
100 | _drawingCanvas: { value: null }, | 106 | _drawingCanvas: { value: null }, |
101 | drawingCanvas: { get: function() { return this._drawingCanvas; } }, | 107 | drawingCanvas: { get: function() { return this._drawingCanvas; } }, |
102 | 108 | ||
@@ -183,7 +189,7 @@ exports.Stage = Montage.create(Component, { | |||
183 | this.initWithDocument(false); | 189 | this.initWithDocument(false); |
184 | } | 190 | } |
185 | } | 191 | } |
186 | }, | 192 | }, |
187 | 193 | ||
188 | _userPaddingLeft: { value: 0 }, | 194 | _userPaddingLeft: { value: 0 }, |
189 | _userPaddingTop: { value: 0 }, | 195 | _userPaddingTop: { value: 0 }, |
@@ -194,7 +200,7 @@ exports.Stage = Montage.create(Component, { | |||
194 | this._userPaddingLeft = value; | 200 | this._userPaddingLeft = value; |
195 | this._documentOffsetLeft = -value; | 201 | this._documentOffsetLeft = -value; |
196 | this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; | 202 | this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; |
197 | this.userContentLeft = this._documentOffsetLeft; | 203 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; |
198 | this.updatedStage = true; | 204 | this.updatedStage = true; |
199 | } | 205 | } |
200 | }, | 206 | }, |
@@ -205,7 +211,7 @@ exports.Stage = Montage.create(Component, { | |||
205 | this._userPaddingTop = value; | 211 | this._userPaddingTop = value; |
206 | this._documentOffsetTop = -value; | 212 | this._documentOffsetTop = -value; |
207 | this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; | 213 | this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; |
208 | this.userContentTop = this._documentOffsetTop; | 214 | this.userContentTop = this._documentOffsetTop - this._scrollTop; |
209 | this.updatedStage = true; | 215 | this.updatedStage = true; |
210 | } | 216 | } |
211 | }, | 217 | }, |
@@ -214,11 +220,14 @@ exports.Stage = Montage.create(Component, { | |||
214 | value: function() { | 220 | value: function() { |
215 | if(this.resizeCanvases) { | 221 | if(this.resizeCanvases) { |
216 | // TODO GET THE SCROLL SIZE FROM THE CSS -- 11 px | 222 | // TODO GET THE SCROLL SIZE FROM THE CSS -- 11 px |
217 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; | 223 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ; |
218 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11;// - 26 - 26; | 224 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this._gridCanvas.height = this.element.offsetHeight - 11;// - 26 - 26; |
219 | 225 | ||
220 | // Hack for now until a full component | 226 | // Hack for now until a full component |
221 | this.layout.draw(); | 227 | this.layout.draw(); |
228 | if(this.application.ninja.currentDocument) { | ||
229 | this.layout.draw3DInfo(true); | ||
230 | } | ||
222 | } else if(this.updatedStage) { | 231 | } else if(this.updatedStage) { |
223 | this.layout.draw(); | 232 | this.layout.draw(); |
224 | this.layout.draw3DInfo(true); | 233 | this.layout.draw3DInfo(true); |
@@ -238,6 +247,7 @@ exports.Stage = Montage.create(Component, { | |||
238 | 247 | ||
239 | this._context = this._canvas.getContext("2d"); | 248 | this._context = this._canvas.getContext("2d"); |
240 | this._drawingContext= this._drawingCanvas.getContext("2d"); | 249 | this._drawingContext= this._drawingCanvas.getContext("2d"); |
250 | this._gridContext= this._gridCanvas.getContext("2d"); | ||
241 | 251 | ||
242 | // Setup event listeners | 252 | // Setup event listeners |
243 | this._drawingCanvas.addEventListener("mousedown", this, false); | 253 | this._drawingCanvas.addEventListener("mousedown", this, false); |
@@ -281,8 +291,8 @@ exports.Stage = Montage.create(Component, { | |||
281 | var designView = this.application.ninja.currentDocument.model.views.design; | 291 | var designView = this.application.ninja.currentDocument.model.views.design; |
282 | 292 | ||
283 | // Recalculate the canvas sizes because of splitter resizing | 293 | // Recalculate the canvas sizes because of splitter resizing |
284 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; | 294 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ; |
285 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; | 295 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this._gridCanvas.height = this.element.offsetHeight - 11; |
286 | 296 | ||
287 | designView.iframe.contentWindow.addEventListener("scroll", this, false); | 297 | designView.iframe.contentWindow.addEventListener("scroll", this, false); |
288 | 298 | ||
@@ -300,6 +310,8 @@ exports.Stage = Montage.create(Component, { | |||
300 | this._scrollLeft = 0; | 310 | this._scrollLeft = 0; |
301 | this._scrollTop = 0; | 311 | this._scrollTop = 0; |
302 | 312 | ||
313 | this.initialize3DOnOpenDocument(); | ||
314 | |||
303 | if(designView._template) { | 315 | if(designView._template) { |
304 | var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); | 316 | var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); |
305 | var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); | 317 | var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); |
@@ -521,11 +533,12 @@ exports.Stage = Montage.create(Component, { | |||
521 | this._canvas.style.visibility = "hidden"; | 533 | this._canvas.style.visibility = "hidden"; |
522 | this._layoutCanvas.style.visibility = "hidden"; | 534 | this._layoutCanvas.style.visibility = "hidden"; |
523 | this._drawingCanvas.style.visibility = "hidden"; | 535 | this._drawingCanvas.style.visibility = "hidden"; |
536 | this._gridCanvas.style.visibility = "hidden"; | ||
524 | } else { | 537 | } else { |
525 | this._canvas.style.visibility = "visible"; | 538 | this._canvas.style.visibility = "visible"; |
526 | this._layoutCanvas.style.visibility = "visible"; | 539 | this._layoutCanvas.style.visibility = "visible"; |
527 | this._drawingCanvas.style.visibility = "visible"; | 540 | this._drawingCanvas.style.visibility = "visible"; |
528 | 541 | this._gridCanvas.style.visibility = "visible"; | |
529 | } | 542 | } |
530 | } | 543 | } |
531 | }, | 544 | }, |
@@ -562,10 +575,17 @@ exports.Stage = Montage.create(Component, { | |||
562 | } | 575 | } |
563 | }, | 576 | }, |
564 | 577 | ||
578 | clearGridCanvas: { | ||
579 | value: function() { | ||
580 | this._gridContext.clearRect(0, 0, this._gridCanvas.width, this._gridCanvas.height); | ||
581 | } | ||
582 | }, | ||
583 | |||
565 | clearAllCanvas: { | 584 | clearAllCanvas: { |
566 | value: function() { | 585 | value: function() { |
567 | this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); | 586 | this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); |
568 | this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); | 587 | this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); |
588 | this._gridContext.clearRect(0, 0, this._gridCanvas.width, this._gridCanvas.height); | ||
569 | this.layout.clearCanvas(); | 589 | this.layout.clearCanvas(); |
570 | } | 590 | } |
571 | }, | 591 | }, |
@@ -1063,6 +1083,18 @@ exports.Stage = Montage.create(Component, { | |||
1063 | this.application.ninja.toolsSplitter.restore(); | 1083 | this.application.ninja.toolsSplitter.restore(); |
1064 | this.application.ninja.optionsSplitter.restore(); | 1084 | this.application.ninja.optionsSplitter.restore(); |
1065 | } | 1085 | } |
1086 | }, | ||
1087 | |||
1088 | initialize3DOnOpenDocument: { | ||
1089 | value: function() { | ||
1090 | |||
1091 | workingPlane = [0,0,1,0]; | ||
1092 | |||
1093 | this.snapManager._isCacheInvalid = true; | ||
1094 | this.snapManager.setupDragPlaneFromPlane (workingPlane); | ||
1095 | |||
1096 | this.drawUtils.initializeFromDocument(); | ||
1097 | } | ||
1066 | } | 1098 | } |
1067 | 1099 | ||
1068 | }); \ No newline at end of file | 1100 | }); \ No newline at end of file |