diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 10 | ||||
-rwxr-xr-x | js/tools/EyedropperTool.js | 3 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 14 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 2 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 11 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 2 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 2 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 40 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 218 | ||||
-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 | 29 |
12 files changed, 73 insertions, 307 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index ded56ecc..5c334b92 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -374,13 +374,11 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | 376 | ||
377 | var left = Math.round(midPt[0] - 0.5 * w); | ||
378 | var top = Math.round(midPt[1] - 0.5 * h); | ||
379 | |||
380 | if (!canvas) { | 377 | if (!canvas) { |
381 | var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 378 | var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
382 | var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas, true); | 379 | document.application.njUtils.createModelWithShape(newCanvas, "Brushstroke"); |
383 | ElementMediator.addElements(newCanvas, elementModel.data, false); | 380 | var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); |
381 | this.application.ninja.elementMediator.addElements(newCanvas, styles, false); | ||
384 | 382 | ||
385 | // create all the GL stuff | 383 | // create all the GL stuff |
386 | var world = this.getGLWorld(newCanvas, this._useWebGL); | 384 | 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/LineTool.js b/js/tools/LineTool.js index 3e9167fd..198d7e69 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -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; |
@@ -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 6edec811..e9dc66bb 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -68,7 +68,7 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
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/PenTool.js b/js/tools/PenTool.js index 8ecc9f79..16990ca7 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -557,17 +557,16 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
557 | return; | 557 | return; |
558 | } | 558 | } |
559 | 559 | ||
560 | w= Math.round(w); | 560 | w = Math.round(w); |
561 | h = Math.round(h); | 561 | h = Math.round(h); |
562 | var left = Math.round(midPt[0] - 0.5 * w); | 562 | var left = Math.round(midPt[0] - 0.5 * w); |
563 | var top = Math.round(midPt[1] - 0.5 * h); | 563 | var top = Math.round(midPt[1] - 0.5 * h); |
564 | 564 | ||
565 | if (!canvas) { | 565 | if (!canvas) { |
566 | var newCanvas = null; | 566 | var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
567 | newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 567 | document.application.njUtils.createModelWithShape(newCanvas, "Subpath"); |
568 | var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, true); | 568 | var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w), parseInt(h), {midPt: midPt, planeMat: planeMat}); |
569 | //note that we set the notify event to false because we send the event separately at end of this code block | 569 | this.application.ninja.elementMediator.addElements(newCanvas, styles, false); |
570 | ElementMediator.addElements(newCanvas, elementModel.data, false); | ||
571 | 570 | ||
572 | // create all the GL stuff | 571 | // create all the GL stuff |
573 | var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); | 572 | var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); |
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 0c14a559..0a3c8200 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js | |||
@@ -87,7 +87,7 @@ exports.RectTool = Montage.create(ShapeTool, { | |||
87 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); | 87 | var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); |
88 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); | 88 | var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); |
89 | 89 | ||
90 | var rect = new Rectangle(); | 90 | var rect = Object.create(Rectangle, {}); |
91 | rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, | 91 | rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, |
92 | tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); | 92 | tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); |
93 | 93 | ||
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 855c7b8c..07c26b8c 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -504,7 +504,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
504 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 504 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
505 | delta[0] = ~~delta[0]; | 505 | delta[0] = ~~delta[0]; |
506 | delta[1] = ~~delta[1]; | 506 | delta[1] = ~~delta[1]; |
507 | delta[2] = 0; | 507 | //delta[2] = 0; |
508 | var transMat = Matrix.Translation( delta ); | 508 | var transMat = Matrix.Translation( delta ); |
509 | this._moveElements(transMat); | 509 | this._moveElements(transMat); |
510 | } | 510 | } |
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d2337000..0562dbc2 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -53,23 +53,17 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
53 | } | 53 | } |
54 | }, | 54 | }, |
55 | 55 | ||
56 | HandleLeftButtonUp: | 56 | HandleLeftButtonUp: { |
57 | { | 57 | value: function (event) { |
58 | value: function (event) | 58 | var canvas, drawData = this.getDrawingData(); |
59 | { | ||
60 | var drawData; | ||
61 | |||
62 | drawData = this.getDrawingData(); | ||
63 | 59 | ||
64 | if(drawData) { | 60 | if(drawData) { |
65 | var canvas; | ||
66 | if(!this._useExistingCanvas()) { | 61 | if(!this._useExistingCanvas()) { |
67 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 62 | canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
68 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, | 63 | document.application.njUtils.createModelWithShape(canvas); |
69 | drawData.planeMat, drawData.midPt, canvas, true); | ||
70 | 64 | ||
71 | canvas.elementModel.isShape = true; | 65 | var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); |
72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 66 | this.application.ninja.elementMediator.addElements(canvas, styles); |
73 | } else { | 67 | } else { |
74 | canvas = this._targetedElement; | 68 | canvas = this._targetedElement; |
75 | if (!canvas.getAttribute( "data-RDGE-id" )) | 69 | if (!canvas.getAttribute( "data-RDGE-id" )) |
@@ -193,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
193 | } | 187 | } |
194 | }, | 188 | }, |
195 | 189 | ||
196 | createCanvas: { | ||
197 | value: function (left, top, w, h) | ||
198 | { | ||
199 | //var tmpDiv = document.createElement("canvas"); | ||
200 | var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block"); | ||
201 | var rules = { | ||
202 | 'position': 'absolute', | ||
203 | 'top' : top + 'px', | ||
204 | 'left' : left + 'px', | ||
205 | '-webkit-transform-style' : 'preserve-3d', | ||
206 | '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' | ||
207 | }; | ||
208 | |||
209 | tmpDiv.width = w; | ||
210 | tmpDiv.height = h; | ||
211 | |||
212 | return {el: tmpDiv, rules: rules}; | ||
213 | } | ||
214 | }, | ||
215 | |||
216 | // We can draw on an existing canvas unless it has only a single shape object | 190 | // We can draw on an existing canvas unless it has only a single shape object |
217 | _useExistingCanvas: { | 191 | _useExistingCanvas: { |
218 | value: function() | 192 | value: function() |