diff options
author | Kris Kowal | 2012-07-06 11:52:06 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:48 -0700 |
commit | 648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch) | |
tree | 8f0f55557bd0c47a84e49c1977c950645d284607 /js/tools/ZoomTool.js | |
parent | aedd14b18695d031f695d27dfbd94df5614495bb (diff) | |
download | ninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz |
Expand tabs
Diffstat (limited to 'js/tools/ZoomTool.js')
-rwxr-xr-x | js/tools/ZoomTool.js | 314 |
1 files changed, 157 insertions, 157 deletions
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, { | |||
65 | }, | 65 | }, |
66 | 66 | ||
67 | HandleAltKeyDown: { | 67 | HandleAltKeyDown: { |
68 | value: function(event) { | 68 | value: function(event) { |
69 | 69 | ||
70 | this.setCursor(); | 70 | this.setCursor(); |
71 | this._altKeyDown=true; | 71 | this._altKeyDown=true; |
72 | 72 | ||
73 | } | 73 | } |
74 | }, | 74 | }, |
75 | 75 | ||
76 | HandleAltKeyUp: { | 76 | HandleAltKeyUp: { |
77 | value: function(event) { | 77 | value: function(event) { |
78 | 78 | ||
79 | this.setCursor(); | 79 | this.setCursor(); |
80 | this._altKeyDown=false; | 80 | this._altKeyDown=false; |
81 | } | 81 | } |
82 | }, | 82 | }, |
83 | 83 | ||
84 | HandleEscape: { | 84 | HandleEscape: { |
85 | value: function(event) { | 85 | value: function(event) { |
@@ -98,23 +98,23 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
98 | if(wasSelected) { | 98 | if(wasSelected) { |
99 | this.AddCustomFeedback(); | 99 | this.AddCustomFeedback(); |
100 | this.eventManager.addEventListener( "toolDoubleClick", this, false); | 100 | this.eventManager.addEventListener( "toolDoubleClick", this, false); |
101 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); | 101 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); |
102 | 102 | ||
103 | } else { | 103 | } else { |
104 | this.RemoveCustomFeedback(); | 104 | this.RemoveCustomFeedback(); |
105 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 105 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
106 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); | 106 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | }, | 109 | }, |
110 | 110 | ||
111 | AddCustomFeedback: { | 111 | AddCustomFeedback: { |
112 | value: function (event) { | 112 | value: function (event) { |
113 | 113 | ||
114 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); | 114 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); |
115 | 115 | ||
116 | } | 116 | } |
117 | }, | 117 | }, |
118 | 118 | ||
119 | handleScrollValue:{ | 119 | handleScrollValue:{ |
120 | value:function(){ | 120 | value:function(){ |
@@ -160,167 +160,167 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
160 | } | 160 | } |
161 | }, | 161 | }, |
162 | 162 | ||
163 | HandleMouseMove: | 163 | HandleMouseMove: |
164 | { | 164 | { |
165 | value : function (event) | 165 | value : function (event) |
166 | { | 166 | { |
167 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, | 167 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, |
168 | new WebKitPoint(event.pageX, event.pageY)); | 168 | new WebKitPoint(event.pageX, event.pageY)); |
169 | // check for some reasonable amount of mouse movement | 169 | // check for some reasonable amount of mouse movement |
170 | var dx = Math.abs(point.x - this.downPoint.x), | 170 | var dx = Math.abs(point.x - this.downPoint.x), |
171 | dy = Math.abs(point.y - this.downPoint.y); | 171 | dy = Math.abs(point.y - this.downPoint.y); |
172 | 172 | ||
173 | if ((dx >= 10) || (dy >= 10)) | 173 | if ((dx >= 10) || (dy >= 10)) |
174 | { | 174 | { |
175 | // Drawing the Marquee | 175 | // Drawing the Marquee |
176 | if(this.options.selectedElement==="zoomInTool") | 176 | if(this.options.selectedElement==="zoomInTool") |
177 | { | 177 | { |
178 | if(this._altKeyDown) | 178 | if(this._altKeyDown) |
179 | this._hasDraw=false; | 179 | this._hasDraw=false; |
180 | else | 180 | else |
181 | this._hasDraw = true; | 181 | this._hasDraw = true; |
182 | } | 182 | } |
183 | else | 183 | else |
184 | { | 184 | { |
185 | if(this._altKeyDown) | 185 | if(this._altKeyDown) |
186 | this._hasDraw=true; | 186 | this._hasDraw=true; |
187 | else | 187 | else |
188 | this._hasDraw=false; | 188 | this._hasDraw=false; |
189 | } | 189 | } |
190 | 190 | ||
191 | if(this._hasDraw) | 191 | if(this._hasDraw) |
192 | { | 192 | { |
193 | this.doDraw(event); | 193 | this.doDraw(event); |
194 | this._x = this.downPoint.x; | 194 | this._x = this.downPoint.x; |
195 | this._y = this.downPoint.y; | 195 | this._y = this.downPoint.y; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | }, | 199 | }, |
200 | 200 | ||
201 | handleZoomChange: | 201 | handleZoomChange: |
202 | { | 202 | { |
203 | value: function(event) | 203 | value: function(event) |
204 | { | 204 | { |
205 | } | 205 | } |
206 | }, | 206 | }, |
207 | 207 | ||
208 | _setZoom:{ | 208 | _setZoom:{ |
209 | value:function(mode,zoomFactor) | 209 | value:function(mode,zoomFactor) |
210 | { | 210 | { |
211 | var userContent = this.application.ninja.currentDocument.model.documentRoot; | 211 | var userContent = this.application.ninja.currentDocument.model.documentRoot; |
212 | this._oldValue = this.application.ninja.documentBar.zoomFactor; | 212 | this._oldValue = this.application.ninja.documentBar.zoomFactor; |
213 | 213 | ||
214 | var globalPt; | 214 | var globalPt; |
215 | if(this._mode==="mouseClickZoom") | 215 | if(this._mode==="mouseClickZoom") |
216 | { | 216 | { |
217 | if(this.options.selectedElement==="zoomInTool") | 217 | if(this.options.selectedElement==="zoomInTool") |
218 | { | 218 | { |
219 | if(this._altKeyDown) | 219 | if(this._altKeyDown) |
220 | this._factor = this._oldValue/(zoomFactor*100); | 220 | this._factor = this._oldValue/(zoomFactor*100); |
221 | else | 221 | else |
222 | this._factor = (zoomFactor*100)/this._oldValue; | 222 | this._factor = (zoomFactor*100)/this._oldValue; |
223 | } | 223 | } |
224 | else | 224 | else |
225 | { | 225 | { |
226 | if(this._altKeyDown) | 226 | if(this._altKeyDown) |
227 | this._factor = (zoomFactor*100)/this._oldValue; | 227 | this._factor = (zoomFactor*100)/this._oldValue; |
228 | else | 228 | else |
229 | this._factor = this._oldValue/(zoomFactor*100); | 229 | this._factor = this._oldValue/(zoomFactor*100); |
230 | } | 230 | } |
231 | 231 | ||
232 | var hitRec = snapManager.snap( this._layerX, this._layerY, true ); | 232 | var hitRec = snapManager.snap( this._layerX, this._layerY, true ); |
233 | if (hitRec) | 233 | if (hitRec) |
234 | { | 234 | { |
235 | var elt = hitRec.getElement(); | 235 | var elt = hitRec.getElement(); |
236 | if (elt) | 236 | if (elt) |
237 | { | 237 | { |
238 | // console.log( "hit: " + hitRec.getElement().id ); | 238 | // console.log( "hit: " + hitRec.getElement().id ); |
239 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); | 239 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); |
240 | var localPt; | 240 | var localPt; |
241 | if (elt != userContent) | 241 | if (elt != userContent) |
242 | localPt = hitRec.calculateElementPreTransformScreenPoint(); | 242 | localPt = hitRec.calculateElementPreTransformScreenPoint(); |
243 | else | 243 | else |
244 | { | 244 | { |
245 | localPt = hitRec.calculateElementWorldPoint(); | 245 | localPt = hitRec.calculateElementWorldPoint(); |
246 | viewUtils.pushViewportObj( userContent ); | 246 | viewUtils.pushViewportObj( userContent ); |
247 | var cop = viewUtils.getCenterOfProjection(); | 247 | var cop = viewUtils.getCenterOfProjection(); |
248 | this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; | 248 | this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; |
249 | localPt = this._localPt.slice(); | 249 | localPt = this._localPt.slice(); |
250 | viewUtils.popViewportObj(); | 250 | viewUtils.popViewportObj(); |
251 | } | 251 | } |
252 | 252 | ||
253 | globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); | 253 | globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); |
254 | } | 254 | } |
255 | else | 255 | else |
256 | globalPt = [this._layerX, this._layerY, 0]; | 256 | globalPt = [this._layerX, this._layerY, 0]; |
257 | } | 257 | } |
258 | else | 258 | else |
259 | globalPt = [this._layerX, this._layerY, 0]; | 259 | globalPt = [this._layerX, this._layerY, 0]; |
260 | } | 260 | } |
261 | else if (this._mode==="marqueeZoom") | 261 | else if (this._mode==="marqueeZoom") |
262 | { | 262 | { |
263 | this._factor = (zoomFactor*100)/this._oldValue; |