aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/OvalTool.js2
-rwxr-xr-xjs/tools/PanTool.js20
-rwxr-xr-xjs/tools/RotateStage3DTool.js18
-rwxr-xr-xjs/tools/SelectionTool.js6
-rwxr-xr-xjs/tools/ShapeTool.js41
-rwxr-xr-xjs/tools/drawing-tool-base.js64
-rwxr-xr-xjs/tools/drawing-tool.js3
7 files changed, 111 insertions, 43 deletions
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index e8e88d1d..6edec811 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -66,7 +66,7 @@ exports.OvalTool = Montage.create(ShapeTool, {
66 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
67 67
68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
69 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 69 var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2));
70 70
71 var oval = new Circle(); //GLCircle(); 71 var oval = new Circle(); //GLCircle();
72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); 72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle);
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js
index 0537a27b..ce7606a1 100755
--- a/js/tools/PanTool.js
+++ b/js/tools/PanTool.js
@@ -331,10 +331,26 @@ exports.PanTool = Montage.create(toolBase,
331 331
332 if (!this._altKeyDown) 332 if (!this._altKeyDown)
333 delta[2] = 0; 333 delta[2] = 0;
334 var transMat = Matrix.Translation( delta ); 334
335 this._worldPt = wPt; 335 // limit the change
336 var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot);
337 var tooMuch = false
338 if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true;
339 if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true;
340 if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true;
341 if ((ucMat[13] < -12000) && (delta[1] < 0)) tooMuch = true;
342 if ((ucMat[14] > 12000) && (delta[2] > 0)) tooMuch = true;
343 if ((ucMat[14] < -12000) && (delta[2] < 0)) tooMuch = true;
344 if (tooMuch)
345 {
346 this._isDrawing = false;
347 delta = [0,0,0];
348 }
349 else
350 this._worldPt = wPt;
336 351
337 // update everything 352 // update everything
353 var transMat = Matrix.Translation( delta );
338 this.applyDeltaMat( transMat ); 354 this.applyDeltaMat( transMat );
339 } 355 }
340 } 356 }
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js
index d1701304..2a9c63db 100755
--- a/js/tools/RotateStage3DTool.js
+++ b/js/tools/RotateStage3DTool.js
@@ -96,6 +96,12 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
96 viewUtils.pushViewportObj( stage ); 96 viewUtils.pushViewportObj( stage );
97 var eltCtr = viewUtils.getCenterOfProjection(); 97 var eltCtr = viewUtils.getCenterOfProjection();
98 viewUtils.popViewportObj(); 98 viewUtils.popViewportObj();
99// if(this.application.ninja.documentController.webTemplate)
100 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent")
101 {
102 eltCtr[0] = stage.scrollWidth/2;
103 eltCtr[1] = stage.scrollHeight/2;
104 }
99 105
100 var curMat = viewUtils.getMatrixFromElement(stage); 106 var curMat = viewUtils.getMatrixFromElement(stage);
101 var curMatInv = glmat4.inverse(curMat, []); 107 var curMatInv = glmat4.inverse(curMat, []);
@@ -113,8 +119,16 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
113 119
114 this._origin = viewUtils.localToGlobal(eltCtr, stage); 120 this._origin = viewUtils.localToGlobal(eltCtr, stage);
115 121
116 this._setTransformOrigin(false); 122// if(this.application.ninja.documentController.webTemplate)
117 123 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent")
124 {
125 this._startOriginArray = [];
126 this._startOriginArray.push(this._origin.slice());
127 }
128 else
129 {
130 this._setTransformOrigin(false);
131 }
118 this.DrawHandles(); 132 this.DrawHandles();
119 } 133 }
120 }, 134 },
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 7033ee3d..855c7b8c 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -751,10 +751,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
751 751
752 var zoomFactor = 1; 752 var zoomFactor = 1;
753 var viewPort = this.application.ninja.stage._viewport; 753 var viewPort = this.application.ninja.stage._viewport;
754 if (viewPort.style && viewPort.style.zoom) 754 if (viewPort && viewPort.style && viewPort.style.zoom) {
755 {
756 zoomFactor = Number(viewPort.style.zoom); 755 zoomFactor = Number(viewPort.style.zoom);
757 } 756 }
757
758 var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); 758 var tmpMat = viewUtils.getLocalToGlobalMatrix( item );
759 for (var j=0; j<4; j++) 759 for (var j=0; j<4; j++)
760 { 760 {
@@ -863,7 +863,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
863 863
864 var zoomFactor = 1; 864 var zoomFactor = 1;
865 var viewPort = this.application.ninja.stage._viewport; 865 var viewPort = this.application.ninja.stage._viewport;
866 if (viewPort.style && viewPort.style.zoom) 866 if (viewPort && viewPort.style && viewPort.style.zoom)
867 { 867 {
868 zoomFactor = Number(viewPort.style.zoom); 868 zoomFactor = Number(viewPort.style.zoom);
869 } 869 }
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 21a5a025..d2337000 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -54,9 +54,9 @@ exports.ShapeTool = Montage.create(DrawingTool, {
54 }, 54 },
55 55
56 HandleLeftButtonUp: 56 HandleLeftButtonUp:
57 { 57 {
58 value: function (event) 58 value: function (event)
59 { 59 {
60 var drawData; 60 var drawData;
61 61
62 drawData = this.getDrawingData(); 62 drawData = this.getDrawingData();
@@ -69,24 +69,27 @@ exports.ShapeTool = Montage.create(DrawingTool, {
69 drawData.planeMat, drawData.midPt, canvas, true); 69 drawData.planeMat, drawData.midPt, canvas, true);
70 70
71 canvas.elementModel.isShape = true; 71 canvas.elementModel.isShape = true;
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data); 72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data);
73 } else { 73 } else {
74 canvas = this._targetedElement; 74 canvas = this._targetedElement;
75 if (!canvas.getAttribute( "data-RDGE-id" ))
76 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
75 canvas.elementModel.controller = ShapesController; 77 canvas.elementModel.controller = ShapesController;
76 if(!canvas.elementModel.shapeModel) { 78 if(!canvas.elementModel.shapeModel) {
77 canvas.elementModel.shapeModel = Montage.create(ShapeModel); 79 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
78 } 80 }
81 this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data);
79 } 82 }
80 } 83 }
81 84
82 this.endDraw(event); 85 this.endDraw(event);
83 86
84 this._isDrawing = false; 87 this._isDrawing = false;
85 this._hasDraw=false; 88 this._hasDraw=false;
86 89
87 this.DrawHandles(); 90 this.DrawHandles();
88 } 91 }
89 }, 92 },
90 93
91 onAddElements: { 94 onAddElements: {
92 value: function(el) { 95 value: function(el) {
@@ -103,6 +106,9 @@ exports.ShapeTool = Montage.create(DrawingTool, {
103 if(wasSelected) { 106 if(wasSelected) {
104 this.AddCustomFeedback(); 107 this.AddCustomFeedback();
105 this.application.ninja.elementMediator.addDelegate = this; 108 this.application.ninja.elementMediator.addDelegate = this;
109 if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") {
110 this._targetedElement = this.application.ninja.currentSelectedContainer;
111 }
106 } else { 112 } else {
107 this.RemoveCustomFeedback(); 113 this.RemoveCustomFeedback();
108 this.application.ninja.elementMediator.addDelegate = null; 114 this.application.ninja.elementMediator.addDelegate = null;
@@ -211,7 +217,20 @@ exports.ShapeTool = Montage.create(DrawingTool, {
211 _useExistingCanvas: { 217 _useExistingCanvas: {
212 value: function() 218 value: function()
213 { 219 {
214 return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); 220 var target;
221 if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement))
222 target = this._targetedElement;
223 else
224 {
225 var container = this.application.ninja.currentSelectedContainer;
226 if (container && (container.nodeName === "CANVAS"))
227 {
228 target = container;
229 this._targetedElement = target;
230 }
231 }
232
233 return target;
215 } 234 }
216 } 235 }
217 236
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js
index 2283dfab..7d97f105 100755
--- a/js/tools/drawing-tool-base.js
+++ b/js/tools/drawing-tool-base.js
@@ -24,6 +24,9 @@ exports.DrawingToolBase = Montage.create(Montage, {
24 value: null 24 value: null
25 }, 25 },
26 26
27 dragPlane: {
28 value: null
29 },
27 /** 30 /**
28 * Used on the initial MouseDown for Drawing Tools 31 * Used on the initial MouseDown for Drawing Tools
29 * 32 *
@@ -33,19 +36,30 @@ exports.DrawingToolBase = Montage.create(Montage, {
33 * 2 - Y value converted to screen point 36 * 2 - Y value converted to screen point
34 */ 37 */
35 getInitialSnapPoint: { 38 getInitialSnapPoint: {
36 value: function(x,y) { 39 value: function(x, y, shapeCanvas) {