From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- .../materials-popup.reel/materials-popup.css | 162 +++++ .../materials-popup.reel/materials-popup.html | 122 ++++ .../materials-popup.reel/materials-popup.js | 674 +++++++++++++++++++++ 3 files changed, 958 insertions(+) create mode 100644 js/panels/Materials/materials-popup.reel/materials-popup.css create mode 100644 js/panels/Materials/materials-popup.reel/materials-popup.html create mode 100644 js/panels/Materials/materials-popup.reel/materials-popup.js (limited to 'js/panels/Materials/materials-popup.reel') diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.css b/js/panels/Materials/materials-popup.reel/materials-popup.css new file mode 100644 index 00000000..299dc5f9 --- /dev/null +++ b/js/panels/Materials/materials-popup.reel/materials-popup.css @@ -0,0 +1,162 @@ +@charset "UTF-8"; +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +.materials_popup { + font-size: 12px; + text-shadow: 1px 1px 1px #000; + overflow: hidden; +} + +.materials_popup a:hover { + color: #CCC; +} + +.materials_popup hr { + float: left; + clear: both; + width: 100%; + display: block; + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.5, #1d1d1d), color-stop(0.75, #424242)); + border: none; + height: 2px; + margin: 4px 0px 4px 0px; +} + +#mp_title { + margin: 4px 0px 0px 0px; + text-align: center; +} + +#mp_preview { + height: 100px; + text-align: center; +} + +#mp_maps div div, +#mp_maps div div:focus, +#mp_maps div input, +#mp_maps div input:focus { + margin: 0px 0px 2px 0px; +} + +#mp_properties_labels, +#mp_maps_labels { + display:block; + float: left; + width:86px; + margin: 0px 8px 2px 5px; + font-family: 'Droid Sans', sans-serif; + font-size: 12px; +} + +#mp_properties_labels div, +#mp_maps_labels div { + float: right; + clear: left; + width: auto; + margin: 0px 0px 3px 0px; +} + +#mp_maps_labels div { + margin: 2px 0px 3px 0px !important; +} + +#mp_properties_labels div { + margin: 6px 0px 6px 0px !important; +} + +#mp_properties_colors +{ + float:left; + width: 24px; + margin: 0px -8px 0px 10px; +} + +#mp_properties_colors button { + width: 22px; + height: 22px; + margin: 2px 0; +} + +#mp_properties_colors input.hottext { + background: none; + float: right; + margin: 4px 0px; + padding: 0px; + width: 23px; + color: #FFF; + text-shadow: 1px 1px 1px #000; + font-family: 'Droid Sans', sans-serif; + font-size: 11px; + text-align: center; +} + +#mp_properties_colors input.hottextInput { + background: #FFF; + color: #000; + text-shadow: none; + border: 1px solid #333; + margin: 3px -2px 5px 1px; + padding: 1px; + text-decoration: none; + outline: none; +} + +#mp_maps_inputs +{ + float: left; + width: auto; +} + +#mp_maps_inputs input { + float:left; + clear:both; + width: 100px; + background: #555; + border: 1px solid #333; + color: #FFF; + padding: 1px 0px 1px 0px; + margin: 0px 0px 0px 10px; + text-decoration: none !important; + text-shadow: 1px 1px 1px #000; + font-family: 'Droid Sans', sans-serif; + font-size: 11px; + letter-spacing: 1px; +} + +#mp_maps_inputs input:focus { + outline: none; + margin: -1px 0px -1px 10px; + background: #FFF; + color: #000; + text-shadow: none; +} + + +#mp_buttons { + clear:both; + float: left; + margin: 0px -4px 0px 4px; + width: 97%; +} + +#mp_buttons button { + height: 22px; + overflow: hidden; + display: block; + cursor: pointer; +} + +#mp_cancel_btn { + float: left; + width: 60px; +} + +#mp_ok_btn { + float: right; + width: 30px; +} \ No newline at end of file diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.html b/js/panels/Materials/materials-popup.reel/materials-popup.html new file mode 100644 index 00000000..bac69f25 --- /dev/null +++ b/js/panels/Materials/materials-popup.reel/materials-popup.html @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + +
+
Material Name
+ +
+ +
Preview Pane
+ +
+ +
+
+
+ +
+ +
+ + +
+ +
+ + + + \ No newline at end of file diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js new file mode 100644 index 00000000..afdc3628 --- /dev/null +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -0,0 +1,674 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; +var Button = require("js/components/button.reel").Button; + +//////////////////////////////////////////////////////////////////////// +//Exporting as MaterialsPopup +exports.MaterialsPopup = Montage.create(Component, { + //////////////////////////////////////////////////////////////////// + okButton: { + enumerable: false, + value: null + }, + + cancelButton: { + enumerable: false, + value: null + }, + + //////////////////////////////////////////////////////////////////// + // Material Properties + + materialsProperties: { + enumerable: true, + serializable: true, + value: null + }, + + _materialName: { + enumerable: true, + value: "Material" + }, + + materialTitle: { + enumerable: true, + value: null + }, + + captureAction: { + value:function(event) { + switch(event._currentTarget.label) + { + case "Cancel": + console.log("Cancel material edit"); + break; + case "OK": + console.log("Committing material with the following values:"); + for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) + { + var childControl = this.materialsProperties.childComponents[i]; + var childValue = childControl._control[childControl._prop]; + + if(typeof childValue === "object") + { + console.log(childControl.label + " is "); + console.dir(childValue); + } + else + { + console.log(childControl.label + " is " + childValue); + } + console.log("--------------"); + + } + break; + } + } + }, + + updatePreview: + { + value: function(event) + { + if(event.type === "propertyChanging") + { + this._handlePropertyChanging(event); + } + else + { + this._handlePropertyChange(event); + } + } + }, + + _handlePropertyChanging: + { + value: function(event) + { + if(typeof event.propertyValue === "object") + { + console.log(event.propertyLabel + " changing to "); + console.dir(event.propertyValue); + } + else + { + console.log(event.propertyLabel + " changing to " + event.propertyValue); + } + + if (event.propertyLabel && event.propertyValue) + this.applyProperty( event.propertyLabel, event.propertyValue ); + } + }, + + _handlePropertyChange: + { + value: function(event) + { + if(typeof event.propertyValue === "object") + { + console.log(event.propertyLabel + " changed to "); + console.dir(event.propertyValue); + } + else + { + console.log(event.propertyLabel + " changed to " + event.propertyValue); + } + + if (event.propertyLabel) + this.applyProperty( event.propertyLabel, event.propertyValue ); + } + }, + + applyProperty: + { + value: function( propLabel, propValue) + { + // find the property lable in the array + // This assumes no duplication in labels + if (this._propLabels) + { + // the label cones through with a trailing ':'. remove that + var ch = propLabel[ propLabel.length - 1]; + if (ch == ':') + propLabel = propLabel.substr(0, propLabel.length - 1); + + var index; + var nProps = this._propLabels.length; + for (var i=0; i 0)) + { + var index = value.lastIndexOf( "/" ); + if (index < 0) index = value.lastIndexOf( "\\" ); + if (index >= 0) + value = value.substr( index+1 ); + value = "assets\\images\\" + value; + rtnValue = value.slice(0); + } + break; + + case "checkbox": + rtnValue = value; + break; + + default: + console.log( "unrecognized material control type: " + type ); + break; + } + return rtnValue; + } + }, + + //////////////////////////////////////////////////////////////////// + // + prepareForDraw: { + enumerable: false, + value: function() { + this.cancelButton.addEventListener("action", this, true); + + this.okButton.addEventListener("action", this, true); + } + }, + //////////////////////////////////////////////////////////////////// + // + didDraw: { + enumerable: false, + value: function() { + this.materialTitle.innerHTML = this._materialName; + } + }, + + //Garbage collection (Manual method) + destroy: { + enumerable: false, + value: function() { + // add cleanup routines here + } + }, + + loadMaterials: + { + enumerable: true, + value: function(materialID) + { + this._materialName = materialID; + if( + (materialID === "BrickMaterial") || + (materialID === "UberMaterial") || + (materialID === "FlatMaterial") || + (materialID === "BumpMetalMaterial") || + (materialID === "PlasmaMaterial") || + (materialID === "LinearGradientMaterial") || + (materialID === "RadialGradientMaterial") || + (materialID === "RadialBlurMaterial") || + (materialID === "PulseMaterial") || + (materialID === "TunnelMaterial") || + (materialID === "TwistMaterial") || + (materialID === "KeleidoscopeMaterial") || + (materialID === "JuliaMaterial") || + (materialID === "MandelMaterial") || + (materialID === "IridescentScalesMaterial") + ) + { + var material = MaterialsLibrary.getMaterial( materialID ); + if (material) + { + this._material = material; + var matData = this.getMaterialData( material ); + this.materialsData = matData; + } + } + else + { + this.materialsData = this._dummyData1; + } + + this.needsDraw = true; + } + }, + + getMaterialData: + { + value: function( material ) + { + // declare the array to hold the results + var rtnArray = []; + + var propNames = [], propValues = [], propTypes = [], propLabels = []; + this._propNames = propNames; + this._propValues = propValues; + this._propTypes = propTypes; + this._propLabels = propLabels; + material.getAllProperties( propNames, propValues, propTypes, propLabels); + var n = propNames.length; + for (var i=0; i 2) + { + obj["defaults"]["data"][2] = + { + "label": "Z", + "description": "Z value", + "controlType": "HotText", + "defaults": + { + "minValue": -1.e8, + "maxValue": 1.e8, + "value": value[2] + } + } + } + + return obj; + } + }, + + _dummyData1: { + value: [ + { + "label": "Texture1", + "description": "Texture1 value", + "controlType": "FileInput", + "defaults": + { + "filePath": "http://localhost/" + } + }, + { + "label": "Diffuse", + "description": "Diffuse value", + "controlType": "ColorChip", + "defaults": + { + } + }, + { + "label": "Specular", + "description": "Specular value", + "controlType": "Button", + "defaults": + { + "isToggleButton": true + } + }, + { + "label": "Shininess", + "description": "Shininess value", + "controlType": "HotText", + "defaults": + { + "minValue": 0, + "maxValue": 128, + "decimalPlace": 100 + } + }, + { + "label": "RGB", + "description": "RGB value", + "controlType": "InputGroup", + "defaults": + { + data:[ + { + "label": "R", + "description": "R value", + "controlType": "HotText", + "defaults": + { + "minValue": 0, + "maxValue": 255, + "value": 255 + } + }, + { + "label": "G", + "description": "G value", + "controlType": "HotText", + "defaults": + { + "minValue": 0, + "maxValue": 255 + } + }, + { + "label": "B", + "description": "B value", + "controlType": "HotText", + "defaults": + { + "minValue": 0, + "maxValue": 255 + } + } + ] + } + }, + { + "label": "XYZ", + "description": "XYZ value", + "controlType": "InputGroup", + "defaults": + { + data:[ + { + "label": "X", + "description": "X value", + "controlType": "TextField", + "defaults": + { + "text": "0" + } + }, + { + "label": "Y", + "description": "Y value", + "controlType": "TextField", + "defaults": + { + "text": "0" + } + }, + { + "label": "Z", + "description": "Z value", + "controlType": "TextField", + "defaults": + { + "text": "1" + } + } + ] + } + }, + { + "label": "Foo", + "description": "Foo value", + "controlType": "Slider", + "defaults": + { + "minValue": 0, + "maxValue": 100, + "value": 50, + "allowTrackClick": true + } + }, + { + "label": "Bar", + "description": "Bar value", + "controlType": "HotTextUnit", + "defaults": + { + "acceptableUnits": ["%"], + "value": 50, + "units": "%" + } + } + ] + }, + + _dummyData2: { + value: [ + { + "label": "Diffuse", + "description": "Diffuse value", + "controlType": "ColorChip", + "defaults": + { + } + }, + { + "label": "Ambient", + "description": "Ambient value", + "controlType": "ColorChip", + "defaults": + { + } + }, + { + "label": "Specular", + "description": "Specular value", + "controlType": "ColorChip", + "defaults": + { + } + }, + { + "label": "Shininess", + "description": "Shininess value", + "controlType": "HotText", + "defaults": + { + "minValue": 0, + "maxValue": 128 + } + } + ] + }, + + _materialsData: { + enumerable: true, + serializable: true, + value: this._dummyData1 + + }, + + materialsData: { + enumerable: true, + serializable: true, + get: function() { + return this._materialsData; + }, + set: function(data) { + this._materialsData = data; + this.materialsProperties.needsDraw = true; + } + } + + +}); -- cgit v1.2.3