aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/shapes-controller.js49
-rwxr-xr-xjs/mediators/element-mediator.js2
-rwxr-xr-xjs/tools/LineTool.js1
3 files changed, 50 insertions, 2 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index a6859361..236e9caa 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -13,7 +13,7 @@ var Montage = require("montage/core/core").Montage,
13exports.ShapesController = Montage.create(CanvasController, { 13exports.ShapesController = Montage.create(CanvasController, {
14 14
15 setProperty: { 15 setProperty: {
16 value: function(el, p, value) { 16 value: function(el, p, value, eventType, source) {
17 var val = parseInt(value), 17 var val = parseInt(value),
18 canvas, 18 canvas,
19 m, 19 m,
@@ -22,6 +22,53 @@ exports.ShapesController = Montage.create(CanvasController, {
22 case "strokeSize": 22 case "strokeSize":
23 // TODO - For now, just handling px units. 23 // TODO - For now, just handling px units.
24 this.setShapeProperty(el, "strokeSize", value); 24 this.setShapeProperty(el, "strokeSize", value);
25 // Changing stroke size should grow/shrink the shape from the center.
26 var delta = ~~(val - el.elementModel.shapeModel.GLGeomObj.getStrokeWidth()),
27 l = this.application.ninja.elementMediator.getProperty(el, "left", parseInt),
28 t = this.application.ninja.elementMediator.getProperty(el, "top", parseInt),
29 w = this.application.ninja.elementMediator.getProperty(el, "width", parseInt),
30 h = this.application.ninja.elementMediator.getProperty(el, "height", parseInt);
31
32 if(el.elementModel.selection === "Line")
33 {
34 var slope = el.elementModel.shapeModel.slope;
35 // set the dimensions
36 if(slope === "horizontal")
37 {
38 h = Math.max(val, 1);
39 }
40 else if(slope === "vertical")
41 {
42 w = Math.max(val, 1);
43 }
44 else
45 {
46 var oldXAdj = el.elementModel.shapeModel.GLGeomObj.getXAdj();
47 var oldYAdj = el.elementModel.shapeModel.GLGeomObj.getYAdj();
48 var theta = Math.atan(el.elementModel.shapeModel.slope);
49 var xAdj = Math.abs((val/2)*Math.sin(theta));
50 var yAdj = Math.abs((val/2)*Math.cos(theta));
51 var dX = ~~(xAdj*2 - oldXAdj*2);
52 var dY = ~~(yAdj*2 - oldYAdj*2);
53
54 if(delta > 0)
55 {
56 l -= dX*2;
57 t -= dY*2;
58 w += dX*2;
59 h += dY*2;
60 }
61
62 el.elementModel.shapeModel.GLGeomObj.setXAdj(xAdj);
63 el.elementModel.shapeModel.GLGeomObj.setYAdj(yAdj);
64
65 }
66 }
67 this.application.ninja.elementMediator.setProperties([el],
68 { "left": [l + "px"],
69 "top": [t + "px"],
70 "width": [w + "px"],
71 "height": [h + "px"] }, eventType, source );
25 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(val); 72 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(val);
26 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 73 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
27 el.elementModel.shapeModel.GLWorld.render(); 74 el.elementModel.shapeModel.GLWorld.render();
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 3eeab9c4..3182d5ec 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -319,7 +319,7 @@ exports.ElementMediator = Montage.create(NJComponent, {
319 319
320 for(var i=0, item; item = els[i]; i++) { 320 for(var i=0, item; item = els[i]; i++) {
321 el = item._element || item; 321 el = item._element || item;
322 el.elementModel.controller["setProperty"](el, p, value[i]); 322 el.elementModel.controller["setProperty"](el, p, value[i], eventType, source);
323 } 323 }
324 324
325 NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null}); 325 NJevent("element" + eventType, {type : "setProperty", source: source, data: {"els": els, "prop": p, "value": value}, redraw: null});
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 9b22c629..a43d4fb6 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -241,6 +241,7 @@ exports.LineTool = Montage.create(ShapeTool, {
241 241
242 canvas.elementModel.shapeModel.GLGeomObj = line; 242 canvas.elementModel.shapeModel.GLGeomObj = line;
243 canvas.elementModel.shapeModel.useWebGl = this.options.use3D; 243 canvas.elementModel.shapeModel.useWebGl = this.options.use3D;
244 canvas.elementModel.shapeModel.slope = slope;
244 } 245 }
245 else 246 else
246 { 247 {