diff options
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 277 |
1 files changed, 157 insertions, 120 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index f0e9458b..45b822e2 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -84,7 +84,6 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
84 | if(sm) | 84 | if(sm) |
85 | { | 85 | { |
86 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); | 86 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); |
87 | el.elementModel.shapeModel.strokeMaterial = sm; | ||
88 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 87 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
89 | el.elementModel.shapeModel.GLWorld.render(); | 88 | el.elementModel.shapeModel.GLWorld.render(); |
90 | } | 89 | } |
@@ -94,16 +93,15 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
94 | if(fm) | 93 | if(fm) |
95 | { | 94 | { |
96 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); | 95 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); |
97 | el.elementModel.shapeModel.fillMaterial = fm; | ||
98 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 96 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
99 | el.elementModel.shapeModel.GLWorld.render(); | 97 | el.elementModel.shapeModel.GLWorld.render(); |
100 | } | 98 | } |
101 | break; | 99 | break; |
102 | case "editStrokeMaterial": | 100 | case "editStrokeMaterial": |
103 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()}); | 101 | NJevent("showMaterialPopup",{materialId : this.getProperty(el, "strokeMaterial")}); |
104 | break; | 102 | break; |
105 | case "editFillMaterial": | 103 | case "editFillMaterial": |
106 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); | 104 | NJevent("showMaterialPopup",{materialId : this.getProperty(el, "fillMaterial")}); |
107 | break; | 105 | break; |
108 | case "animate": | 106 | case "animate": |
109 | if(value) | 107 | if(value) |
@@ -134,17 +132,28 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
134 | case "trRadius": | 132 | case "trRadius": |
135 | case "blRadius": | 133 | case "blRadius": |
136 | case "brRadius": | 134 | case "brRadius": |
137 | case "border": | ||
138 | case "background": | ||
139 | case "useWebGl": | 135 | case "useWebGl": |
140 | case "animate": | 136 | case "animate": |
141 | return this.getShapeProperty(el, p); | 137 | return this.getShapeProperty(el, p); |
138 | case "border": | ||
139 | return this.getColor(el, false); | ||
140 | case "background": | ||
141 | return this.getColor(el, true); | ||
142 | case "strokeMaterial": | 142 | case "strokeMaterial": |
143 | var sm = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); | ||
144 | if(sm) | ||
145 | { | ||
146 | return sm.getName(); | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | return "FlatMaterial"; | ||
151 | } | ||
143 | case "fillMaterial": | 152 | case "fillMaterial": |
144 | var m = this.getShapeProperty(el, p); | 153 | var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); |
145 | if(m) | 154 | if(fm) |
146 | { | 155 | { |
147 | return this.getShapeProperty(el, p).getName(); | 156 | return fm.getName(); |
148 | } | 157 | } |
149 | else | 158 | else |
150 | { | 159 | { |
@@ -255,67 +264,94 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
255 | // Routines to get/set color properties | 264 | // Routines to get/set color properties |
256 | getColor: { | 265 | getColor: { |
257 | value: function(el, isFill) { | 266 | value: function(el, isFill) { |
258 | var color, | ||
259 | css; | ||
260 | if(isFill) | 267 | if(isFill) |
261 | { | 268 | { |
262 | if(el.elementModel.shapeModel.background) | 269 | if(el.elementModel.shapeModel.GLGeomObj.getFillColor) |
263 | { | 270 | { |
264 | return el.elementModel.shapeModel.background; | 271 | return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getFillColor()); |
265 | } | 272 | } |
266 | color = this.getShapeProperty(el, "fill"); | 273 | else |
267 | } | ||
268 | else | ||
269 | { | ||
270 | if(el.elementModel.shapeModel.border) | ||
271 | { | 274 | { |
272 | return el.elementModel.shapeModel.border; | 275 | return null; |
273 | } | 276 | } |
274 | color = this.getShapeProperty(el, "stroke"); | ||
275 | } | 277 | } |
276 | 278 | else | |
277 | if(!css) { | 279 | { |
278 | return null; | 280 | return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getStrokeColor()); |
279 | } | 281 | } |
280 | |||
281 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); | ||
282 | return this.application.ninja.colorController.getColorObjFromCss(css); | ||
283 | } | 282 | } |
284 | }, | 283 | }, |
285 | 284 | ||
286 | _setGradientMaterial: { | 285 | _setGradientMaterial: { |
287 | value: function(el, gradientMode, isFill) { | 286 | value: function(el, gradientMode, isFill) { |
288 | var m = "LinearGradientMaterial", | 287 | var m, |
289 | fm; | 288 | gradientM; |
289 | if(isFill) | ||
290 | { | ||
291 | m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); | ||
292 | } | ||
293 | else | ||
294 | { | ||
295 | m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); | ||
296 | } | ||
297 | |||
290 | if(gradientMode === "radial") | 298 | if(gradientMode === "radial") |
291 | { | 299 | { |
292 | m = "RadialGradientMaterial"; | 300 | if( !m || (m.getName() !== "RadialGradientMaterial") ) |
301 | { | ||
302 | gradientM = Object.create(MaterialsModel.getMaterial("RadialGradientMaterial")); | ||
303 | } | ||
304 | } | ||
305 | else | ||
306 | { | ||
307 | if( !m || (m.getName() !== "LinearGradientMaterial") ) | ||
308 | { | ||
309 | gradientM = Object.create(MaterialsModel.getMaterial("LinearGradientMaterial")); | ||
310 | } | ||
293 | } | 311 | } |
294 | 312 | ||
295 | if(isFill) | 313 | if(gradientM) |
296 | { | 314 | { |
297 | if(el.elementModel.shapeModel.fillMaterial.getName() !== m) | 315 | if(isFill) |
298 | { | 316 | { |
299 | fm = Object.create(MaterialsModel.getMaterial(m)); | 317 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); |
300 | if(fm) | ||
301 | { | ||
302 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); | ||
303 | el.elementModel.shapeModel.fillMaterial = fm; | ||
304 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | ||
305 | } | ||
306 | } | 318 | } |
319 | else | ||
320 | { | ||
321 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); | ||
322 | } | ||
323 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | ||
324 | } | ||
325 | } | ||
326 | }, | ||
327 | |||
328 | _setFlatMaterial: { | ||
329 | value: function(el, isFill) { | ||
330 | var m, | ||
331 | flatM; | ||
332 | if(isFill) | ||
333 | { | ||
334 | m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); | ||
307 | } | 335 | } |
308 | else | 336 | else |
309 | { | 337 | { |
310 | if(el.elementModel.shapeModel.strokeMaterial.getName() !== m) | 338 | m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); |
339 | } | ||
340 | |||
341 | if(!m || ((m.getName() === "LinearGradientMaterial") || m.getName() === "RadialGradientMaterial") ) | ||
342 | { | ||
343 | flatM = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | ||
344 | if(flatM) | ||
311 | { | 345 | { |
312 | fm = Object.create(MaterialsModel.getMaterial(m)); | 346 | if(isFill) |
313 | if(fm) | ||
314 | { | 347 | { |
315 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(fm); | 348 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM); |
316 | el.elementModel.shapeModel.strokeMaterial = fm; | 349 | } |
317 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 350 | else |
351 | { | ||
352 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM); | ||
318 | } | 353 | } |
354 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | ||
319 | } | 355 | } |
320 | } | 356 | } |