From e52b0dcb9540b854a341a881de2d26aa753e9a82 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 16:18:38 -0700 Subject: Adding checkbox in PI to start/stop WebGL animation preview. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 13 ++++++++++++ js/data/pi/pi-data.js | 30 ++++++++++++++++++++++++++++ js/models/shape-model.js | 3 ++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b3ac9ddb..9b2fa618 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -105,6 +105,18 @@ exports.ShapesController = Montage.create(CanvasController, { case "editFillMaterial": NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); break; + case "animate": + if(value) + { + el.elementModel.shapeModel.animate = true; + el.elementModel.shapeModel.GLWorld.restartRenderLoop(); + } + else + { + el.elementModel.shapeModel.animate = false; + el.elementModel.shapeModel.GLWorld._canvas.task.stop(); + } + break; default: CanvasController.setProperty(el, p, value); } @@ -123,6 +135,7 @@ exports.ShapesController = Montage.create(CanvasController, { case "border": case "background": case "useWebGl": + case "animate": return this.getShapeProperty(el, p); case "strokeMaterial": case "fillMaterial": diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js index 53fec3be..56337124 100755 --- a/js/data/pi/pi-data.js +++ b/js/data/pi/pi-data.js @@ -391,6 +391,16 @@ exports.PiData = Montage.create( Montage, { checked: false } ], + [ + { + type: "checkbox", + id: "animate", + prop: "animate", + defaultValue: true, + value: "Animate", + checked: true + } + ], [ { type: "dropdown", @@ -484,6 +494,16 @@ exports.PiData = Montage.create( Montage, { checked: false } ], + [ + { + type: "checkbox", + id: "animate", + prop: "animate", + defaultValue: true, + value: "Animate", + checked: true + } + ], [ { type: "dropdown", @@ -578,6 +598,16 @@ exports.PiData = Montage.create( Montage, { checked: false } ], + [ + { + type: "checkbox", + id: "animate", + prop: "animate", + defaultValue: true, + value: "Animate", + checked: true + } + ], [ { type: "dropdown", diff --git a/js/models/shape-model.js b/js/models/shape-model.js index 58a88fd0..ea8c2cfc 100755 --- a/js/models/shape-model.js +++ b/js/models/shape-model.js @@ -10,7 +10,8 @@ var Montage = require("montage/core/core").Montage, exports.ShapeModel = Montage.create(Component, { shapeCount: { value: 0 }, - useWebGl: { value: false }, + useWebGl: { value: false }, + animate: { value: true }, GLWorld: { value: null }, GLGeomObj: { value: null }, -- cgit v1.2.3 From ccbbf1318fcf21409f0b1841119b49fadd92f83d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 16:53:23 -0700 Subject: Start WebGL animation during live preview. And set WebGL animation back to user preference when closing live preview. Signed-off-by: Nivesh Rajbhandari --- js/ninja.reel/ninja.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 2a6e49f7..7db2a82c 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -166,6 +166,25 @@ exports.Ninja = Montage.create(Component, { this.currentDocument.documentRoot.elementModel.controller.setProperty(this.currentDocument.documentRoot, "overflow", overflow); this.currentDocument.documentRoot.elementModel.controller.changeSelector(this.currentDocument.documentRoot, "transitionStopRule", transitionStopRule); + this._toggleWebGlAnimation(this.appModel.livePreview); + } + }, + + // Turn on WebGL animation during preview + _toggleWebGlAnimation: { + value: function(inLivePreview) { + var glCanvases = this.currentDocument.iframe.contentWindow.document.querySelectorAll('[data-RDGE-id]'), + glShapeModel; + if(glCanvases) { + for(var i = 0, len = glCanvases.length; i