From db4f235dc9fd6f2242dee481d2f377005cf23596 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Jul 2012 16:56:52 -0700 Subject: adding a viewIdentifier to the model to enable design/code switch Todo: - Cleanup and remove listeners - Finish stage reload - Add remaining bindings. Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'js/stage/stage.reel/stage.js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 817220d4..39336b57 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -368,6 +368,8 @@ exports.Stage = Montage.create(Component, { this.clearAllCanvas(); this.initWithDocument(); + + this._currentDocument.addPropertyChangeListener("model.currentView", this, false); } else { this.collapseAllPanels(); this.hideCanvas(true); @@ -376,6 +378,20 @@ exports.Stage = Montage.create(Component, { } }, + handleDocumentViewChange: { + value: function() { + if(this.currentDocument.model.currentView.identifier === "design-code") { + this.collapseAllPanels(); + this.hideRulers(); + this.hideCanvas(true); + } else { + this.restoreAllPanels(true); + this.hideCanvas(false); + this.showRulers(); + } + } + }, + _userPaddingLeft: { value: 0 }, _userPaddingTop: { value: 0 }, @@ -492,8 +508,6 @@ exports.Stage = Montage.create(Component, { this.eventManager.addEventListener( "elementChange", this, false); this.addPropertyChangeListener("currentDocument.model.domContainer", this, true); -// this.addPropertyChangeListener("currentDocument.model.domContainer", this); - } }, @@ -586,6 +600,8 @@ exports.Stage = Montage.create(Component, { drawUtils.drawXZ = false; this.updatedStage = true; } + } else if(notification.currentPropertyPath === "model.currentView") { + this.handleDocumentViewChange(); } /* else if(notification.currentPropertyPath === "currentDocument.model.domContainer") { -- cgit v1.2.3 From 1fae8b14621970680ca51c2a4a5f4f8006e1aee2 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 25 Jul 2012 00:04:22 -0700 Subject: design/code view switching for stage and menu Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'js/stage/stage.reel/stage.js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 39336b57..883f1526 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -349,6 +349,9 @@ exports.Stage = Montage.create(Component, { //call configure false with the old document on the selected tool to tear down down any temp. stuff this.application.ninja.toolsData.selectedToolInstance._configure(false); + + // Remove the change listener + this._currentDocument.removePropertyChangeListener("model.currentViewIdentifier", this, false); } else if(this.currentDocument && (this.currentDocument.currentView === "code")) { this.switchedFromCodeDoc = true; // Switching from code document affects stage's size and scrollbar } @@ -369,7 +372,7 @@ exports.Stage = Montage.create(Component, { this.clearAllCanvas(); this.initWithDocument(); - this._currentDocument.addPropertyChangeListener("model.currentView", this, false); + this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false); } else { this.collapseAllPanels(); this.hideCanvas(true); @@ -381,6 +384,9 @@ exports.Stage = Montage.create(Component, { handleDocumentViewChange: { value: function() { if(this.currentDocument.model.currentView.identifier === "design-code") { + drawUtils._eltArray.length = 0; + drawUtils._planesArray.length = 0; + this.collapseAllPanels(); this.hideRulers(); this.hideCanvas(true); @@ -388,6 +394,9 @@ exports.Stage = Montage.create(Component, { this.restoreAllPanels(true); this.hideCanvas(false); this.showRulers(); + + this.clearAllCanvas(); + this.initWithDocument(); } } }, @@ -600,7 +609,7 @@ exports.Stage = Montage.create(Component, { drawUtils.drawXZ = false; this.updatedStage = true; } - } else if(notification.currentPropertyPath === "model.currentView") { + } else if(notification.currentPropertyPath === "model.currentViewIdentifier") { this.handleDocumentViewChange(); } /* -- cgit v1.2.3