aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js19
-rwxr-xr-xjs/tools/LineTool.js5
-rwxr-xr-xjs/tools/PanTool.js23
-rwxr-xr-xjs/tools/Rotate3DToolBase.js11
-rwxr-xr-xjs/tools/SelectionTool.js19
-rwxr-xr-xjs/tools/Translate3DToolBase.js1
6 files changed, 65 insertions, 13 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index fec89eb2..8b0f60bb 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var ShapeTool = require("js/tools/ShapeTool").ShapeTool; 7var ShapeTool = require("js/tools/ShapeTool").ShapeTool;
8var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
8var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; 9var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase;
9var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; 10var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager;
10var Montage = require("montage/core/core").Montage; 11var Montage = require("montage/core/core").Montage;
@@ -67,12 +68,24 @@ exports.BrushTool = Montage.create(ShapeTool, {
67 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 68 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
68 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 69 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
69 } 70 }
71 if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){
72 this._selectedBrushStroke.setSecondStrokeColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor);
73 }
70 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move 74 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move
71 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); 75 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY);
72 this._selectedBrushStroke.addPoint(currMousePos); 76 this._selectedBrushStroke.addPoint(currMousePos);
73 77
74 //TODO get these values from the options 78 var strokeSize = 1;
75 this._selectedBrushStroke.setStrokeWidth(20); 79 if (this.options.strokeSize) {
80 strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units);
81 }
82 this._selectedBrushStroke.setStrokeWidth(strokeSize);
83
84 var strokeHardness = 100;
85 if (this.options.strokeHardness){
86 strokeHardness = ShapesController.GetValueInPixels(this.options.strokeHardness.value, this.options.strokeHardness.units);
87 }
88 this._selectedBrushStroke.setStrokeHardness(strokeHardness);
76 } 89 }
77 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); 90 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove();
78 } //value: function (event) { 91 } //value: function (event) {
@@ -112,7 +125,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
112 125
113 if (this._isDrawing) { 126 if (this._isDrawing) {
114 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); 127 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY);
115 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){ 128 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<1000){
116 this._selectedBrushStroke.addPoint(currMousePos); 129 this._selectedBrushStroke.addPoint(currMousePos);
117 } 130 }
118 this.ShowCurrentBrushStrokeOnStage(); 131 this.ShowCurrentBrushStrokeOnStage();
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 233316a5..0a7c0534 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -42,7 +42,10 @@ exports.LineTool = Montage.create(ShapeTool, {
42 } 42 }
43 43
44 this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null); 44 this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null);
45 this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; 45 if (this.application.ninja.colorController.colorToolbar.stroke.color)
46 this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css;
47 else
48 this._strokeColor = [0,0,0,1];
46 this.startDraw(event); 49 this.startDraw(event);
47 } 50 }
48 }, 51 },
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js
index 71301d46..0537a27b 100755
--- a/js/tools/PanTool.js
+++ b/js/tools/PanTool.js
@@ -81,6 +81,14 @@ exports.PanTool = Montage.create(toolBase,
81 { 81 {
82 this._altKeyDown = true; 82 this._altKeyDown = true;
83 } 83 }
84 else if (event.shiftKey)
85 {
86 if (!this._shiftKeyDown)
87 {
88 this._shiftKeyDown = true;
89 this._shiftPt = this._lastGPt.slice();
90 }
91 }
84 } 92 }
85 }, 93 },
86 94
@@ -90,6 +98,10 @@ exports.PanTool = Montage.create(toolBase,
90 { 98 {
91 this._altKeyDown = false; 99 this._altKeyDown = false;
92 } 100 }
101 else if (event.keyCode === Keyboard.SHIFT)
102 {
103 this._shiftKeyDown = false;
104 }
93 } 105 }
94 }, 106 },
95 107
@@ -221,6 +233,7 @@ exports.PanTool = Montage.create(toolBase,
221 var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); 233 var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat );
222 234
223 this._lastGPt = this._globalPt.slice(); 235 this._lastGPt = this._globalPt.slice();
236 this._shiftPt = this._lastGPt.slice();
224 this._lastY = this._lastGPt[1]; 237 this._lastY = this._lastGPt[1];
225 238
226 // set up the matrices we will be needing 239 // set up the matrices we will be needing
@@ -285,6 +298,16 @@ exports.PanTool = Montage.create(toolBase,
285 this._globalPt[2] += dy; 298 this._globalPt[2] += dy;
286 gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; 299 gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]];
287 } 300 }
301 else if (this._shiftKeyDown)
302 {
303 var dx = Math.abs( this._shiftPt[0] - gPt[0] ),
304 dy = Math.abs( this._shiftPt[1] - gPt[1] );
305
306 if (dx >= dy)
307 gPt[1] = this._shiftPt[1];
308 else
309 gPt[0] = this._shiftPt[0];
310 }
288 311
289 // update the scrollbars 312 // update the scrollbars
290 var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); 313 var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt);
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index aa91b2f4..b04e8b0a 100755
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -447,16 +447,13 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
447 iMat; 447 iMat;
448 for(var i = 0; i < len; i++) 448 for(var i = 0; i < len; i++)
449 { 449 {
450 // Reset to the identity matrix but retain the rotation values 450 // Reset to the identity matrix
451 item = this._targets[i]; 451 item = this._targets[i];
452 elt = item.elt;
453
454 // Reset to the identity matrix but retain the translation values
455 iMat = Matrix.I(4); 452 iMat = Matrix.I(4);
456 mat = item.mat; 453 mat = item.mat;
457 iMat[12] = mat[12]; 454// iMat[12] = mat[12];
458 iMat[13] = mat[13]; 455// iMat[13] = mat[13];
459 iMat[14] = mat[14]; 456// iMat[14] = mat[14];
460 457
461 dist = this._undoArray[i].dist; 458 dist = this._undoArray[i].dist;
462 459
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 37029e8c..caa9e8d6 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -305,16 +305,33 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
305 newHeight.push(_h + "px"); 305 newHeight.push(_h + "px");
306 306
307 viewUtils.setMatrixForElement(elt, previousMat); 307 viewUtils.setMatrixForElement(elt, previousMat);
308
309 this._targets[i].mat = previousMat;
310 this._targets[i].matInv = glmat4.inverse(previousMat, []);
308 } 311 }
309 } 312 }
310 if(addToUndoStack) 313 if(addToUndoStack)
311 { 314 {
312 ElementsMediator.setProperties(this.application.ninja.selectedElements, 315 // if we have a delta, that means the transform handles were used and
316 // we should update the width and height too. Otherwise, just update left and top.
317 if(this._delta)
318 {
319 ElementsMediator.setProperties(this.application.ninja.selectedElements,
313 { "left": newLeft, "top": newTop, "width": newWidth, "height": newHeight }, 320 { "left": newLeft, "top": newTop, "width": newWidth, "height": newHeight },
314 "Change", 321 "Change",
315 "selectionTool", 322 "selectionTool",
316 { "left" : previousLeft, "top" : previousTop, "width": previousWidth, "height": previousHeight} 323 { "left" : previousLeft, "top" : previousTop, "width": previousWidth, "height": previousHeight}
317 ); 324 );
325 }
326 else
327 {
328 ElementsMediator.setProperties(this.application.ninja.selectedElements,
329 { "left": newLeft, "top": newTop },
330 "Change",
331 "selectionTool",
332 { "left" : previousLeft, "top" : previousTop }
333 );
334 }
318 } 335 }
319 // Save previous value for undo/redo 336 // Save previous value for undo/redo
320 this._undoArray = []; 337 this._undoArray = [];
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index cbf76830..3d9191da 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -85,7 +85,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
85 { 85 {
86 // Reset to the identity matrix but retain the rotation values 86 // Reset to the identity matrix but retain the rotation values
87 item = this._targets[i]; 87 item = this._targets[i];
88 elt = item.elt;
89 mat = item.mat.slice(0); 88 mat = item.mat.slice(0);
90 mat[12] = 0; 89 mat[12] = 0;
91 mat[13] = 0; 90 mat[13] = 0;