diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/tools/PanTool.js | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/tools/PanTool.js')
-rwxr-xr-x | js/tools/PanTool.js | 632 |
1 files changed, 316 insertions, 316 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 6b3dbdbb..28e4c04d 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -38,33 +38,33 @@ var Montage = require("montage/core/core").Montage, | |||
38 | 38 | ||
39 | exports.PanTool = Montage.create(toolBase, | 39 | exports.PanTool = Montage.create(toolBase, |
40 | { | 40 | { |
41 | _localPt :{value: [0,0] , writable:true}, | 41 | _localPt :{value: [0,0] , writable:true}, |
42 | _worldPt :{value: [0,0] , writable:true}, | 42 | _worldPt :{value: [0,0] , writable:true}, |
43 | _globalPt :{value: [0,0] , writable:true}, | 43 | _globalPt :{value: [0,0] , writable:true}, |
44 | _globalToUCWorld :{value: [] , writable:true}, | 44 | _globalToUCWorld :{value: [] , writable:true}, |
45 | _lastGPt :{value: [0,0], writable:true}, | 45 | _lastGPt :{value: [0,0], writable:true}, |
46 | _lastY :{value: 0, writable:true}, | 46 | _lastY :{value: 0, writable:true}, |
47 | 47 | ||
48 | _maxHorizontalScroll: {value: 0, writable:true}, | 48 | _maxHorizontalScroll: {value: 0, writable:true}, |
49 | _maxVerticalScroll: {value: 0, writable:true}, | 49 | _maxVerticalScroll: {value: 0, writable:true}, |
50 | 50 | ||
51 | Configure: { | 51 | Configure: { |
52 | value: function ( doActivate ) | 52 | value: function ( doActivate ) |
53 | { | 53 | { |
54 | if (doActivate) | 54 | if (doActivate) |
55 | { | 55 | { |
56 | NJevent("enableStageMove"); | 56 | NJevent("enableStageMove"); |
57 | this.eventManager.addEventListener( "toolDoubleClick", this, false); | 57 | this.eventManager.addEventListener( "toolDoubleClick", this, false); |
58 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); | 58 | this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); |
59 | this.activate(); | 59 | this.activate(); |
60 | } | 60 | } |
61 | else | 61 | else |
62 | { | 62 | { |
63 | NJevent("disableStageMove"); | 63 | NJevent("disableStageMove"); |
64 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); | 64 | this.eventManager.removeEventListener( "toolDoubleClick", this, false); |
65 | this.application.ninja.stage.canvas.removeEventListener("mousewheel", this, false); | 65 | this.application.ninja.stage.canvas.removeEventListener("mousewheel", this, false); |
66 | this.deactivate(); | 66 | this.deactivate(); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | }, | 69 | }, |
70 | 70 | ||
@@ -87,23 +87,23 @@ exports.PanTool = Montage.create(toolBase, | |||
87 | }, | 87 | }, |
88 | 88 | ||
89 | HandleMouseMove: | 89 | HandleMouseMove: |
90 | { | 90 | { |
91 | value : function (event) | 91 | value : function (event) |
92 | { | 92 | { |
93 | this.mouseMove( event ); | 93 | this.mouseMove( event ); |
94 | } | 94 | } |
95 | }, | 95 | }, |
96 | 96 | ||
97 | HandleLeftButtonUp: | 97 | HandleLeftButtonUp: |
98 | { | 98 | { |
99 | value : function ( event ) | 99 | value : function ( event ) |
100 | { | 100 | { |
101 | //if(this._isDrawing) | 101 | //if(this._isDrawing) |
102 | { | 102 | { |
103 | // do one final mouse move to update the scrollbars | 103 | // do one final mouse move to update the scrollbars |
104 | this.mouseUp( event ); | 104 | this.mouseUp( event ); |
105 | 105 | ||
106 | this.application.ninja.stage.clearDrawingCanvas(); | 106 | this.application.ninja.stage.clearDrawingCanvas(); |
107 | this._hasDraw = false; | 107 | this._hasDraw = false; |
108 | this._isDrawing = false; | 108 | this._isDrawing = false; |
109 | this.isDrawing = false; | 109 | this.isDrawing = false; |
@@ -114,248 +114,248 @@ exports.PanTool = Montage.create(toolBase, | |||
114 | HandleKeyPress: { | 114 | HandleKeyPress: { |
115 | value: function(event) { | 115 | value: function(event) { |
116 | if(event.altKey) | 116 | if(event.altKey) |
117 | { | 117 | { |
118 | this._altKeyDown = true; | 118 | this._altKeyDown = true; |
119 | } | 119 | } |
120 | else if (event.shiftKey) | 120 | else if (event.shiftKey) |
121 | { | 121 | { |
122 | if (!this._shiftKeyDown) | 122 | if (!this._shiftKeyDown) |
123 | { | 123 | { |
124 | this._shiftKeyDown = true; | 124 | this._shiftKeyDown = true; |
125 | this._shiftPt = this._lastGPt.slice(); | 125 | this._shiftPt = this._lastGPt.slice(); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | }, | 129 | }, |
130 | 130 | ||
131 | HandleKeyUp: { | 131 | HandleKeyUp: { |
132 | value: function(event) { | 132 | value: function(event) { |
133 | if(event.keyCode === Keyboard.ALT) | 133 | if(event.keyCode === Keyboard.ALT) |
134 | { | 134 | { |
135 | this._altKeyDown = false; | 135 | this._altKeyDown = false; |
136 | } | 136 | } |
137 | else if (event.keyCode === Keyboard.SHIFT) | 137 | else if (event.keyCode === Keyboard.SHIFT) |
138 | { | 138 | { |
139 | this._shiftKeyDown = false; | 139 | this._shiftKeyDown = false; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | }, | 142 | }, |
143 | 143 | ||
144 | handleToolDoubleClick: | 144 | handleToolDoubleClick: |
145 | { | 145 | { |
146 | value: function () | 146 | value: function () |
147 | { | 147 | { |
148 | var uc = this.application.ninja.currentDocument.model.documentRoot; | 148 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
149 | var ucMat = viewUtils.getMatrixFromElement(uc); | 149 | var ucMat = viewUtils.getMatrixFromElement(uc); |
150 | 150 | ||
151 | var noTrans = ucMat.slice(); | 151 | var noTrans = ucMat.slice(); |
152 | noTrans[12] = 0; noTrans[13] = 0; noTrans[14] = 0; | 152 | noTrans[12] = 0; noTrans[13] = 0; noTrans[14] = 0; |
153 | var ucMatInv = glmat4.inverse( ucMat, [] ); | 153 | var ucMatInv = glmat4.inverse( ucMat, [] ); |
154 | var deltaMat = glmat4.multiply( noTrans, ucMatInv, [] ); | 154 | var deltaMat = glmat4.multiply( noTrans, ucMatInv, [] ); |
155 | 155 | ||
156 | this.application.ninja.stage.centerStage(); | 156 | this.application.ninja.stage.centerStage(); |
157 | 157 | ||
158 | this.applyDeltaMat( deltaMat ); | 158 | this.applyDeltaMat( deltaMat ); |
159 | } | 159 | } |
160 | }, | 160 | }, |
161 | 161 | ||
162 | handleMousewheel : | 162 | handleMousewheel : |
163 | { | 163 | { |
164 | value:function(event) | 164 | value:function(event) |
165 | { | 165 | { |
166 | var zoom = this.application.ninja.documentBar.zoomFactor/100.0; | 166 | var zoom = this.application.ninja.documentBar.zoomFactor/100.0; |
167 | if (!zoom) zoom = 1.0; | 167 | if (!zoom) zoom = 1.0; |
168 | 168 | ||
169 | var delta = 0; | 169 | var delta = 0; |
170 | if (event.wheelDelta) | 170 | if (event.wheelDelta) |
171 | delta = 10*event.wheelDelta/120; | 171 | delta = 10*event.wheelDelta/120; |
172 | //console.log( "delta: " + delta ); | 172 | //console.log( "delta: " + delta ); |
173 | 173 | ||
174 | this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; | 174 | this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; |
175 | 175 | ||
176 | delta *= zoom; | 176 | delta *= zoom; |
177 | 177 | ||
178 | var uc = this.application.ninja.currentDocument.model.documentRoot; | 178 | var uc = this.application.ninja.currentDocument.model.documentRoot; |
179 | var ucMat = viewUtils.getMatrixFromElement(uc); | 179 | var ucMat = viewUtils.getMatrixFromElement(uc); |
180 | var offset = viewUtils.getElementOffset( uc ); | 180 | var offset = viewUtils.getElementOffset( uc ); |
181 | //console.log( "uc offset: " + offset[0] ); | 181 | //console.log( "uc offset: " + offset[0] ); |
182 | 182 | ||
183 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( uc ); | 183 | var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( uc ); |
184 | var globalToLocalMat = glmat4.inverse( localToGlobalMat, []); | 184 | var globalToLocalMat = glmat4.inverse( localToGlobalMat, []); |
185 | 185 | ||
186 | var w = uc.offsetWidth, | 186 | var w = uc.offsetWidth, |
187 | h = uc.offsetHeight; | 187 | h = uc.offsetHeight; |
188 | if(uc.width) | 188 | if(uc.width) |
189 | w = uc.width; | 189 | w = uc.width; |
190 | if(uc.height) | 190 | if(uc.height) |
191 | h = uc.height; | 191 | h = uc.height; |
192 | var localPt = [ w/2, h/2, 0]; | 192 | var localPt = [ w/2, h/2, 0]; |
193 | var globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); | 193 | var globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); |
194 | this.doMouseDown( { x:globalPt[0], y:globalPt[1] } ); | 194 | this.doMouseDown( { x:globalPt[0], y:globalPt[1] } ); |
195 | 195 | ||
196 | globalPt[0] += delta; | 196 | globalPt[0] += delta; |
197 | this._isDrawing = true; | 197 | this._isDrawing = true; |
198 | this.doMouseMove( { x:globalPt[0], y:globalPt[1] } ); | 198 | this.doMouseMove( { x:globalPt[0], y:globalPt[1] } ); |
199 | this._isDrawing = false; | 199 | this._isDrawing = false; |
200 | } | 200 | } |
201 | }, | 201 | }, |
202 | 202 | ||
203 | 203 | ||
204 | ///////////////////////////////////////////////////////////////////// | 204 | ///////////////////////////////////////////////////////////////////// |
205 | // Simple tool API | 205 | // Simple tool API |
206 |