diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/tools/ZoomTool.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/tools/ZoomTool.js')
-rwxr-xr-x | js/tools/ZoomTool.js | 337 |
1 files changed, 169 insertions, 168 deletions
diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index 14ef0f1a..a285db0f 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -65,21 +66,21 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
65 | }, | 66 | }, |
66 | 67 | ||
67 | HandleAltKeyDown: { | 68 | HandleAltKeyDown: { |
68 | value: function(event) { | 69 | value: function(event) { |
69 | 70 | ||
70 | this.setCursor(); | 71 | this.setCursor(); |
71 | this._altKeyDown=true; | 72 | this._altKeyDown=true; |
72 | 73 | ||
73 | } | 74 | } |
74 | }, | 75 | }, |
75 | 76 | ||
76 | HandleAltKeyUp: { | 77 | HandleAltKeyUp: { |
77 | value: function(event) { | 78 | value: function(event) { |
78 | 79 | ||
79 | this.setCursor(); | 80 | this.setCursor(); |
80 | this._altKeyDown=false; | 81 | this._altKeyDown=false; |
81 | } | 82 | } |
82 | }, | 83 | }, |
83 | 84 | ||
84 | HandleEscape: { | 85 | HandleEscape: { |
85 | value: function(event) { | 86 | value: function(event) { |
@@ -98,23 +99,23 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
98 | if(wasSelected) { | 99 | if(wasSelected) { |
99 | this.AddCustomFeedback(); | 100 | this.AddCustomFeedback(); |
100 | this.eventManager.addEventListener( "toolDoubleClick", this, false); | 101 | this.eventManager.addEventListener( "toolDoubleClick", this, false); |
101 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); | 102 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); |
102 | 103 | ||
103 | } else { | 104 | } else { |
104 | this.RemoveCustomFeedback(); | 105 | this.RemoveCustomFeedback(); |
105 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 106 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
106 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); | 107 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); |
107 | } | 108 | } |
108 | } | 109 | } |
109 | }, | 110 | }, |
110 | 111 | ||
111 | AddCustomFeedback: { | 112 | AddCustomFeedback: { |
112 | value: function (event) { | 113 | value: function (event) { |
113 | 114 | ||
114 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); | 115 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); |
115 | 116 | ||
116 | } | 117 | } |
117 | }, | 118 | }, |
118 | 119 | ||
119 | handleScrollValue:{ | 120 | handleScrollValue:{ |
120 | value:function(){ | 121 | value:function(){ |
@@ -160,167 +161,167 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
160 | } | 161 | } |
161 | }, | 162 | }, |
162 | 163 | ||
163 | HandleMouseMove: | 164 | HandleMouseMove: |
164 | { | 165 | { |
165 | value : function (event) | 166 | value : function (event) |
166 | { | 167 | { |
167 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, | 168 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, |
168 | new WebKitPoint(event.pageX, event.pageY)); | 169 | new WebKitPoint(event.pageX, event.pageY)); |
169 | // check for some reasonable amount of mouse movement | 170 | // check for some reasonable amount of mouse movement |
170 | var dx = Math.abs(point.x - this.downPoint.x), | 171 | var dx = Math.abs(point.x - this.downPoint.x), |
171 | dy = Math.abs(point.y - this.downPoint.y); | 172 | dy = Math.abs(point.y - this.downPoint.y); |
172 | 173 | ||
173 | if ((dx >= 10) || (dy >= 10)) | 174 | if ((dx >= 10) || (dy >= 10)) |
174 | { | 175 | { |
175 | // Drawing the Marquee | 176 | // Drawing the Marquee |
176 | if(this.options.selectedElement==="zoomInTool") | 177 | if(this.options.selectedElement==="zoomInTool") |
177 | { | 178 | { |
178 | if(this._altKeyDown) | 179 | if(this._altKeyDown) |
179 | this._hasDraw=false; | 180 | this._hasDraw=false; |
180 | else | 181 | else |
181 | this._hasDraw = true; | 182 | this._hasDraw = true; |
182 | } | 183 | } |
183 | else | 184 | else |
184 | { | 185 | { |
185 | if(this._altKeyDown) | 186 | if(this._altKeyDown) |
186 | this._hasDraw=true; | 187 | this._hasDraw=true; |
187 | else | 188 | else |
188 | this._hasDraw=false; | 189 | this._hasDraw=false; |
189 | } | 190 | } |
190 | 191 | ||
191 | if(this._hasDraw) | 192 | if(this._hasDraw) |
192 | { | 193 | { |
193 | this.doDraw(event); | 194 | this.doDraw(event); |
194 | this._x = this.downPoint.x; | 195 | this._x = this.downPoint.x; |
195 | this._y = this.downPoint.y; | 196 | this._y = this.downPoint.y; |
196 | } | 197 | } |
197 | } | 198 | } |
198 | } | 199 | } |
199 | }, | 200 | }, |
200 | 201 | ||
201 | handleZoomChange: | 202 | handleZoomChange: |
202 | { | 203 | { |
203 | value: function(event) | 204 | value: function(event) |
204 | { | 205 | { |
205 | } | 206 | } |
206 | }, | 207 | }, |
207 | 208 | ||
208 | _setZoom:{ | 209 | _setZoom:{ |
209 | value:function(mode,zoomFactor) | 210 | value:function(mode,zoomFactor) |
210 | { | 211 | { |
211 | var userContent = this.application.ninja.currentDocument.model.documentRoot; | 212 | var userContent = this.application.ninja.currentDocument.model.documentRoot; |
212 | this._oldValue = this.application.ninja.documentBar.zoomFactor; | 213 | this._oldValue = this.application.ninja.documentBar.zoomFactor; |
213 | 214 | ||
214 | var globalPt; | 215 | var globalPt; |
215 | if(this._mode==="mouseClickZoom") | 216 | if(this._mode==="mouseClickZoom") |
216 | { | 217 | { |
217 | if(this.options.selectedElement==="zoomInTool") | 218 | if(this.options.selectedElement==="zoomInTool") |
218 | { | 219 | { |
219 | if(this._altKeyDown) | 220 | if(this._altKeyDown) |
220 | this._factor = this._oldValue/(zoomFactor*100); | 221 | this._factor = this._oldValue/(zoomFactor*100); |
221 | else | 222 | else |
222 | this._factor = (zoomFactor*100)/this._oldValue; | 223 | this._factor = (zoomFactor*100)/this._oldValue; |
223 | } | 224 | } |
224 | else | 225 | else |
225 | { | 226 | { |
226 | if(this._altKeyDown) | 227 | if(this._altKeyDown) |
227 | this._factor = (zoomFactor*100)/this._oldValue; | 228 | this._factor = (zoomFactor*100)/this._oldValue; |
228 | else | 229 | else |
229 | this._factor = this._oldValue/(zoomFactor*100); | 230 | this._factor = this._oldValue/(zoomFactor*100); |
230 | } | 231 | } |
231 | 232 | ||
232 | var hitRec = snapManager.snap( this._layerX, this._layerY, true ); | 233 | var hitRec = snapManager.snap( this._layerX, this._layerY, true ); |
233 | if (hitRec) | 234 | if (hitRec) |
234 | { | 235 | { |
235 | var elt = hitRec.getElement(); | 236 | var elt = hitRec.getElement(); |
236 | if (elt) | 237 | if (elt) |
237 | { | 238 | { |
238 | // console.log( "hit: " + hitRec.getElement().id ); | 239 |