aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/body-controller.js95
-rwxr-xr-xjs/controllers/elements/controller-factory.js7
-rwxr-xr-xjs/controllers/elements/element-controller.js16
-rwxr-xr-xjs/controllers/elements/shapes-controller.js2
4 files changed, 115 insertions, 5 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
new file mode 100755
index 00000000..14aeae24
--- /dev/null
+++ b/js/controllers/elements/body-controller.js
@@ -0,0 +1,95 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 ElementController = require("js/controllers/elements/element-controller").ElementController;
9
10exports.BodyController = Montage.create(ElementController, {
11
12 // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat"
13 set3DProperties: {
14 value: function(el, props, update3DModel) {
15 var dist = props["dist"], mat = props["mat"];
16 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true);
17
18 el.elementModel.props3D.matrix3d = mat;
19 el.elementModel.props3D.perspectiveDist = dist;
20
21 this.application.ninja.stage.updatedStage = true;
22
23 if(update3DModel) {
24 this._update3DProperties(el, mat, dist);
25 }
26 }
27 },
28
29 getProperty: {
30 value: function(el, p) {
31 }
32 },
33
34 setProperty: {
35 value: function(el, p, value) {
36 }
37 },
38
39 setAttribute: {
40 value: function(el, att, value) {
41 }
42 },
43
44 getPerspectiveDist: {
45 value: function(el) {
46 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) {
47 return el.elementModel.props3D.perspectiveDist;
48 } else {
49 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true);
50 el.elementModel.props3D.perspectiveDist = dist;
51 return dist;
52 }
53 }
54 },
55
56 getMatrix: {
57 value: function(el) {
58 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d)
59 {
60 return el.elementModel.props3D.matrix3d.slice(0);
61 }
62 else
63 {
64 var mat;
65
66 if (el)
67 {
68 mat = this.application.ninja.stylesController.getMatrixFromElement(el, true);
69 if (!mat) {
70 mat = Matrix.I(4);
71 }
72
73 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
74 if (zoom)
75 {
76 zoom = Number(zoom);
77 if (zoom != 1)
78 {
79 var zoomMat = Matrix.create( [
80 [ zoom, 0, 0, 0],
81 [ 0, zoom, 0, 0],
82 [ 0, 0, zoom, 0],
83 [ 0, 0, 0, 1]
84 ] );
85 glmat4.multiply( zoomMat, mat, mat );
86 }
87 }
88 }
89
90 el.elementModel.props3D.matrix3d = mat;
91 return mat;
92 }
93 }
94 }
95});
diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js
index a772eb16..3ac3fe14 100755
--- a/js/controllers/elements/controller-factory.js
+++ b/js/controllers/elements/controller-factory.js
@@ -6,7 +6,8 @@ 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 8
9var BlockController = require("js/controllers/elements/block-controller").BlockController, 9var BodyController = require("js/controllers/elements/body-controller").BodyController,
10 BlockController = require("js/controllers/elements/block-controller").BlockController,
10 StageController = require("js/controllers/elements/stage-controller").StageController, 11 StageController = require("js/controllers/elements/stage-controller").StageController,
11 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, 12 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController,
12 ImageController = require("js/controllers/elements/image-controller").ImageController, 13 ImageController = require("js/controllers/elements/image-controller").ImageController,
@@ -27,6 +28,8 @@ exports.ControllerFactory = Montage.create(Montage, {
27 return BlockController; 28 return BlockController;
28 } else if(value.indexOf("stage") !== -1) { 29 } else if(value.indexOf("stage") !== -1) {
29 return StageController; 30 return StageController;
31 } else if(value.indexOf("body") !== -1) {
32 return BodyController;
30 } else if(value.indexOf("shape") !== -1) { 33 } else if(value.indexOf("shape") !== -1) {
31 return ShapesController; 34 return ShapesController;
32 } else if(value.indexOf("canvas") !== -1) { 35 } else if(value.indexOf("canvas") !== -1) {
@@ -39,6 +42,8 @@ exports.ControllerFactory = Montage.create(Montage, {
39 return ImageController; 42 return ImageController;
40 } else if(value.indexOf("video") !== -1) { 43 } else if(value.indexOf("video") !== -1) {
41 return VideoController; 44 return VideoController;
45 } else {
46 return BlockController;
42 } 47 }
43 } catch (err) { 48 } catch (err) {
44 console.log("Could not create Controller Factory " + err); 49 console.log("Could not create Controller Factory " + err);
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 452d09f1..20225c61 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -11,9 +11,19 @@ exports.ElementController = Montage.create(Component, {
11 11
12 addElement: { 12 addElement: {
13 value: function(el, styles) { 13 value: function(el, styles) {
14 this.application.ninja.currentDocument.documentRoot.appendChild(el); 14 if(this.application.ninja.timeline.currentLayerSelected) {
15 // Nested elements - TODO make sure the CSS is correct before nesting elements 15 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
16 // this.application.ninja.currentSelectedContainer.appendChild(el); 16
17 if(selectedLayerIndex === 0) {
18 this.application.ninja.currentSelectedContainer.appendChild(el);
19 } else {
20 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0];
21 element.parentNode.insertBefore(el, element.nextSibling);
22 }
23 } else {
24 this.application.ninja.currentSelectedContainer.appendChild(el);
25 }
26
17 if(styles) { 27 if(styles) {
18 this.application.ninja.stylesController.setElementStyles(el, styles); 28 this.application.ninja.stylesController.setElementStyles(el, styles);
19 } 29 }
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 8d7b74f0..e9a5f865 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -129,7 +129,7 @@ exports.ShapesController = Montage.create(CanvasController, {
129 el.elementModel.shapeModel.GLWorld.render(); 129 el.elementModel.shapeModel.GLWorld.render();
130 break; 130 break;
131 case "useWebGl": 131 case "useWebGl":
132 canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 132 canvas = njModule.NJUtils.make("canvas", el.className, this.application.ninja.currentDocument);
133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); 133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
134 canvas.width = el.width; 134 canvas.width = el.width;
135 canvas.height = el.height; 135 canvas.height = el.height;