aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorJohn Mayhew2012-05-07 16:30:19 -0700
committerJohn Mayhew2012-05-07 16:30:19 -0700
commitdb4ba95f50148198759dde503ec1c778184d9dbe (patch)
tree8b79ad58108af2f17d15abc8cdc33d35229ab20d /js/tools
parent843d8ea8ee58a54bcb71d7b28dbf78fae153b491 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-db4ba95f50148198759dde503ec1c778184d9dbe.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/components/layout/tools-list.reel/tools-list.html js/components/layout/tools-properties.reel/tools-properties.html js/components/tools-properties/brush-properties.reel/brush-properties.html js/components/tools-properties/fill-properties.reel/fill-properties.html js/components/tools-properties/pen-properties.reel/pen-properties.html js/components/tools-properties/pencil-properties.reel/pencil-properties.html js/components/tools-properties/selection-properties.reel/selection-properties.html js/components/tools-properties/shape-properties.reel/shape-properties.html js/components/tools-properties/tag-properties.reel/tag-properties.html js/components/tools-properties/text-properties.reel/text-properties.html
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/PenTool.js11
-rwxr-xr-xjs/tools/RotateStage3DTool.js18
-rwxr-xr-xjs/tools/SelectionTool.js8
-rwxr-xr-xjs/tools/ShapeTool.js45
-rwxr-xr-xjs/tools/TagTool.js218
-rwxr-xr-xjs/tools/drawing-tool-base.js88
-rwxr-xr-xjs/tools/drawing-tool.js3
10 files changed, 107 insertions, 308 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 7e5e0630..0be378fd 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 92352880..9160e220 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/PenTool.js b/js/tools/PenTool.js
index 83d0c8d2..e70bed27 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/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 9c9aee93..855c7b8c 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -222,10 +222,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
222 value: function(event) { 222 value: function(event) {
223 if(this.application.ninja.selectedElements.length > 0) { 223 if(this.application.ninja.selectedElements.length > 0) {
224 this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; 224 this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0];
225 console.log( "setting container to selected element" );
226 } else { 225 } else {
227 this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; 226 this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot;
228 console.log( "setting container to stage" );
229 } 227 }
230 } 228 }
231 }, 229 },
@@ -753,10 +751,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
753 751
754 var zoomFactor = 1; 752 var zoomFactor = 1;
755 var viewPort = this.application.ninja.stage._viewport; 753 var viewPort = this.application.ninja.stage._viewport;
756 if (viewPort.style && viewPort.style.zoom) 754 if (viewPort && viewPort.style && viewPort.style.zoom) {
757 {
758 zoomFactor = Number(viewPort.style.zoom); 755 zoomFactor = Number(viewPort.style.zoom);
759 } 756 }
757
760 var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); 758 var tmpMat = viewUtils.getLocalToGlobalMatrix( item );
761 for (var j=0; j<4; j++) 759 for (var j=0; j<4; j++)
762 { 760 {
@@ -865,7 +863,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
865 863
866 var zoomFactor = 1; 864 var zoomFactor = 1;
867 var viewPort = this.application.ninja.stage._viewport; 865 var viewPort = this.application.ninja.stage._viewport;
868 if (viewPort.style && viewPort.style.zoom) 866 if (viewPort && viewPort.style && viewPort.style.zoom)
869 { 867 {
870 zoomFactor = Number(viewPort.style.zoom); 868 zoomFactor = Number(viewPort.style.zoom);
871 } 869 }
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index c0681200..0562dbc2 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -53,26 +53,18 @@ 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 console.log( "creating a new canvas" ); 62 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
68 canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 63 document.application.njUtils.createModelWithShape(canvas);
69 var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height,
70 drawData.planeMat, drawData.midPt, canvas, true);
71 64
72 canvas.elementModel.isShape = true; 65