aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-04-10 11:24:21 -0700
committerJose Antonio Marquez2012-04-10 11:24:21 -0700
commitd14f78b06d37aa469885f2ecf84419bcb7e3e613 (patch)
tree91b95c6c9aef779a743b710105546a8ae74bff12 /js/controllers
parenta9bcc403df76ad2cb7c31ff7fdd42a85c35cf424 (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-d14f78b06d37aa469885f2ecf84419bcb7e3e613.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js11
-rwxr-xr-xjs/controllers/elements/component-controller.js2
-rwxr-xr-xjs/controllers/elements/element-controller.js59
-rwxr-xr-xjs/controllers/elements/shapes-controller.js395
-rwxr-xr-xjs/controllers/elements/stage-controller.js16
-rw-r--r--js/controllers/presets-controller.js9
-rwxr-xr-xjs/controllers/selection-controller.js7
-rwxr-xr-xjs/controllers/styles-controller.js66
8 files changed, 357 insertions, 208 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index a308f191..ddaeb061 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -32,9 +32,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
32 _iframeHolder: { value: null, enumerable: false }, 32 _iframeHolder: { value: null, enumerable: false },
33 _textHolder: { value: null, enumerable: false }, 33 _textHolder: { value: null, enumerable: false },
34 _codeMirrorCounter: {value: 1, enumerable: false}, 34 _codeMirrorCounter: {value: 1, enumerable: false},
35
36 canSave:{value: false},//for Save menu state update
37 canSaveAll:{value: false},//for Save All menu state update
38 35
39 activeDocument: { 36 activeDocument: {
40 get: function() { 37 get: function() {
@@ -50,12 +47,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
50 if(!!this._activeDocument.editor){ 47 if(!!this._activeDocument.editor){
51 this._activeDocument.editor.focus(); 48 this._activeDocument.editor.focus();
52 } 49 }
53
54 this.canSave = doc.needsSave;
55 this.canSaveAll = doc.needsSave;
56 }else{
57 this.canSave = false;
58 this.canSaveAll = false;
59 } 50 }
60 } 51 }
61 }, 52 },
@@ -80,7 +71,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
80 handleAddComponentFirstDraw: { 71 handleAddComponentFirstDraw: {
81 value: function (e) { 72 value: function (e) {
82 //TODO: Add logic to reparse the document for dynamically added styles 73 //TODO: Add logic to reparse the document for dynamically added styles
83 console.log(e); 74 //console.log(e);
84 } 75 }
85 }, 76 },
86 77
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 260ee8a0..d902e4a1 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -16,6 +16,7 @@ exports.ComponentController = Montage.create(ElementController, {
16 switch(prop) { 16 switch(prop) {
17 case "id": 17 case "id":
18 case "class": 18 case "class":
19 case "-webkit-transform-style":
19 case "left": 20 case "left":
20 case "top": 21 case "top":
21 case "width": 22 case "width":
@@ -38,6 +39,7 @@ exports.ComponentController = Montage.create(ElementController, {
38 switch(p) { 39 switch(p) {
39 case "id": 40 case "id":
40 case "class": 41 case "class":
42 case "-webkit-transform-style":
41 case "left": 43 case "left":
42 case "top": 44 case "top":
43 case "width": 45 case "width":
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index efb33292..fda3a3c5 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -228,11 +228,10 @@ exports.ElementController = Montage.create(Component, {
228 228
229 if (el) 229 if (el)
230 { 230 {
231 var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform"); 231 mat = this.application.ninja.stylesController.getMatrixFromElement(el, false);
232 if (xformStr) 232 if (!mat) {
233 mat = this.transformStringToMat( xformStr );
234 if (!mat)
235 mat = Matrix.I(4); 233 mat = Matrix.I(4);
234 }
236 } 235 }
237 236
238 el.elementModel.props3D.matrix3d = mat; 237 el.elementModel.props3D.matrix3d = mat;
@@ -249,23 +248,9 @@ exports.ElementController = Montage.create(Component, {
249 } 248 }
250 else 249 else
251 { 250 {
252 var dist = 1400; 251 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false);
253 252 if(dist == null) {
254 var str = this.getProperty(el, "-webkit-transform"); 253 dist = 1400;
255 if (str)
256 {
257 var index1 = str.indexOf( "perspective(");
258 if (index1 >= 0)
259 {
260 index1 += 12; // do not include 'perspective('
261 var index2 = str.indexOf( ")", index1 );
262 if (index2 >= 0)
263 {
264 var substr = str.substr( index1, (index2-index1));
265 if (substr && (substr.length > 0))
266 dist = MathUtils.styleToNumber( substr );
267 }
268 }
269 } 254 }
270 255
271 el.elementModel.props3D.perspectiveDist = dist; 256 el.elementModel.props3D.perspectiveDist = dist;
@@ -308,36 +293,6 @@ exports.ElementController = Montage.create(Component, {
308 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]); 293 elt.elementModel.props3D.z3D = ~~(elt3DInfo.translation[2]);
309 } 294 }
310 } 295 }
311 },
312
313 transformStringToMat: {
314 value: function( str ) {
315 var rtnMat;
316
317 var index1 = str.indexOf( "matrix3d(");
318 if (index1 >= 0)
319 {
320 index1 += 9; // do not include 'matrix3d('
321 var index2 = str.indexOf( ")", index1 );
322 if (index2 >= 0)
323 {
324 var substr = str.substr( index1, (index2-index1));
325 if (substr && (substr.length > 0))
326 {
327 var numArray = substr.split(',');
328 var nNums = numArray.length;
329 if (nNums == 16)
330 {
331 // gl-matrix wants row order
332 rtnMat = numArray;
333 for (var i=0; i<16; i++)
334 rtnMat[i] = Number( rtnMat[i] );
335 }
336 }
337 }
338 }
339
340 return rtnMat;
341 }
342 } 296 }
297
343}); \ No newline at end of file 298}); \ No newline at end of file
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index c9164e3e..14cdc473 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -13,12 +13,74 @@ var Montage = require("montage/core/core").Montage,
13exports.ShapesController = Montage.create(CanvasController, { 13exports.ShapesController = Montage.create(CanvasController, {
14 14
15 setProperty: { 15 setProperty: {
16 value: function(el, p, value) { 16 value: function(el, p, value, eventType, source) {
17 var val = parseInt(value); 17 var val = parseInt(value),
18 canvas,
19 m,
20 color;
18 switch(p) { 21 switch(p) {
19 case "strokeSize": 22 case "strokeSize":
20 // TODO - For now, just handling px units. 23 // TODO - For now, just handling px units.
21 this.setShapeProperty(el, "strokeSize", value); 24 this.setShapeProperty(el, "strokeSize", value);
25 // TODO - For now, just handle Line, Rectangle and Oval. Eventually, move this into each class's
26 // setStrokeWidth code like SubPath and BrushStroke do.
27 var geomType = el.elementModel.shapeModel.GLGeomObj.geomType();
28 if( (geomType > 0) && (geomType < 4) )
29 {
30 // Changing stroke size should grow/shrink the shape from the center.
31 var delta = ~~(val - el.elementModel.shapeModel.GLGeomObj.getStrokeWidth()),
32 l = this.application.ninja.elementMediator.getProperty(el, "left", parseInt),
33 t = this.application.ninja.elementMediator.getProperty(el, "top", parseInt),
34 w = this.application.ninja.elementMediator.getProperty(el, "width", parseInt),
35 h = this.application.ninja.elementMediator.getProperty(el, "height", parseInt);
36
37 if(geomType === 3)
38 {
39 var slope = el.elementModel.shapeModel.slope;
40 // set the dimensions
41 if(slope === "horizontal")
42 {
43 h = Math.max(val, 1);
44 t -= ~~(delta/2);
45 }
46 else if(slope === "vertical")
47 {
48 w = Math.max(val, 1);
49 l -= ~~(delta/2);
50 }
51 else
52 {
53 var oldXAdj = el.elementModel.shapeModel.GLGeomObj.getXAdj();
54 var oldYAdj = el.elementModel.shapeModel.GLGeomObj.getYAdj();
55 var theta = Math.atan(el.elementModel.shapeModel.slope);
56 var xAdj = Math.abs((val/2)*Math.sin(theta));