diff options
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-x | js/stage/stage.reel/stage.js | 265 |
1 files changed, 221 insertions, 44 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 63339c57..33c4fd22 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -11,6 +11,11 @@ var Montage = require("montage/core/core").Montage, | |||
11 | 11 | ||
12 | exports.Stage = Montage.create(Component, { | 12 | exports.Stage = Montage.create(Component, { |
13 | 13 | ||
14 | appModel: { | ||
15 | value: null, | ||
16 | serializable: true | ||
17 | }, | ||
18 | |||
14 | // TODO - Need to figure out how to remove this dependency | 19 | // TODO - Need to figure out how to remove this dependency |
15 | // Needed by some tools that depend on selectionDrawn event to set up some logic | 20 | // Needed by some tools that depend on selectionDrawn event to set up some logic |
16 | drawNow: { value : false }, | 21 | drawNow: { value : false }, |
@@ -25,7 +30,10 @@ exports.Stage = Montage.create(Component, { | |||
25 | value: null | 30 | value: null |
26 | }, | 31 | }, |
27 | 32 | ||
28 | _iframeContainer: { value: null }, | 33 | _iframeContainer: { |
34 | value: null, | ||
35 | serializable: true | ||
36 | }, | ||
29 | 37 | ||
30 | _scrollFlag: {value: true, writable: true}, | 38 | _scrollFlag: {value: true, writable: true}, |
31 | outFlag: { value: false, writable: true }, | 39 | outFlag: { value: false, writable: true }, |
@@ -91,29 +99,82 @@ exports.Stage = Montage.create(Component, { | |||
91 | }, | 99 | }, |
92 | 100 | ||
93 | /** MAIN CANVASES **/ | 101 | /** MAIN CANVASES **/ |
94 | _canvas: { value: null }, // selection bounds, 3d normals and the overall 3d selection box use this canvas | 102 | // selection bounds, 3d normals and the overall 3d selection box use this canvas |
95 | canvas: { get: function() { return this._canvas; } }, | 103 | _canvas: { |
104 | value: null, | ||
105 | serializable: true | ||
106 | }, | ||
107 | |||
108 | canvas: { | ||
109 | get: function() { | ||
110 | return this._canvas; | ||
111 | } | ||
112 | }, | ||
96 | 113 | ||
97 | _context: { value: null }, | 114 | _context: { value: null }, |
98 | context: { get: function() { return this._context; } }, | 115 | context: { get: function() { return this._context; } }, |
99 | 116 | ||
100 | _layoutCanvas: { value: null }, | 117 | _layoutCanvas: { |
101 | layoutCanvas: { get: function() { return this._layoutCanvas; } }, | 118 | value: null, |
119 | serializable: true | ||
120 | }, | ||
102 | 121 | ||
103 | _gridCanvas: { value: null }, | 122 | layoutCanvas: { |
104 | gridCanvas: { get: function() { return this._gridCanvas; } }, | 123 | get: function() { |
124 | return this._layoutCanvas; | ||
125 | } | ||
126 | }, | ||
127 | |||
128 | _gridCanvas: { | ||
129 | value: null, | ||
130 | serializable: true | ||
131 | }, | ||
132 | |||
133 | gridCanvas: { | ||
134 | get: function() { | ||
135 | return this._gridCanvas; | ||
136 | } | ||
137 | }, | ||
105 | 138 | ||
106 | _gridContext: { value: null }, | 139 | _gridContext: { value: null }, |
107 | gridContext: { get: function() { return this._gridContext; } }, | 140 | gridContext: { get: function() { return this._gridContext; } }, |
108 | 141 | ||
109 | _drawingCanvas: { value: null }, | 142 | _drawingCanvas: { |
110 | drawingCanvas: { get: function() { return this._drawingCanvas; } }, | 143 | value: null, |
144 | serializable: true | ||
145 | }, | ||
146 | |||
147 | drawingCanvas: { | ||
148 | get: function() { | ||
149 | return this._drawingCanvas; | ||
150 | } | ||
151 | }, | ||
111 | 152 | ||
112 | _drawingContext: { value: null }, | 153 | _drawingContext: { value: null }, |
113 | drawingContext: { get: function() { return this._drawingContext; } }, | 154 | drawingContext: { get: function() { return this._drawingContext; } }, |
114 | 155 | ||
115 | _clickPoint: { value: { x: { value: null }, y: { value: null } } }, | 156 | _clickPoint: { value: { x: { value: null }, y: { value: null } } }, |
116 | 157 | ||
158 | stageDeps: { | ||
159 | value: null, | ||
160 | serializable: true | ||
161 | }, | ||
162 | |||
163 | layout: { | ||
164 | value: null, | ||
165 | serializable: true | ||
166 | }, | ||
167 | |||
168 | textTool: { | ||
169 | value: null, | ||
170 | serializable: true | ||
171 | }, | ||
172 | |||
173 | focusManager: { | ||
174 | value: null, | ||
175 | serializable: true | ||
176 | }, | ||
177 | |||
117 | // We will set this to false while moving objects to improve performance | 178 | // We will set this to false while moving objects to improve performance |
118 | showSelectionBounds: { value: true }, | 179 | showSelectionBounds: { value: true }, |
119 | 180 | ||
@@ -185,6 +246,13 @@ exports.Stage = Montage.create(Component, { | |||
185 | if(this.currentDocument && (this.currentDocument.currentView === "design")) { | 246 | if(this.currentDocument && (this.currentDocument.currentView === "design")) { |
186 | this.currentDocument.model.scrollLeft = this._scrollLeft; | 247 | this.currentDocument.model.scrollLeft = this._scrollLeft; |
187 | this.currentDocument.model.scrollTop = this._scrollTop; | 248 | this.currentDocument.model.scrollTop = this._scrollTop; |
249 | this.currentDocument.model.userPaddingLeft = this._userPaddingLeft; | ||
250 | this.currentDocument.model.userPaddingTop = this._userPaddingTop; | ||
251 | this.currentDocument.model.documentOffsetLeft = this._documentOffsetLeft; | ||
252 | this.currentDocument.model.documentOffsetTop = this._documentOffsetTop; | ||
253 | this.currentDocument.model.userContentLeft = this._userContentLeft; | ||
254 | this.currentDocument.model.userContentTop = this._userContentTop; | ||
255 | |||
188 | //call configure false with the old document on the selected tool to tear down down any temp. stuff | 256 | //call configure false with the old document on the selected tool to tear down down any temp. stuff |
189 | this.application.ninja.toolsData.selectedToolInstance._configure(false); | 257 | this.application.ninja.toolsData.selectedToolInstance._configure(false); |
190 | } | 258 | } |
@@ -279,9 +347,6 @@ exports.Stage = Montage.create(Component, { | |||
279 | 347 | ||
280 | this.eventManager.addEventListener( "appMouseUp", this, false); | 348 | this.eventManager.addEventListener( "appMouseUp", this, false); |
281 | 349 | ||
282 | |||
283 | this.eventManager.addEventListener( "openDocument", this, false); | ||
284 | this.eventManager.addEventListener( "switchDocument", this, false); | ||
285 | this.eventManager.addEventListener( "enableStageMove", this, false); | 350 | this.eventManager.addEventListener( "enableStageMove", this, false); |
286 | this.eventManager.addEventListener( "disableStageMove", this, false); | 351 | this.eventManager.addEventListener( "disableStageMove", this, false); |
287 | 352 | ||
@@ -289,19 +354,9 @@ exports.Stage = Montage.create(Component, { | |||
289 | this.eventManager.addEventListener( "elementChanging", this, false); | 354 | this.eventManager.addEventListener( "elementChanging", this, false); |
290 | this.eventManager.addEventListener( "elementChange", this, false); | 355 | this.eventManager.addEventListener( "elementChange", this, false); |
291 | 356 | ||
292 | } | 357 | this.addPropertyChangeListener("currentDocument.model.domContainer", this, true); |
293 | }, | 358 | // this.addPropertyChangeListener("currentDocument.model.domContainer", this); |
294 | |||
295 | // Event details will contain the active document prior to opening a new one | ||
296 | handleOpenDocument: { | ||
297 | value: function(evt) { | ||
298 | this.initWithDocument(); | ||
299 | } | ||
300 | }, | ||
301 | 359 | ||
302 | handleSwitchDocument: { | ||
303 | value: function(evt) { | ||
304 | this.initWithDocument(true); | ||
305 | } | 360 | } |
306 | }, | 361 | }, |
307 | 362 | ||
@@ -313,6 +368,23 @@ exports.Stage = Montage.create(Component, { | |||
313 | 368 | ||
314 | if(model.scrollLeft != null) { | 369 | if(model.scrollLeft != null) { |
315 | didSwitch = true; | 370 | didSwitch = true; |
371 | this._userPaddingLeft = this.currentDocument.model.userPaddingLeft; | ||
372 | this._userPaddingTop = this.currentDocument.model.userPaddingTop; | ||
373 | this._documentOffsetLeft = this.currentDocument.model.documentOffsetLeft; | ||
374 | this._documentOffsetTop = this.currentDocument.model.documentOffsetTop; | ||
375 | this._userContentLeft = this.currentDocument.model.userContentLeft; | ||
376 | this._userContentTop = this.currentDocument.model.userContentTop; | ||
377 | this._scrollLeft = this.currentDocument.model.scrollLeft; | ||
378 | this._scrollTop = this.currentDocument.model.scrollTop; | ||
379 | } else { | ||
380 | this._userPaddingLeft = 0; | ||
381 | this._userPaddingTop = 0; | ||
382 | this._documentOffsetLeft = 0; | ||
383 | this._documentOffsetTop = 0; | ||
384 | this._userContentLeft = 0; | ||
385 | this._userContentTop = 0; | ||
386 | this._scrollLeft = 0; | ||
387 | this._scrollTop = 0; | ||
316 | } | 388 | } |
317 | 389 | ||
318 | // Recalculate the canvas sizes because of splitter resizing | 390 | // Recalculate the canvas sizes because of splitter resizing |
@@ -323,19 +395,7 @@ exports.Stage = Montage.create(Component, { | |||
323 | 395 | ||
324 | this.addPropertyChangeListener("appModel.show3dGrid", this, false); | 396 | this.addPropertyChangeListener("appModel.show3dGrid", this, false); |
325 | 397 | ||
326 | this._userPaddingLeft = 0; | 398 | this.initialize3DOnOpenDocument(!didSwitch); |
327 | this._userPaddingTop = 0; | ||
328 | |||
329 | this._documentOffsetLeft = 0; | ||
330 | this._documentOffsetTop = 0; | ||
331 | |||
332 | this._userContentLeft = 0; | ||
333 | this._userContentTop = 0; | ||
334 | |||
335 | this._scrollLeft = 0; | ||
336 | this._scrollTop = 0; | ||
337 | |||
338 | this.initialize3DOnOpenDocument(); | ||
339 | 399 | ||
340 | if(designView._template) { | 400 | if(designView._template) { |
341 | var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); | 401 | var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); |
@@ -380,6 +440,17 @@ exports.Stage = Montage.create(Component, { | |||
380 | this.updatedStage = true; | 440 | this.updatedStage = true; |
381 | } | 441 | } |
382 | } | 442 | } |
443 | /* | ||
444 | else if(notification.currentPropertyPath === "currentDocument.model.domContainer") { | ||
445 | if() | ||
446 | } | ||
447 | */ | ||
448 | } | ||
449 |