diff options
author | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
commit | e6e539f345f5e1ac36a595db5d1a1c3700715e88 (patch) | |
tree | 39846bf1570f9b5a4057b726c54905de9e9e1c02 /js/tools | |
parent | 7950424cf704bb221971f4645406b01e6979db18 (diff) | |
parent | c630ead20487c3948fa36448d3e7d5f7b5cba782 (diff) | |
download | ninja-e6e539f345f5e1ac36a595db5d1a1c3700715e88.tar.gz |
Merge branch 'master' into components
Conflicts:
node_modules/montage/ui/bluemoon/progress.reel/progress.html
node_modules/montage/ui/image2.reel/image2.html
node_modules/ninja-components/effect/desaturate-effect.js
node_modules/ninja-components/effect/effect.js
node_modules/ninja-components/effect/invert-effect.js
node_modules/ninja-components/effect/kaliedoscope-effect.js
node_modules/ninja-components/effect/multiply-effect.js
node_modules/ninja-components/effect/sepia-effect.js
node_modules/ninja-components/flow-controller.reel/flow-controller.html
node_modules/ninja-components/flow-controller.reel/flow-controller.js
node_modules/ninja-components/flow-offset.js
node_modules/ninja-components/hottext.reel/hottext.css
node_modules/ninja-components/hottext.reel/hottext.html
node_modules/ninja-components/hottext.reel/hottext.js
node_modules/ninja-components/hottextunit.reel/hottextunit.css
node_modules/ninja-components/hottextunit.reel/hottextunit.html
node_modules/ninja-components/hottextunit.reel/hottextunit.js
node_modules/ninja-components/image2.reel/image2.html
node_modules/ninja-components/image2.reel/image2.js
node_modules/ninja-components/image3d.reel/image3d.html
node_modules/ninja-components/image3d.reel/image3d.js
node_modules/ninja-components/photo-editor.reel/photo-editor.css
node_modules/ninja-components/photo-editor.reel/photo-editor.html
node_modules/ninja-components/photo-editor.reel/photo-editor.js
node_modules/ninja-components/slider-base.js
user-document-templates/montage-application-cloud/appdelegate.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/PanTool.js | 33 | ||||
-rw-r--r-- | js/tools/SelectionTool.js | 1 | ||||
-rw-r--r-- | js/tools/ZoomTool.js | 39 | ||||
-rw-r--r-- | js/tools/drawing-tool-base.js | 1 |
4 files changed, 23 insertions, 51 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index ba40b020..71301d46 100644 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -19,6 +19,7 @@ exports.PanTool = Montage.create(toolBase, | |||
19 | _globalPt :{value: [0,0] , writable:true}, | 19 | _globalPt :{value: [0,0] , writable:true}, |
20 | _globalToUCWorld :{value: [] , writable:true}, | 20 | _globalToUCWorld :{value: [] , writable:true}, |
21 | _lastGPt :{value: [0,0], writable:true}, | 21 | _lastGPt :{value: [0,0], writable:true}, |
22 | _lastY :{value: 0, writable:true}, | ||
22 | 23 | ||
23 | Configure: { | 24 | Configure: { |
24 | value: function ( doActivate ) | 25 | value: function ( doActivate ) |
@@ -43,6 +44,7 @@ exports.PanTool = Montage.create(toolBase, | |||
43 | HandleLeftButtonDown: { | 44 | HandleLeftButtonDown: { |
44 | value : function ( event ) { | 45 | value : function ( event ) { |
45 | this._isDrawing = true; | 46 | this._isDrawing = true; |
47 | this.isDrawing = true; | ||
46 | 48 | ||
47 | this.mouseDown( event ); | 49 | this.mouseDown( event ); |
48 | } | 50 | } |
@@ -68,6 +70,7 @@ exports.PanTool = Montage.create(toolBase, | |||
68 | this.application.ninja.stage.clearDrawingCanvas(); | 70 | this.application.ninja.stage.clearDrawingCanvas(); |
69 | this._hasDraw = false; | 71 | this._hasDraw = false; |
70 | this._isDrawing = false; | 72 | this._isDrawing = false; |
73 | this.isDrawing = false; | ||
71 | } | 74 | } |
72 | } | 75 | } |
73 | }, | 76 | }, |
@@ -77,7 +80,6 @@ exports.PanTool = Montage.create(toolBase, | |||
77 | if(event.altKey) | 80 | if(event.altKey) |
78 | { | 81 | { |
79 | this._altKeyDown = true; | 82 | this._altKeyDown = true; |
80 | //console.log( "altKeyDown" ); | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | }, | 85 | }, |
@@ -87,7 +89,6 @@ exports.PanTool = Montage.create(toolBase, | |||
87 | if(event.keyCode === Keyboard.ALT) | 89 | if(event.keyCode === Keyboard.ALT) |
88 | { | 90 | { |
89 | this._altKeyDown = false; | 91 | this._altKeyDown = false; |
90 | console.log( "altKeyUp" ); | ||
91 | } | 92 | } |
92 | } | 93 | } |
93 | }, | 94 | }, |
@@ -220,6 +221,7 @@ exports.PanTool = Montage.create(toolBase, | |||
220 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); | 221 | var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); |
221 | 222 | ||
222 | this._lastGPt = this._globalPt.slice(); | 223 | this._lastGPt = this._globalPt.slice(); |
224 | this._lastY = this._lastGPt[1]; | ||
223 | 225 | ||
224 | // set up the matrices we will be needing | 226 | // set up the matrices we will be needing |
225 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); | 227 | var eltToStageWorldMat = glmat4.multiply( ucMat, viewUtils.getObjToStageWorldMatrix(elt, true), []); |
@@ -275,14 +277,19 @@ exports.PanTool = Montage.create(toolBase, | |||
275 | { | 277 | { |
276 | if (this._isDrawing) | 278 | if (this._isDrawing) |
277 | { | 279 | { |
278 | //console.log( "PanTool.mouseMove (drag)" ); | ||
279 | |||
280 | // get the global screen point | 280 | // get the global screen point |
281 | var gPt = [point.x, point.y, this._globalPt[2]]; | 281 | var gPt = [point.x, point.y, this._globalPt[2]]; |
282 | if (this._altKeyDown) | ||
283 | { | ||
284 | var dy = 5*(point.y - this._lastY); | ||
285 | this._globalPt[2] += dy; | ||
286 | gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; | ||
287 | } | ||
282 | 288 | ||
283 | // update the scrollbars | 289 | // update the scrollbars |
284 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); | 290 | var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); |
285 | this._lastGPt = gPt.slice(); | 291 | this._lastGPt = gPt.slice(); |
292 | this._lastY = point.y; | ||
286 | 293 | ||
287 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, | 294 | var oldLeft = this.application.ninja.stage._iframeContainer.scrollLeft, |
288 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; | 295 | oldTop = this.application.ninja.stage._iframeContainer.scrollTop; |
@@ -297,27 +304,13 @@ exports.PanTool = Montage.create(toolBase, | |||
297 | this.updateGlobalToUCWorldMatrix(); | 304 | this.updateGlobalToUCWorldMatrix(); |
298 | 305 | ||
299 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); | 306 | var wPt = MathUtils.transformAndDivideHomogeneousPoint( gPt, this._globalToUCWorld ); |
300 | //console.log( "wPt: " + wPt ); | ||
301 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); | 307 | var delta = vecUtils.vecSubtract( 3, wPt, this._worldPt ); |
302 | if (this._altKeyDown) | 308 | |
303 | { | 309 | if (!this._altKeyDown) |
304 | //console.log( "moveZ" ); | ||
305 | var dist = vecUtils.vecMag(2, delta); | ||
306 | delta[0] = 0; delta[1] = 0; delta[2] = dist; | ||
307 | var dy = point.y - this._globalPt[1]; | ||
308 | if (dy < 0) delta[2] = -delta[2]; | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | console.log( "NOT MOVING Z" ); | ||
313 | delta[2] = 0; | 310 | delta[2] = 0; |
314 | } | ||
315 | var transMat = Matrix.Translation( delta ); | 311 | var transMat = Matrix.Translation( delta ); |
316 | this._worldPt = wPt; | 312 | this._worldPt = wPt; |
317 | 313 | ||
318 | if (this._altKeyDown) | ||
319 | this._globalPt[1] = point.y; | ||
320 | |||
321 | // update everything | 314 | // update everything |
322 | this.applyDeltaMat( transMat ); | 315 | this.applyDeltaMat( transMat ); |
323 | } | 316 | } |
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 5f2a959f..862b2e88 100644 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -180,7 +180,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
180 | this._handleMode = null; | 180 | this._handleMode = null; |
181 | this._delta = null; | 181 | this._delta = null; |
182 | this.DrawHandles(); | 182 | this.DrawHandles(); |
183 | console.log( "move: (" + dx + ", " + dy + ")" ); | ||
184 | } | 183 | } |
185 | 184 | ||
186 | this.endDraw(event); | 185 | this.endDraw(event); |
diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index cabf3a3d..4b6705c1 100644 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js | |||
@@ -74,10 +74,12 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
74 | if(wasSelected) { | 74 | if(wasSelected) { |
75 | this.AddCustomFeedback(); | 75 | this.AddCustomFeedback(); |
76 | this.eventManager.addEventListener( "toolDoubleClick", this, false); | 76 | this.eventManager.addEventListener( "toolDoubleClick", this, false); |
77 | this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); | ||
77 | 78 | ||
78 | } else { | 79 | } else { |
79 | this.RemoveCustomFeedback(); | 80 | this.RemoveCustomFeedback(); |
80 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 81 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
82 | this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false); | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | }, | 85 | }, |
@@ -138,9 +140,11 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
138 | { | 140 | { |
139 | value : function (event) | 141 | value : function (event) |
140 | { | 142 | { |
141 | // check for some reasonable amount of mouse movement | 143 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, |
142 | var dx = Math.abs(event.layerX - this.downPoint.x), | 144 | new WebKitPoint(event.pageX, event.pageY)); |
143 | dy = Math.abs(event.layerY - this.downPoint.y); | 145 | // check for some reasonable amount of mouse movement |
146 | var dx = Math.abs(point.x - this.downPoint.x), | ||
147 | dy = Math.abs(point.y - this.downPoint.y); | ||
144 | 148 | ||
145 | if ((dx >= 4) || (dy >= 4)) | 149 | if ((dx >= 4) || (dy >= 4)) |
146 | { | 150 | { |
@@ -238,19 +242,6 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
238 | var p1 = [this._layerX, this._layerY, 0]; | 242 | var p1 = [this._layerX, this._layerY, 0]; |
239 | globalPt = vecUtils.vecAdd(3, p0, p1); | 243 | globalPt = vecUtils.vecAdd(3, p0, p1); |
240 | vecUtils.vecScale(3, globalPt, 0.5); | 244 | vecUtils.vecScale(3, globalPt, 0.5); |
241 | |||
242 | var hitRec = snapManager.snap( globalPt[0], globalPt[1], true ); | ||
243 | if (hitRec) | ||
244 | { | ||
245 | var elt = hitRec.getElement(); | ||
246 | if (elt) | ||
247 | { | ||
248 | // console.log( "hit: " + hitRec.getElement().id ); | ||
249 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); | ||
250 | var localPt = hitRec.calculateElementPreTransformScreenPoint(); | ||
251 | globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); | ||
252 | } | ||
253 | } | ||
254 | } | 245 | } |
255 | else if (this._mode === "doubleClickReset") | 246 | else if (this._mode === "doubleClickReset") |
256 | { | 247 | { |
@@ -270,19 +261,9 @@ exports.ZoomTool = Montage.create(DrawingTool, { | |||
270 | } | 261 | } |
271 | else if (this._mode === "mouseWheelZoom") | 262 | else if (this._mode === "mouseWheelZoom") |
272 | { | 263 | { |
273 | if (userContent) | 264 | var w = this.application.ninja.stage._canvas.width, |
274 | { | 265 | h = this.application.ninja.stage._canvas.height; |
275 | var w = userContent.offsetWidth, | 266 | globalPt = [w/2, h/2, 0]; |
276 | h = userContent.offsetHeight; | ||
277 | if(userContent.width) | ||
278 | w = userContent.width; | ||
279 | if(userContent.height) | ||
280 | h = userContent.height; | ||
281 | var localPt = [ w/2, h/2, 0]; | ||
282 | globalPt = viewUtils.localToGlobal( localPt, userContent ); | ||
283 | } | ||
284 | else | ||
285 | globalPt = [0,0,0]; | ||
286 | } |