aboutsummaryrefslogtreecommitdiff
path: root/js/stage/layout.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-03 09:57:41 -0800
committerAnanya Sen2012-02-03 09:57:41 -0800
commitc093dd13a84ce6eb3e00a672c38a808093c5d966 (patch)
tree5dfd4a800bbbe02a8cbcb3ffeee542686bc258bb /js/stage/layout.js
parent79b0173eeca079dec42ff1480182656dbe3af44f (diff)
parent8e06b63e5eab5558823f4923e20a832c8b36cbe2 (diff)
downloadninja-c093dd13a84ce6eb3e00a672c38a808093c5d966.tar.gz
Merge branch 'FileIO' of github.com:joseeight/ninja-internal into FileIO
Conflicts: js/io/document/document-controller.js js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js js/io/ui/save-as-dialog.reel/save-as-dialog.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/stage/layout.js')
-rwxr-xr-xjs/stage/layout.js67
1 files changed, 15 insertions, 52 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index 625c09ad..dd5be081 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -112,6 +112,7 @@ exports.Layout = Montage.create(Component, {
112 } 112 }
113 113
114 this.draw(); // Not a reel yet :) 114 this.draw(); // Not a reel yet :)
115 this.draw3DInfo(false);
115 116
116 117
117 } 118 }
@@ -128,9 +129,16 @@ exports.Layout = Montage.create(Component, {
128 }, 129 },
129 130
130 draw3DInfo: { 131 draw3DInfo: {
131 value: function() { 132 value: function(updatePlanes) {
132 drawUtils.updatePlanes(); 133 if(updatePlanes)
133 if(this.stage.appModel.show3dGrid) drawUtils.drawWorkingPlane(); 134 {
135 drawUtils.updatePlanes();
136 }
137 if(this.stage.appModel.show3dGrid)
138 {
139 this.application.ninja.stage.stageDeps.snapManager.updateWorkingPlaneFromView();
140 drawUtils.drawWorkingPlane();
141 }
134 drawUtils.draw3DCompass(); 142 drawUtils.draw3DCompass();
135 } 143 }
136 }, 144 },
@@ -282,8 +290,9 @@ exports.Layout = Montage.create(Component, {
282 } 290 }
283 }, 291 },
284 292
285 // Alternate dashed line method. 293 // Dashed line function found at http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas/
286 ___dashedLine: { 294 // Portions used with permission of Gavin Kistner (phrogz)
295 _dashedLine: {
287 value: function(x, y, x2, y2, dashArray) { 296 value: function(x, y, x2, y2, dashArray) {
288 this.ctx.lineCap = "square"; 297 this.ctx.lineCap = "square";
289 this.ctx.beginPath(); 298 this.ctx.beginPath();
@@ -303,7 +312,7 @@ exports.Layout = Montage.create(Component, {
303 var step = Math.sqrt(dashLength * dashLength / (1 + slope * slope)); 312 var step = Math.sqrt(dashLength * dashLength / (1 + slope * slope));
304 if(xSlope){ 313 if(xSlope){
305 if(dx < 0) step = -step; 314 if(dx < 0) step = -step;
306 x += step 315 x += step;
307 y += slope * step; 316 y += slope * step;
308 }else{ 317 }else{
309 if(dy < 0) step = -step; 318 if(dy < 0) step = -step;
@@ -321,52 +330,6 @@ exports.Layout = Montage.create(Component, {
321 } 330 }
322 }, 331 },
323 332
324 _dashedLine: {
325 value: function (fromX, fromY, toX, toY, pattern){
326 this.ctx.beginPath();
327 // Our growth rate for our line can be one of the following:
328 // (+,+), (+,-), (-,+), (-,-)
329 // Because of this, our algorithm needs to understand if the x-coord and
330 // y-coord should be getting smaller or larger and properly cap the values
331 // based on (x,y).
332 var lt = function (a, b) { return a <= b; };
333 var gt = function (a, b) { return a >= b; };
334 var capmin = function (a, b) { return Math.min(a, b); };
335 var capmax = function (a, b) { return Math.max(a, b); };
336
337 var checkX = { thereYet: gt, cap: capmin };
338 var checkY = { thereYet: gt, cap: capmin };
339
340 if (fromY - toY > 0) {
341 checkY.thereYet = lt;
342 checkY.cap = capmax;
343 }
344 if (fromX - toX > 0) {
345 checkX.thereYet = lt;
346 checkX.cap = capmax;
347 }
348
349 this.ctx.moveTo(fromX, fromY);
350 var offsetX = fromX;
351 var offsetY = fromY;
352 var idx = 0, dash = true;
353 while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) {
354 var ang = Math.atan2(toY - fromY, toX - fromX);
355 var len = pattern[idx];
356
357 offsetX = checkX.cap(toX, offsetX + (Math.cos(ang) * len));
358 offsetY = checkY.cap(toY, offsetY + (Math.sin(ang) * len));
359
360 if (dash) this.ctx.lineTo(offsetX, offsetY);
361 else this.ctx.moveTo(offsetX, offsetY);
362
363 idx = (idx + 1) % pattern.length;
364 dash = !dash;
365 }
366 this.ctx.stroke();
367 }
368 },
369
370 _elementName: { 333 _elementName: {
371 value: function(item) { 334 value: function(item) {
372 return this.application.ninja.elementMediator.getNJProperty(item, "selection"); 335 return this.application.ninja.elementMediator.getNJProperty(item, "selection");