aboutsummaryrefslogtreecommitdiff
path: root/js/stage/layout.js
diff options
context:
space:
mode:
authorEric Guzman2012-06-11 13:28:42 -0700
committerEric Guzman2012-06-11 13:28:42 -0700
commit3a4727ffc350216a434a7c6977b6a23653b77780 (patch)
treec5dff306f8803c36a16163ba5df1e7f492e762b5 /js/stage/layout.js
parentd6b46ba496c9c8974ae39bb476aea35bcd1ddaf1 (diff)
parent337efc667372326ae2f9984d89a47bb151016774 (diff)
downloadninja-3a4727ffc350216a434a7c6977b6a23653b77780.tar.gz
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Diffstat (limited to 'js/stage/layout.js')
-rwxr-xr-xjs/stage/layout.js52
1 files changed, 33 insertions, 19 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index 460c8b4a..71296405 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -23,6 +23,30 @@ exports.Layout = Montage.create(Component, {
23 drawFillColor: { value: 'rgba(255,255,255,1)' }, 23 drawFillColor: { value: 'rgba(255,255,255,1)' },
24 ctxLineWidth: { value: 0.2 }, 24 ctxLineWidth: { value: 0.2 },
25 25
26 _currentDocument: {
27 value : null,
28 enumerable : false
29 },
30
31 currentDocument : {
32 get : function() {
33 return this._currentDocument;
34 },
35 set : function(value) {
36 if (value === this._currentDocument) {// || value.getProperty("currentView") !== "design") {
37 return;
38 }
39
40 this._currentDocument = value;
41
42 if(!value) {
43
44 } else if(this._currentDocument.currentView === "design") {
45 this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes;
46 }
47 }
48 },
49
26 _layoutView: { 50 _layoutView: {
27 value: "layoutAll" 51 value: "layoutAll"
28 }, 52 },
@@ -58,15 +82,6 @@ exports.Layout = Montage.create(Component, {
58 } 82 }
59 }, 83 },
60 84
61 handleOpenDocument: {
62 value: function() {
63 // Initial elements to draw are the childrens of the root element
64 if(this.application.ninja.documentController.activeDocument.currentView === "design") {
65 this.elementsToDraw = this.application.ninja.documentController.activeDocument.model.documentRoot.childNodes;
66 }
67 }
68 },
69
70 // Redraw stage only once after all deletion is completed 85 // Redraw stage only once after all deletion is completed
71 handleElementsRemoved: { 86 handleElementsRemoved: {
72 value: function(event) { 87 value: function(event) {
@@ -79,11 +94,11 @@ exports.Layout = Montage.create(Component, {
79 value: function(event) { 94 value: function(event) {
80 var containerIndex; 95 var containerIndex;
81 96
82 if(this.application.ninja.documentController.activeDocument === null){ 97 if(this.currentDocument === null){
83 return; 98 return;
84 } 99 }
85 100
86 if(this.application.ninja.documentController.activeDocument.currentView === "design"){ 101 if(this.currentDocument.currentView === "design"){
87 // Make an array copy of the line node list which is not an array like object 102 // Make an array copy of the line node list which is not an array like object
88 this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); 103 this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true);
89 // Index of the current container 104 // Index of the current container
@@ -121,6 +136,10 @@ exports.Layout = Montage.create(Component, {
121 value: function() { 136 value: function() {
122 this.clearCanvas(); 137 this.clearCanvas();
123 138
139 // TODO Bind the layoutview mode to the current document
140 // var mode = this.application.ninja.currentDocument.layoutMode;
141 if(this.layoutView === "layoutOff") return;
142
124 var els = this.elementsToDraw.length; 143 var els = this.elementsToDraw.length;
125 for(var i = 0, el; i < els; i++){ 144 for(var i = 0, el; i < els; i++){
126 this.drawTagOutline(this.elementsToDraw[i]); 145 this.drawTagOutline(this.elementsToDraw[i]);
@@ -132,13 +151,13 @@ exports.Layout = Montage.create(Component, {
132 value: function(updatePlanes) { 151 value: function(updatePlanes) {
133 if(updatePlanes) { 152 if(updatePlanes) {
134 drawUtils.updatePlanes(); 153 drawUtils.updatePlanes();
154 this.application.ninja.stage.stageDeps.snapManager._isCacheInvalid = true;
135 } 155 }
136 156
137 if(this.stage.appModel.show3dGrid) { 157 if(this.stage.appModel.show3dGrid) {
138 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView(); 158 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView();
139 drawUtils.drawWorkingPlane();
140 } 159 }
141 160 drawUtils.drawWorkingPlane();
142 drawUtils.draw3DCompass(); 161 drawUtils.draw3DCompass();
143 } 162 }
144 }, 163 },
@@ -154,11 +173,6 @@ exports.Layout = Montage.create(Component, {
154 173
155 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return; 174 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return;
156 175
157 // TODO Bind the layoutview mode to the current document
158 // var mode = this.application.ninja.currentDocument.layoutMode;
159
160 if(this.layoutView === "layoutOff") return;
161
162 // Don't draw outlines for shapes. 176 // Don't draw outlines for shapes.
163 // TODO Use the element mediator/controller/model to see if its a shape 177 // TODO Use the element mediator/controller/model to see if its a shape
164 // if (utilsModule.utils.isElementAShape(item)) return; 178 // if (utilsModule.utils.isElementAShape(item)) return;
@@ -219,7 +233,7 @@ exports.Layout = Montage.create(Component, {
219 if(this.layoutView === "layoutAll") { 233 if(this.layoutView === "layoutAll") {
220 this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke 234 this.ctx.strokeStyle = 'rgba(0,0,0,1)'; // Black Stroke
221 this.ctx.strokeRect(bounds3D[0][0]+5.5, bounds3D[0][1]-15.5, 70, 11); 235 this.ctx.strokeRect(bounds3D[0][0]+5.5, bounds3D[0][1]-15.5, 70, 11);
222 this.ctx.fillStyle = 'rgba(255,255,255,1)' // White Fill 236 this.ctx.fillStyle = 'rgba(255,255,255,1)'; // White Fill
223 this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10); 237 this.ctx.fillRect(bounds3D[0][0]+6, bounds3D[0][1]-15, 69, 10);
224 238
225 this.ctx.fillStyle = 'rgba(0,0,0,1)'; 239 this.ctx.fillStyle = 'rgba(0,0,0,1)';