From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/tools/ZoomTool.js | 314 +++++++++++++++++++++++++-------------------------- 1 file changed, 157 insertions(+), 157 deletions(-) (limited to 'js/tools/ZoomTool.js') diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 14ef0f1a..0a3b3593 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -65,21 +65,21 @@ exports.ZoomTool = Montage.create(DrawingTool, { }, HandleAltKeyDown: { - value: function(event) { + value: function(event) { this.setCursor(); this._altKeyDown=true; - } - }, + } + }, - HandleAltKeyUp: { - value: function(event) { + HandleAltKeyUp: { + value: function(event) { this.setCursor(); this._altKeyDown=false; - } - }, + } + }, HandleEscape: { value: function(event) { @@ -98,23 +98,23 @@ exports.ZoomTool = Montage.create(DrawingTool, { if(wasSelected) { this.AddCustomFeedback(); this.eventManager.addEventListener( "toolDoubleClick", this, false); - this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); + this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); } else { this.RemoveCustomFeedback(); this.eventManager.removeEventListener( "toolDoubleClick", this, false); - this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); + this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); } } }, AddCustomFeedback: { - value: function (event) { + value: function (event) { this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); - } - }, + } + }, handleScrollValue:{ value:function(){ @@ -160,167 +160,167 @@ exports.ZoomTool = Montage.create(DrawingTool, { } }, - HandleMouseMove: - { - value : function (event) - { + HandleMouseMove: + { + value : function (event) + { var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); // check for some reasonable amount of mouse movement - var dx = Math.abs(point.x - this.downPoint.x), - dy = Math.abs(point.y - this.downPoint.y); - - if ((dx >= 10) || (dy >= 10)) - { - // Drawing the Marquee - if(this.options.selectedElement==="zoomInTool") - { - if(this._altKeyDown) - this._hasDraw=false; - else - this._hasDraw = true; - } - else - { - if(this._altKeyDown) - this._hasDraw=true; - else - this._hasDraw=false; - } - - if(this._hasDraw) - { - this.doDraw(event); - this._x = this.downPoint.x; - this._y = this.downPoint.y; - } - } - } - }, - - handleZoomChange: - { - value: function(event) - { - } - }, + var dx = Math.abs(point.x - this.downPoint.x), + dy = Math.abs(point.y - this.downPoint.y); + + if ((dx >= 10) || (dy >= 10)) + { + // Drawing the Marquee + if(this.options.selectedElement==="zoomInTool") + { + if(this._altKeyDown) + this._hasDraw=false; + else + this._hasDraw = true; + } + else + { + if(this._altKeyDown) + this._hasDraw=true; + else + this._hasDraw=false; + } + + if(this._hasDraw) + { + this.doDraw(event); + this._x = this.downPoint.x; + this._y = this.downPoint.y; + } + } + } + }, + + handleZoomChange: + { + value: function(event) + { + } + }, _setZoom:{ value:function(mode,zoomFactor) - { + { var userContent = this.application.ninja.currentDocument.model.documentRoot; this._oldValue = this.application.ninja.documentBar.zoomFactor; - var globalPt; + var globalPt; if(this._mode==="mouseClickZoom") - { - if(this.options.selectedElement==="zoomInTool") - { - if(this._altKeyDown) - this._factor = this._oldValue/(zoomFactor*100); - else - this._factor = (zoomFactor*100)/this._oldValue; - } - else - { - if(this._altKeyDown) - this._factor = (zoomFactor*100)/this._oldValue; - else - this._factor = this._oldValue/(zoomFactor*100); - } - - var hitRec = snapManager.snap( this._layerX, this._layerY, true ); - if (hitRec) - { - var elt = hitRec.getElement(); - if (elt) - { -// console.log( "hit: " + hitRec.getElement().id ); - var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); - var localPt; - if (elt != userContent) - localPt = hitRec.calculateElementPreTransformScreenPoint(); - else - { - localPt = hitRec.calculateElementWorldPoint(); - viewUtils.pushViewportObj( userContent ); - var cop = viewUtils.getCenterOfProjection(); - this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; - localPt = this._localPt.slice(); - viewUtils.popViewportObj(); - } - - globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); - } - else - globalPt = [this._layerX, this._layerY, 0]; - } - else - globalPt = [this._layerX, this._layerY, 0]; - } - else if (this._mode==="marqueeZoom") - { - this._factor = (zoomFactor*100)/this._oldValue; - - var p0 = [this._x, this._y, 0]; - var p1 = [this._layerX, this._layerY, 0]; - globalPt = vecUtils.vecAdd(3, p0, p1); - vecUtils.vecScale(3, globalPt, 0.5); - } - else if (this._mode === "doubleClickReset") - { - if (userContent) - { - var w = userContent.offsetWidth, - h = userContent.offsetHeight; - if(userContent.width) - w = userContent.width; - if(userContent.height) - h = userContent.height; - globalPt = [ w/2, h/2, 0]; - } - else - globalPt = [0,0,0]; - zoomFactor = 1; - } - else if (this._mode === "mouseWheelZoom") - { + { + if(this.options.selectedElement==="zoomInTool") + { + if(this._altKeyDown) + this._factor = this._oldValue/(zoomFactor*100); + else + this._factor = (zoomFactor*100)/this._oldValue; + } + else + { + if(this._altKeyDown) + this._factor = (zoomFactor*100)/this._oldValue; + else + this._factor = this._oldValue/(zoomFactor*100); + } + + var hitRec = snapManager.snap( this._layerX, this._layerY, true ); + if (hitRec) + { + var elt = hitRec.getElement(); + if (elt) + { +// console.log( "hit: " + hitRec.getElement().id ); + var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); + var localPt; + if (elt != userContent) + localPt = hitRec.calculateElementPreTransformScreenPoint(); + else + { + localPt = hitRec.calculateElementWorldPoint(); + viewUtils.pushViewportObj( userContent ); + var cop = viewUtils.getCenterOfProjection(); + this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; + localPt = this._localPt.slice(); + viewUtils.popViewportObj(); + } + + globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); + } + else + globalPt = [this._layerX, this._layerY, 0]; + } + else + globalPt = [this._layerX, this._layerY, 0]; + } + else if (this._mode==="marqueeZoom") + { + this._factor = (zoomFactor*100)/this._oldValue; + + var p0 = [this._x, this._y, 0]; + var p1 = [this._layerX, this._layerY, 0]; + globalPt = vecUtils.vecAdd(3, p0, p1); + vecUtils.vecScale(3, globalPt, 0.5); + } + else if (this._mode === "doubleClickReset") + { + if (userContent) + { + var w = userContent.offsetWidth, + h = userContent.offsetHeight; + if(userContent.width) + w = userContent.width; + if(userContent.height) + h = userContent.height; + globalPt = [ w/2, h/2, 0]; + } + else + globalPt = [0,0,0]; + zoomFactor = 1; + } + else if (this._mode === "mouseWheelZoom") + { var w = this.application.ninja.stage._canvas.width, h = this.application.ninja.stage._canvas.height; - globalPt = [w/2, h/2, 0]; - } - else - { - console.log( "unhandled zoom mode: " + this._mode ); - return; - } - - // apply the scale to the matrices - var localPt = viewUtils.globalToLocal( globalPt, userContent ); - viewUtils.setStageZoom( globalPt, zoomFactor ); - - // let the document and stage manager know about the zoom change - this.application.ninja.stage._firstDraw = true; - this.application.ninja.documentBar.zoomFactor = zoomFactor*100; + globalPt = [w/2, h/2, 0]; + } + else + { + console.log( "unhandled zoom mode: " + this._mode ); + return; + } + + // apply the scale to the matrices + var localPt = viewUtils.globalToLocal( globalPt, userContent ); + viewUtils.setStageZoom( globalPt, zoomFactor ); + + // let the document and stage manager know about the zoom change + this.application.ninja.stage._firstDraw = true; + this.application.ninja.documentBar.zoomFactor = zoomFactor*100; //this.application.ninja.stage.zoomFactor = zoomFactor; - if (zoomFactor >= 1) + if (zoomFactor >= 1) { this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = zoomFactor; } - this.application.ninja.stage._firstDraw = false; - //tmp3 = viewUtils.localToGlobal( localPt, userContent ); // DEBUG - remove this line + this.application.ninja.stage._firstDraw = false; + //tmp3 = viewUtils.localToGlobal( localPt, userContent ); // DEBUG - remove this line - // if we are resetting the zoom, clear out the translation from the matrices - if (this._mode === "doubleClickReset") - { - viewUtils.clearStageTranslation(); + // if we are resetting the zoom, clear out the translation from the matrices + if (this._mode === "doubleClickReset") + { + viewUtils.clearStageTranslation(); this.application.ninja.stage.centerStage(); - } + } - // we need to redraw the entire stage after a zoom + // we need to redraw the entire stage after a zoom this.application.ninja.stage.updatedStage = true; - } - }, + } + }, handleToolDoubleClick: { value: function () { @@ -333,12 +333,12 @@ exports.ZoomTool = Montage.create(DrawingTool, { }, RemoveCustomFeedback: { - value: function (event) { + value: function (event) { this.application.ninja.stage.canvas.removeEventListener("mousewheel", this, false); - } - }, + } + }, HandleLeftButtonUp : { value : function(event) { @@ -410,7 +410,7 @@ exports.ZoomTool = Montage.create(DrawingTool, { if(zoomFactor < .25) zoomFactor = .25; - return zoomFactor; + return zoomFactor; } }, -- cgit v1.2.3 From fdbec324dad4ab33d97282ab021d2c1661bc097c Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:27:52 -0700 Subject: BSD License --- js/tools/ZoomTool.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'js/tools/ZoomTool.js') diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 0a3b3593..a285db0f 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- cgit v1.2.3