aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js9
-rwxr-xr-xjs/tools/OvalTool.js20
-rwxr-xr-xjs/tools/RectTool.js19
-rwxr-xr-xjs/tools/SelectionTool.js282
-rwxr-xr-xjs/tools/TranslateObject3DTool.js7
-rwxr-xr-xjs/tools/modifier-tool-base.js7
6 files changed, 262 insertions, 82 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 0a7c0534..32572af1 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -206,10 +206,13 @@ exports.LineTool = Montage.create(ShapeTool, {
206 // for default stroke and fill/no materials 206 // for default stroke and fill/no materials
207 var strokeMaterial = null; 207 var strokeMaterial = null;
208 208
209 var strokeM = this.options.strokeMaterial; 209 if(this.options.use3D)
210 if(strokeM)
211 { 210 {
212 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); 211 var strokeM = this.options.strokeMaterial;
212 if(strokeM)
213 {
214 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM));
215 }
213 } 216 }
214 217
215 var world = this.getGLWorld(canvas, this.options.use3D); 218 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 14655312..911059a7 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -43,19 +43,21 @@ exports.OvalTool = Montage.create(ShapeTool, {
43 var strokeMaterial = null; 43 var strokeMaterial = null;
44 var fillMaterial = null; 44 var fillMaterial = null;
45 45
46 var strokeM = this.options.strokeMaterial; 46 if(this.options.use3D)
47 if(strokeM)
48 { 47 {
49 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); 48 var strokeM = this.options.strokeMaterial;
50 } 49 if(strokeM)
50 {
51 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM));
52 }
51 53
52 var fillM = this.options.fillMaterial; 54 var fillM = this.options.fillMaterial;
53 if(fillM) 55 if(fillM)
54 { 56 {
55 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); 57 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM));
58 }
56 } 59 }
57 60
58
59 var world = this.getGLWorld(canvas, this.options.use3D); 61 var world = this.getGLWorld(canvas, this.options.use3D);
60 62
61 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 63 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index 31ac7faa..5e148de3 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -62,16 +62,19 @@ exports.RectTool = Montage.create(ShapeTool, {
62 var strokeMaterial = null; 62 var strokeMaterial = null;
63 var fillMaterial = null; 63 var fillMaterial = null;
64 64
65 var strokeM = this.options.strokeMaterial; 65 if(this.options.use3D)
66 if(strokeM)
67 { 66 {
68 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); 67 var strokeM = this.options.strokeMaterial;
69 } 68 if(strokeM)
69 {
70 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM));
71 }
70 72
71 var fillM = this.options.fillMaterial; 73 var fillM = this.options.fillMaterial;
72 if(fillM) 74 if(fillM)
73 { 75 {
74 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); 76 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM));
77 }
75 } 78 }
76 79
77 var world = this.getGLWorld(canvas, this.options.use3D); 80 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index caa9e8d6..6d8ff175 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -19,6 +19,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
19 _canOperateOnStage: { value: true}, 19 _canOperateOnStage: { value: true},
20 _isSelecting: {value: false, writable:true}, 20 _isSelecting: {value: false, writable:true},
21 _shiftMove: { value: 10}, 21 _shiftMove: { value: 10},
22 _use3DMode: { value: false },
22 23
23 _showTransformHandles: { value: false, enumerable: true }, 24 _showTransformHandles: { value: false, enumerable: true },
24 25
@@ -29,6 +30,27 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
29 } 30 }
30 }, 31 },
31 32
33 _areElementsOnSamePlane : {
34 value: function () {
35 if(this._targets && this._targets.length)
36 {
37 // TODO - drawUtils's elementPlanes check in drawSelectionBounds doesn't seem to work,
38 // so temporary workaround to simply check if all elements have identity matrix
39 // TODO - Eventually, this should instead check if all the selected items are on the view plane
40 var len = this._targets.length;
41 for(var i = 0; i < len; i++)
42 {
43 var mat = this._targets[i].mat;
44 if(!MathUtils.isIdentityMatrix(mat))
45 {
46 return false;
47 }
48 }
49 }
50 return true;
51 }
52 },
53
32 startDraw: { 54 startDraw: {
33 value: function(event) { 55 value: function(event) {
34 if(!this.application.ninja.selectedElements.length) 56 if(!this.application.ninja.selectedElements.length)
@@ -44,9 +66,13 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
44 this.isDrawing = true; 66 this.isDrawing = true;
45 this.application.ninja.stage.showSelectionBounds = false; 67 this.application.ninja.stage.showSelectionBounds = false;
46 68
69 this._use3DMode = false;
70
47 if(this._canSnap) 71 if(this._canSnap)
48 { 72 {
49 this.initializeSnapping(event); 73 this.initializeSnapping(event);
74 this._use3DMode = !this._areElementsOnSamePlane();
75// console.log("use3DMode = " + this._use3DMode);
50 } 76 }
51 else 77 else
52 { 78 {
@@ -122,6 +148,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
122 if(this._escape) { 148 if(this._escape) {
123 this._escape = false; 149 this._escape = false;
124 this._isSelecting = false; 150 this._isSelecting = false;
151 this._canSnap = true;
152 this._use3DMode = false;
125 return; 153 return;
126 } 154 }
127 155
@@ -153,6 +181,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
153 } 181 }
154 182
155 this.endDraw(event); 183 this.endDraw(event);
184 this._canSnap = true;
185 this._use3DMode = false;
156 return; 186 return;
157 } 187 }
158 188
@@ -180,6 +210,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
180 } 210 }
181 211
182 this.endDraw(event); 212 this.endDraw(event);
213 this._canSnap = true;
214 this._use3DMode = false;
183 } 215 }
184 }, 216 },
185 217
@@ -211,7 +243,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
211 case Keyboard.LEFT: 243 case Keyboard.LEFT:
212 var newLeft = []; 244 var newLeft = [];
213 var leftArr = this.application.ninja.selectedElements.map(function(item) { 245 var leftArr = this.application.ninja.selectedElements.map(function(item) {
214 newLeft.push( (parseFloat(ElementsMediator.getProperty(item._element, "left")) - inc) + "px" ); 246 newLeft.push( (parseInt(ElementsMediator.getProperty(item._element, "left")) - inc) + "px" );
215 return ElementsMediator.getProperty(item._element, "left"); 247 return ElementsMediator.getProperty(item._element, "left");
216 }); 248 });
217 249
@@ -220,7 +252,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
220 case Keyboard.UP: 252 case Keyboard.UP:
221 var newTop = []; 253 var newTop = [];
222 var topArr = this.application.ninja.selectedElements.map(function(item) { 254 var topArr = this.application.ninja.selectedElements.map(function(item) {
223 newTop.push( (parseFloat(ElementsMediator.getProperty(item._element, "top")) - inc) + "px" ); 255 newTop.push( (parseInt(ElementsMediator.getProperty(item._element, "top")) - inc) + "px" );
224 return ElementsMediator.getProperty(item._element, "top"); 256 return ElementsMediator.getProperty(item._element, "top");
225 }); 257 });
226 258
@@ -229,7 +261,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
229 case Keyboard.RIGHT: 261 case Keyboard.RIGHT:
230 var newLeft = []; 262 var newLeft = [];
231 var leftArr = this.application.ninja.selectedElements.map(function(item) { 263 var leftArr = this.application.ninja.selectedElements.map(function(item) {
232 newLeft.push( (parseFloat(ElementsMediator.getProperty(item._element, "left")) + inc) + "px" ); 264 newLeft.push( (parseInt(ElementsMediator.getProperty(item._element, "left")) + inc) + "px" );
233 return ElementsMediator.getProperty(item._element, "left"); 265 return ElementsMediator.getProperty(item._element, "left");
234 }); 266 });
235 267
@@ -238,7 +270,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
238 case Keyboard.DOWN: 270 case Keyboard.DOWN:
239 var newTop = []; 271 var newTop = [];
240 var topArr = this.application.ninja.selectedElements.map(function(item) { 272 var topArr = this.application.ninja.selectedElements.map(function(item) {
241 newTop.push( (parseFloat(ElementsMediator.getProperty(item._element, "top")) + inc) + "px" ); 273 newTop.push( (parseInt(ElementsMediator.getProperty(item._element, "top")) + inc) + "px" );
242 return ElementsMediator.getProperty(item._element, "top"); 274 return ElementsMediator.getProperty(item._element, "top");
243 }); 275 });
244 276
@@ -269,10 +301,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
269 newTop = [], 301 newTop = [],
270 newWidth = [], 302 newWidth = [],
271 newHeight = [], 303 newHeight = [],
304 newStyles = [],
272 previousLeft = [], 305 previousLeft = [],
273 previousTop = [], 306 previousTop = [],
274 previousW