aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-04 11:11:58 -0700
committerValerio Virgillito2012-04-04 11:11:58 -0700
commita11ef2eed7049835c8bdfa50a2b893632c46eaa0 (patch)
treefcbb067044d339daa49622537e934bf3a309db96 /js/controllers/elements
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-a11ef2eed7049835c8bdfa50a2b893632c46eaa0.tar.gz
Squashed commit of Preparing for the montage undo-manager: Architecture changes
Reworked the add and remove elements into 1 function which can take 1 or more elements. Removed the _element from the selection array Many other changes related to those 2 changes Undo/Redo shortcuts are now using montage undo/redo manager. Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/element-controller.js15
-rwxr-xr-xjs/controllers/elements/shapes-controller.js5
2 files changed, 13 insertions, 7 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index b35251ad..efb33292 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -5,22 +5,27 @@ 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 NJComponent = require("js/lib/nj-base").NJComponent; 8 Component = require("montage/ui/component").Component;
9 9
10var ElementController = exports.ElementController = Montage.create(NJComponent, { 10exports.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 this.application.ninja.currentDocument.documentRoot.appendChild(el);
15 // Nested elements - 15 // Nested elements - TODO make sure the CSS is correct before nesting elements
16 // TODO make sure the CSS is correct before nesting elements
17 // this.application.ninja.currentSelectedContainer.appendChild(el); 16 // this.application.ninja.currentSelectedContainer.appendChild(el);
18 this.application.ninja.stylesController.setElementStyles(el, styles); 17 if(styles) {
18 this.application.ninja.stylesController.setElementStyles(el, styles);
19 }
19 } 20 }
20 }, 21 },
21 22
23 // Remove the element from the DOM and clear the GLWord.
22 removeElement: { 24 removeElement: {
23 value: function(el) { 25 value: function(el) {
26 if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) {
27 el.elementModel.shapeModel.GLWorld.clearTree();
28 }
24 el.parentNode.removeChild(el); 29 el.parentNode.removeChild(el);
25 } 30 }
26 }, 31 },
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index ef453bea..c9164e3e 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -72,8 +72,9 @@ exports.ShapesController = Montage.create(CanvasController, {
72 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); 72 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
73 canvas.width = el.width; 73 canvas.width = el.width;
74 canvas.height = el.height; 74 canvas.height = el.height;
75 this.application.ninja.elementMediator.replaceElement(el, canvas); 75 canvas.elementModel = el.elementModel;
76 NJevent("elementDeleted", el); 76 this.application.ninja.currentDocument.documentRoot.replaceChild(canvas, el);
77 NJevent("elementsRemoved", el);
77 el = canvas; 78 el = canvas;
78 this.toggleWebGlMode(el, value); 79 this.toggleWebGlMode(el, value);
79 el.elementModel.shapeModel.GLWorld.render(); 80 el.elementModel.shapeModel.GLWorld.render();