aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/canvas-runtime.js2
-rwxr-xr-xjs/controllers/elements/shapes-controller.js377
-rwxr-xr-xjs/data/menu-data.js40
-rwxr-xr-xjs/data/pi/pi-data.js2
-rwxr-xr-xjs/document/html-document.js11
-rwxr-xr-xjs/document/templates/montage-html/default_html.css4
-rwxr-xr-xjs/io/ui/file-picker/file-input-field.reel/file-input-field.js9
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js11
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js4
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js13
-rwxr-xr-xjs/lib/NJUtils.js4
-rwxr-xr-xjs/lib/drawing/world.js2
-rwxr-xr-xjs/lib/geom/circle.js19
-rwxr-xr-xjs/lib/geom/geom-obj.js80
-rwxr-xr-xjs/lib/geom/line.js10
-rwxr-xr-xjs/lib/geom/rectangle.js15
-rwxr-xr-xjs/mediators/element-mediator.js3
-rwxr-xr-xjs/models/color-model.js56
-rwxr-xr-xjs/models/shape-model.js7
-rwxr-xr-xjs/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js4
-rwxr-xr-xjs/stage/tool-handle.js7
-rwxr-xr-xjs/tools/FillTool.js20
-rwxr-xr-xjs/tools/InkBottleTool.js21
-rwxr-xr-xjs/tools/LineTool.js9
-rwxr-xr-xjs/tools/OvalTool.js15
-rwxr-xr-xjs/tools/RectTool.js15
-rwxr-xr-xjs/tools/SelectionTool.js1
-rwxr-xr-xjs/tools/ShapeTool.js13
-rwxr-xr-xjs/tools/modifier-tool-base.js8
29 files changed, 496 insertions, 286 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index f53a4ef6..967b483b 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -1026,7 +1026,7 @@ function RuntimeOval()
1026 mat[5] = yScale; 1026 mat[5] = yScale;
1027 1027
1028 // get the bezier points 1028 // get the bezier points
1029 var bezPts = this.circularArcToBezier( Vector.create([0,0,0]), Vector.create([1,0,0]), -2.0*Math.PI ); 1029 var bezPts = this.circularArcToBezier( [0,0,0], [1,0,0], -2.0*Math.PI );
1030 if (bezPts) 1030 if (bezPts)
1031 { 1031 {
1032 var n = bezPts.length; 1032 var n = bezPts.length;
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index ef453bea..236e9caa 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -13,12 +13,62 @@ 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,
19 m,
20 color;
18 switch(p) { 21 switch(p) {
19 case "strokeSize": 22 case "strokeSize":
20 // TODO - For now, just handling px units. 23 // TODO - For now, just handling px units.
21 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 );
22 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(val); 72 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(val);
23 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 73 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
24 el.elementModel.shapeModel.GLWorld.render(); 74 el.elementModel.shapeModel.GLWorld.render();
@@ -68,42 +118,48 @@ exports.ShapesController = Montage.create(CanvasController, {
68 el.elementModel.shapeModel.GLWorld.render(); 118 el.elementModel.shapeModel.GLWorld.render();
69 break; 119 break;
70 case "useWebGl": 120 case "useWebGl":
71 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 121 canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true);
72 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); 122 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
73 canvas.width = el.width; 123 canvas.width = el.width;
74 canvas.height = el.height; 124 canvas.height = el.height;
75 this.application.ninja.elementMediator.replaceElement(el, canvas); 125 this.application.ninja.elementMediator.replaceElement(el, canvas);
76 NJevent("elementDeleted", el); 126 NJevent("elementDeleted", el);
77 el = canvas; 127 this.toggleWebGlMode(canvas, value);
78 this.toggleWebGlMode(el, value); 128 NJevent("elementAdded", canvas);
79 el.elementModel.shapeModel.GLWorld.render(); 129 break;
80 this.application.ninja.selectionController.selectElement(el);
81 return;
82 case "strokeMaterial": 130 case "strokeMaterial":
83 var sm = Object.create(MaterialsModel.getMaterial(value)); 131 m = Object.create(MaterialsModel.getMaterial(value));
84 if(sm) 132 if(m)
85 { 133 {
86 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 134 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(m);
87 el.elementModel.shapeModel.strokeMaterial = sm; 135 color = this.getMaterialColor(value);
136 if(color)
137 {
138 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(color);
139 }
88 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 140 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
89 el.elementModel.shapeModel.GLWorld.render(); 141 el.elementModel.shapeModel.GLWorld.render();
90 } 142 }
91 break; 143 break;
92 case "fillMaterial": 144 case "fillMaterial":
93 var fm = Object.create(MaterialsModel.getMaterial(value)); 145 m = Object.create(MaterialsModel.getMaterial(value));
94 if(fm) 146 if(m)
95 { 147 {
96 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); 148 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(m);
97 el.elementModel.shapeModel.fillMaterial = fm; 149 color = this.getMaterialColor(value);
150 if(color)
151 {
152 el.elementModel.shapeModel.GLGeomObj.setFillColor(color);
153 }
98 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 154 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
99 el.elementModel.shapeModel.GLWorld.render(); 155 el.elementModel.shapeModel.GLWorld.render();
100 } 156 }
101 break; 157 break;
102 case "editStrokeMaterial": 158 case "editStrokeMaterial":
103 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()}); 159 NJevent("showMaterialPopup",{materialId : this.getProperty(el, "strokeMaterial")});
104 break; 160 break;
105 case "editFillMaterial": 161 case "editFillMaterial":
106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); 162 NJevent("showMaterialPopup",{materialId : this.getProperty(el, "fillMaterial")});
107 break; 163 break;
108 case "animate": 164 case "animate":
109 if(value) 165 if(value)
@@ -147,6 +203,7 @@ exports.ShapesController = Montage.create(CanvasController, {
147 default: 203 default:
148 CanvasController.setProperty(el, p, value); 204 CanvasController.setProperty(el, p, value);
149 } 205 }