aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorPushkar Joshi2012-05-07 11:00:22 -0700
committerPushkar Joshi2012-05-07 11:00:22 -0700
commite5ae6e0b6e54db0e6efd75d1f14cb791060ed67a (patch)
treee84d2dc5033c1b5c1b993662660a90af12584b69 /js/tools
parentba890518b5a35d5e6893f9fc72d2eee30ae07e17 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-e5ae6e0b6e54db0e6efd75d1f14cb791060ed67a.tar.gz
Merge branch 'master' into pentool
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js10
-rwxr-xr-xjs/tools/EyedropperTool.js3
-rwxr-xr-xjs/tools/LineTool.js11
-rwxr-xr-xjs/tools/OvalTool.js2
-rwxr-xr-xjs/tools/PanTool.js20
-rwxr-xr-xjs/tools/PenTool.js11
-rwxr-xr-xjs/tools/RotateStage3DTool.js18
-rwxr-xr-xjs/tools/SelectionTool.js6
-rwxr-xr-xjs/tools/ShapeTool.js73
-rwxr-xr-xjs/tools/TagTool.js218
-rwxr-xr-xjs/tools/drawing-tool-base.js88
-rwxr-xr-xjs/tools/drawing-tool.js3
12 files changed, 154 insertions, 309 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 1666d311..5d4e8288 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -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/LineTool.js b/js/tools/LineTool.js
index 3e9167fd..5941b464 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;
@@ -241,7 +242,7 @@ exports.LineTool = Montage.create(ShapeTool, {
241 canvas.elementModel.shapeModel.shapeCount++; 242 canvas.elementModel.shapeModel.shapeCount++;
242 if(canvas.elementModel.shapeModel.shapeCount === 1) 243 if(canvas.elementModel.shapeModel.shapeCount === 1)
243 { 244 {
244 canvas.elementModel.selection = "Line"; 245// canvas.elementModel.selection = "Line";
245 canvas.elementModel.pi = "LinePi"; 246 canvas.elementModel.pi = "LinePi";
246 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 247 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
247 248
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index e8e88d1d..6edec811 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -66,7 +66,7 @@ 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 = new Circle(); //GLCircle();
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);
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 if ((ucMat[13] < -12000) && (delta[1] < 0)) tooMuch = true;
342 if ((ucMat[14] > 12000) && (delta[2] > 0)) tooMuch = true;
343 if ((ucMat[14] < -12000) && (delta[2] < 0)) tooMuch = true;
344 if (tooMuch)
345 {
346 this._isDrawing = false;
347 delta = [0,0,0];
348 }
349 else
350 this._worldPt = wPt;
336 351
337 // update everything 352 // update everything
353 var transMat = Matrix.Translation( delta );
338 this.applyDeltaMat( transMat ); 354 this.applyDeltaMat( transMat );
339 } 355 }
340 } 356 }
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index fb7f6d6d..fd470af7 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -578,17 +578,16 @@ exports.PenTool = Montage.create(ShapeTool, {
578 return; 578 return;
579 } 579 }
580 580
581 w= Math.round(w); 581 w = Math.round(w);
582 h = Math.round(h); 582 h = Math.round(h);
583 var left = Math.round(midPt[0] - 0.5 * w); 583 var left = Math.round(midPt[0] - 0.5 * w);
584 var top = Math.round(midPt[1] - 0.5 * h); 584 var top = Math.round(midPt[1] - 0.5 * h);
585 585
586 if (!canvas) { 586 if (!canvas) {
587 var newCanvas = null; 587 var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
588 newCanvas = NJUtils.makeNJElement("canvas", "Subpath", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 588 document.application.njUtils.createModelWithShape(newCanvas, "Subpath");
589 var elementModel = TagTool.makeElement(parseInt(w), parseInt(h), planeMat, midPt, newCanvas, true); 589 var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w), parseInt(h), {midPt: midPt, planeMat: planeMat});
590 //note that we set the notify event to false because we send the event separately at end of this code block 590 this.application.ninja.elementMediator.addElements(newCanvas, styles, false);
591 ElementMediator.addElements(newCanvas, elementModel.data, false);
592 591
593 // create all the GL stuff 592 // create all the GL stuff
594 var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); 593 var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial);
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js
index d1701304..2a9c63db 100755
--- a/js/tools/RotateStage3DTool.js
+++ b/js/tools/RotateStage3DTool.js
@@ -96,6 +96,12 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
96 viewUtils.pushViewportObj( stage ); 96 viewUtils.pushViewportObj( stage );
97 var eltCtr = viewUtils.getCenterOfProjection(); 97 var eltCtr = viewUtils.getCenterOfProjection();
98 viewUtils.popViewportObj(); 98 viewUtils.popViewportObj();
99// if(this.application.ninja.documentController.webTemplate)
100 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent")
101 {
102 eltCtr[0] = stage.scrollWidth/2;
103 eltCtr[1] = stage.scrollHeight/2;
104 }
99 105
100 var curMat = viewUtils.getMatrixFromElement(stage); 106 var curMat = viewUtils.getMatrixFromElement(stage);
101 var curMatInv = glmat4.inverse(curMat, []); 107 var curMatInv = glmat4.inverse(curMat, []);
@@ -113,8 +119,16 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
113 119
114 this._origin = viewUtils.localToGlobal(eltCtr, stage); 120 this._origin = viewUtils.localToGlobal(eltCtr, stage);
115 121
116 this._setTransformOrigin(false); 122// if(this.application.ninja.documentController.webTemplate)
117 123 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent")
124 {
125 this._startOriginArray = [];
126 this._startOriginArray.push(this._origin.slice());
127 }
128 else
129 {
130 this._setTransformOrigin(false);
131 }
118 this.DrawHandles(); 132 this.DrawHandles();
119 } 133 }
120 }, 134 },
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index 7033ee3d..855c7b8c 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -751,10 +751,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
751 751
752 var zoomFactor = 1; 752 var zoomFactor = 1;
753 var viewPort = this.application.ninja.stage._viewport; 753 var viewPort = this.application.ninja.stage._viewport;
754 if (viewPort.style && viewPort.style.zoom) 754 if (viewPort && viewPort.style && viewPort.style.zoom) {
755 {
756 zoomFactor = Number(viewPort.style.zoom); 755 zoomFactor = Number(viewPort.style.zoom);
757 } 756 }
757
758 var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); 758 var tmpMat = viewUtils.getLocalToGlobalMatrix( item );
759 for (var j=0; j<4; j++) 759 for (var j=0; j<4; j++)
760 { 760 {
@@ -863,7 +863,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
863 863
864 var zoomFactor = 1; 864 var zoomFactor = 1;
865 var viewPort = this.application.ninja.stage._viewport; 865 var viewPort = this.application.ninja.stage._viewport;