aboutsummaryrefslogtreecommitdiff
path: root/js/stage/layout.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/stage/layout.js')
-rwxr-xr-xjs/stage/layout.js58
1 files changed, 10 insertions, 48 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index d133f100..5cc8dbea 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -67,19 +67,11 @@ exports.Layout = Montage.create(Component, {
67 return this._currentDocument; 67 return this._currentDocument;
68 }, 68 },
69 set : function(value) { 69 set : function(value) {
70 if (value === this._currentDocument) {// || value.getProperty("currentView") !== "design") { 70 if (value !== this._currentDocument) {
71 return; 71 this._currentDocument = value;
72 } 72 if(this._currentDocument && this._currentDocument.currentView === "design") {
73 73 this.elementsToDraw = Array.prototype.slice.call(this._currentDocument.model.documentRoot.childNodes, 0);
74 drawUtils._eltArray.length = 0; 74 }
75 drawUtils._planesArray.length = 0;
76
77 this._currentDocument = value;
78
79 if(!value) {
80
81 } else if(this._currentDocument.currentView === "design") {
82 this.elementsToDraw = this._currentDocument.model.documentRoot.childNodes;
83 } 75 }
84 } 76 }
85 }, 77 },
@@ -113,17 +105,6 @@ exports.Layout = Montage.create(Component, {
113 this.ctx = this.canvas.getContext("2d"); 105 this.ctx = this.canvas.getContext("2d");
114 this.ctx.lineWidth = this.ctxLineWidth; 106 this.ctx.lineWidth = this.ctxLineWidth;
115 this.ctx.fillStyle = this.drawFillColor; 107 this.ctx.fillStyle = this.drawFillColor;
116
117 this.eventManager.addEventListener("selectionChange", this, false);
118 this.eventManager.addEventListener("elementsRemoved", this, false);
119 }
120 },
121
122 // Redraw stage only once after all deletion is completed
123 handleElementsRemoved: {
124 value: function(event) {
125 this.draw();
126 this.draw3DInfo(false);
127 } 108 }
128 }, 109 },
129 110
@@ -131,13 +112,16 @@ exports.Layout = Montage.create(Component, {
131 value: function(event) { 112 value: function(event) {
132 var containerIndex; 113 var containerIndex;
133 114
115 // Clear the elements to draw
116 this.elementsToDraw.length = 0;
117
134 if(this.currentDocument === null){ 118 if(this.currentDocument === null){
135 return; 119 return;
136 } 120 }
137 121
138 if(this.currentDocument.currentView === "design"){ 122 if(this.currentDocument.currentView === "design"){
139 // Make an array copy of the line node list which is not an array like object 123 // Make an array copy of the live node list which is not an array like object
140 this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); 124 this.domTree = this.currentDocument.model.views.design.getLiveNodeList(true);
141 // Index of the current container 125 // Index of the current container
142 containerIndex = this.domTree.indexOf(this.currentDocument.model.domContainer); 126 containerIndex = this.domTree.indexOf(this.currentDocument.model.domContainer);
143 127
@@ -149,8 +133,6 @@ exports.Layout = Montage.create(Component, {
149 this.domTree = Array.prototype.slice.call(this.domTree[containerIndex].childNodes, 0); 133 this.domTree = Array.prototype.slice.call(this.domTree[containerIndex].childNodes, 0);
150 } 134 }
151 } 135 }
152 // Clear the elements to draw
153 this.elementsToDraw.length = 0;
154 136
155 // Draw the non selected elements 137 // Draw the non selected elements
156 if(!event.detail.isDocument) { 138 if(!event.detail.isDocument) {
@@ -161,9 +143,6 @@ exports.Layout = Montage.create(Component, {
161 this.elementsToDraw = Array.prototype.slice.call(this.domTree, 0); 143 this.elementsToDraw = Array.prototype.slice.call(this.domTree, 0);
162 } 144 }
163 145
164 this.draw(); // Not a reel yet
165 this.draw3DInfo(false);
166
167 // Clear the domTree copy 146 // Clear the domTree copy
168 this.domTree.length = 0; 147 this.domTree.length = 0;
169 } 148 }
@@ -171,8 +150,6 @@ exports.Layout = Montage.create(Component, {
171 150
172 draw: { 151 draw: {
173 value: function() { 152 value: function() {
174 this.clearCanvas();
175
176 // TODO Bind the layoutview mode to the current document 153 // TODO Bind the layoutview mode to the current document
177 // var mode = this.application.ninja.currentDocument.layoutMode; 154 // var mode = this.application.ninja.currentDocument.layoutMode;
178 if(this.layoutView === "layoutOff") return; 155 if(this.layoutView === "layoutOff") return;
@@ -184,21 +161,6 @@ exports.Layout = Montage.create(Component, {
184 } 161 }
185 }, 162 },
186 163
187 draw3DInfo: {
188 value: function(updatePlanes) {
189 if(updatePlanes) {
190 drawUtils.updatePlanes();
191 this.application.ninja.stage.stageDeps.snapManager._isCacheInvalid = true;
192 }
193
194 if(this.stage.appModel.show3dGrid) {
195 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView();
196 }
197 drawUtils.drawWorkingPlane();
198 drawUtils.draw3DCompass();
199 }
200 },
201
202 clearCanvas: { 164 clearCanvas: {
203 value: function() { 165 value: function() {
204 this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); 166 this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);