aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/tools
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js6
-rwxr-xr-xjs/tools/LineTool.js14
-rwxr-xr-xjs/tools/OvalTool.js25
-rwxr-xr-xjs/tools/PenTool.js25
-rwxr-xr-xjs/tools/RectTool.js24
-rwxr-xr-xjs/tools/SelectionTool.js282
-rwxr-xr-xjs/tools/ShapeTool.js4
-rwxr-xr-xjs/tools/TranslateObject3DTool.js7
-rwxr-xr-xjs/tools/drawing-tool-base.js18
-rwxr-xr-xjs/tools/modifier-tool-base.js7
10 files changed, 304 insertions, 108 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index fec89eb2..752aa2a3 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -13,6 +13,8 @@ var ElementMediator = require("js/mediators/element-mediator").ElementMediator;
13var TagTool = require("js/tools/TagTool").TagTool; 13var TagTool = require("js/tools/TagTool").TagTool;
14var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; 14var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
15 15
16var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke;
17
16exports.BrushTool = Montage.create(ShapeTool, { 18exports.BrushTool = Montage.create(ShapeTool, {
17 hasReel: { value: false }, 19 hasReel: { value: false },
18 _toolID: { value: "brushTool" }, 20 _toolID: { value: "brushTool" },
@@ -63,7 +65,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
63 } 65 }
64 //start a new brush stroke 66 //start a new brush stroke
65 if (this._selectedBrushStroke === null){ 67 if (this._selectedBrushStroke === null){
66 this._selectedBrushStroke = new GLBrushStroke(); 68 this._selectedBrushStroke = new BrushStroke();
67 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 69 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
68 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 70 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
69 } 71 }
@@ -192,7 +194,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
192 var bboxMax = this._selectedBrushStroke.getBBoxMax(); 194 var bboxMax = this._selectedBrushStroke.getBBoxMax();
193 var bboxWidth = bboxMax[0] - bboxMin[0]; 195 var bboxWidth = bboxMax[0] - bboxMin[0];
194 var bboxHeight = bboxMax[1] - bboxMin[1]; 196 var bboxHeight = bboxMax[1] - bboxMin[1];
195 var bboxMid = Vector.create([0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]); 197 var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])];
196 198
197 this._selectedBrushStroke.setCanvasX(bboxMid[0]); 199 this._selectedBrushStroke.setCanvasX(bboxMid[0]);
198 this._selectedBrushStroke.setCanvasY(bboxMid[1]); 200 this._selectedBrushStroke.setCanvasY(bboxMid[1]);
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 0a7c0534..a61f8f79 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -13,6 +13,9 @@ var Montage = require("montage/core/core").Montage,
13 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, 13 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController,
14 ShapeModel = require("js/models/shape-model").ShapeModel; 14 ShapeModel = require("js/models/shape-model").ShapeModel;
15 15
16var Line = require("js/lib/geom/line").Line;
17var MaterialsModel = require("js/models/materials-model").MaterialsModel;
18
16exports.LineTool = Montage.create(ShapeTool, { 19exports.LineTool = Montage.create(ShapeTool, {
17 _toolID: { value: "lineTool" }, 20 _toolID: { value: "lineTool" },
18 _imageID: { value: "lineToolImg" }, 21 _imageID: { value: "lineToolImg" },
@@ -206,10 +209,13 @@ exports.LineTool = Montage.create(ShapeTool, {
206 // for default stroke and fill/no materials 209 // for default stroke and fill/no materials
207 var strokeMaterial = null; 210 var strokeMaterial = null;
208 211
209 var strokeM = this.options.strokeMaterial; 212 if(this.options.use3D)
210 if(strokeM)
211 { 213 {
212 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); 214 var strokeM = this.options.strokeMaterial;
215 if(strokeM)
216 {
217 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
218 }
213 } 219 }
214 220
215 var world = this.getGLWorld(canvas, this.options.use3D); 221 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -217,7 +223,7 @@ exports.LineTool = Montage.create(ShapeTool, {
217 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 223 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
218 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 224 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2));
219 225
220 var line = new GLLine(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); 226 var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj);
221 227
222 world.addObject(line); 228 world.addObject(line);
223 world.render(); 229 world.render();
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 14655312..a10e0bb5 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage,
8 ShapeTool = require("js/tools/ShapeTool").ShapeTool, 8 ShapeTool = require("js/tools/ShapeTool").ShapeTool,
9 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; 9 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
10 10
11var Circle = require("js/lib/geom/circle").Circle;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13
11exports.OvalTool = Montage.create(ShapeTool, { 14exports.OvalTool = Montage.create(ShapeTool, {
12 15
13 _toolID: { value: "ovalTool" }, 16 _toolID: { value: "ovalTool" },
@@ -43,25 +46,27 @@ exports.OvalTool = Montage.create(ShapeTool, {
43 var strokeMaterial = null; 46 var strokeMaterial = null;
44 var fillMaterial = null; 47 var fillMaterial = null;
45 48
46 var strokeM = this.options.strokeMaterial; 49 if(this.options.use3D)
47 if(strokeM)
48 { 50 {
49 strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); 51 var strokeM = this.options.strokeMaterial;
50 } 52 if(strokeM)
53 {
54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
55 }
51 56
52 var fillM = this.options.fillMaterial; 57 var fillM = this.options.fillMaterial;
53 if(fillM) 58 if(fillM)
54 { 59 {
55 fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); 60 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
61 }
56 } 62 }
57 63
58
59 var world = this.getGLWorld(canvas, this.options.use3D); 64 var world = this.getGLWorld(canvas, this.options.use3D);
60 65
61 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 66 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
62 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 67 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2));
63 68
64 var oval = new GLCircle(); 69 var oval = new Circle(); //GLCircle();
65 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); 70 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle);
66 71
67 world.addObject(oval); 72 world.addObject(oval);
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index ddc8bc04..71a91870 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -15,6 +15,9 @@ var TagTool = require("js/tools/TagTool").TagTool;
15var ElementController = require("js/controllers/elements/element-controller").ElementController; 15var ElementController = require("js/controllers/elements/element-controller").ElementController;
16var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; 16var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
17 17
18var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint;
19var SubPath = require("js/lib/geom/sub-path").SubPath;
20
18//todo remove this global var 21//todo remove this global var
19var g_DoPenToolMouseMove = true; 22var g_DoPenToolMouseMove = true;
20 23
@@ -146,7 +149,7 @@ exports.PenTool = Montage.create(ShapeTool, {
146 if (mouseDownPos) { 149 if (mouseDownPos) {
147 //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath 150 //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath
148 if (this._selectedSubpath === null) { 151 if (this._selectedSubpath === null) {
149 this._selectedSubpath = new GLSubpath(); 152 this._selectedSubpath = new SubPath();
150 this._isNewPath = true; 153 this._isNewPath = true;
151 if (this._entryEditMode === this.ENTRY_SELECT_PATH){ 154 if (this._entryEditMode === this.ENTRY_SELECT_PATH){
152 //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath 155 //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath
@@ -212,13 +215,13 @@ exports.PenTool = Montage.create(ShapeTool, {
212 this._penCanvas = null; 215 this._penCanvas = null;
213 this._penPlaneMat = null; 216 this._penPlaneMat = null;
214 this._snapTarget = null; 217 this._snapTarget = null;
215 this._selectedSubpath = new GLSubpath(); 218 this._selectedSubpath = new SubPath();
216 this._isNewPath = true; 219 this._isNewPath = true;
217 } 220 }
218 221
219 //add an anchor point to end of the subpath, and make it the selected anchor point 222 //add an anchor point to end of the subpath, and make it the selected anchor point
220 if (!this._selectedSubpath.getIsClosed() || this._makeMultipleSubpaths) { 223 if (!this._selectedSubpath.getIsClosed() || this._makeMultipleSubpaths) {
221 this._selectedSubpath.addAnchor(new GLAnchorPoint()); 224 this._selectedSubpath.addAnchor(new AnchorPoint());
222 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 225 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex());
223 newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 226 newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);
224 newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 227 newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);
@@ -231,7 +234,7 @@ exports.PenTool = Montage.create(ShapeTool, {
231 if (this._isPickedEndPointInSelectPathMode){ 234 if (this._isPickedEndPointInSelectPathMode){
232 //TODO clean up this code...very similar to the code block above 235 //TODO clean up this code...very similar to the code block above
233 if (!this._selectedSubpath.getIsClosed()) { 236 if (!this._selectedSubpath.getIsClosed()) {
234 this._selectedSubpath.addAnchor(new GLAnchorPoint()); 237 this._selectedSubpath.addAnchor(new AnchorPoint());
235 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 238 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex());
236 newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 239 newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);