aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-24 12:08:49 -0800
committerPushkar Joshi2012-02-24 12:08:49 -0800
commit03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch)
treec51112223ceb9121cd595a60335eb2795215590f /js/controllers/elements
parentfcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff)
parent053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff)
downloadninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz
Merge branch 'pentool' into brushtool
Conflicts: imports/codemirror/mode/scheme/scheme.js js/tools/BrushTool.js
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/block-controller.js0
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/canvas-controller.js0
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/component-controller.js44
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/controller-factory.js0
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/element-controller.js16
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/image-controller.js2
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/shapes-controller.js42
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/stage-controller.js8
-rwxr-xr-x[-rw-r--r--]js/controllers/elements/video-controller.js0
9 files changed, 100 insertions, 12 deletions
diff --git a/js/controllers/elements/block-controller.js b/js/controllers/elements/block-controller.js
index 395a1a4d..395a1a4d 100644..100755
--- a/js/controllers/elements/block-controller.js
+++ b/js/controllers/elements/block-controller.js
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js
index b5df3911..b5df3911 100644..100755
--- a/js/controllers/elements/canvas-controller.js
+++ b/js/controllers/elements/canvas-controller.js
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 458e6b46..83450d0f 100644..100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -9,4 +9,48 @@ var Montage = require("montage/core/core").Montage,
9 9
10exports.ComponentController = Montage.create(ElementController, { 10exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: {
13 value: function(el, prop) {
14 switch(prop) {
15 case "id":
16 case "class":
17 case "left":
18 case "top":
19 case "width":
20 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
23 } else {
24 return ElementController.getProperty(el, prop, true);
25 }
26 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop];
28 }
29 }
30 },
31
32 setProperty: {
33 value: function(el, p, value) {
34 switch(p) {
35 case "id":
36 case "class":
37 case "left":
38 case "top":
39 case "width":
40 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
43 } else {
44 ElementController.setProperty(el, p, value);
45 }
46 break;
47 default:
48 if(p === "min" || p === "max") value = parseFloat(value);
49
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break;
52
53 }
54 }
55 }
12}); 56});
diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js
index a772eb16..a772eb16 100644..100755
--- a/js/controllers/elements/controller-factory.js
+++ b/js/controllers/elements/controller-factory.js
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 65d26bdd..46e82ace 100644..100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -12,6 +12,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
12 addElement: { 12 addElement: {
13 value: function(el, styles) { 13 value: function(el, styles) {
14 this.application.ninja.currentDocument.documentRoot.appendChild(el); 14 this.application.ninja.currentDocument.documentRoot.appendChild(el);
15 // Nested elements -
16 // TODO make sure the CSS is correct before nesting elements
17 // this.application.ninja.currentSelectedContainer.appendChild(el);
15 this.application.ninja.stylesController.setElementStyles(el, styles); 18 this.application.ninja.stylesController.setElementStyles(el, styles);
16 } 19 }
17 }, 20 },
@@ -115,6 +118,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
115 } 118 }
116 else 119 else
117 { 120 {
121 // TODO - Need to update border style and width also
118 el.elementModel.stroke = colorObj; 122 el.elementModel.stroke = colorObj;
119 } 123 }
120 124
@@ -159,10 +163,22 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
159 case 'gradient': 163 case 'gradient':
160 this.setProperty(el, "border-image", color.color.css); 164 this.setProperty(el, "border-image", color.color.css);
161 this.setProperty(el, "border-color", "none"); 165 this.setProperty(el, "border-color", "none");
166 if(color.borderInfo)
167 {
168 this.setProperty(el, "border-width", color.borderInfo.borderWidth +
169 color.borderInfo.borderUnits);
170 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
171 }
162 break; 172 break;
163 default: 173 default:
164 this.setProperty(el, "border-image", "none"); 174 this.setProperty(el, "border-image", "none");
165 this.setProperty(el, "border-color", color.color.css); 175 this.setProperty(el, "border-color", color.color.css);
176 if(color.borderInfo)
177 {
178 this.setProperty(el, "border-width", color.borderInfo.borderWidth +
179 color.borderInfo.borderUnits);
180 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
181 }
166 } 182 }
167 } 183 }
168 el.elementModel.stroke = color; 184 el.elementModel.stroke = color;
diff --git a/js/controllers/elements/image-controller.js b/js/controllers/elements/image-controller.js
index 5abce13e..25ca8da6 100644..100755
--- a/js/controllers/elements/image-controller.js
+++ b/js/controllers/elements/image-controller.js
@@ -19,7 +19,7 @@ exports.ImageController = Montage.create(ElementController, {
19 return el.getAttribute(prop); 19 return el.getAttribute(prop);
20 break; 20 break;
21 default: 21 default:
22 return ElementController.getProperty(el, prop); 22 return ElementController.getProperty(el, prop, true);
23 } 23 }
24 } 24 }
25 }, 25 },
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b9c033aa..e0bff70c 100644..100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -59,6 +59,7 @@ exports.ShapesController = Montage.create(CanvasController, {
59 break; 59 break;
60 case "useWebGl": 60 case "useWebGl":
61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 61 var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true);
62 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
62 canvas.width = el.width; 63 canvas.width = el.width;
63 canvas.height = el.height; 64 canvas.height = el.height;
64 this.application.ninja.elementMediator.replaceElement(el, canvas); 65 this.application.ninja.elementMediator.replaceElement(el, canvas);
@@ -249,6 +250,10 @@ exports.ShapesController = Montage.create(CanvasController, {
249 setColor: { 250 setColor: {
250 value: function(el, color, isFill) { 251 value: function(el, color, isFill) {
251 var webGl = color.webGlColor || color.color.webGlColor; 252 var webGl = color.webGlColor || color.color.webGlColor;
253 if(!webGl)
254 {
255 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
256 }
252 if(isFill) 257 if(isFill)
253 { 258 {
254 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); 259 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl);
@@ -260,6 +265,14 @@ exports.ShapesController = Montage.create(CanvasController, {
260 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); 265 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl);
261 this.setShapeProperty(el, "stroke", webGl); 266 this.setShapeProperty(el, "stroke", webGl);
262 this.setShapeProperty(el, "border", color); 267 this.setShapeProperty(el, "border", color);
268 if(color.strokeInfo)
269 {
270 var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize,
271 color.strokeInfo.strokeUnits);
272 el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth);
273 this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " "
274 + color.strokeInfo.strokeUnits);
275 }
263 } 276 }
264 el.elementModel.shapeModel.GLWorld.render(); 277 el.elementModel.shapeModel.GLWorld.render();
265 } 278 }
@@ -346,19 +359,24 @@ exports.ShapesController = Montage.create(CanvasController, {
346 { 359 {
347 world = new GLWorld(el, true); 360 world = new GLWorld(el, true);
348 el.elementModel.shapeModel.GLWorld = world; 361 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
350 el.elementModel.shapeModel.useWebGl = true; 362 el.elementModel.shapeModel.useWebGl = true;
363 world.import(worldData);
364 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
365
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 366 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 367 if(sm)
353 if(sm && fm)
354 { 368 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 369 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm; 370 el.elementModel.shapeModel.strokeMaterial = sm;
371 }
372 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
373 // TODO - Use consts after GL c