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.js108
1 files changed, 82 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 a4f758cf..3ef2e4ef 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 },
@@ -158,14 +166,20 @@ exports.MaterialsPopup = Montage.create(Component, {
158 rtnValue = value; 166 rtnValue = value;
159 break; 167 break;
160 168
169 case "angle":
170 rtnValue = value*3.14159/180.0;
171 break;
172
161 case "file": 173 case "file":
162 if (value && (value.length > 0)) 174 if (value && (value.length > 0))
163 { 175 {
164 var index = value.lastIndexOf( "/" ); 176 var index = value.lastIndexOf( "/" );
165 if (index < 0) index = value.lastIndexOf( "\\" ); 177 if (index < 0) index = value.lastIndexOf( "\\" );
166 if (index >= 0) 178 if (index >= 0)
179 {
167 value = value.substr( index+1 ); 180 value = value.substr( index+1 );
168 value = "assets\\images\\" + value; 181 value = "assets/images/" + value;
182 }
169 rtnValue = value.slice(0); 183 rtnValue = value.slice(0);
170 } 184 }
171 break; 185 break;
@@ -212,32 +226,70 @@ exports.MaterialsPopup = Montage.create(Component, {
212 loadMaterials: 226 loadMaterials:
213 { 227 {
214 enumerable: true, 228 enumerable: true,
215 value: function(materialID) 229 value: function(materialID, useSelection, whichMaterial)
216 { 230 {
217 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. 231 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work.
218 this.materialsData = []; 232 this.materialsData = [];
219 233
220 this._materialName = materialID; 234 var material;
221 if( 235 this._materialName = materialID;
222 (materialID === "UberMaterial") || 236 if (useSelection)
223 (materialID === "FlatMaterial") ||
224 (materialID === "BumpMetalMaterial") ||
225 (materialID === "LinearGradientMaterial") ||
226 (materialID === "RadialGradientMaterial")
227 )
228 { 237 {
229 var material = MaterialsModel.getMaterial( materialID ); 238 this._useSelection = true;
230 if (material) 239 var selection = this.application.ninja.selectedElements;
240 if (selection && (selection.length > 0))
231 { 241 {
232 this._material = material; 242 var canvas = selection[0];
233 this.materialsData = this.getMaterialData( material ); 243 var obj;
244 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj;
245 if (obj)
246 material = (whichMaterial === 'stroke') ? obj.getStrokeMaterial() : obj.getFillMaterial();
234 } 247 }
235 } 248 }
236 else 249 else
237 { 250 {
238 this.materialsData = this[materialID]; 251 this._useSelection = false;
239 } 252
240 this.needsDraw = true; 253 if(
254 (materialID === "BumpMetalMaterial") ||
255 (materialID === "DeformMaterial") ||
256 (materialID === "FlatMaterial") ||
257 (materialID === "FlagMaterial") ||
258 (materialID === "FlyMaterial") ||
259 (materialID === "JuliaMaterial") ||
260 (materialID === "KeleidoscopeMaterial") ||
261 (materialID === "LinearGradientMaterial") ||
262 (materialID === "MandelMaterial") ||
263 (materialID === "PlasmaMaterial") ||
264 (materialID === "PulseMaterial") ||
265 (materialID === "RadialBlurMaterial") ||
266 (materialID === "RadialGradientMaterial") ||
267 (materialID === "ReliefTunnelMaterial") ||
268 (materialID === "SquareTunnelMaterial") ||
269 (materialID === "StarMaterial") ||
270 (materialID === "TaperMaterial") ||
271 (materialID === "TunnelMaterial") ||
272 (materialID === "TwistMaterial") ||
273 (materialID === "TwistVertMaterial") ||
274 (materialID === "UberMaterial") ||
275 (materialID === "WaterMaterial") ||
276 (materialID === "ZInvertMaterial")
277 )
278 {
279 material = MaterialsModel.getMaterial( materialID );
280 }
281 }
282
283 if (material)
284 {
285 this._material = material;
286 this.materialsData = this.getMaterialData( material );
287 }
288 else
289 {
290 this.materialsData = this[materialID];
291 }
292 this.needsDraw = true;
241 } 293 }
242 }, 294 },
243 295
@@ -276,6 +328,10 @@ exports.MaterialsPopup = Montage.create(Component, {
276 obj = this.createFloatData( propLabels[i], propValues[i] ); 328 obj = this.createFloatData( propLabels[i], propValues[i] );
277 break; 329 break;
278 330
331 case "angle":
332 obj = this.createFloatData( propLabels[i], propValues[i]*180.0/3.14159 );
333 break;
334
279 case "file": 335 case "file":
280 obj = this.createFileData( propLabels[i], propValues[i] ); 336 obj = this.createFileData( propLabels[i], propValues[i] );
281 break; 337 break;
@@ -304,7 +360,7 @@ exports.MaterialsPopup = Montage.create(Component, {
304 { 360 {
305 value: function( label, color ) 361 value: function( label, color )
306 { 362 {
307 var css = 'rgba(' + color[0]*255 + ',' + color[1]*255 + ',' + color[2]*255 + ',' + color[3] + ')'; 363 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) 364 var colorObj = this.application.ninja.colorController.getColorObjFromCss(css)
309 var obj = 365 var obj =
310 { 366 {
@@ -333,7 +389,7 @@ exports.MaterialsPopup = Montage.create(Component, {
333 "defaults": 389 "defaults":
334 { 390 {
335 "minValue": 0, 391 "minValue": 0,
336 "maxValue": 128, 392 "maxValue":