diff options
author | Jose Antonio Marquez | 2012-05-01 10:13:35 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-01 10:13:35 -0700 |
commit | 7812925f6864a6f3a01e4a76924dc5c71706ff37 (patch) | |
tree | cc4be068b5de74fb8b1ff28fd6b556fe2c115e97 /js/tools | |
parent | 7bdcab084d1991361ba8d37a7435efd229648630 (diff) | |
parent | fb47c04b0a4d65f53d975311754aa0dd8a8a3f69 (diff) | |
download | ninja-7812925f6864a6f3a01e4a76924dc5c71706ff37.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/tools')
-rwxr-xr-x | js/tools/OvalTool.js | 2 | ||||
-rwxr-xr-x | js/tools/PanTool.js | 20 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 6 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 38 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 13 |
5 files changed, 60 insertions, 19 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/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..8f45891d 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) { |
@@ -211,7 +214,20 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
211 | _useExistingCanvas: { | 214 | _useExistingCanvas: { |
212 | value: function() | 215 | value: function() |
213 | { | 216 | { |
214 | return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); | 217 | var target; |
218 | if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) | ||
219 | target = this._targetedElement; | ||
220 | else | ||
221 | { | ||
222 | var container = this.application.ninja.currentSelectedContainer; | ||
223 | if (container && (container.nodeName === "CANVAS")) | ||
224 | { | ||
225 | target = container; | ||
226 | this._targetedElement = target; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | return target; | ||
215 | } | 231 | } |
216 | } | 232 | } |
217 | 233 | ||
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 2283dfab..0b51aa28 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js | |||
@@ -41,11 +41,20 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
41 | 41 | ||
42 | // do the snap | 42 | // do the snap |
43 | var hitRec = snapManager.snap(x, y, true); | 43 | var hitRec = snapManager.snap(x, y, true); |
44 | var dragPlane; | ||
44 | if (hitRec) { | 45 | if (hitRec) { |
45 | // set up the working plane and convert the hit record to be working plane relative | 46 | // set up the working plane and convert the hit record to be working plane relative |
46 | var dragPlane = snapManager.setupDragPlanes( hitRec ); | 47 | if (hitRec.getElement() === snapManager.application.ninja.currentSelectedContainer) |
47 | var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); | 48 | { |
49 | dragPlane = viewUtils.getUnprojectedElementPlane( hitRec.getElement() ); | ||
50 | snapManager.setupDragPlaneFromPlane( dragPlane ); | ||
51 | } | ||
52 | else | ||
53 | { | ||
54 | dragPlane = snapManager.setupDragPlanes( hitRec ); | ||
55 | } | ||
48 | 56 | ||
57 | var wpHitRec = hitRec.convertToWorkingPlane( dragPlane ); | ||
49 | var pt = hitRec.getScreenPoint(); | 58 | var pt = hitRec.getScreenPoint(); |
50 | 59 | ||
51 | return( [wpHitRec, pt[0], pt[1]] ); | 60 | return( [wpHitRec, pt[0], pt[1]] ); |