diff options
author | Pushkar Joshi | 2012-05-22 13:22:26 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-22 13:22:26 -0700 |
commit | 01dbc1f329a95bc7e3b93224543d88ad5bdbd315 (patch) | |
tree | ceb527713554f506c537168e36a10452cd09ad10 /js/tools | |
parent | b9262c831952e77135b79c2de7c455d5e7ff0589 (diff) | |
parent | c37a876b373ddc7cb19277aaeaa6bb2d2d5a50ac (diff) | |
download | ninja-01dbc1f329a95bc7e3b93224543d88ad5bdbd315.tar.gz |
Merge branch 'master' into brushtool
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 12 | ||||
-rwxr-xr-x | js/tools/EyedropperTool.js | 3 | ||||
-rwxr-xr-x | js/tools/FillTool.js | 7 | ||||
-rwxr-xr-x | js/tools/InkBottleTool.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 20 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 8 | ||||
-rwxr-xr-x | js/tools/PanTool.js | 20 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 17 | ||||
-rwxr-xr-x | js/tools/PencilTool.js | 32 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 6 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 18 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 8 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 73 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 219 | ||||
-rwxr-xr-x | js/tools/TextTool.js | 40 | ||||
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 9 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 87 | ||||
-rwxr-xr-x | js/tools/drawing-tool.js | 3 |
18 files changed, 195 insertions, 389 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 1666d311..03edef79 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -132,7 +132,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
132 | if (this._selectedBrushStroke === null){ | 132 | if (this._selectedBrushStroke === null){ |
133 | this._selectedBrushStroke = new BrushStroke(); | 133 | this._selectedBrushStroke = new BrushStroke(); |
134 | var colorArray=[0,0,0,0]; | 134 | var colorArray=[0,0,0,0]; |
135 | var color = this.application.ninja.colorController.colorToolbar.fill.color; | 135 | var color = this.options.fill.color; |
136 | if (color){ | 136 | if (color){ |
137 | colorArray = [color.r/255, color.g/255, color.b/255, color.a]; | 137 | colorArray = [color.r/255, color.g/255, color.b/255, color.a]; |
138 | } else { | 138 | } else { |
@@ -376,13 +376,11 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | 378 | ||
379 | var left = Math.round(midPt[0] - 0.5 * w); | ||
380 | var top = Math.round(midPt[1] - 0.5 * h); | ||
381 | |||
382 | if (!canvas) { | 379 | if (!canvas) { |
383 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 380 | var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
384 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, true); | 381 | document.application.njUtils.createModelWithShape(newCanvas, "Brushstroke"); |
385 | ElementMediator.addElements(newCanvas, elementModel.data, false); | 382 | var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); |
383 | this.application.ninja.elementMediator.addElements(newCanvas, styles, false); | ||
386 | 384 | ||
387 | // create all the GL stuff | 385 | // create all the GL stuff |
388 | var world = this.getGLWorld(newCanvas, this._useWebGL); | 386 | var world = this.getGLWorld(newCanvas, this._useWebGL); |
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 346975b2..6678e498 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js | |||
@@ -375,7 +375,8 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
375 | var worldData = elt.elementModel.shapeModel.GLWorld.exportJSON(); | 375 | var worldData = elt.elementModel.shapeModel.GLWorld.exportJSON(); |
376 | if(worldData) | 376 | if(worldData) |
377 | { | 377 | { |
378 | this._webGlDataCanvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, true); | 378 | this._webGlDataCanvas = njModule.NJUtils.make("canvas", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
379 | njModule.NJUtils.createModelWithShape(this._webGlDataCanvas, "Canvas"); | ||
379 | this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", | 380 | this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", |
380 | "-webkit-transform", "-webkit-transform-style"]); | 381 | "-webkit-transform", "-webkit-transform-style"]); |
381 | this._webGlDataCanvas.style.left = eltCoords[0] + "px"; | 382 | this._webGlDataCanvas.style.left = eltCoords[0] + "px"; |
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 87a093ff..66dd9305 100755 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js | |||
@@ -72,9 +72,9 @@ exports.FillTool = Montage.create(ModifierToolBase, { | |||
72 | value: function(event) { | 72 | value: function(event) { |
73 | this.isDrawing = true; | 73 | this.isDrawing = true; |
74 | 74 | ||
75 | if(this._canColor && this.application.ninja.selectedElements.length) | 75 | if(this._canColor && this.application.ninja.selectedElements.length) { |
76 | { | 76 | |
77 | var color = this.application.ninja.colorController.colorToolbar.fill, | 77 | var color = this.options.fill, |
78 | colorInfo; | 78 | colorInfo; |
79 | if(color && color.color) | 79 | if(color && color.color) |
80 | { | 80 | { |
@@ -92,5 +92,4 @@ exports.FillTool = Montage.create(ModifierToolBase, { | |||
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | |||
96 | }); \ No newline at end of file | 95 | }); \ No newline at end of file |
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index fd17f4d6..2c03d133 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js | |||
@@ -69,7 +69,7 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { | |||
69 | 69 | ||
70 | if(this._canColor && this.application.ninja.selectedElements.length) | 70 | if(this._canColor && this.application.ninja.selectedElements.length) |
71 | { | 71 | { |
72 | var color = this.application.ninja.colorController.colorToolbar.stroke, | 72 | var color = this.options.stroke, |
73 | colorInfo; | 73 | colorInfo; |
74 | if(color && color.color) | 74 | if(color && color.color) |
75 | { | 75 | { |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 3e9167fd..b2b48383 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -44,8 +44,8 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null); | 46 | this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null); |
47 | if (this.application.ninja.colorController.colorToolbar.stroke.color) | 47 | if (this.options.stroke.color) |
48 | this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; | 48 | this._strokeColor = this.options.stroke.color.css; |
49 | else | 49 | else |
50 | this._strokeColor = [0,0,0,1]; | 50 | this._strokeColor = [0,0,0,1]; |
51 | this.startDraw(event); | 51 | this.startDraw(event); |
@@ -77,10 +77,11 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
77 | h += ~~(yAdj*2); | 77 | h += ~~(yAdj*2); |
78 | } | 78 | } |
79 | 79 | ||
80 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 80 | canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
81 | var elementModel = TagTool.makeElement(w, h, drawData.planeMat, drawData.midPt, canvas, true); | 81 | document.application.njUtils.createModelWithShape(canvas, "Line"); |
82 | canvas.elementModel.isShape = true; | 82 | |
83 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 83 | var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, drawData); |
84 | this.application.ninja.elementMediator.addElements(canvas, styles); | ||
84 | } else { | 85 | } else { |
85 | canvas = this._targetedElement; | 86 | canvas = this._targetedElement; |
86 | canvas.elementModel.controller = ShapesController; | 87 | canvas.elementModel.controller = ShapesController; |
@@ -214,7 +215,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
214 | var left = Math.round(midPt[0] - 0.5*w); | 215 | var left = Math.round(midPt[0] - 0.5*w); |
215 | var top = Math.round(midPt[1] - 0.5*h); | 216 | var top = Math.round(midPt[1] - 0.5*h); |
216 | 217 | ||
217 | var strokeColor = this.application.ninja.colorController.colorToolbar.stroke.webGlColor; | 218 | var strokeColor = this.options.stroke.webGlColor; |
218 | // for default stroke and fill/no materials | 219 | // for default stroke and fill/no materials |
219 | var strokeMaterial = null; | 220 | var strokeMaterial = null; |
220 | 221 | ||
@@ -233,7 +234,8 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
233 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); | 234 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); |
234 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); | 235 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); |
235 | 236 | ||
236 | var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); | 237 | var line = Object.create(Line, {}); |
238 | line.init(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); | ||
237 | 239 | ||
238 | world.addObject(line); | 240 | world.addObject(line); |
239 | world.render(); | 241 | world.render(); |
@@ -241,7 +243,7 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
241 | canvas.elementModel.shapeModel.shapeCount++; | 243 | canvas.elementModel.shapeModel.shapeCount++; |
242 | if(canvas.elementModel.shapeModel.shapeCount === 1) | 244 | if(canvas.elementModel.shapeModel.shapeCount === 1) |
243 | { | 245 | { |
244 | canvas.elementModel.selection = "Line"; | 246 | // canvas.elementModel.selection = "Line"; |
245 | canvas.elementModel.pi = "LinePi"; | 247 | canvas.elementModel.pi = "LinePi"; |
246 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; | 248 | canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; |
247 | 249 | ||
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index e8e88d1d..ce812398 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -39,8 +39,8 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
39 | 39 | ||
40 | var innerRadius = this.options.innerRadius.value / 100; | 40 | var innerRadius = this.options.innerRadius.value / 100; |
41 | 41 | ||
42 | var strokeColor = this.application.ninja.colorController.colorToolbar.stroke.webGlColor; | 42 | var strokeColor = this.options.stroke.webGlColor; |
43 | var fillColor = this.application.ninja.colorController.colorToolbar.fill.webGlColor; | 43 | var fillColor = this.options.fill.webGlColor; |
44 | 44 | ||
45 | // for default stroke and fill/no materials | 45 | // for default stroke and fill/no materials |
46 | var strokeMaterial = null; | 46 | var strokeMaterial = null; |
@@ -66,9 +66,9 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
66 | var world = this.getGLWorld(canvas, this.options.use3D); | 66 | var world = this.getGLWorld(canvas, this.options.use3D); |
67 | 67 | ||
68 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); | 68 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); |
69 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); | 69 | var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2)); |
70 | 70 | ||
71 | var oval = new Circle(); //GLCircle(); | 71 | var oval = Object.create(Circle, {}); |
72 | oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); | 72 | oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); |
73 | 73 | ||
74 | world.addObject(oval); | 74 | world.addObject(oval); |
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 0537a27b..ce7606a1 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js | |||
@@ -331,10 +331,26 @@ exports.PanTool = Montage.create(toolBase, | |||
331 | 331 | ||
332 | if (!this._altKeyDown) | 332 | if (!this._altKeyDown) |
333 | delta[2] = 0; | 333 | delta[2] = 0; |
334 | var transMat = Matrix.Translation( delta ); | 334 | |
335 | this._worldPt = wPt; | 335 | // limit the change |
336 | var ucMat = viewUtils.getMatrixFromElement(this.application.ninja.currentDocument.documentRoot); | ||
337 | var tooMuch = false | ||
338 | if ((ucMat[12] > 12000) && (delta[0] > 0)) tooMuch = true; | ||
339 | if ((ucMat[12] < -12000) && (delta[0] < 0)) tooMuch = true; | ||
340 | if ((ucMat[13] > 12000) && (delta[1] > 0)) tooMuch = true; | ||
341 |