aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-08 13:14:29 -0800
committerJose Antonio Marquez2012-02-08 13:14:29 -0800
commit9b45b897949bf934c8bf2c90ee2ff78f8713cb12 (patch)
treee7c276a3934c823cab894f46ee7dc5d3eda9ca83 /js/controllers
parentaa01c1210f3a4d9fd55a771b9de2c58ee3fa4bb6 (diff)
parent10cdeb52403f16d5d4be43a516e8cdfbc866a2a2 (diff)
downloadninja-9b45b897949bf934c8bf2c90ee2ff78f8713cb12.tar.gz
Merge branch 'refs/heads/NinjaInternal' into Color
Conflicts: js/controllers/elements/shapes-controller.js js/data/pi/pi-data.js js/panels/properties/content.reel/content.js
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/elements/element-controller.js13
-rw-r--r--js/controllers/elements/shapes-controller.js102
-rw-r--r--js/controllers/styles-controller.js232
-rw-r--r--js/controllers/tree-controller.js185
4 files changed, 494 insertions, 38 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 65c24b46..65d26bdd 100644
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -144,10 +144,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
144 this.setProperty(el, "background-color", color.color.css); 144 this.setProperty(el, "background-color", color.color.css);
145 } 145 }
146 } 146 }
147 else
148 {
149 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css);
150 }
151 el.elementModel.fill = color; 147 el.elementModel.fill = color;
152 } 148 }
153 else 149 else
@@ -169,10 +165,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
169 this.setProperty(el, "border-color", color.color.css); 165 this.setProperty(el, "border-color", color.color.css);
170 } 166 }
171 } 167 }
172 else
173 {
174 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css);
175 }
176 el.elementModel.stroke = color; 168 el.elementModel.stroke = color;
177 } 169 }
178 } 170 }
@@ -187,8 +179,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
187 179
188 setStroke: { 180 setStroke: {
189 value: function(el, stroke) { 181 value: function(el, stroke) {
190 var border = stroke.borderWidth + stroke.borderUnits + " " + stroke.borderStyle + " " + stroke.color.color.css; 182 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits);
191 this.application.ninja.stylesController.setElementStyle(el, "border", border); 183 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle);
184 this.setColor(el, stroke.color, false);
192 } 185 }
193 }, 186 },
194 187
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 1717db94..39300eb8 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
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 10
10exports.ShapesController = Montage.create(CanvasController, { 11exports.ShapesController = Montage.create(CanvasController, {
11 12
@@ -36,6 +37,35 @@ exports.ShapesController = Montage.create(CanvasController, {
36 el.elementModel.shapeModel.GLWorld.setViewportFromCanvas(el); 37 el.elementModel.shapeModel.GLWorld.setViewportFromCanvas(el);
37 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 38 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
38 break; 39 break;
40 case "useWebGl":
41 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true);
42 canvas.width = el.width;
43 canvas.height = el.height;
44 this.application.ninja.elementMediator.replaceElement(el, canvas);
45 NJevent("elementDeleted", el);
46 this.application.ninja.selectionController.selectElement(canvas);
47 el = canvas;
48 this.toggleWebGlMode(el, value);
49 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
50 break;
51 case "strokeMaterial":
52 var sm = Object.create(MaterialsLibrary.getMaterial(value));
53 if(sm)
54 {
55 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
56 el.elementModel.shapeModel.strokeMaterial = sm;
57 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
58 }
59 break;
60 case "fillMaterial":
61 var fm = Object.create(MaterialsLibrary.getMaterial(value));
62 if(fm)
63 {
64 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
65 el.elementModel.shapeModel.fillMaterial = fm;
66 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
67 }
68 break;
39 default: 69 default:
40 CanvasController.setProperty(el, p, value); 70 CanvasController.setProperty(el, p, value);
41 } 71 }
@@ -48,9 +78,25 @@ exports.ShapesController = Montage.create(CanvasController, {
48 switch(p) { 78 switch(p) {
49 case "strokeSize": 79 case "strokeSize":
50 case "innerRadius": 80 case "innerRadius":
81 case "tlRadius":
82 case "trRadius":
83 case "blRadius":
84 case "brRadius":
51 case "border": 85 case "border":
52 case "background": 86 case "background":
87 case "useWebGl":
53 return this.getShapeProperty(el, p); 88 return this.getShapeProperty(el, p);
89 case "strokeMaterial":
90 case "fillMaterial":
91 var m = this.getShapeProperty(el, p);
92 if(m)
93 {
94 return this.getShapeProperty(el, p).getName();
95 }
96 else
97 {
98 return "FlatMaterial";
99 }
54 default: 100 default:
55 return CanvasController.getProperty(el, p); 101 return CanvasController.getProperty(el, p);
56 } 102 }
@@ -249,6 +295,60 @@ exports.ShapesController = Montage.create(CanvasController, {
249 { 295 {
250 return (el.elementModel && el.elementModel.isShape); 296 return (el.elementModel && el.elementModel.isShape);
251 } 297 }
298 },
299
300 toggleWebGlMode: {
301 value: function(el, useWebGl)
302 {
303 if(useWebGl)
304 {
305 this.convertToWebGlWorld(el);
306 }
307 else
308 {
309 this.convertTo2DWorld(el);
310 }
311 }
312 },
313
314 convertToWebGlWorld: {
315 value: function(el)
316 {
317 if(el.elementModel.shapeModel.useWebGl)
318 {
319 return;
320 }
321 var world,
322 worldData = el.elementModel.shapeModel.GLWorld.export();
323 if(worldData)
324 {
325 world = new GLWorld(el, true);
326 el.elementModel.shapeModel.GLWorld = world;
327 el.elementModel.shapeModel.useWebGl = true;
328 world.import(worldData);
329 }
330
331 }
332 },
333
334 convertTo2DWorld: {
335 value: function(el)
336 {
337 if(!el.elementModel.shapeModel.useWebGl)
338 {
339 return;
340 }
341 var world,
342 worldData = el.elementModel.shapeModel.GLWorld.export();
343 if(worldData)
344 {
345 world = new GLWorld(el, false);
346 el.elementModel.shapeModel.GLWorld = world;
347 el.elementModel.shapeModel.useWebGl = false;
348 world.import(worldData);
349 }
350
351 }
252 } 352 }
253 353
254}); 354});
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index afd298c9..011caec5 100644
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -171,10 +171,12 @@ var stylesController = exports.StylesController = Montage.create(Component, {
171 if(argType === 'string') { 171 if(argType === 'string') {
172 ruleText += '{' + declaration + '}'; 172 ruleText += '{' + declaration + '}';
173 } else if(argType === 'object') { 173 } else if(argType === 'object') {
174 ruleText += '{' + nj.cssFromObject(declaration) + '}'; 174 ruleText += '{' + this.cssFromObject(declaration) + '}';
175 } 175 }
176 176
177 stylesheet.insertRule(ruleText, index); 177 stylesheet.insertRule(ruleText, index);
178
179 this.styleSheetModified(stylesheet);
178 180
179 rule = stylesheet.rules[index]; 181 rule = stylesheet.rules[index];
180 182
@@ -199,25 +201,42 @@ var stylesController = exports.StylesController = Montage.create(Component, {
199 201
200 ///// Locally-scoped function to de-clutter variable declarations 202 ///// Locally-scoped function to de-clutter variable declarations
201 function getSelector(el, rule) { 203 function getSelector(el, rule) {