aboutsummaryrefslogtreecommitdiff
path: root/js/panels
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels')
-rw-r--r--js/panels/Materials/Materials.xml20
-rw-r--r--js/panels/Materials/materials-popup.reel/materials-popup.js21
-rw-r--r--js/panels/properties/sections/position-and-size.reel/position-and-size.js89
-rw-r--r--js/panels/properties/sections/three-d-view.reel/three-d-view.js3
4 files changed, 82 insertions, 51 deletions
diff --git a/js/panels/Materials/Materials.xml b/js/panels/Materials/Materials.xml
index 7d10fcfa..e955623a 100644
--- a/js/panels/Materials/Materials.xml
+++ b/js/panels/Materials/Materials.xml
@@ -2,24 +2,10 @@
2<tree id="Materials"> 2<tree id="Materials">
3 <folder id="ninjaMaterials" label="Ninja Materials"> 3 <folder id="ninjaMaterials" label="Ninja Materials">
4 <leaf id="UberMaterial" label="Uber" /> 4 <leaf id="UberMaterial" label="Uber" />
5 <leaf id="RadialBlurMaterial" label="Radial Blur" />
6 <leaf id="PulseMaterial" label="Pulse" />
7 <leaf id="TunnelMaterial" label="Tunnel" />
8 <leaf id="ReliefTunnelMaterial" label="Relief Tunnel" />
9 <leaf id="SquareTunnelMaterial" label="Square Tunnel" />
10 <leaf id="FlyMaterial" label="Fly" />
11 <leaf id="WaterMaterial" label="Water" />
12 <leaf id="ZInvertMaterial" label="ZInvert" />
13 <leaf id="DeformMaterial" label="Deform" />
14 <leaf id="StarMaterial" label="Star" />
15 <leaf id="TwistMaterial" label="Twist" />
16 <leaf id="KeleidoscopeMaterial" label="Keleidoscope" />
17 <leaf id="JuliaMaterial" label="Julia" />
18 <leaf id="MandelMaterial" label="Mandel" />
19 <leaf id="PlasmaMaterial" label="Plasma" />
20 <leaf id="BumpMetalMaterial" label="Bump Metal" /> 5 <leaf id="BumpMetalMaterial" label="Bump Metal" />
21 <leaf id="LinearGradientMaterial" label="Linear Gradient" /> 6 <leaf id="LinearGradientMaterial" label="Linear Gradient" />
22 <leaf id="RadialGradientMaterial" label="Radial Gradient" /> 7 <leaf id="RadialGradientMaterial" label="Radial Gradient" />
8 <leaf id="FlatMaterial" label="Flat" />
23 </folder> 9 </folder>
24 <folder id="customMaterials" label="Custom Materials"> 10 <folder id="customMaterials" label="Custom Materials">
25 <leaf id="CheckerBoard" label="CheckerBoard" /> 11 <leaf id="CheckerBoard" label="CheckerBoard" />
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index bce2e42b..62ca5395 100644
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -236,28 +236,11 @@ exports.MaterialsPopup = Montage.create(Component, {
236 { 236 {
237 this._materialName = materialID; 237 this._materialName = materialID;
238 if( 238 if(
239 (materialID === "BrickMaterial") || 239 (materialID === "UberMaterial") ||
240 (materialID === "UberMaterial") ||
241 (materialID === "FlatMaterial") || 240 (materialID === "FlatMaterial") ||
242 (materialID === "BumpMetalMaterial") || 241 (materialID === "BumpMetalMaterial") ||
243 (materialID === "PlasmaMaterial") ||
244 (materialID === "LinearGradientMaterial") || 242 (materialID === "LinearGradientMaterial") ||
245 (materialID === "RadialGradientMaterial") || 243 (materialID === "RadialGradientMaterial")
246 (materialID === "RadialBlurMaterial") ||
247 (materialID === "PulseMaterial") ||
248 (materialID === "TunnelMaterial") ||
249 (materialID === "ReliefTunnelMaterial") ||
250 (materialID === "SquareTunnelMaterial") ||
251 (materialID === "FlyMaterial") ||
252 (materialID === "WaterMaterial") ||
253 (materialID === "ZInvertMaterial") ||
254 (materialID === "DeformMaterial") ||
255 (materialID === "StarMaterial") ||
256 (materialID === "TwistMaterial") ||
257 (materialID === "KeleidoscopeMaterial") ||
258 (materialID === "JuliaMaterial") ||
259 (materialID === "MandelMaterial") ||
260 (materialID === "IridescentScalesMaterial")
261 ) 244 )
262 { 245 {
263 var material = MaterialsLibrary.getMaterial( materialID ); 246 var material = MaterialsLibrary.getMaterial( materialID );
diff --git a/js/panels/properties/sections/position-and-size.reel/position-and-size.js b/js/panels/properties/sections/position-and-size.reel/position-and-size.js
index 43f08fcf..49117090 100644
--- a/js/panels/properties/sections/position-and-size.reel/position-and-size.js
+++ b/js/panels/properties/sections/position-and-size.reel/position-and-size.js
@@ -28,6 +28,14 @@ exports.PosSize = Montage.create(Component, {
28 value: null 28 value: null
29 }, 29 },
30 30
31 aspectRatioWidth: {
32 value: null
33 },
34
35 aspectRatioHeight: {
36 value: null
37 },
38
31 _disablePosition: { 39 _disablePosition: {
32 value: true 40 value: true
33 }, 41 },
@@ -62,9 +70,8 @@ exports.PosSize = Montage.create(Component, {
62 this.widthControl.addEventListener("change", this, false); 70 this.widthControl.addEventListener("change", this, false);
63 this.widthControl.addEventListener("changing", this, false); 71 this.widthControl.addEventListener("changing", this, false);
64 72
65 73 this.bindButton.identifier = "ratio";
66 //this._controlList[0].control.addEventListener("action", this._handleStageEvent.bind(this), false); 74 this.bindButton.addEventListener("action", this, false);
67 //PropertiesPanelModule.PropertiesPanelBase.PIControlList["stageWidthHeightLock"] = this._controlList[0].control;
68 75
69 } 76 }
70 }, 77 },
@@ -87,6 +94,25 @@ exports.PosSize = Montage.create(Component, {
87 } 94 }
88 }, 95 },
89 96
97 /**
98 * Calculate the current aspect ration when the bind button is pressed.
99 * If one of the values is 0, then use 1:1 as the ratio;
100 */
101 handleRatioAction: {
102 value: function() {
103 if(this.bindButton.value) {
104 this.aspectRatioWidth = this.heightControl.value / this.widthControl.value;
105 if(isNaN(this.aspectRatioWidth) || !isFinite(this.aspectRatioWidth) || this.aspectRatioWidth === 0) this.aspectRatioWidth = 1;
106
107 this.aspectRatioHeight = this.widthControl.value / this.heightControl.value;
108 if(isNaN(this.aspectRatioHeight) || !isFinite(this.aspectRatioHeight) || this.aspectRatioHeight === 0) this.aspectRatioHeight = 1;
109 } else {
110 this.aspectRatioWidth = 1;
111 this.aspectRatioHeight = 1;
112 }
113 }
114 },
115
90 handleLeftChange: { 116 handleLeftChange: {
91 value: function(event) { 117 value: function(event) {
92 var prevPosition; 118 var prevPosition;
@@ -121,6 +147,17 @@ exports.PosSize = Montage.create(Component, {
121 if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; 147 if(this.savedPosition) prevPosition = [this.savedPosition + "px"];
122 148
123 this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.documentRoot]; 149 this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.documentRoot];
150
151 if(this.bindButton.value) {
152
153 var newWidth = Math.round(this.aspectRatioHeight * this.heightControl.value);
154
155 if(!isFinite(newWidth)) newWidth = this.heightControl.value;
156
157 this.widthControl.value = newWidth;
158 this.application.ninja.elementMediator.setProperty(items, "width", [newWidth + "px"] , "Change", "pi");
159 }
160
124 this.application.ninja.elementMediator.setProperty(items, "height", [this.heightControl.value + "px"] , "Change", "pi", prevPosition); 161 this.application.ninja.elementMediator.setProperty(items, "height", [this.heightControl.value + "px"] , "Change", "pi", prevPosition);
125 this.savedPosition = null; 162 this.savedPosition = null;
126 } 163 }
@@ -135,9 +172,23 @@ exports.PosSize = Montage.create(Component, {
135 if(this.savedPosition) prevPosition = [this.savedPosition + "px"]; 172 if(this.savedPosition) prevPosition = [this.savedPosition + "px"];
136 173
137 this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.documentRoot]; 174 this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.documentRoot];
175
176 if(this.bindButton.value) {
177
178 var newHeight = Math.round(this.aspectRatioWidth * this.widthControl.value);
179
180 if(!isFinite(newHeight)) newHeight = this.widthControl.value;
181
182 this.heightControl.value = newHeight;
183 this.application.ninja.elementMediator.setProperty(items, "height", [newHeight + "px"] , "Change", "pi");
184
185 }
186
138 this.application.ninja.elementMediator.setProperty(items, "width", [this.widthControl.value + "px"] , "Change", "pi", prevPosition); 187 this.application.ninja.elementMediator.setProperty(items, "width", [this.widthControl.value + "px"] , "Change", "pi", prevPosition);
139 this.savedPosition = null; 188 this.savedPosition = null;
189
140 } 190 }
191
141 } 192 }
142 }, 193 },
143 194
@@ -166,24 +217,22 @@ exports.PosSize = Montage.create(Component, {
166 var items; 217 var items;
167 if(!event.wasSetByCode) { 218 if(!event.wasSetByCode) {
168 219
220 if(!this.savedPosition) this.savedPosition = this.heightSize;
221
222 this.application.ninja.selectedElements.length ? items = this.application.ninja.selectedElements : items = [this.application.ninja.currentDocument.documentRoot];
223
169 if(this.bindButton.value) {