diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 8 | ||||
-rwxr-xr-x | js/tools/PanTool.js | 77 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 95 | ||||
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 12 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 40 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 9 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 2 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 4 | ||||
-rwxr-xr-x | js/tools/ZoomTool.js | 6 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 39 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 8 |
11 files changed, 159 insertions, 141 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 03edef79..f85978ad 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -39,7 +39,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
39 | //view options | 39 | //view options |
40 | _brushStrokeCanvas: {value: null, writable: true}, | 40 | _brushStrokeCanvas: {value: null, writable: true}, |
41 | _brushStrokePlaneMat: {value: null, writable: true}, | 41 | _brushStrokePlaneMat: {value: null, writable: true}, |
42 | _draggingPlane: {value: null, writable: true}, | 42 | dragPlane: {value: null, writable: true}, |
43 | 43 | ||
44 | //the current brush stroke | 44 | //the current brush stroke |
45 | _selectedBrushStroke: {value: null, writable: true}, | 45 | _selectedBrushStroke: {value: null, writable: true}, |
@@ -67,7 +67,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
67 | 67 | ||
68 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 68 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
69 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); | 69 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); |
70 | this._draggingPlane = snapManager.getDragPlane(); | 70 | this.dragPlane = snapManager.getDragPlane(); |
71 | 71 | ||
72 | snapManager.enableElementSnap(elemSnap); | 72 | snapManager.enableElementSnap(elemSnap); |
73 | snapManager.enableGridSnap(gridSnap); | 73 | snapManager.enableGridSnap(gridSnap); |
@@ -100,7 +100,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
100 | } | 100 | } |
101 | var tmpPoint = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 101 | var tmpPoint = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
102 | var hitRec = snapManager.snap(tmpPoint.x, tmpPoint.y, false); | 102 | var hitRec = snapManager.snap(tmpPoint.x, tmpPoint.y, false); |
103 | this._draggingPlane = snapManager.getDragPlane(); | 103 | this.dragPlane = snapManager.getDragPlane(); |
104 | if (this._selectedSubpathCanvas){ | 104 | if (this._selectedSubpathCanvas){ |
105 | snapManager.popWorkingPlane(); | 105 | snapManager.popWorkingPlane(); |
106 | } | 106 | } |
@@ -228,7 +228,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
228 | if (this._selectedBrushStroke){ | 228 | if (this._selectedBrushStroke){ |
229 | this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat); | 229 | this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat); |
230 | this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[])); | 230 | this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[])); |
231 | this._selectedBrushStroke.setDragPlane(this._draggingPlane); | 231 | this._selectedBrushStroke.setDragPlane(this.dragPlane); |
232 | } | 232 | } |
233 | 233 | ||
234 | //display the previously drawn stroke in a separate canvas | 234 | //display the previously drawn stroke in a separate canvas |
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ce7606a1..39f89d17 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -21,6 +21,9 @@ exports.PanTool = Montage.create(toolBase, | |||
21 | _lastGPt :{value: [0,0], writable:true}, | 21 | _lastGPt :{value: [0,0], writable:true}, |
22 | _lastY :{value: 0, writable:true}, | 22 | _lastY :{value: 0, writable:true}, |
23 | 23 | ||
24 | _maxHorizontalScroll: {value: 0, writable:true}, | ||
25 | _maxVerticalScroll: {value: 0, writable:true}, | ||
26 | |||
24 | Configure: { | 27 | Configure: { |
25 | value: function ( doActivate ) | 28 | value: function ( doActivate ) |
26 | { | 29 | { |
@@ -43,10 +46,19 @@ exports.PanTool = Montage.create(toolBase, | |||
43 | 46 | ||
44 | HandleLeftButtonDown: { | 47 | HandleLeftButtonDown: { |
45 | value : function ( event ) { | 48 | value : function ( event ) { |
46 | this._isDrawing = true; | 49 | // Determine the maximum horizontal and vertical scroll values |
47 | this.isDrawing = true; | 50 | this._maxHorizontalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11; |
48 | 51 | this._maxVerticalScroll = this.application.ninja.currentDocument.model.documentRoot.scrollHeight - this.application.ninja.stage._canvas.height - 11; | |
49 | this.mouseDown( event ); | 52 | if((this._maxHorizontalScroll > 0) || (this._maxVerticalScroll > 0) || this._altKeyDown) |
53 | { | ||
54 | this._isDrawing = true; | ||
55 | this.isDrawing = true; | ||
56 | this.mouseDown( event ); | ||
57 | } | ||
58 | // else | ||
59 | // { | ||
60 | // console.log("nothing to scroll"); | ||
61 | // } | ||
50 | } | 62 | } |
51 | }, | 63 | }, |
52 | 64 | ||
@@ -109,7 +121,7 @@ exports.PanTool = Montage.create(toolBase, | |||
109 | { | 121 | { |
110 | value: function () | 122 | value: function () |
111 | { | 123 | { |
112 | var uc = this.application.ninja.currentDocument.documentRoot; | 124 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
113 | //var uc = documentManagerModule.DocumentManager.activeDocument | 125 | //var uc = documentManagerModule.DocumentManager.activeDocument |
114 | var ucMat = viewUtils.getMatrixFromElement(uc); | 126 | var ucMat = viewUtils.getMatrixFromElement(uc); |
115 | 127 | ||
@@ -136,12 +148,11 @@ exports.PanTool = Montage.create(toolBase, | |||
136 | delta = 10*event.wheelDelta/120; | 148 | delta = 10*event.wheelDelta/120; |
137 | //console.log( "delta: " + delta ); | 149 | //console.log( "delta: " + delta ); |
138 | 150 | ||
139 | this.application.ninja.stage._iframeContainer.scrollLeft += delta; | 151 | this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; |
140 | this.application.ninja.stage._scrollLeft += delta; | ||
141 | 152 | ||
142 | delta *= zoom; | 153 | delta *= zoom; |
143 | 154 | ||
144 | var uc = this.application.ninja.currentDocument.documentRoot; | 155 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
145 | var ucMat = viewUtils.getMatrixFromElement(uc); | 156 | var ucMat = viewUtils.getMatrixFromElement(uc); |
146 | var offset = viewUtils.getElementOffset( uc ); | 157 | var offset = viewUtils.getElementOffset( uc ); |
147 | //console.log( "uc offset: " + offset[0] ); | 158 | //console.log( "uc offset: " + offset[0] ); |
@@ -213,7 +224,7 @@ exports.PanTool = Montage.create(toolBase, | |||
213 | if (elt) | 224 | if (elt) |
214 | { | 225 | { |
215 | // get the userContent object (stage) and its matrix | 226 | // get the userContent object (stage) and its matrix |
216 | var userContent = this.application.ninja.currentDocument.documentRoot; | 227 | var userContent = this.application.ninja.currentDocument.model.documentRoot; |
217 | var ucMat = viewUtils.getMatrixFromElement(userContent); | 228 | var ucMat = viewUtils.getMatrixFromElement(userContent); |
218 | 229 | ||
219 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); | 230 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); |
@@ -291,17 +302,19 @@ exports.PanTool = Montage.create(toolBase, | |||
291 | if (this._isDrawing) | 302 | if (this._isDrawing) |
292 | { | 303 | { |
293 | // get the global screen point | 304 | // get the global screen point |
294 | var gPt = [point.x, point.y, this._globalPt[2]]; | 305 | var gPt = [point.x, point.y, this._globalPt[2]], |
306 | dx, | ||
307 | dy; | ||
295 | if (this._altKeyDown) | 308 | if (this._altKeyDown) |
296 | { | 309 | { |
297 | var dy = 5*(point.y - this._lastY); | 310 | dy = 5*(point.y - this._lastY); |
298 | this._globalPt[2] += dy; | 311 | this._globalPt[2] += dy; |
299 | gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; | 312 | gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; |
300 | } | 313 | } |
301 | else if (this._shiftKeyDown) | 314 | else if (this._shiftKeyDown) |
302 | { | 315 | { |
303 | var dx = Math.abs( this._shiftPt[0] - gPt[0] ), | 316 | dx = Math.abs( this._shiftPt[0] - gPt[0] ); |
304 | dy = Math.abs( this._shiftPt[1] - gPt[1] ); | 317 | dy = Math.abs( this._shiftPt[1] - gPt[1] ); |
305 | 318 | ||
306 | if (dx >= dy) | 319 | if (dx >= dy) |
307 | gPt[1] = this._shiftPt[1]; | 320 | gPt[1] = this._shiftPt[1]; |
@@ -310,16 +323,28 @@ exports.PanTool = Montage.create(toolBase, | |||
310 | } | 323 | } |
311 | 324 | ||
312 | // update the scrollbars | 325 | // update the scrollbars |
313 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); | 326 | var deltaGPt = vecUtils.vecSubtract(2, gPt, this._lastGPt); |
314 | this._lastGPt = gPt.slice(); | 327 | this._lastGPt = gPt.slice(); |
315 | this._lastY = point.y; | 328 | this._lastY = point.y; |
316 | 329 | var limitX = false; | |
317 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, | 330 | var limitY = false; |
318 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; | 331 | |
319 | this.application.ninja.stage._iframeContainer.scrollLeft -= deltaGPt[0]; | 332 | var oldLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft, |
320 | this.application.ninja.stage._iframeContainer.scrollTop -= deltaGPt[1]; | 333 | oldTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop, |
321 | deltaGPt[0] = oldLeft - this.application.ninja.stage._iframeContainer.scrollLeft; | 334 | newLeft = oldLeft - deltaGPt[0], |
322 | deltaGPt[1] = oldTop - this.application.ninja.stage._iframeContainer.scrollTop; | 335 | newTop = oldTop - deltaGPt[1]; |
336 | if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) | ||
337 | { | ||
338 | limitX = true; | ||
339 | } | ||
340 | if((newTop < 0) || (newTop > this._maxVerticalScroll)) | ||
341 | { | ||
342 | limitY = true; | ||
343 | } | ||
344 | this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft -= deltaGPt[0]; | ||
345 | this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= deltaGPt[1]; | ||
346 | deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; | ||
347 | deltaGPt[1] = oldTop - this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; | ||
323 | 348 | ||
324 | gPt[0] -= deltaGPt[0]; | 349 | gPt[0] -= deltaGPt[0]; |
325 | gPt[1] -= deltaGPt[1]; | 350 | gPt[1] -= deltaGPt[1]; |
@@ -333,8 +358,8 @@ exports.PanTool = Montage.create(toolBase, | |||
333 | delta[2] = 0; | 358 | delta[2] = 0; |
334 | 359 | ||
335 | // limit the change | 360 | // limit the change |
336 | var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); | 361 | var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.model.documentRoot); |
337 | var tooMuch = false | 362 | var tooMuch = false; |
338 | if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; | 363 | if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; |
339 | if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; | 364 | if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; |
340 | if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; | 365 | if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; |
@@ -349,6 +374,8 @@ exports.PanTool = Montage.create(toolBase, | |||
349 | else | 374 | else |
350 | this._worldPt = wPt; | 375 | this._worldPt = wPt; |
351 | 376 | ||
377 | if(limitX) delta[0] = 0; | ||