diff options
author | Armen Kesablyan | 2012-02-07 16:51:14 -0800 |
---|---|---|
committer | Armen Kesablyan | 2012-02-07 16:51:14 -0800 |
commit | 8110e01dc5093ac6baf621103dcaa5f769e5be92 (patch) | |
tree | ecf339e3097b6ba25d81cbe44d913ee67591bf4b /js/tools | |
parent | 5f506542d28e12b707c3bfa41b53383519838477 (diff) | |
parent | 668510892537eaaeb2e11520831d87b44b2489b7 (diff) | |
download | ninja-8110e01dc5093ac6baf621103dcaa5f769e5be92.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/FillTool.js | 20 | ||||
-rw-r--r-- | js/tools/LineTool.js | 5 | ||||
-rw-r--r-- | js/tools/OvalTool.js | 8 | ||||
-rw-r--r-- | js/tools/PanTool.js | 33 | ||||
-rw-r--r-- | js/tools/RectTool.js | 8 | ||||
-rw-r--r-- | js/tools/SelectionTool.js | 1 | ||||
-rw-r--r-- | js/tools/ShapeTool.js | 1 | ||||
-rw-r--r-- | js/tools/ZoomTool.js | 39 | ||||
-rw-r--r-- | js/tools/drawing-tool-base.js | 1 |
9 files changed, 62 insertions, 54 deletions
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 477966da..fabcec69 100644 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js | |||
@@ -54,10 +54,24 @@ exports.FillTool = Montage.create(ModifierToolBase, { | |||
54 | value: function(event) { | 54 | value: function(event) { |
55 | this.isDrawing = true; | 55 | this.isDrawing = true; |
56 | 56 | ||
57 | if(this._canColor) | 57 | if(this._canColor && this.application.ninja.selectedElements.length) |
58 | { | 58 | { |
59 | var color = this.application.ninja.colorController.colorToolbar.fill; | 59 | var color = this.application.ninja.colorController.colorToolbar.fill, |
60 | ElementsMediator.setColor(this.application.ninja.selectedElements, color, true, "Change", "fillTool"); | 60 | colorInfo; |
61 | if(color && color.color) | ||
62 | { | ||
63 | colorInfo = { mode:color.colorMode, | ||
64 | color:color.color | ||
65 | }; | ||
66 | ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | colorInfo = { mode:"nocolor", | ||
71 | color:color.color | ||
72 | }; | ||
73 | ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); | ||
74 | } | ||
61 | } | 75 | } |
62 | } | 76 | } |
63 | } | 77 | } |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 042ba0b2..17157f23 100644 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -99,6 +99,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
99 | } | 99 | } |
100 | this.RenderShape(w, h, drawData.planeMat, drawData.midPt, | 100 | this.RenderShape(w, h, drawData.planeMat, drawData.midPt, |
101 | canvas, slope, xAdj, yAdj); | 101 | canvas, slope, xAdj, yAdj); |
102 | NJevent("elementAdded", canvas); | ||
102 | } | 103 | } |
103 | 104 | ||
104 | this.endDraw(event); | 105 | this.endDraw(event); |
@@ -225,6 +226,10 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
225 | canvas.elementModel.pi = "LinePi"; | 226 | canvas.elementModel.pi = "LinePi"; |
226 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; | 227 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; |
227 | canvas.elementModel.shapeModel.stroke = strokeColor; | 228 | canvas.elementModel.shapeModel.stroke = strokeColor; |
229 | if(strokeColor) | ||
230 | { | ||
231 | canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; | ||
232 | } | ||
228 | 233 | ||
229 | canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; | 234 | canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial; |
230 | canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex; | 235 | canvas.elementModel.shapeModel.strokeMaterialIndex = strokeIndex; |
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index e0f1f03f..2fa5411b 100644 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -75,6 +75,14 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
75 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; | 75 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; |
76 | canvas.elementModel.shapeModel.stroke = strokeColor; | 76 | canvas.elementModel.shapeModel.stroke = strokeColor; |
77 | canvas.elementModel.shapeModel.fill = fillColor; | 77 | canvas.elementModel.shapeModel.fill = fillColor; |
78 | if(strokeColor) | ||
79 | { | ||
80 | canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; | ||
81 | } | ||
82 | if(fillColor) | ||
83 | { | ||
84 | canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill; | ||
85 | } | ||
78 | 86 | ||
79 | canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units; | 87 | canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units; |
80 | 88 | ||
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/RectTool.js b/js/tools/RectTool.js index fbf1693e..94d80b53 100644 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js | |||
@@ -94,6 +94,14 @@ exports.RectTool = Montage.create(ShapeTool, { | |||
94 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; | 94 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; |
95 | canvas.elementModel.shapeModel.stroke = strokeColor; | 95 | canvas.elementModel.shapeModel.stroke = strokeColor; |
96 | canvas.elementModel.shapeModel.fill = fillColor; | 96 | canvas.elementModel.shapeModel.fill = fillColor; |
97 | if(strokeColor) | ||
98 | { | ||
99 | canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke; | ||
100 | } | ||
101 | if(fillColor) | ||