aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-popup.reel/materials-popup.js
diff options
context:
space:
mode:
authorKruti Shah2012-07-17 12:40:00 -0700
committerKruti Shah2012-07-17 12:40:00 -0700
commitbf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /js/panels/Materials/materials-popup.reel/materials-popup.js
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js/panels/Materials/materials-popup.reel/materials-popup.js')
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js1171
1 files changed, 552 insertions, 619 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index 7c5493c6..a5e09c52 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -30,7 +31,11 @@ POSSIBILITY OF SUCH DAMAGE.
30 31
31var Montage = require("montage/core/core").Montage, 32var Montage = require("montage/core/core").Montage,
32 Component = require("montage/ui/component").Component, 33 Component = require("montage/ui/component").Component,
33 MaterialsModel = require("js/models/materials-model").MaterialsModel; 34 MaterialsModel = require("js/models/materials-model").MaterialsModel,
35 NJUtils = require("js/lib/NJUtils").NJUtils,
36 World = require("js/lib/drawing/world").World,
37 Rectangle = require("js/lib/geom/rectangle").Rectangle,
38 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
34 39
35//////////////////////////////////////////////////////////////////////// 40////////////////////////////////////////////////////////////////////////
36//Exporting as MaterialsPopup 41//Exporting as MaterialsPopup
@@ -46,31 +51,55 @@ exports.MaterialsPopup = Montage.create(Component, {
46 serializable: true 51 serializable: true
47 }, 52 },
48 53
54 saveAsButton: {
55 value: null,
56 serializable: true
57 },
58
59 resetButton: {
60 value: null,
61 serializable: true
62 },
63
64 materialsLibraryRef: {
65 value: null
66 },
67
49 materialTitle: { 68 materialTitle: {
50 value: null, 69 value: null,
51 serializable: true 70 serializable: true
52 }, 71 },
53 72
54 // Material Properties 73 previewCanvas: {
74 value: null,
75 serializable: true
76 },
77
78 previewShape: {
79 value: null,
80 serializable: true
81 },
82
83 // Material Properties
55 _materialName: { 84 _materialName: {
56 enumerable: true, 85 enumerable: true,
57 value: "" 86 value: ""
58 }, 87 },
59 88
60 _useSelection: { value: false, enumerable: true }, 89 _useSelection: { value: false, enumerable: true },
61 _whichMaterial: { value: "fill", enumerable: true }, 90 _whichMaterial: { value: "fill", enumerable: true },
62 _originalValues: {value: null, enumerable: true }, 91 _originalValues: {value: null, enumerable: true },
63 92
64 captureAction: { 93 captureAction: {
65 value:function(event) { 94 value:function(event) {
66 switch(event._currentTarget.label) 95 switch(event._currentTarget.label)
67 { 96 {
68 case "Cancel": 97 case "Cancel":
69 console.log("Cancel material edit"); 98// console.log("Cancel material edit");
70 this.revertToOriginalValues(); 99 this.revertToOriginalValues();
71 break; 100 break;
72 case "OK": 101 case "OK":
73 console.log("Committing material with the following values:"); 102// console.log("Committing material with the following values:");
74 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) 103 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++)
75 { 104 {
76 var childControl = this.materialsProperties.childComponents[i]; 105 var childControl = this.materialsProperties.childComponents[i];
@@ -88,53 +117,81 @@ exports.MaterialsPopup = Montage.create(Component, {
88 console.log("--------------"); 117 console.log("--------------");
89 118
90 } 119 }
91 break; 120 break;
92 } 121 case "Save As...":
122 this.saveAs();
123 break;
124 case "Reset":
125 this.reset();
126 break;
127 }
93 128
94 // Notify Materials Library to close popup 129 // Notify Materials Library to close popup
95 NJevent("hideMaterialPopup"); 130 NJevent("hideMaterialPopup");
96 } 131 }
97 }, 132 },
98 133
99 revertToOriginalValues: 134 saveAs:
100 { 135 {
101 value: function() 136 value: function()
102 { 137 {
103 if (this._originalValues) 138// console.log("Save As...");
104 { 139 var materialCopy = prompt("Save material as", this._materialName + "_Copy");
105 this._material.importJSON( this._originalValues ); 140
106 141 if (materialCopy)
107 if (this._useSelection) 142 {
108 { 143 this.materialsLibraryRef.duplicateMaterial(materialCopy);
109 var selection = this.application.ninja.selectedElements; 144 }
110 if (selection && (selection.length > 0)) 145 }
111 { 146 },
112 var nObjs = selection.length; 147
113 for (var iObj=0; iObj<nObjs; iObj++) 148 reset:
114 { 149 {
115 var canvas = selection[iObj]; 150 value: function()
116 var obj; 151 {
117 if (canvas.elementModel && canvas.elementModel.shapeModel) obj = canvas.elementModel.shapeModel.GLGeomObj; 152// console.log("Reset");
118 if (obj) 153 }
119 { 154 },
120 var matArray = obj._materialArray; 155
121 var matTypeArray = obj._materialTypeArray; 156 revertToOriginalValues:
122 var nMats = matArray.length; 157 {
123 for (var iMat=0; iMat<nMats; iMat++) 158 value: function()
124 { 159 {
125 if (matTypeArray[iMat] === this._whichMaterial) 160 if (this._originalValues)
126 matArray[iMat].importJSON( this._originalValues );