aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/component-controller.js13
-rwxr-xr-xjs/controllers/elements/element-controller.js16
-rwxr-xr-xjs/controllers/elements/shapes-controller.js122
-rwxr-xr-xjs/controllers/elements/stage-controller.js41
4 files changed, 163 insertions, 29 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 83450d0f..260ee8a0 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,6 +11,8 @@ exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
15
14 switch(prop) { 16 switch(prop) {
15 case "id": 17 case "id":
16 case "class": 18 case "class":
@@ -19,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, {
19 case "width": 21 case "width":
20 case "height": 22 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { 23 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 24 return component[prop];
23 } else { 25 } else {
24 return ElementController.getProperty(el, prop, true); 26 return ElementController.getProperty(el, prop, true);
25 } 27 }
26 default: 28 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 29 return component[prop];
28 } 30 }
29 } 31 }
30 }, 32 },
31 33
32 setProperty: { 34 setProperty: {
33 value: function(el, p, value) { 35 value: function(el, p, value) {
36 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
37
34 switch(p) { 38 switch(p) {
35 case "id": 39 case "id":
36 case "class": 40 case "class":
@@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, {
39 case "width": 43 case "width":
40 case "height": 44 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) { 45 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; 46 component[p] = value;
43 } else { 47 } else {
44 ElementController.setProperty(el, p, value); 48 ElementController.setProperty(el, p, value);
45 } 49 }
46 break; 50 break;
47 default: 51 default:
48 if(p === "min" || p === "max") value = parseFloat(value); 52 if(p === "min" || p === "max") value = parseFloat(value);
49 53 component[p] = value;
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break; 54 break;
52 55
53 } 56 }
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 70aba54e..b35251ad 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -228,22 +228,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
228 mat = this.transformStringToMat( xformStr ); 228 mat = this.transformStringToMat( xformStr );
229 if (!mat) 229 if (!mat)
230 mat = Matrix.I(4); 230 mat = Matrix.I(4);
231
232 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
233 if (zoom)
234 {
235 zoom = Number(zoom);
236 if (zoom != 1)
237 {
238 var zoomMat = Matrix.create( [
239 [ zoom, 0, 0, 0],
240 [ 0, zoom, 0, 0],
241 [ 0, 0, zoom, 0],
242 [ 0, 0, 0, 1]
243 ] );
244 glmat4.multiply( zoomMat, mat, mat );
245 }
246 }
247 } 231 }
248 232
249 el.elementModel.props3D.matrix3d = mat; 233 el.elementModel.props3D.matrix3d = mat;
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index d72d9c14..ef453bea 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -6,10 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, 8 CanvasController = require("js/controllers/elements/canvas-controller").CanvasController,
9 njModule = require("js/lib/NJUtils"); 9 njModule = require("js/lib/NJUtils"),
10 10 World = require("js/lib/drawing/world").World,
11var World = require("js/lib/drawing/world").World; 11 MaterialsModel = require("js/models/materials-model").MaterialsModel;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13 12
14exports.ShapesController = Montage.create(CanvasController, { 13exports.ShapesController = Montage.create(CanvasController, {
15 14
@@ -100,6 +99,51 @@ exports.ShapesController = Montage.create(CanvasController, {
100 el.elementModel.shapeModel.GLWorld.render(); 99 el.elementModel.shapeModel.GLWorld.render();
101 } 100 }
102 break; 101 break;
102 case "editStrokeMaterial":
103 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()});
104 break;
105 case "editFillMaterial":
106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()});
107 break;
108 case "animate":
109 if(value)
110 {
111 el.elementModel.shapeModel.animate = true;
112 el.elementModel.shapeModel.GLWorld._previewAnimation = true;
113 el.elementModel.shapeModel.GLWorld.restartRenderLoop();
114 }
115 else
116 {
117 el.elementModel.shapeModel.animate = false;
118 el.elementModel.shapeModel.GLWorld._previewAnimation = false;
119 el.elementModel.shapeModel.GLWorld._canvas.task.stop();
120 }
121 break;
122 case "strokeHardness":
123 this.setShapeProperty(el, "strokeHardness", value);
124 el.elementModel.shapeModel.GLGeomObj.setStrokeHardness(val);
125 el.elementModel.shapeModel.GLWorld.render();
126 break;
127 case "strokeSmoothing":
128 this.setShapeProperty(el, "strokeSmoothing", value);
129 el.elementModel.shapeModel.GLGeomObj.setSmoothingAmount(val);
130 el.elementModel.shapeModel.GLWorld.render();
131 break;
132 case "doSmoothing":
133 this.setShapeProperty(el, "doSmoothing", value);
134 el.elementModel.shapeModel.GLGeomObj.setDoSmoothing(value);
135 el.elementModel.shapeModel.GLWorld.render();
136 break;
137 case "isCalligraphic":
138 this.setShapeProperty(el, "isCalligraphic", value);
139 el.elementModel.shapeModel.GLGeomObj.setStrokeUseCalligraphic(value);
140 el.elementModel.shapeModel.GLWorld.render();
141 break;
142 case "strokeAngle":
143 this.setShapeProperty(el, "strokeAngle", value);
144 el.elementModel.shapeModel.GLGeomObj.setStrokeAngle(Math.PI * val/180);
145 el.elementModel.shapeModel.GLWorld.render();
146 break;
103 default: 147 default:
104 CanvasController.setProperty(el, p, value); 148 CanvasController.setProperty(el, p, value);
105 } 149 }
@@ -118,7 +162,45 @@ exports.ShapesController = Montage.create(CanvasController, {
118 case "border": 162 case "border":
119 case "background": 163 case "background":
120 case "useWebGl": 164 case "useWebGl":
165 case "animate":
121 return this.getShapeProperty(el, p); 166 return this.getShapeProperty(el, p);
167 case "strokeHardness":
168 if (el.elementModel && el.elementModel.shapeModel){
169 return el.elementModel.shapeModel.GLGeomObj.getStrokeHardness();
170 } else {
171 return null;
172 }
173 break;
174 case "doSmoothing":
175 if (el.elementModel && el.elementModel.shapeModel){
176 return el.elementModel.shapeModel.GLGeomObj.getDoSmoothing();
177 } else {
178 return null;
179 }
180 break;
181 case "strokeSmoothing":
182 if (el.elementModel && el.elementModel.shapeModel){
183 return el.elementModel.shapeModel.GLGeomObj.getSmoothingAmount();
184 } else {
185 return null;
186 }
187 break;
188 case "isCalligraphic":
189 if (el.elementModel && el.elementModel.shapeModel){
190 return el.elementModel.shapeModel.GLGeomObj.getStrokeUseCalligraphic();
191 } else {
192 return null;
193 }
194 break;
195 case "strokeAngle":
196 if (el.elementModel && el.elementModel.shapeModel){
197 return 180*el.elementModel.shapeModel.GLGeomObj.getStrokeAngle()/Math.PI;
198 } else {
199 return null;
200 }
201 break;
202
203