aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ZoomTool.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools/ZoomTool.js')
-rwxr-xr-xjs/tools/ZoomTool.js330
1 files changed, 132 insertions, 198 deletions
diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js
index a285db0f..0bcba2a3 100755
--- a/js/tools/ZoomTool.js
+++ b/js/tools/ZoomTool.js
@@ -34,7 +34,6 @@ var Montage = require("montage/core/core").Montage,
34 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, 34 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager,
35 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, 35 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
36 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, 36 vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
37 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
38 DrawingTool = require("js/tools/drawing-tool").DrawingTool; 37 DrawingTool = require("js/tools/drawing-tool").DrawingTool;
39 38
40exports.ZoomTool = Montage.create(DrawingTool, { 39exports.ZoomTool = Montage.create(DrawingTool, {
@@ -53,13 +52,11 @@ exports.ZoomTool = Montage.create(DrawingTool, {
53 52
54 53
55 HandleLeftButtonDown: { 54 HandleLeftButtonDown: {
56 value : function (event) { 55 value: function(event) {
57
58 NJevent("enableStageMove"); 56 NJevent("enableStageMove");
59 this._isDrawing=true; 57 this._isDrawing = true;
60 58
61 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, 59 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
62 new WebKitPoint(event.pageX, event.pageY));
63 this.downPoint.x = point.x; 60 this.downPoint.x = point.x;
64 this.downPoint.y = point.y; 61 this.downPoint.y = point.y;
65 } 62 }
@@ -67,40 +64,36 @@ exports.ZoomTool = Montage.create(DrawingTool, {
67 64
68 HandleAltKeyDown: { 65 HandleAltKeyDown: {
69 value: function(event) { 66 value: function(event) {
70
71 this.setCursor(); 67 this.setCursor();
72 this._altKeyDown=true; 68 this._altKeyDown = true;
73
74 } 69 }
75 }, 70 },
76 71
77 HandleAltKeyUp: { 72 HandleAltKeyUp: {
78 value: function(event) { 73 value: function(event) {
79
80 this.setCursor(); 74 this.setCursor();
81 this._altKeyDown=false; 75 this._altKeyDown = false;
82 } 76 }
83 }, 77 },
84 78
85 HandleEscape: { 79 HandleEscape: {
86 value: function(event) { 80 value: function(event) {
87 this.application.ninja.stage.clearDrawingCanvas(); 81 this.application.ninja.stage.clearDrawingCanvas();
88 this._escPressed=false; 82 this._escPressed = false;
89 } 83 }
90 }, 84 },
91 85
92 Configure: { 86 Configure: {
93 value: function(wasSelected) { 87 value: function(wasSelected) {
94 88 if(this.options.selectedElement === "zoomOutTool") {
95 if(this.options.selectedElement==="zoomOutTool"){
96 var cursor = "url('images/cursors/zoom_minus.png'), default"; 89 var cursor = "url('images/cursors/zoom_minus.png'), default";
97 this.application.ninja.stage.drawingCanvas.style.cursor = cursor; 90 this.application.ninja.stage.drawingCanvas.style.cursor = cursor;
98 } 91 }
99 if(wasSelected) { 92
93 if(wasSelected) {
100 this.AddCustomFeedback(); 94 this.AddCustomFeedback();
101 this.eventManager.addEventListener( "toolDoubleClick", this, false); 95 this.eventManager.addEventListener("toolDoubleClick", this, false);
102 this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); 96 this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false);
103
104 } else { 97 } else {
105 this.RemoveCustomFeedback(); 98 this.RemoveCustomFeedback();
106 this.eventManager.removeEventListener( "toolDoubleClick", this, false); 99 this.eventManager.removeEventListener( "toolDoubleClick", this, false);
@@ -110,87 +103,76 @@ exports.ZoomTool = Montage.create(DrawingTool, {
110 }, 103 },
111 104
112 AddCustomFeedback: { 105 AddCustomFeedback: {
113 value: function (event) { 106 value: function(event) {
114
115 this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); 107 this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false);
116
117 } 108 }
118 }, 109 },
119 110
120 handleScrollValue:{ 111 handleScrollValue: {
121 value:function(){ 112 value: function() {
122
123 this._mode = "mouseWheelZoom"; 113 this._mode = "mouseWheelZoom";
124 this._zoomFactor= this.application.ninja.documentBar.zoomFactor/100; 114 this._zoomFactor = this.application.ninja.documentBar.zoomFactor/100;
125 115
126 if(this._delta > 0){ 116 if(this._delta > 0){
127 this._zoomFactor *= 1.2; 117 this._zoomFactor *= 1.2;
128 } 118 } else{
129 else{
130 this._zoomFactor /= 1.2; 119 this._zoomFactor /= 1.2;
131 } 120 }
121
132 this._zoomFactor = this.checkZoomLimit(this._zoomFactor); 122 this._zoomFactor = this.checkZoomLimit(this._zoomFactor);
133 this._setZoom(this._mode,this._zoomFactor); 123 this._setZoom(this._mode,this._zoomFactor);
134 this._mode="modeReset"; 124 this._mode = "modeReset";
135
136 } 125 }
137 }, 126 },
138 127
139 handleMousewheel :{ 128 handleMousewheel: {
140 value:function(event){ 129 value: function(event) {
141 130 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
142 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
143 new WebKitPoint(event.pageX, event.pageY));
144 this._layerX = point.x; 131 this._layerX = point.x;
145 this._layerY = point.y; 132 this._layerY = point.y;
146 133
147 this._delta = 0; 134 this._delta = 0;
148 135
149 if (event.wheelDelta) { 136 if(event.wheelDelta) {
150 this._delta = event.wheelDelta/120; 137 this._delta = event.wheelDelta/120;
151 } 138 }
152 139
153 if (this._delta){ 140 if(this._delta) {
154 this.handleScrollValue(this._delta); 141 this.handleScrollValue(this._delta);
155 } 142 }
156 143
157 if (event.preventDefault) 144 if(event.preventDefault) {
158 event.preventDefault(); 145 event.preventDefault();
159 event.returnValue = false; 146 }
160 147
148 event.returnValue = false;
161 } 149 }
162 }, 150 },
163 151
164 HandleMouseMove: 152 HandleMouseMove: {
165 { 153 value: function(event) {
166 value : function (event) 154 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY));
167 {
168 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
169 new WebKitPoint(event.pageX, event.pageY));
170 // check for some reasonable amount of mouse movement 155 // check for some reasonable amount of mouse movement
171 var dx = Math.abs(point.x - this.downPoint.x), 156 var dx = Math.abs(point.x - this.downPoint.x),
172 dy = Math.abs(point.y - this.downPoint.y); 157 dy = Math.abs(point.y - this.downPoint.y);
173 158
174 if ((dx >= 10) || (dy >= 10)) 159 if ((dx >= 10) || (dy >= 10)) {
175 {
176 // Drawing the Marquee 160 // Drawing the Marquee
177 if(this.options.selectedElement==="zoomInTool") 161 if(this.options.selectedElement === "zoomInTool") {
178 { 162 if(this._altKeyDown) {
179 if(this._altKeyDown)
180 this._hasDraw=false; 163 this._hasDraw=false;
181 else 164 } else {
182 this._hasDraw = true; 165 this._hasDraw = true;
183 } 166 }
184 else 167 } else {
185 { 168 if(this._altKeyDown) {
186 if(this._altKeyDown)
187 this._hasDraw=true; 169 this._hasDraw=true;
188 else 170 } else {
189 this._hasDraw=false; 171 this._hasDraw=false;
172 }
190 } 173 }
191 174
192 if(this._hasDraw) 175 if(this._hasDraw) {
193 {
194 this.doDraw(event); 176 this.doDraw(event);
195 this._x = this.downPoint.x; 177 this._x = this.downPoint.x;
196 this._y = this.downPoint.y; 178 this._y = this.downPoint.y;
@@ -199,50 +181,36 @@ exports.ZoomTool = Montage.create(DrawingTool, {
199 } 181 }
200 }, 182 },
201 183
202 handleZoomChange: 184 _setZoom: {
203 { 185 value: function(mode,zoomFactor) {
204 value: function(event)
205 {
206 }
207 },
208
209 _setZoom:{
210 value:function(mode,zoomFactor)
211 {
212 var userContent = this.application.ninja.currentDocument.model.documentRoot; 186 var userContent = this.application.ninja.currentDocument.model.documentRoot;
213 this._oldValue = this.application.ninja.documentBar.zoomFactor; 187 this._oldValue = this.application.ninja.documentBar.zoomFactor;
214 188
215 var globalPt; 189 var globalPt, localPt, w, h;
216 if(this._mode==="mouseClickZoom") 190 if(this._mode === "mouseClickZoom") {
217 { 191 if(this.options.selectedElement === "zoomInTool") {
218 if(this.options.selectedElement==="zoomInTool") 192 if(this._altKeyDown) {
219 {
220 if(this._altKeyDown)
221 this._factor = this._oldValue/(zoomFactor*100); 193 this._factor = this._oldValue/(zoomFactor*100);
222