aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js15
-rwxr-xr-xjs/tools/FillTool.js5
-rwxr-xr-xjs/tools/LineTool.js22
-rwxr-xr-xjs/tools/OvalTool.js19
-rwxr-xr-xjs/tools/PenTool.js32
-rwxr-xr-xjs/tools/RectTool.js19
-rwxr-xr-xjs/tools/ShapeTool.js16
-rwxr-xr-xjs/tools/TagTool.js37
-rw-r--r--js/tools/bindingTool.js18
9 files changed, 132 insertions, 51 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 5d983a93..85a9e963 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -131,14 +131,17 @@ exports.BrushTool = Montage.create(ShapeTool, {
131 //start a new brush stroke 131 //start a new brush stroke
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 colorObj;
135 var color = this.options.fill.color; 135 var fill = this.options.fill;
136 if (color){ 136 var color = fill.color;
137 colorArray = [color.r/255, color.g/255, color.b/255, color.a]; 137 if(fill.colorMode === "gradient") {
138 colorObj = {gradientMode:fill.color.gradientMode, color:fill.color.stops};
139 } else if (color) {
140 colorObj = [color.r/255, color.g/255, color.b/255, color.a];
138 } else { 141 } else {
139 colorArray = [1,1,1,0]; 142 colorObj = [1,1,1,0];
140 } 143 }
141 this._selectedBrushStroke.setFillColor(colorArray); 144 this._selectedBrushStroke.setFillColor(colorObj);
142 145
143 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move 146 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move
144 var currMousePos = hitRec.calculateStageWorldPoint(); 147 var currMousePos = hitRec.calculateStageWorldPoint();
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js
index e08ec1da..72e03379 100755
--- a/js/tools/FillTool.js
+++ b/js/tools/FillTool.js
@@ -12,7 +12,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
12 12
13var Montage = require("montage/core/core").Montage, 13var Montage = require("montage/core/core").Montage,
14 ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase, 14 ModifierToolBase = require("js/tools/modifier-tool-base").ModifierToolBase,
15 ElementsMediator = require("js/mediators/element-mediator").ElementMediator; 15 ElementsMediator = require("js/mediators/element-mediator").ElementMediator,
16 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
16 17
17exports.FillTool = Montage.create(ModifierToolBase, { 18exports.FillTool = Montage.create(ModifierToolBase, {
18 _canSnap: { value: false }, 19 _canSnap: { value: false },
@@ -28,7 +29,7 @@ exports.FillTool = Montage.create(ModifierToolBase, {
28 if (obj) 29 if (obj)
29 { 30 {
30 var name = obj.nodeName; 31 var name = obj.nodeName;
31 if ((name !== 'CANVAS') && (name !== 'DIV')) 32 if ( ((name !== 'CANVAS') && (name !== 'DIV')) || (ShapesController.isElementAShape(obj) && !obj.elementModel.shapeModel.GLGeomObj.canFill))
32 { 33 {
33 cursor = "url('images/cursors/nofill.png') 14 14, default"; 34 cursor = "url('images/cursors/nofill.png') 14 14, default";
34 canColor = false; 35 canColor = false;
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 07429bc0..413c0302 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -44,10 +44,16 @@ 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.options.stroke.color) 47 if (this.options.stroke.color) {
48 this._strokeColor = this.options.stroke.color.css; 48 if( (this.options.stroke.colorMode === "gradient") || (this.options.stroke.colorMode === "nocolor") ) {
49 else 49 this._strokeColor = [0,0,0,1];
50 this._strokeColor = [0,0,0,1]; 50 } else {
51 this._strokeColor = this.options.stroke.color.css;
52 }
53 } else {
54 this._strokeColor = [0,0,0,1];
55 }
56
51 this.startDraw(event); 57 this.startDraw(event);
52 } 58 }
53 }, 59 },
@@ -229,10 +235,11 @@ exports.LineTool = Montage.create(ShapeTool, {
229 var strokeColor = this.options.stroke.webGlColor; 235 var strokeColor = this.options.stroke.webGlColor;
230 // for default stroke and fill/no materials 236 // for default stroke and fill/no materials
231 var strokeMaterial = null; 237 var strokeMaterial = null;
238 var strokeM = null;
232 239
233 if(this.options.use3D) 240 if(this.options.use3D)
234 { 241 {
235 var strokeM = this.options.strokeMaterial; 242 strokeM = this.options.strokeMaterial;
236 if(strokeM) 243 if(strokeM)
237 { 244 {
238 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 245 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
@@ -270,6 +277,11 @@ exports.LineTool = Montage.create(ShapeTool, {
270 // TODO - update the shape's info only. shapeModel will likely need an array of shapes. 277 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
271 } 278 }
272 279
280 // TODO - This needs to be moved into geom obj's init routine instead of here
281 if(!strokeM) {
282 this.setColor(canvas, this.options.stroke, false, "lineTool");
283 }
284
273 if(canvas.elementModel.isShape) 285 if(canvas.elementModel.isShape)
274 { 286 {
275 this.application.ninja.selectionController.selectElement(canvas); 287 this.application.ninja.selectionController.selectElement(canvas);
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index ce812398..e798d1a7 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -39,23 +39,24 @@ 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.options.stroke.webGlColor; 42 var strokeColor = this.options.stroke.webGlColor || [0,0,0,1];
43 var fillColor = this.options.fill.webGlColor; 43 var fillColor = this.options.fill.webGlColor || [1,1,1,1];
44
45 // for default stroke and fill/no materials 44 // for default stroke and fill/no materials
46 var strokeMaterial = null; 45 var strokeMaterial = null;
47 var fillMaterial = null; 46 var fillMaterial = null;
47 var fillM = null;
48 var strokeM = null;
48 49
49 if(this.options.use3D) 50 if(this.options.use3D)
50 { 51 {
51 var strokeM = this.options.strokeMaterial; 52 strokeM = this.options.strokeMaterial;
52 if(strokeM) 53 if(strokeM)
53 { 54 {
54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 55 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
55 } 56 }
56 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; 57 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
57 58
58 var fillM = this.options.fillMaterial; 59 fillM = this.options.fillMaterial;
59 if(fillM) 60 if(fillM)
60 { 61 {
61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 62 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
@@ -94,6 +95,14 @@ exports.OvalTool = Montage.create(ShapeTool, {
94 // TODO - update the shape's info only. shapeModel will likely need an array of shapes. 95 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
95 } 96 }
96 97
98 // TODO - This needs to be moved into geom obj's init routine instead of here
99 if(!fillM) {
100 this.setColor(canvas, this.options.fill, true, "ovalTool");
101 }
102 if(!strokeM) {
103 this.setColor(canvas, this.options.stroke, false, "ovalTool");
104 }
105
97 if(canvas.elementModel.isShape) 106 if(canvas.elementModel.isShape)
98 { 107 {
99 this.application.ninja.selectionController.selectElement(canvas); 108 this.application.ninja.selectionController.selectElement(canvas);
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 2cffb44d..1097f28c 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -338,22 +338,28 @@ exports.PenTool = Montage.create(ShapeTool, {
338 } 338 }
339 this._selectedSubpath.setStrokeWidth(strokeSize); 339 this._selectedSubpath.setStrokeWidth(strokeSize);
340 340
341 var colorArray=[]; 341 var colorObj;
342 var color = this.options.stroke.color; 342 var stroke = this.options.stroke;
343 if (color){ 343 var color = stroke.color;
344 colorArray = [color.r/255, color.g/255, color.b/255, color.a]; 344 if(stroke.colorMode === "gradient") {
345 }else { 345 colorObj = {gradientMode:stroke.color.gradientMode, color:stroke.color.stops};
346 colorArray = [1,1,1,0]; 346 } else if (color) {
347 colorObj = [color.r/255, color.g/255, color.b/255, color.a];
348 } else {
349 colorObj = [1,1,1,0];
347 } 350 }
348 this._selectedSubpath.setStrokeColor(colorArray); 351 this._selectedSubpath.setStrokeColor(colorObj);
349 352
350 color = this.options.fill.color; 353 var fill = this.options.fill;
351 if (color){ 354 color = fill.color;
352 colorArray = [color.r/255, color.g/255, color.b/255, color.a]; 355 if(fill.colorMode === "gradient") {
356 colorObj = {gradientMode:fill.color.gradientMode, color:fill.color.stops};
357 } else if (color) {
358 colorObj = [color.r/255, color.g/255, color.b/255, color.a];
353 } else { 359 } else {
354 colorArray = [1,1,1,0]; 360 colorObj = [1,1,1,0];
355 } 361 }
356 this._selectedSubpath.setFillColor(colorArray); 362 this._selectedSubpath.setFillColor(colorObj);
357 } //if the selectedSubpath was null and needed to be constructed 363 } //if the selectedSubpath was null and needed to be constructed
358 364
359 //build the current mouse position in stage world space in case we don't already have a canvas 365 //build the current mouse position in stage world space in case we don't already have a canvas
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index b35a101a..6f0e65c7 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -59,22 +59,24 @@ exports.RectTool = Montage.create(ShapeTool, {
59 var blRadius = ShapesController.GetValueInPixels(this.options.BLRadiusControl.value, this.options.BLRadiusControl.units, h); 59 var blRadius = ShapesController.GetValueInPixels(this.options.BLRadiusControl.value, this.options.BLRadiusControl.units, h);
60 var brRadius = ShapesController.GetValueInPixels(this.options.BRRadiusControl.value, this.options.BRRadiusControl.units, h); 60 var brRadius = ShapesController.GetValueInPixels(this.options.BRRadiusControl.value, this.options.BRRadiusControl.units, h);
61 61
62 var strokeColor = this.options.stroke.webGlColor; 62 var strokeColor = this.options.stroke.webGlColor || [0,0,0,1];
63 var fillColor = this.options.fill.webGlColor; 63 var fillColor = this.options.fill.webGlColor || [1,1,1,1];
64 // for default stroke and fill/no materials 64 // for default stroke and fill/no materials
65 var strokeMaterial = null; 65 var strokeMaterial = null;
66 var fillMaterial = null; 66 var fillMaterial = null;
67 var fillM = null;
68 var strokeM = null;
67