aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-13 00:30:19 -0700
committerValerio Virgillito2012-04-13 00:30:19 -0700
commitf91e64235eb03c889ff4f5577c3e3480cd0d787f (patch)
tree946cfe53bd9281478f32c7a446c1c803383d8d17 /js
parent5b4826eced782fe7b4691d4bbbe0e3605d3164c1 (diff)
downloadninja-f91e64235eb03c889ff4f5577c3e3480cd0d787f.tar.gz
removing _undo array and _targets array and use object instead of matching arrays to set properties
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/canvas-controller.js8
-rwxr-xr-xjs/controllers/elements/element-controller.js19
-rwxr-xr-xjs/controllers/elements/stage-controller.js58
-rwxr-xr-xjs/mediators/element-mediator.js94
-rwxr-xr-xjs/models/element-model.js36
-rwxr-xr-xjs/tools/Rotate3DToolBase.js184
-rwxr-xr-xjs/tools/RotateStage3DTool.js12
-rwxr-xr-xjs/tools/SelectionTool.js254
-rwxr-xr-xjs/tools/Translate3DToolBase.js158
-rwxr-xr-xjs/tools/TranslateObject3DTool.js17
-rwxr-xr-xjs/tools/modifier-tool-base.js35
11 files changed, 345 insertions, 530 deletions
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js
index b5df3911..7af7e824 100755
--- a/js/controllers/elements/canvas-controller.js
+++ b/js/controllers/elements/canvas-controller.js
@@ -33,13 +33,5 @@ exports.CanvasController = Montage.create(ElementController, {
33 ElementController.setProperty(el, p, value); 33 ElementController.setProperty(el, p, value);
34 } 34 }
35 } 35 }
36 },
37
38 setProperties: {
39 value: function(el, props, index) {
40 for(var p in props) {
41 el.elementModel.controller.setProperty(el, p, props[p][index]);
42 }
43 }
44 } 36 }
45}); \ No newline at end of file 37}); \ No newline at end of file
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 0f17dd46..35a543ac 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -48,16 +48,6 @@ exports.ElementController = Montage.create(Component, {
48 48
49 setProperties: { 49 setProperties: {
50 value: function(element, properties) { 50 value: function(element, properties) {
51 /* Array of properties is not supported yet
52 if(Array.isArray(properties)) {
53
54 elements.forEach(function(property) {
55 this.application.ninja.stylesController.setElementStyle(element, p, props[p][index]);
56 });
57 } else {
58 }
59 */
60
61 for(var property in properties) { 51 for(var property in properties) {
62 this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); 52 this.application.ninja.stylesController.setElementStyle(element, property, properties[property]);
63 } 53 }
@@ -239,15 +229,16 @@ exports.ElementController = Montage.create(Component, {
239 229
240 // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat" 230 // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat"
241 set3DProperties: { 231 set3DProperties: {
242 value: function(el, props, index, update3DModel) { 232 value: function(el, props, update3DModel) {
243 var dist = props[index]["dist"], 233 var dist = props["dist"],
244 mat = props[index]["mat"]; 234 mat = props["mat"];
235
245 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); 236 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")");
246 237
247 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform-style", "preserve-3d"); 238 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform-style", "preserve-3d");
248 239
249 // TODO - We don't support perspective on individual elements yet 240 // TODO - We don't support perspective on individual elements yet
250// this.application.ninja.stylesController.setElementStyle(el, "-webkit-perspective", dist); 241 // this.application.ninja.stylesController.setElementStyle(el, "-webkit-perspective", dist);
251 242
252 el.elementModel.props3D.matrix3d = mat; 243 el.elementModel.props3D.matrix3d = mat;
253 el.elementModel.props3D.perspectiveDist = dist; 244 el.elementModel.props3D.perspectiveDist = dist;
diff --git a/js/controllers/elements/stage-controller.js b/js/controllers/elements/stage-controller.js
index f376e40f..3ef7dacc 100755
--- a/js/controllers/elements/stage-controller.js
+++ b/js/controllers/elements/stage-controller.js
@@ -31,46 +31,34 @@ exports.StageController = Montage.create(ElementController, {
31 } 31 }
32 }, 32 },
33 33
34
34 // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat" 35 // TODO - perspective distance needs to be passed in as "dist" and matrix3d needs to be passed in as "mat"
35 set3DProperties: { 36 set3DProperties: {
36 value: function(el, props, index, update3DModel) { 37 value: function(el, props, update3DModel) {
37 var dist = props[index]["dist"], 38 var dist = props["dist"], mat = props["mat"];
38 mat = props[index]["mat"]; 39 this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true);
39 this.application.ninja.stylesController.setElementStyle(el, 40
40 "-webkit-transform", 41 el.elementModel.props3D.matrix3d = mat;
41 "perspective(" + dist + ") " + 42 el.elementModel.props3D.perspectiveDist = dist;
42 "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")",
43 true);
44
45 el.elementModel.props3D.matrix3d = mat;
46 el.elementModel.props3D.perspectiveDist = dist;
47
48 // TODO - Move this to matrix class
49 if(this._isRotated(mat))
50 {
51 this.application.ninja.currentDocument.stageBG.style.display = "none";
52 }
53 else
54 {
55 this.application.ninja.stylesController.setElementStyle(this.application.ninja.currentDocument.stageBG,
56 "-webkit-transform",
57 "perspective(" + dist + ") " +
58 "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")",
59 true);
60
61 this.application.ninja.currentDocument.stageBG.elementModel.props3D.matrix3d = mat;
62 this.application.ninja.currentDocument.stageBG.elementModel.props3D.perspectiveDist = dist;
63 this.application.ninja.currentDocument.stageBG.style.display = "block";
64 }
65 43
66 this.application.ninja.stage.updatedStage = true; 44 // TODO - Move this to matrix class
45 if(this._isRotated(mat)) {
46 this.application.ninja.currentDocument.stageBG.style.display = "none";
47 } else {
48 this.application.ninja.stylesController.setElementStyle(this.application.ninja.currentDocument.stageBG, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true);
67 49
68 if(update3DModel) 50 this.application.ninja.currentDocument.stageBG.elementModel.props3D.matrix3d = mat;
69 { 51 this.application.ninja.currentDocument.stageBG.elementModel.props3D.perspectiveDist = dist;
70 this._update3DProperties(el, mat, dist); 52 this.application.ninja.currentDocument.stageBG.style.display = "block";
53 }
54
55 this.application.ninja.stage.updatedStage = true;
56
57 if(update3DModel) {
58 this._update3DProperties(el, mat, dist);
59 }
71 } 60 }
72 } 61 },
73 },
74 62
75 getProperty: { 63 getProperty: {
76 value: function(el, p) { 64 value: function(el, p) {
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index 6ab33eff..a5f72462 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -234,8 +234,25 @@ exports.ElementMediator = Montage.create(Component, {
234 @param eventType: Change/Changing. Will be passed to the dispatched event 234 @param eventType: Change/Changing. Will be passed to the dispatched event
235 @param source: String for the source object making the call 235 @param source: String for the source object making the call
236 */ 236 */
237 /*value: function(elements, properties, currentProperties, eventType, source) {*/
237 setProperties: { 238 setProperties: {
238 value: function(elements, properties, currentProperties, eventType, source) { 239 value: function(elements, eventType, source) {
240
241 elements.forEach(function(elementObject) {
242 elementObject.element.elementModel.controller["setProperties"](elementObject.element, elementObject.properties);
243 });
244
245 if(eventType !== "Changing") {
246 var undoLabel = "Properties change";
247 elements.forEach(function(elementObject) {
248 var swap = elementObject.properties;
249 elementObject.properties = elementObject.previousProperties;
250 elementObject.previousProperties = swap;
251 });
252 document.application.undoManager.add(undoLabel, this.setProperties, this, elements, eventType, source);
253 }
254
255 /*
239 // Assume elements is an array of elements always 256 // Assume elements is an array of elements always
240 elements.forEach(function(element) { 257 elements.forEach(function(element) {
241 element.elementModel.controller["setProperties"](element, properties); 258 element.elementModel.controller["setProperties"](element, properties);
@@ -246,79 +263,34 @@ exports.ElementMediator = Montage.create(Component, {
246 var undoLabel = "Properties change"; 263 var undoLabel = "Properties change";
247 document.application.undoManager.add(undoLabel, this.setProperties, this, elements, currentProperties, properties, eventType, source); 264 document.application.undoManager.add(undoLabel, this.setProperties, this, elements, currentProperties, properties, eventType, source);
248 } 265 }
266 */
267 // Map the elements for the event data
268 var els = elements.map(function(element) {
269 return element.element;
270 });
249 271
250 // Dispatch the element change/changing event. 272 // Dispatch the element change/changing event.
251 NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": elements, "prop": properties, "value": properties}, redraw: null}); 273 NJevent("element" + eventType, {type : "setProperties", source: source, data: {"els": els, "prop": elements[0].properties, "value": elements}, redraw: null});
252 } 274 }
253 }, 275 },
254 276
255 /**
256 Set a property change command for an element or array of elements
257 @param els: Array of elements. Can contain 1 or more elements
258 @param props: Property/ies object containing both the value and property
259 @param eventType: Change/Changing. Will be passed to the dispatched event
260 @param source: String for the source object making the call
261 @param currentProps *OPTIONAL*: current properties objects array. If not found it will be calculated
262 @param stageRedraw: *OPTIONAL*: True. If set to false the stage will not redraw the selection/outline
263 */
264 set3DProperties: {