aboutsummaryrefslogtreecommitdiff
path: root/js/panels
diff options
context:
space:
mode:
authorhwc4872012-05-02 17:00:12 -0700
committerhwc4872012-05-02 17:00:12 -0700
commit8eac5582b72115969a9f915f4303535c22018033 (patch)
treeb9ad1621fee37eb73824dab7de062ac4ec2abf77 /js/panels
parentf6983a69649b1c274ce6fe2d278a325994d092b6 (diff)
downloadninja-8eac5582b72115969a9f915f4303535c22018033.tar.gz
Material editor
Diffstat (limited to 'js/panels')
-rwxr-xr-xjs/panels/Materials/materials-library-panel.reel/materials-library-panel.js13
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js80
2 files changed, 57 insertions, 36 deletions
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, {
51 51
52 handleNodeActivation: { 52 handleNodeActivation: {
53 value:function(obj) { 53 value:function(obj) {
54 this._showMaterialPopup(obj.id); 54 this._showMaterialPopup({ materialId: obj.id });
55 } 55 }
56 }, 56 },
57 57
58 handleShowMaterialPopup: { 58 handleShowMaterialPopup: {
59 enumerable: false, 59 enumerable: false,
60 value: function (event) { 60 value: function (event) {
61 this._showMaterialPopup(event.detail.materialId); 61 //this._showMaterialPopup(event.detail.materialId);
62 this._showMaterialPopup(event.detail);
62 } 63 }
63 }, 64 },
64 65
@@ -73,9 +74,9 @@ exports.MaterialsLibraryPanel = Montage.create(Component, {
73 74
74 _showMaterialPopup: { 75 _showMaterialPopup: {
75 enumerable: false, 76 enumerable: false,
76 value: function (materialID) { 77 value: function (materialObj) {
77 78
78 if(!this._materialPopup) 79 if(!this._materialPopup)
79 { 80 {
80 this._materialPopup = Popup.create(); 81 this._materialPopup = Popup.create();
81 this._materialPopup.content = this._materialInfo; 82 this._materialPopup.content = this._materialInfo;
@@ -84,7 +85,9 @@ exports.MaterialsLibraryPanel = Montage.create(Component, {
84 this._materialPopup.addEventListener("show", this, false); 85 this._materialPopup.addEventListener("show", this, false);
85 } 86 }
86 this._materialPopup.show(); 87 this._materialPopup.show();
87 this._materialInfo.loadMaterials(materialID); 88
89 materialID = materialObj.materialId;
90 this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial);
88 } 91 }
89 }, 92 },
90 93
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, {
88 88
89 _handlePropertyChange: 89 _handlePropertyChange:
90 { 90 {
91 value: function(event) 91 value: function(theEvent)
92 { 92 {
93 var event = theEvent._event;
93 if(typeof event.propertyValue === "object") 94 if(typeof event.propertyValue === "object")
94 { 95 {
95 console.log(event.propertyLabel + " changed to "); 96 console.log(event.propertyLabel + " changed to ");
@@ -214,47 +215,64 @@ exports.MaterialsPopup = Montage.create(Component, {
214 loadMaterials: 215 loadMaterials:
215 { 216 {
216 enumerable: true, 217 enumerable: true,
217 value: function(materialID) 218 value: function(materialID, useSelection, whichMaterial)
218 { 219 {
219 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. 220 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work.
220 this.materialsData = []; 221 this.materialsData = [];
221 222
223 var material;
222 this._materialName = materialID; 224 this._materialName = materialID;
223 if( 225 if (useSelection)
224 (materialID === "BumpMetalMaterial") ||
225 (materialID === "DeformMaterial") ||
226 (materialID === "FlatMaterial") ||
227 (materialID === "FlagMaterial") ||
228 (materialID === "FlyMaterial") ||
229 (materialID === "JuliaMaterial") ||
230 (materialID === "KeleidoscopeMaterial") ||
231 (materialID === "LinearGradientMaterial") ||
232 (materialID === "MandelMaterial") ||
233 (materialID === "PlasmaMaterial") ||
234 (materialID === "PulseMaterial") ||
235 (materialID === "RadialBlurMaterial") ||
236 (materialID === "RadialGradientMaterial") ||
237 (materialID === "ReliefTunnelMaterial") ||
238 (materialID === "SquareTunnelMaterial") ||
239 (materialID === "StarMaterial") ||
240 (materialID === "TaperMaterial") ||
241 (materialID === "TunnelMaterial") ||
242 (materialID === "TwistMaterial") ||
243 (materialID === "TwistVertMaterial") ||
244 (materialID === "UberMaterial") ||
245 (materialID === "WaterMaterial") ||
246 (materialID === "ZInvertMaterial")
247 )
248 { 226 {
249 var material = MaterialsModel.getMaterial( materialID ); 227 var selection = this.application.ninja.selectedElements;
250 if (material) 228 if (selection && (selection.length > 0))
251 { 229 {
252 this._material = material; 230 var canvas = selection[0];
253 this.materialsData = this.getMaterialData( material ); 231 var obj;
232 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
233 if (obj)
234 material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial();
254 } 235 }
255 } 236 }
256 else 237 else
257 { 238 {
239 if(
240 (materialID === "BumpMetalMaterial") ||
241 (materialID === "DeformMaterial") ||
242 (materialID === "FlatMaterial") ||
243 (materialID === "FlagMaterial") ||
244 (materialID === "FlyMaterial") ||
245 (materialID === "JuliaMaterial") ||
246 (materialID === "KeleidoscopeMaterial") ||
247 (materialID === "LinearGradientMaterial") ||
248 (materialID === "MandelMaterial") ||
249 (materialID === "PlasmaMaterial") ||
250 (materialID === "PulseMaterial") ||
251 (materialID === "RadialBlurMaterial") ||
252 (materialID === "RadialGradientMaterial") ||
253 (materialID === "ReliefTunnelMaterial") ||
254 (materialID === "SquareTunnelMaterial") ||
255 (materialID === "StarMaterial") ||
256 (materialID === "TaperMaterial") ||
257 (materialID === "TunnelMaterial") ||
258 (materialID === "TwistMaterial") ||
259 (materialID === "TwistVertMaterial") ||
260 (materialID === "UberMaterial") ||
261 (materialID === "WaterMaterial") ||
262 (materialID === "ZInvertMaterial")
263 )
264 {
265 material = MaterialsModel.getMaterial( materialID );
266 }
267 }
268
269 if (material)
270 {
271 this._material = material;
272 this.materialsData = this.getMaterialData( material );
273 }
274 else
275 {
258 this.materialsData = this[materialID]; 276 this.materialsData = this[materialID];
259 } 277 }
260 this.needsDraw = true; 278 this.needsDraw = true;