From 8eac5582b72115969a9f915f4303535c22018033 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 2 May 2012 17:00:12 -0700 Subject: Material editor --- .../materials-library-panel.js | 13 ++-- .../materials-popup.reel/materials-popup.js | 80 +++++++++++++--------- 2 files changed, 57 insertions(+), 36 deletions(-) (limited to 'js/panels/Materials') diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js index 2176c6d5..205ecd90 100755 --- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js +++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js @@ -51,14 +51,15 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { handleNodeActivation: { value:function(obj) { - this._showMaterialPopup(obj.id); + this._showMaterialPopup({ materialId: obj.id }); } }, handleShowMaterialPopup: { enumerable: false, value: function (event) { - this._showMaterialPopup(event.detail.materialId); + //this._showMaterialPopup(event.detail.materialId); + this._showMaterialPopup(event.detail); } }, @@ -73,9 +74,9 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { _showMaterialPopup: { enumerable: false, - value: function (materialID) { + value: function (materialObj) { - if(!this._materialPopup) + if(!this._materialPopup) { this._materialPopup = Popup.create(); this._materialPopup.content = this._materialInfo; @@ -84,7 +85,9 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { this._materialPopup.addEventListener("show", this, false); } this._materialPopup.show(); - this._materialInfo.loadMaterials(materialID); + + materialID = materialObj.materialId; + this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); } }, diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index 9220659e..5a711455 100755 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -88,8 +88,9 @@ exports.MaterialsPopup = Montage.create(Component, { _handlePropertyChange: { - value: function(event) + value: function(theEvent) { + var event = theEvent._event; if(typeof event.propertyValue === "object") { console.log(event.propertyLabel + " changed to "); @@ -214,46 +215,63 @@ exports.MaterialsPopup = Montage.create(Component, { loadMaterials: { enumerable: true, - value: function(materialID) + value: function(materialID, useSelection, whichMaterial) { //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. this.materialsData = []; + var material; this._materialName = materialID; - if( - (materialID === "BumpMetalMaterial") || - (materialID === "DeformMaterial") || - (materialID === "FlatMaterial") || - (materialID === "FlagMaterial") || - (materialID === "FlyMaterial") || - (materialID === "JuliaMaterial") || - (materialID === "KeleidoscopeMaterial") || - (materialID === "LinearGradientMaterial") || - (materialID === "MandelMaterial") || - (materialID === "PlasmaMaterial") || - (materialID === "PulseMaterial") || - (materialID === "RadialBlurMaterial") || - (materialID === "RadialGradientMaterial") || - (materialID === "ReliefTunnelMaterial") || - (materialID === "SquareTunnelMaterial") || - (materialID === "StarMaterial") || - (materialID === "TaperMaterial") || - (materialID === "TunnelMaterial") || - (materialID === "TwistMaterial") || - (materialID === "TwistVertMaterial") || - (materialID === "UberMaterial") || - (materialID === "WaterMaterial") || - (materialID === "ZInvertMaterial") - ) + if (useSelection) { - var material = MaterialsModel.getMaterial( materialID ); - if (material) + var selection = this.application.ninja.selectedElements; + if (selection && (selection.length > 0)) { - this._material = material; - this.materialsData = this.getMaterialData( material ); + var canvas = selection[0]; + var obj; + if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; + if (obj) + material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial(); } } else + { + if( + (materialID === "BumpMetalMaterial") || + (materialID === "DeformMaterial") || + (materialID === "FlatMaterial") || + (materialID === "FlagMaterial") || + (materialID === "FlyMaterial") || + (materialID === "JuliaMaterial") || + (materialID === "KeleidoscopeMaterial") || + (materialID === "LinearGradientMaterial") || + (materialID === "MandelMaterial") || + (materialID === "PlasmaMaterial") || + (materialID === "PulseMaterial") || + (materialID === "RadialBlurMaterial") || + (materialID === "RadialGradientMaterial") || + (materialID === "ReliefTunnelMaterial") || + (materialID === "SquareTunnelMaterial") || + (materialID === "StarMaterial") || + (materialID === "TaperMaterial") || + (materialID === "TunnelMaterial") || + (materialID === "TwistMaterial") || + (materialID === "TwistVertMaterial") || + (materialID === "UberMaterial") || + (materialID === "WaterMaterial") || + (materialID === "ZInvertMaterial") + ) + { + material = MaterialsModel.getMaterial( materialID ); + } + } + + if (material) + { + this._material = material; + this.materialsData = this.getMaterialData( material ); + } + else { this.materialsData = this[materialID]; } -- cgit v1.2.3