diff options
author | Armen Kesablyan | 2012-04-04 11:34:19 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-04-04 11:34:19 -0700 |
commit | 211f514882144de8df69ebb2106f3b446be1dda0 (patch) | |
tree | c8eaf3d9fc7ac1bc841320e73d41818fbfb5827d /js/controllers | |
parent | 5a5d0f68dd82b829405a0b301dd11b4cf385c8d5 (diff) | |
parent | a11ef2eed7049835c8bdfa50a2b893632c46eaa0 (diff) | |
download | ninja-211f514882144de8df69ebb2106f3b446be1dda0.tar.gz |
Merge branch 'refs/heads/master' into BugFixes
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 15 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 67 | ||||
-rw-r--r-- | js/controllers/presets-controller.js | 8 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 147 |
4 files changed, 114 insertions, 123 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 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | NJComponent = require("js/lib/nj-base").NJComponent; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | var ElementController = exports.ElementController = Montage.create(NJComponent, { | 10 | 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 | 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 f0e9458b..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(); |
@@ -119,6 +120,31 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
119 | el.elementModel.shapeModel.GLWorld._canvas.task.stop(); | 120 | el.elementModel.shapeModel.GLWorld._canvas.task.stop(); |
120 | } | 121 | } |
121 | break; | 122 | break; |
123 | case "strokeHardness": | ||
124 | this.setShapeProperty(el, "strokeHardness", value); | ||
125 | el.elementModel.shapeModel.GLGeomObj.setStrokeHardness(val); | ||
126 | el.elementModel.shapeModel.GLWorld.render(); | ||
127 | break; | ||
128 | case "strokeSmoothing": | ||
129 | this.setShapeProperty(el, "strokeSmoothing", value); | ||
130 | el.elementModel.shapeModel.GLGeomObj.setSmoothingAmount(val); | ||
131 | el.elementModel.shapeModel.GLWorld.render(); | ||
132 | break; | ||
133 | case "doSmoothing": | ||
134 | this.setShapeProperty(el, "doSmoothing", value); | ||
135 | el.elementModel.shapeModel.GLGeomObj.setDoSmoothing(value); | ||
136 | el.elementModel.shapeModel.GLWorld.render(); | ||
137 | break; | ||
138 | case "isCalligraphic": | ||
139 | this.setShapeProperty(el, "isCalligraphic", value); | ||
140 | el.elementModel.shapeModel.GLGeomObj.setStrokeUseCalligraphic(value); | ||
141 | el.elementModel.shapeModel.GLWorld.render(); | ||
142 | break; | ||
143 | case "strokeAngle": | ||
144 | this.setShapeProperty(el, "strokeAngle", value); | ||
145 | el.elementModel.shapeModel.GLGeomObj.setStrokeAngle(Math.PI * val/180); | ||
146 | el.elementModel.shapeModel.GLWorld.render(); | ||
147 | break; | ||
122 | default: | 148 | default: |
123 | CanvasController.setProperty(el, p, value); | 149 | CanvasController.setProperty(el, p, value); |
124 | } | 150 | } |
@@ -139,6 +165,43 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
139 | case "useWebGl": | 165 | case "useWebGl": |
140 | case "animate": | 166 | case "animate": |
141 | return this.getShapeProperty(el, p); | 167 | return this.getShapeProperty(el, p); |
168 | case "strokeHardness": | ||
169 | if (el.elementModel && el.elementModel.shapeModel){ | ||
170 | return el.elementModel.shapeModel.GLGeomObj.getStrokeHardness(); | ||
171 | } else { | ||
172 | return null; | ||
173 | } | ||
174 | break; | ||
175 | case "doSmoothing": | ||
176 | if (el.elementModel && el.elementModel.shapeModel){ | ||
177 | return el.elementModel.shapeModel.GLGeomObj.getDoSmoothing(); | ||
178 | } else { | ||
179 | return null; | ||
180 | } | ||
181 | break; | ||
182 | case "strokeSmoothing": | ||
183 | if (el.elementModel && el.elementModel.shapeModel){ | ||
184 | return el.elementModel.shapeModel.GLGeomObj.getSmoothingAmount(); | ||
185 | } else { | ||
186 | return null; | ||
187 | } | ||
188 | break; | ||
189 | case "isCalligraphic": | ||
190 | if (el.elementModel && el.elementModel.shapeModel){ | ||
191 | return el.elementModel.shapeModel.GLGeomObj.getStrokeUseCalligraphic(); | ||
192 | } else { | ||
193 | return null; | ||
194 | } | ||
195 | break; | ||
196 | case "strokeAngle": | ||
197 | if (el.elementModel && el.elementModel.shapeModel){ | ||
198 | return 180*el.elementModel.shapeModel.GLGeomObj.getStrokeAngle()/Math.PI; | ||
199 | } else { | ||
200 | return null; | ||
201 | } | ||
202 | break; | ||
203 | |||
204 | |||
142 | case "strokeMaterial": | 205 | case "strokeMaterial": |
143 | case "fillMaterial": | 206 | case "fillMaterial": |
144 | var m = this.getShapeProperty(el, p); | 207 | var m = this.getShapeProperty(el, p); |
diff --git a/js/controllers/presets-controller.js b/js/controllers/presets-controller.js index 7152ba93..0467f73c 100644 --- a/js/controllers/presets-controller.js +++ b/js/controllers/presets-controller.js | |||
@@ -59,16 +59,14 @@ exports.PresetsController = Montage.create(Component, { | |||
59 | }, this); | 59 | }, this); |
60 | 60 | ||
61 | selection.forEach(function(element) { | 61 | selection.forEach(function(element) { |
62 | var el = element._element; | ||
63 | |||
64 | if(useTransition) { | 62 | if(useTransition) { |
65 | this.addTransition(el); | 63 | this.addTransition(element); |
66 | } | 64 | } |
67 | 65 | ||
68 | el.classList.add(selectorBase); | 66 | element.classList.add(selectorBase); |
69 | 67 | ||
70 | //// Keep track of elements with presets and don't add duplicates | 68 | //// Keep track of elements with presets and don't add duplicates |
71 | this.setCachedPreset(el, presetData.id, rules); | 69 | this.setCachedPreset(element, presetData.id, rules); |
72 | 70 | ||
73 | }, this); | 71 | }, this); |
74 | 72 | ||
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 53cca029..dbb3f30d 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js | |||
@@ -6,8 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | 7 | ||
8 | var Montage = require("montage/core/core").Montage, | 8 | var Montage = require("montage/core/core").Montage, |
9 | Component = require("montage/ui/component").Component, | 9 | Component = require("montage/ui/component").Component; |
10 | NJUtils = require("js/lib/NJUtils").NJUtils; | ||
11 | 10 | ||
12 | exports.SelectionController = Montage.create(Component, { | 11 | exports.SelectionController = Montage.create(Component, { |
13 | 12 | ||
@@ -45,13 +44,10 @@ exports.SelectionController = Montage.create(Component, { | |||
45 | value: function() { | 44 | value: function() { |
46 | this.eventManager.addEventListener("openDocument", this, false); | 45 | this.eventManager.addEventListener("openDocument", this, false); |
47 | this.eventManager.addEventListener("elementAdded", this, false); | 46 | this.eventManager.addEventListener("elementAdded", this, false); |
48 | this.eventManager.addEventListener("elementDeleted", this, false); | 47 | this.eventManager.addEventListener("elementsRemoved", this, false); |
49 | this.eventManager.addEventListener("selectAll", this, false); | 48 | this.eventManager.addEventListener("selectAll", this, false); |
50 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
51 | this.eventManager.addEventListener("switchDocument", this, false); | 49 | this.eventManager.addEventListener("switchDocument", this, false); |
52 | this.eventManager.addEventListener("closeDocument", this, false); | 50 | this.eventManager.addEventListener("closeDocument", this, false); |
53 | // defaultEventManager.addEventListener( "undo", this, false); | ||
54 | // defaultEventManager.addEventListener( "redo", this, false); | ||
55 | } | 51 | } |
56 | }, | 52 | }, |
57 | 53 | ||
@@ -67,35 +63,25 @@ exports.SelectionController = Montage.create(Component, { | |||
67 | 63 | ||
68 | initWithDocument: { | 64 | initWithDocument: { |
69 | value: function(currentSelectionArray) { | 65 | value: function(currentSelectionArray) { |
70 | this._selectedItems = []; | ||
71 | this._isDocument = true; | 66 | this._isDocument = true; |
72 | 67 | ||