diff options
author | Nivesh Rajbhandari | 2012-05-24 11:11:47 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-05-24 11:11:47 -0700 |
commit | 209ec9524a987a8f8bc20c57e2a76ac55be15fd9 (patch) | |
tree | 80e5bf306dc5e24c3c502181354a37a2383bdd08 /js | |
parent | bf8a79b0ed1593b5b9e3085373dcdab9aeab055e (diff) | |
download | ninja-209ec9524a987a8f8bc20c57e2a76ac55be15fd9.tar.gz |
Fixed selection bug when switching/opening documents. Also, use saved scroll values when switching between documents.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/selection-controller.js | 5 | ||||
-rwxr-xr-x | js/stage/stage-deps.js | 2 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 40 |
3 files changed, 25 insertions, 22 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 1092615a..214b9032 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -67,10 +67,9 @@ exports.SelectionController = Montage.create(Component, { | |||
67 | this._isDocument = true; | 67 | this._isDocument = true; |
68 | 68 | ||
69 | if(currentSelectionArray) { | 69 | if(currentSelectionArray) { |
70 | if(currentSelectionArray.length >= 1) { | 70 | this.application.ninja.selectedElements = currentSelectionArray; |
71 | if(currentSelectionArray.length) { | ||
71 | this._isDocument = false; | 72 | this._isDocument = false; |
72 | |||
73 | this.application.ninja.selectedElements = currentSelectionArray; | ||
74 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); | 73 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); |
75 | } | 74 | } |
76 | } | 75 | } |
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index d018b03b..64adc01c 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js | |||
@@ -30,8 +30,6 @@ exports.StageDeps = Montage.create(Component, { | |||
30 | value: function() { | 30 | value: function() { |
31 | 31 | ||
32 | this.eventManager.addEventListener("appLoaded", this, false); | 32 | this.eventManager.addEventListener("appLoaded", this, false); |
33 | // this.eventManager.addEventListener("openDocument", this, false); | ||
34 | // this.eventManager.addEventListener("switchDocument", this, false); | ||
35 | 33 | ||
36 | // Initialize Deps | 34 | // Initialize Deps |
37 | // HACK | 35 | // HACK |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index ad05f1cc..6d421e4b 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -117,9 +117,6 @@ exports.Stage = Montage.create(Component, { | |||
117 | _userContentTop: { value: 0 }, | 117 | _userContentTop: { value: 0 }, |
118 | _userContentBorder: { value: 0 }, | 118 | _userContentBorder: { value: 0 }, |
119 | 119 | ||
120 | _maxHorizontalScroll: { value: 0 }, | ||
121 | _maxVerticalScroll: { value: 0 }, | ||
122 | |||
123 | viewport: { | 120 | viewport: { |
124 | get: function () { return this._viewport; }, | 121 | get: function () { return this._viewport; }, |
125 | set: function(value) { this._viewport = value; } | 122 | set: function(value) { this._viewport = value; } |
@@ -262,18 +259,18 @@ exports.Stage = Montage.create(Component, { | |||
262 | // Event details will contain the active document prior to opening a new one | 259 | // Event details will contain the active document prior to opening a new one |
263 | handleOpenDocument: { | 260 | handleOpenDocument: { |
264 | value: function(evt) { | 261 | value: function(evt) { |
265 | this._initFromDocument(evt); | 262 | this.initWithDocument(); |
266 | } | 263 | } |
267 | }, | 264 | }, |
268 | 265 | ||
269 | handleSwitchDocument: { | 266 | handleSwitchDocument: { |
270 | value: function(evt) { | 267 | value: function(evt) { |
271 | this._initFromDocument(evt); | 268 | this.initWithDocument(true); |
272 | } | 269 | } |
273 | }, | 270 | }, |
274 | 271 | ||
275 | _initFromDocument: { | 272 | initWithDocument: { |
276 | value: function(evt) { | 273 | value: function(didSwitch) { |
277 | var designView = this.application.ninja.currentDocument.model.views.design; | 274 | var designView = this.application.ninja.currentDocument.model.views.design; |
278 | 275 | ||
279 | this.hideCanvas(false); | 276 | this.hideCanvas(false); |
@@ -282,12 +279,22 @@ exports.Stage = Montage.create(Component, { | |||
282 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; | 279 | this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; |
283 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; | 280 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; |
284 | 281 | ||
285 | this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; | ||
286 | this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; | ||
287 | designView.iframe.contentWindow.addEventListener("scroll", this, false); | 282 | designView.iframe.contentWindow.addEventListener("scroll", this, false); |
288 | 283 | ||
289 | this.addPropertyChangeListener("appModel.show3dGrid", this, false); | 284 | this.addPropertyChangeListener("appModel.show3dGrid", this, false); |
290 | 285 | ||
286 | this._userPaddingLeft = 0; | ||
287 | this._userPaddingTop = 0; | ||
288 | |||
289 | this._documentOffsetLeft = 0; | ||
290 | this._documentOffsetTop = 0; | ||
291 | |||
292 | this._userContentLeft = 0; | ||
293 | this._userContentTop = 0; | ||
294 | |||
295 | this._scrollLeft = 0; | ||
296 | this._scrollTop = 0; | ||
297 | |||
291 | this.stageDeps.handleOpenDocument(); | 298 | this.stageDeps.handleOpenDocument(); |
292 | this.layout.handleOpenDocument(); | 299 | this.layout.handleOpenDocument(); |
293 | 300 | ||
@@ -302,7 +309,13 @@ exports.Stage = Montage.create(Component, { | |||
302 | } | 309 | } |
303 | } | 310 | } |
304 | 311 | ||
305 | this.centerStage(); | 312 | if(didSwitch) { |
313 | this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = this.application.ninja.currentDocument.model.scrollLeft; | ||
314 | this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = this.application.ninja.currentDocument.model.scrollTop; | ||
315 | this.handleScroll(); | ||
316 | } else { | ||
317 | this.centerStage(); | ||
318 | } | ||
306 | 319 | ||
307 | // TODO - We will need to modify this once we support switching between multiple documents | 320 | // TODO - We will need to modify this once we support switching between multiple documents |
308 | this.application.ninja.toolsData.selectedToolInstance._configure(true); | 321 | this.application.ninja.toolsData.selectedToolInstance._configure(true); |
@@ -488,13 +501,6 @@ exports.Stage = Montage.create(Component, { | |||
488 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; | 501 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; |
489 | this.userContentTop = this._documentOffsetTop - this._scrollTop; | 502 | this.userContentTop = this._documentOffsetTop - this._scrollTop; |
490 | 503 | ||
491 | // TODO - scroll events are not dependable. We may need to use a timer to simulate | ||
492 | // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values | ||
493 | // on mouse down. | ||
494 | // this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; | ||
495 | // this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; | ||
496 | |||
497 | |||
498 | // Need to clear the snap cache and set up the drag plane | 504 | // Need to clear the snap cache and set up the drag plane |
499 | //snapManager.setupDragPlaneFromPlane( workingPlane ); | 505 | //snapManager.setupDragPlaneFromPlane( workingPlane ); |
500 | this.stageDeps.snapManager._isCacheInvalid = true; | 506 | this.stageDeps.snapManager._isCacheInvalid = true; |