diff options
author | Eric Guzman | 2012-04-02 15:36:08 -0700 |
---|---|---|
committer | Eric Guzman | 2012-04-02 15:36:08 -0700 |
commit | 0241bf331b7e06e206a54be441edf2f4c7261f63 (patch) | |
tree | b7e2f9cad73eed4fc616cf1841cd0be02bd955d4 /js/document | |
parent | dde5b5054f93db493e5d4d502e677f5781334b08 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-0241bf331b7e06e206a54be441edf2f4c7261f63.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 183 | ||||
-rwxr-xr-x | js/document/templates/montage-html/default_html.css | 4 | ||||
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 42 | ||||
-rwxr-xr-x | js/document/text-document.js | 8 |
4 files changed, 119 insertions, 118 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index d4db6e2f..42a7d537 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -9,7 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | TextDocument = require("js/document/text-document").TextDocument, | 10 | TextDocument = require("js/document/text-document").TextDocument, |
11 | NJUtils = require("js/lib/NJUtils").NJUtils, | 11 | NJUtils = require("js/lib/NJUtils").NJUtils, |
12 | GLWorld = require("js/lib/drawing/world").World; | 12 | GLWorld = require("js/lib/drawing/world").World, |
13 | MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
13 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
14 | // | 15 | // |
15 | exports.HTMLDocument = Montage.create(TextDocument, { | 16 | exports.HTMLDocument = Montage.create(TextDocument, { |
@@ -193,12 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
193 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); | 194 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); |
194 | // | 195 | // |
195 | if (elt) { | 196 | if (elt) { |
196 | this._glData = []; | 197 | var matLib = MaterialsModel.exportMaterials(); |
197 | //if (path) { | 198 | this._glData = [matLib]; |
198 | //this.collectGLData(elt, this._glData, path); | 199 | this.collectGLData(elt, this._glData ); |
199 | //} else { | ||
200 | this.collectGLData(elt, this._glData ); | ||
201 | //} | ||
202 | } else { | 200 | } else { |
203 | this._glData = null | 201 | this._glData = null |
204 | } | 202 | } |
@@ -219,29 +217,74 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
219 | */ | 217 | */ |
220 | 218 | ||
221 | // /* | 219 | // /* |
220 | // get the data for the next canvas | ||
222 | var importStr = value[i]; | 221 | var importStr = value[i]; |
223 | var startIndex = importStr.indexOf( "id: " ); | 222 | |
224 | if (startIndex >= 0) { | 223 | // determine if it is the new (JSON) or old style format |
225 | var endIndex = importStr.indexOf( "\n", startIndex ); | 224 | var id = null; |
226 | if (endIndex > 0) { | 225 | var jObj = null; |
227 | var id = importStr.substring( startIndex+4, endIndex ); | 226 | var index = importStr.indexOf( ';' ); |
228 | if (id) { | 227 | if ((importStr[0] === 'v') && (index < 24)) |
229 | var canvas = this.findCanvasWithID( id, elt ); | 228 | { |
230 | if (canvas) { | 229 | // JSON format. pull off the |
231 | if (!canvas.elementModel) { | 230 | importStr = importStr.substr( index+1 ); |
232 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | 231 | jObj = jObj = JSON.parse( importStr ); |
233 | } | 232 | id = jObj.id; |
234 | if (canvas.elementModel) { | 233 | } |
235 | if (canvas.elementModel.shapeModel.GLWorld) { | 234 | else |
236 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | 235 | { |
237 | } | 236 | // at this point the data could be either the materials library or |
238 | var index = importStr.indexOf( "webGL: " ); | 237 | // an old style world. We can determine which by converting the string |
239 | var useWebGL = (index >= 0) | 238 | // to an object via JSON.parse. That operation will fail if the string |
240 | var world = new GLWorld( canvas, useWebGL ); | 239 | // is an old style world. |
241 | world.import( importStr ); | 240 | var matLibStr = 'materialLibrary;'; |
242 | this.buildShapeModel( canvas.elementModel, world ); | 241 | index = importStr.indexOf( matLibStr ); |
243 | } | 242 | if (index == 0) |
243 | { | ||
244 | importStr = importStr.substr( matLibStr.length ); | ||
245 | var matLibObj = JSON.parse( importStr ); | ||
246 | MaterialsModel.importMaterials( matLibObj ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | var startIndex = importStr.indexOf( "id: " ); | ||
251 | if (startIndex >= 0) { | ||
252 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
253 | if (endIndex > 0) | ||
254 | id = importStr.substring( startIndex+4, endIndex ); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | if (id != null) | ||
260 | { | ||
261 | var canvas = this.findCanvasWithID( id, elt ); | ||
262 | if (canvas) | ||
263 | { | ||
264 | if (!canvas.elementModel) | ||
265 | { | ||
266 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
267 | } | ||
268 | if (canvas.elementModel) | ||
269 | { | ||
270 | if (canvas.elementModel.shapeModel.GLWorld) | ||
271 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
272 | |||
273 | if (jObj) | ||
274 | { | ||
275 | var useWebGL = jObj.webGL; | ||
276 | var world = new GLWorld( canvas, useWebGL ); | ||
277 | world.importJSON( jObj ); | ||
244 | } | 278 | } |
279 | else | ||
280 | { | ||
281 | var index = importStr.indexOf( "webGL: " ); | ||
282 | var useWebGL = (index >= 0); | ||
283 | var world = new GLWorld( canvas, useWebGL ); | ||
284 | world.import( importStr ); | ||
285 | } | ||
286 | |||
287 | this.buildShapeModel( canvas.elementModel, world ); | ||
245 | } | 288 | } |
246 | } | 289 | } |
247 | } | 290 | } |
@@ -265,7 +308,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
265 | shapeModel.GLGeomObj = root; | 308 | shapeModel.GLGeomObj = root; |
266 | shapeModel.strokeSize = root._strokeWidth; | 309 | shapeModel.strokeSize = root._strokeWidth; |
267 | shapeModel.stroke = root._strokeColor.slice(); | 310 | shapeModel.stroke = root._strokeColor.slice(); |
268 | shapeModel.strokeMaterial = root._strokeMaterial.dup(); | 311 | shapeModel.strokeMaterial = root._strikeMaterial ? root._strokeMaterial.dup() : null; |
269 | shapeModel.strokeStyle = "solid"; | 312 | shapeModel.strokeStyle = "solid"; |
270 | //shapeModel.strokeStyleIndex | 313 | //shapeModel.strokeStyleIndex |
271 | //shapeModel.border | 314 | //shapeModel.border |
@@ -276,7 +319,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
276 | elementModel.selection = "Rectangle"; | 319 | elementModel.selection = "Rectangle"; |
277 | elementModel.pi = "RectanglePi"; | 320 | elementModel.pi = "RectanglePi"; |
278 | shapeModel.fill = root._fillColor.slice(); | 321 | shapeModel.fill = root._fillColor.slice(); |
279 | shapeModel.fillMaterial = root._fillMaterial.dup(); | 322 | shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null; |
280 | shapeModel.tlRadius = root._tlRadius; | 323 | shapeModel.tlRadius = root._tlRadius; |
281 | shapeModel.trRadius = root._trRadius; | 324 | shapeModel.trRadius = root._trRadius; |
282 | shapeModel.blRadius = root._blRadius; | 325 | shapeModel.blRadius = root._blRadius; |
@@ -287,7 +330,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
287 | elementModel.selection = "Oval"; | 330 | elementModel.selection = "Oval"; |
288 | elementModel.pi = "OvalPi"; | 331 | elementModel.pi = "OvalPi"; |
289 | shapeModel.fill = root._fillColor.slice(); | 332 | shapeModel.fill = root._fillColor.slice(); |
290 | shapeModel.fillMaterial = root._fillMaterial.dup(); | 333 | shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null; |
291 | shapeModel.innerRadius = root._innerRadius; | 334 | shapeModel.innerRadius = root._innerRadius; |
292 | break; | 335 | break; |
293 | 336 | ||
@@ -297,6 +340,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
297 | shapeModel.slope = root._slope; | 340 | shapeModel.slope = root._slope; |
298 | break; | 341 | break; |
299 | 342 | ||
343 | case root.GEOM_TYPE_BRUSH_STROKE: | ||
344 | elementModel.selection = "BrushStroke"; | ||
345 | elementModel.pi = "BrushStrokePi"; | ||
346 | break; | ||
347 | |||
348 | |||
300 | default: | 349 | default: |
301 | console.log( "geometry type not supported for file I/O, " + root.geomType()); | 350 | console.log( "geometry type not supported for file I/O, " + root.geomType()); |
302 | break; | 351 | break; |
@@ -382,7 +431,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
382 | { | 431 | { |
383 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 432 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
384 | { | 433 | { |
385 | var data = elt.elementModel.shapeModel.GLWorld.export(); | 434 | var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
435 | //var data = elt.elementModel.shapeModel.GLWorld.export(); | ||
386 | dataArray.push( data ); | 436 | dataArray.push( data ); |
387 | } | 437 | } |
388 | 438 | ||
@@ -520,67 +570,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
520 | } | 570 | } |
521 | // | 571 | // |
522 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; | 572 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
523 | //Inserting user's document into template | ||
524 | |||
525 | |||
526 | |||
527 | |||
528 | |||
529 | |||
530 | |||
531 | |||
532 | |||
533 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
534 | //////////////////////////////////////// |