aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-07-25 07:52:19 -0700
committerJose Antonio Marquez Russo2012-07-25 07:52:19 -0700
commitbb2f1d0e9a559f44348e95ad726801a5031aea3a (patch)
treea73b1dbc93fd8cba24bc97475905d182d90a1d6b /js
parentc127d66ed02d61e281ce931a6caecfdcef7f2999 (diff)
parent1fae8b14621970680ca51c2a4a5f4f8006e1aee2 (diff)
downloadninja-bb2f1d0e9a559f44348e95ad726801a5031aea3a.tar.gz
Merge pull request #46 from mencio/document-switch
design/code view switching for stage and menu
Diffstat (limited to 'js')
-rwxr-xr-xjs/stage/stage.reel/stage.js13
-rw-r--r--js/ui/menu/menu-controller.js17
2 files changed, 28 insertions, 2 deletions
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, {
349 349
350 //call configure false with the old document on the selected tool to tear down down any temp. stuff 350 //call configure false with the old document on the selected tool to tear down down any temp. stuff
351 this.application.ninja.toolsData.selectedToolInstance._configure(false); 351 this.application.ninja.toolsData.selectedToolInstance._configure(false);
352
353 // Remove the change listener
354 this._currentDocument.removePropertyChangeListener("model.currentViewIdentifier", this, false);
352 } else if(this.currentDocument && (this.currentDocument.currentView === "code")) { 355 } else if(this.currentDocument && (this.currentDocument.currentView === "code")) {
353 this.switchedFromCodeDoc = true; // Switching from code document affects stage's size and scrollbar 356 this.switchedFromCodeDoc = true; // Switching from code document affects stage's size and scrollbar
354 } 357 }
@@ -369,7 +372,7 @@ exports.Stage = Montage.create(Component, {
369 this.clearAllCanvas(); 372 this.clearAllCanvas();
370 this.initWithDocument(); 373 this.initWithDocument();
371 374
372 this._currentDocument.addPropertyChangeListener("model.currentView", this, false); 375 this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false);
373 } else { 376 } else {
374 this.collapseAllPanels(); 377 this.collapseAllPanels();
375 this.hideCanvas(true); 378 this.hideCanvas(true);
@@ -381,6 +384,9 @@ exports.Stage = Montage.create(Component, {
381 handleDocumentViewChange: { 384 handleDocumentViewChange: {
382 value: function() { 385 value: function() {
383 if(this.currentDocument.model.currentView.identifier === "design-code") { 386 if(this.currentDocument.model.currentView.identifier === "design-code") {
387 drawUtils._eltArray.length = 0;
388 drawUtils._planesArray.length = 0;
389
384 this.collapseAllPanels(); 390 this.collapseAllPanels();
385 this.hideRulers(); 391 this.hideRulers();
386 this.hideCanvas(true); 392 this.hideCanvas(true);
@@ -388,6 +394,9 @@ exports.Stage = Montage.create(Component, {
388 this.restoreAllPanels(true); 394 this.restoreAllPanels(true);
389 this.hideCanvas(false); 395 this.hideCanvas(false);
390 this.showRulers(); 396 this.showRulers();
397
398 this.clearAllCanvas();
399 this.initWithDocument();
391 } 400 }
392 } 401 }
393 }, 402 },
@@ -600,7 +609,7 @@ exports.Stage = Montage.create(Component, {
600 drawUtils.drawXZ = false; 609 drawUtils.drawXZ = false;
601 this.updatedStage = true; 610 this.updatedStage = true;
602 } 611 }
603 } else if(notification.currentPropertyPath === "model.currentView") { 612 } else if(notification.currentPropertyPath === "model.currentViewIdentifier") {
604 this.handleDocumentViewChange(); 613 this.handleDocumentViewChange();
605 } 614 }
606 /* 615 /*
diff --git a/js/ui/menu/menu-controller.js b/js/ui/menu/menu-controller.js
index c80745f4..ebffddf1 100644
--- a/js/ui/menu/menu-controller.js
+++ b/js/ui/menu/menu-controller.js
@@ -56,6 +56,7 @@ exports.MenuController = Montage.create(Component, {
56 if(this._currentDocument && this._currentDocument.currentView === "design") { 56 if(this._currentDocument && this._currentDocument.currentView === "design") {
57 document.application.model.show3dGrid = this._currentDocument.model.draw3DGrid; 57 document.application.model.show3dGrid = this._currentDocument.model.draw3DGrid;
58 this.topLevelMenu[2].entries[5].checked = this._currentDocument.model.draw3DGrid; 58 this.topLevelMenu[2].entries[5].checked = this._currentDocument.model.draw3DGrid;
59 this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false);
59 } 60 }
60 61
61 if(!this._currentDocument) { 62 if(!this._currentDocument) {
@@ -85,6 +86,22 @@ exports.MenuController = Montage.create(Component, {
85 } 86 }
86 }, 87 },
87 88
89 handleChange: {
90 value: function(notification) {
91 if(notification.currentPropertyPath === "model.currentViewIdentifier") {
92 if(this.currentDocument.model.currentView.identifier === "design-code") {
93 this.designDocumentEnabledItems.forEach(function(index) {
94 index.enabled = false;
95 });
96 } else {
97 this.designDocumentEnabledItems.forEach(function(index) {
98 index.enabled = true;
99 });
100 }
101 }
102 }
103 },
104
88 didCreate: { 105 didCreate: {
89 value: function() { 106 value: function() {
90 var self = this; 107 var self = this;