aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ZoomTool.js
diff options
context:
space:
mode:
authorJonathan Duran2012-07-17 09:30:22 -0700
committerJonathan Duran2012-07-17 09:30:22 -0700
commit53051672a62208fbc96957719d8285fac6431ed6 (patch)
tree79d542ee811044e8af2ef84aa0d6662c6eb895c4 /js/tools/ZoomTool.js
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parent5146f224258929415adf4a8022e492454b4e2476 (diff)
downloadninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts: js/panels/Timeline/DragDrop.js js/panels/Timeline/Keyframe.reel/Keyframe.js js/panels/Timeline/Layer.reel/Layer.js js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js js/panels/Timeline/Span.reel/Span.js js/panels/Timeline/Style.reel/Style.js js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js js/panels/Timeline/Track.reel/Track.html js/panels/Timeline/Track.reel/Track.js js/panels/Timeline/Track.reel/css/Track.css js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css js/panels/Timeline/Tween.reel/Tween.js Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/tools/ZoomTool.js')
-rwxr-xr-xjs/tools/ZoomTool.js337
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>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, 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
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE 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 {