aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/PanTool.js65
-rwxr-xr-xjs/tools/RotateStage3DTool.js20
-rwxr-xr-xjs/tools/SelectionTool.js5
-rwxr-xr-xjs/tools/ShapeTool.js2
-rwxr-xr-xjs/tools/ZoomTool.js4
5 files changed, 55 insertions, 41 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js
index ce7606a1..5cfeec75 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.documentRoot.scrollWidth - this.application.ninja.stage._canvas.width - 11;
48 51 this._maxVerticalScroll = this.application.ninja.currentDocument.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
@@ -136,8 +148,7 @@ 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
@@ -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];
@@ -334,7 +359,7 @@ exports.PanTool = Montage.create(toolBase,
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.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;
378 if(limitY) delta[1] = 0;
352 // update everything 379 // update everything
353 var transMat = Matrix.Translation( delta ); 380 var transMat = Matrix.Translation( delta );
354 this.applyDeltaMat( transMat ); 381 this.applyDeltaMat( transMat );
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js
index 2a9c63db..c8818021 100755
--- a/js/tools/RotateStage3DTool.js
+++ b/js/tools/RotateStage3DTool.js
@@ -96,12 +96,6 @@ 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 }
105 99
106 var curMat = viewUtils.getMatrixFromElement(stage); 100 var curMat = viewUtils.getMatrixFromElement(stage);
107 var curMatInv = glmat4.inverse(curMat, []); 101 var curMatInv = glmat4.inverse(curMat, []);
@@ -118,17 +112,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
118 } 112 }
119 113
120 this._origin = viewUtils.localToGlobal(eltCtr, stage); 114 this._origin = viewUtils.localToGlobal(eltCtr, stage);
121 115 this._setTransformOrigin(false);
122// if(this.application.ninja.documentController.webTemplate)
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 }
132 this.DrawHandles(); 116 this.DrawHandles();
133 } 117 }
134 }, 118 },
@@ -155,7 +139,7 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
155 // let the document and stage manager know about the zoom change 139 // let the document and stage manager know about the zoom change
156 this.application.ninja.stage._firstDraw = true; 140 this.application.ninja.stage._firstDraw = true;
157 this.application.ninja.documentBar.zoomFactor = 100; 141 this.application.ninja.documentBar.zoomFactor = 100;
158 this.application.ninja.currentDocument.iframe.style.zoom = 1.0; 142 this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = 1.0;
159 this.application.ninja.stage._firstDraw = false; 143 this.application.ninja.stage._firstDraw = false;
160 144
161 // TODO - Any updates to the stage should redraw stage's children. Move this to mediator? 145 // TODO - Any updates to the stage should redraw stage's children. Move this to mediator?
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 07c26b8c..5c8b15ae 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -165,10 +165,11 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
165 box[3] = point.y; 165 box[3] = point.y;
166 166
167 //selectionManagerModule.selectionManager.marqueeSelection(box); 167 //selectionManagerModule.selectionManager.marqueeSelection(box);
168 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; 168 var childNodes = this.application.ninja.currentDocument.documentRoot.childNodes,
169 selectionController = this.application.ninja.selectionController;
169 childNodes = Array.prototype.slice.call(childNodes, 0); 170 childNodes = Array.prototype.slice.call(childNodes, 0);
170 childNodes.forEach(function(item) { 171 childNodes.forEach(function(item) {
171 if(item.nodeType == 1 && SelectionTool._complicatedCollisionDetection(item, box)) { 172 if(selectionController.isNodeTraversable(item) && SelectionTool._complicatedCollisionDetection(item, box)) {
172 selectedItems.push(item); 173 selectedItems.push(item);
173 } 174 }
174 }); 175 });
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 0562dbc2..367ab78d 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -72,7 +72,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
72 if(!canvas.elementModel.shapeModel) { 72 if(!canvas.elementModel.shapeModel) {
73 canvas.elementModel.shapeModel = Montage.create(ShapeModel); 73 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
74 } 74 }
75 this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); 75 this.RenderShape(drawData.width, drawData.