aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-popup.reel/materials-popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-popup.reel/materials-popup.js')
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js100
1 files changed, 74 insertions, 26 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index bd10f7a5..1e92e144 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -18,6 +18,8 @@ exports.MaterialsPopup = Montage.create(Component, {
18 value: "" 18 value: ""
19 }, 19 },
20 20
21 _useSelection: { value: false, enumerable: true },
22
21 captureAction: { 23 captureAction: {
22 value:function(event) { 24 value:function(event) {
23 switch(event._currentTarget.label) 25 switch(event._currentTarget.label)
@@ -88,8 +90,9 @@ exports.MaterialsPopup = Montage.create(Component, {
88 90
89 _handlePropertyChange: 91 _handlePropertyChange:
90 { 92 {
91 value: function(event) 93 value: function(theEvent)
92 { 94 {
95 var event = theEvent._event;
93 if(typeof event.propertyValue === "object") 96 if(typeof event.propertyValue === "object")
94 { 97 {
95 console.log(event.propertyLabel + " changed to "); 98 console.log(event.propertyLabel + " changed to ");
@@ -133,6 +136,11 @@ exports.MaterialsPopup = Montage.create(Component, {
133 var value = this.decodeValue( this._propTypes[index], propValue ); 136 var value = this.decodeValue( this._propTypes[index], propValue );
134 this._material.setProperty( this._propNames[index], value ); 137 this._material.setProperty( this._propNames[index], value );
135 } 138 }
139
140 if (this._useSelection)
141 {
142 console.log( "apply to selection" );
143 }
136 } 144 }
137 } 145 }
138 }, 146 },
@@ -164,8 +172,10 @@ exports.MaterialsPopup = Montage.create(Component, {
164 var index = value.lastIndexOf( "/" ); 172 var index = value.lastIndexOf( "/" );
165 if (index < 0) index = value.lastIndexOf( "\\" ); 173 if (index < 0) index = value.lastIndexOf( "\\" );
166 if (index >= 0) 174 if (index >= 0)
175 {
167 value = value.substr( index+1 ); 176 value = value.substr( index+1 );
168 value = "assets\\images\\" + value; 177 value = "assets\\images\\" + value;
178 }
169 rtnValue = value.slice(0); 179 rtnValue = value.slice(0);
170 } 180 }
171 break; 181 break;
@@ -212,32 +222,70 @@ exports.MaterialsPopup = Montage.create(Component, {
212 loadMaterials: 222 loadMaterials:
213 { 223 {
214 enumerable: true, 224 enumerable: true,
215 value: function(materialID) 225 value: function(materialID, useSelection, whichMaterial)
216 { 226 {
217 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. 227 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work.
218 this.materialsData = []; 228 this.materialsData = [];
219 229
220 this._materialName = materialID; 230 var material;
221 if( 231 this._materialName = materialID;
222 (materialID === "UberMaterial") || 232 if (useSelection)
223 (materialID === "FlatMaterial") ||
224 (materialID === "BumpMetalMaterial") ||
225 (materialID === "LinearGradientMaterial") ||
226 (materialID === "RadialGradientMaterial")
227 )
228 { 233 {
229 var material = MaterialsModel.getMaterial( materialID ); 234 this._useSelection = true;
230 if (material) 235 var selection = this.application.ninja.selectedElements;
236 if (selection && (selection.length > 0))
231 { 237 {
232 this._material = material; 238 var canvas = selection[0];
233 this.materialsData = this.getMaterialData( material ); 239 var obj;
240 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
241 if (obj)
242 material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial();
234 } 243 }
235 } 244 }
236 else 245 else
237 { 246 {
238 this.materialsData = this[materialID]; 247 this._useSelection = false;
239 } 248
240 this.needsDraw = true; 249 if(
250 (materialID === "BumpMetalMaterial") ||
251 (materialID === "DeformMaterial") ||
252 (materialID === "FlatMaterial") ||
253 (materialID === "FlagMaterial") ||
254 (materialID === "FlyMaterial") ||
255 (materialID === "JuliaMaterial") ||
256 (materialID === "KeleidoscopeMaterial") ||
257 (materialID === "LinearGradientMaterial") ||
258 (materialID === "MandelMaterial") ||
259 (materialID === "PlasmaMaterial") ||
260 (materialID === "PulseMaterial") ||
261 (materialID === "RadialBlurMaterial") ||
262 (materialID === "RadialGradientMaterial") ||
263 (materialID === "ReliefTunnelMaterial") ||
264 (materialID === "SquareTunnelMaterial") ||
265 (materialID === "StarMaterial") ||
266 (materialID === "TaperMaterial") ||
267 (materialID === "TunnelMaterial") ||
268 (materialID === "TwistMaterial") ||
269 (materialID === "TwistVertMaterial") ||
270 (materialID === "UberMaterial") ||
271 (materialID === "WaterMaterial") ||
272 (materialID === "ZInvertMaterial")
273 )
274 {
275 material = MaterialsModel.getMaterial( materialID );
276 }
277 }
278
279 if (material)
280 {
281 this._material = material;
282 this.materialsData = this.getMaterialData( material );
283 }
284 else
285 {
286 this.materialsData = this[materialID];
287 }
288 this.needsDraw = true;
241 } 289 }
242 }, 290 },
243 291
@@ -304,7 +352,7 @@ exports.MaterialsPopup = Montage.create(Component, {
304 { 352 {
305 value: function( label, color ) 353 value: function( label, color )
306 { 354 {
307 var css = 'rgba(' + color[0]*255 + ',' + color[1]*255 + ',' + color[2]*255 + ',' + color[3] + ')'; 355 var css = 'rgba(' + Math.floor(color[0]*255) + ',' + Math.floor(color[1]*255) + ',' + Math.floor(color[2]*255) + ',' + color[3] + ')';
308 var colorObj = this.application.ninja.colorController.getColorObjFromCss(css) 356 var colorObj = this.application.ninja.colorController.getColorObjFromCss(css)
309 var obj = 357 var obj =
310 { 358 {
@@ -333,7 +381,7 @@ exports.MaterialsPopup = Montage.create(Component, {
333 "defaults": 381 "defaults":
334 { 382 {
335 "minValue": 0, 383 "minValue": 0,
336 "maxValue": 128, 384 "maxValue": 400,
337 "decimalPlace": 100, 385 "decimalPlace": 100,
338 "value": value 386 "value": value
339 } 387 }