From 8ad767b61460984a4031ba630f76ac8247a61857 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 7 Feb 2012 11:42:10 -0800 Subject: Fixed PI to support WebGL materials. Signed-off-by: Nivesh Rajbhandari --- js/components/combobox.reel/combobox.js | 4 ++-- js/controllers/elements/shapes-controller.js | 23 ++++++++++++++++++++-- js/data/pi/pi-data.js | 5 +++++ .../properties/sections/custom.reel/custom.js | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js index 8906a649..ebbfbffa 100644 --- a/js/components/combobox.reel/combobox.js +++ b/js/components/combobox.reel/combobox.js @@ -15,7 +15,7 @@ exports.Combobox = Montage.create(Component, { }, _wasSetByCode: { - enumerable: false, + enumerable: true, value: true }, @@ -79,7 +79,7 @@ exports.Combobox = Montage.create(Component, { e.value = this._value; this.dispatchEvent(e); - this._wasSetByCode = false; + this._wasSetByCode = true; } } }, diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 3f1ccc3d..21373aca 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -68,6 +68,24 @@ exports.ShapesController = Montage.create(CanvasController, { this.toggleWebGlMode(el, value); el.elementModel.shapeModel.GLGeomObj.buildBuffers(); break; + case "strokeMaterial": + var sm = Object.create(MaterialsLibrary.getMaterial(value)); + if(sm) + { + el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); + el.elementModel.shapeModel.strokeMaterial = sm; + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + } + break; + case "fillMaterial": + var fm = Object.create(MaterialsLibrary.getMaterial(value)); + if(fm) + { + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); + el.elementModel.shapeModel.strokeMaterial = fm; + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + } + break; default: CanvasController.setProperty(el, p, value); } @@ -84,12 +102,13 @@ exports.ShapesController = Montage.create(CanvasController, { case "trRadius": case "blRadius": case "brRadius": - case "strokeMaterial": - case "fillMaterial": case "border": case "background": case "useWebGl": return this.getShapeProperty(el, p); + case "strokeMaterial": + case "fillMaterial": + return this.getShapeProperty(el, p).getName(); default: return CanvasController.getProperty(el, p); } diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js index de192b57..10b33a0e 100644 --- a/js/data/pi/pi-data.js +++ b/js/data/pi/pi-data.js @@ -384,6 +384,7 @@ exports.PiData = Montage.create( Montage, { prop: "strokeMaterial", label: "Stroke", labelField: "_name", + dataField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, enabled: { boundObject: "this.controls", boundProperty: "useWebGl" }, divider : true @@ -396,6 +397,7 @@ exports.PiData = Montage.create( Montage, { prop: "fillMaterial", label: "Fill", labelField: "_name", + dataField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, enabled: { boundObject: "this.controls", boundProperty: "useWebGl" } } @@ -460,6 +462,7 @@ exports.PiData = Montage.create( Montage, { id: "stroke", label: "Stroke", labelField: "_name", + dataField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, enabled: { boundObject: "this.controls", boundProperty: "useWebGl" } } @@ -545,6 +548,7 @@ exports.PiData = Montage.create( Montage, { prop: "strokeMaterial", label: "Stroke", labelField: "_name", + dataField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, enabled: { boundObject: "this.controls", boundProperty: "useWebGl" }, divider : true @@ -557,6 +561,7 @@ exports.PiData = Montage.create( Montage, { prop: "fillMaterial", label: "Fill", labelField: "_name", + dataField: "_name", items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, enabled: { boundObject: "this.controls", boundProperty: "useWebGl" } } diff --git a/js/panels/properties/sections/custom.reel/custom.js b/js/panels/properties/sections/custom.reel/custom.js index e92a39fd..992db8e6 100644 --- a/js/panels/properties/sections/custom.reel/custom.js +++ b/js/panels/properties/sections/custom.reel/custom.js @@ -186,6 +186,8 @@ exports.CustomSection = Montage.create(Component, { if (aField.value) obj.value = aField.value; if (aField.labelField) obj.labelField = aField.labelField; if (aField.labelFunction) obj.labelFunction = aField.labelFunction; + if (aField.dataField) obj.dataField = aField.dataField; + if (aField.dataFunction) obj.dataFunction = aField.dataFunction; if (aField.items) { if(aField.items.boundObject) { obj.items = eval(aField.items.boundObject)[aField.items.boundProperty]; -- cgit v1.2.3