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.js470
1 files changed, 213 insertions, 257 deletions
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index 40f07509..0d0435a4 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -1,12 +1,40 @@
1/* <copyright> 1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2Copyright (c) 2012, Motorola Mobility, Inc
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3All Rights Reserved.
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4BSD License.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE.
5</copyright> */ 29</copyright> */
6 30
7var Montage = require("montage/core/core").Montage, 31var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 32 Component = require("montage/ui/component").Component,
9 MaterialsModel = require("js/models/materials-model").MaterialsModel; 33 MaterialsModel = require("js/models/materials-model").MaterialsModel,
34 NJUtils = require("js/lib/NJUtils").NJUtils,
35 World = require("js/lib/drawing/world").World,
36 Rectangle = require("js/lib/geom/rectangle").Rectangle,
37 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
10 38
11//////////////////////////////////////////////////////////////////////// 39////////////////////////////////////////////////////////////////////////
12//Exporting as MaterialsPopup 40//Exporting as MaterialsPopup
@@ -22,11 +50,35 @@ exports.MaterialsPopup = Montage.create(Component, {
22 serializable: true 50 serializable: true
23 }, 51 },
24 52
53 saveAsButton: {
54 value: null,
55 serializable: true
56 },
57
58 resetButton: {
59 value: null,
60 serializable: true
61 },
62
63 materialsLibraryRef: {
64 value: null
65 },
66
25 materialTitle: { 67 materialTitle: {
26 value: null, 68 value: null,
27 serializable: true 69 serializable: true
28 }, 70 },
29 71
72 previewCanvas: {
73 value: null,
74 serializable: true
75 },
76
77 previewShape: {
78 value: null,
79 serializable: true
80 },
81
30 // Material Properties 82 // Material Properties
31 _materialName: { 83 _materialName: {
32 enumerable: true, 84 enumerable: true,
@@ -42,11 +94,11 @@ exports.MaterialsPopup = Montage.create(Component, {
42 switch(event._currentTarget.label) 94 switch(event._currentTarget.label)
43 { 95 {
44 case "Cancel": 96 case "Cancel":
45 console.log("Cancel material edit"); 97// console.log("Cancel material edit");
46 this.revertToOriginalValues(); 98 this.revertToOriginalValues();
47 break; 99 break;
48 case "OK": 100 case "OK":
49 console.log("Committing material with the following values:"); 101// console.log("Committing material with the following values:");
50 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++) 102 for(var i=0, len=this.materialsProperties.childComponents.length; i< len; i++)
51 { 103 {
52 var childControl = this.materialsProperties.childComponents[i]; 104 var childControl = this.materialsProperties.childComponents[i];
@@ -65,6 +117,12 @@ exports.MaterialsPopup = Montage.create(Component, {
65 117
66 } 118 }
67 break; 119 break;
120 case "Save As...":
121 this.saveAs();
122 break;
123 case "Reset":
124 this.reset();
125 break;
68 } 126 }
69 127
70 // Notify Materials Library to close popup 128 // Notify Materials Library to close popup
@@ -72,6 +130,28 @@ exports.MaterialsPopup = Montage.create(Component, {
72 } 130 }
73 }, 131 },
74 132
133 saveAs:
134 {
135 value: function()
136 {
137// console.log("Save As...");
138 var materialCopy = prompt("Save material as", this._materialName + "_Copy");
139
140 if (materialCopy)
141 {
142 this.materialsLibraryRef.duplicateMaterial(materialCopy);
143 }
144 }
145 },
146
147 reset:
148 {
149 value: function()
150 {
151// console.log("Reset");
152 }
153 },
154
75 revertToOriginalValues: 155 revertToOriginalValues:
76 { 156 {
77 value: function() 157 value: function()
@@ -131,15 +211,15 @@ exports.MaterialsPopup = Montage.create(Component, {
131 { 211 {
132 value: function(event) 212 value: function(event)
133 { 213 {
134 if(typeof event.propertyValue === "object") 214// if(typeof event.propertyValue === "object")
135 { 215// {
136 console.log(event.propertyLabel + " changing to "); 216// console.log(event.propertyLabel + " changing to ");
137 console.dir(event.propertyValue); 217// console.dir(event.propertyValue);
138 } 218// }
139 else 219// else
140 { 220// {
141 console.log(event.propertyLabel + " changing to " + event.propertyValue); 221// console.log(event.propertyLabel + " changing to " + event.propertyValue);
142 } 222// }
143 223
144 if (event.propertyLabel && event.propertyValue) 224 if (event.propertyLabel && event.propertyValue)
145 this.applyProperty( event.propertyLabel, event.propertyValue ); 225 this.applyProperty( event.propertyLabel, event.propertyValue );
@@ -151,15 +231,15 @@ exports.MaterialsPopup = Montage.create(Component, {
151 value: function(theEvent) 231 value: function(theEvent)
152 { 232 {
153 var event = theEvent._event; 233 var event = theEvent._event;
154 if(typeof event.propertyValue === "object") 234// if(typeof event.propertyValue === "object")
155 { 235// {
156 console.log(event.propertyLabel + " changed to "); 236// console.log(event.propertyLabel + " changed to ");
157 console.dir(event.propertyValue); 237// console.dir(event.propertyValue);
158 } 238// }
159 else 239// else
160 { 240// {
161 console.log(event.propertyLabel + " changed to " + event.propertyValue); 241// console.log(event.propertyLabel + " changed to " + event.propertyValue);
162 } 242// }
163 243
164 if (event.propertyLabel) 244 if (event.propertyLabel)
165 this.applyProperty( event.propertyLabel, event.propertyValue ); 245 this.applyProperty( event.propertyLabel, event.propertyValue );
@@ -195,9 +275,10 @@ exports.MaterialsPopup = Montage.create(Component, {
195 this._material.setProperty( this._propNames[index], value ); 275 this._material.setProperty( this._propNames[index], value );
196 }