aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-29 14:57:00 -0700
committerValerio Virgillito2012-06-29 14:57:00 -0700
commitec69c8761f798eaf39c4a154997f8bc54b7e47f4 (patch)
tree4f4136503c87a72f7af67a54dad69c14469ee01e /js/tools
parentecd9e3b3b09695e3e7115c04e75add5a20c5c6fe (diff)
parent81d75ac08ff24dc3078d79a9133e54f592c23026 (diff)
downloadninja-ec69c8761f798eaf39c4a154997f8bc54b7e47f4.tar.gz
Merge pull request #362 from mqg734/ColorGradientFix
Fixed not being able to draw linear and radial gradients and two other tools bugs.
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/FillTool.js5
-rwxr-xr-xjs/tools/LineTool.js21
-rwxr-xr-xjs/tools/OvalTool.js18
-rwxr-xr-xjs/tools/RectTool.js20
-rwxr-xr-xjs/tools/ShapeTool.js18
5 files changed, 46 insertions, 36 deletions
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 fde09959..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));
@@ -271,7 +278,9 @@ exports.LineTool = Montage.create(ShapeTool, {
271 } 278 }
272 279
273 // TODO - This needs to be moved into geom obj's init routine instead of here 280 // TODO - This needs to be moved into geom obj's init routine instead of here
274 this.setColor(this.options.stroke, null, canvas, "lineTool"); 281 if(!strokeM) {
282 this.setColor(canvas, this.options.stroke, false, "lineTool");
283 }
275 284
276 if(canvas.elementModel.isShape) 285 if(canvas.elementModel.isShape)
277 { 286 {
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index 33bf763d..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));
@@ -95,7 +96,12 @@ exports.OvalTool = Montage.create(ShapeTool, {
95 } 96 }
96 97
97 // TODO - This needs to be moved into geom obj's init routine instead of here 98 // TODO - This needs to be moved into geom obj's init routine instead of here
98 this.setColor(this.options.stroke, this.options.fill, canvas, "ovalTool"); 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 }
99 105
100 if(canvas.elementModel.isShape) 106 if(canvas.elementModel.isShape)
101 { 107 {
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index df049395..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 69
68 if(this.options.use3D) 70 if(this.options.use3D)
69 { 71 {
70 var strokeM = this.options.strokeMaterial; 72 strokeM = this.options.strokeMaterial;
71 if(strokeM) 73 if(strokeM)
72 { 74 {
73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 75 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
74 } 76 }
75 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; 77 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
76 78
77 var fillM = this.options.fillMaterial; 79 fillM = this.options.fillMaterial;
78 if(fillM) 80 if(fillM)
79 { 81 {
80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 82 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
@@ -118,14 +120,16 @@ exports.RectTool = Montage.create(ShapeTool, {
118 } 120 }
119 121
120 // TODO - This needs to be moved into geom obj's init routine instead of here 122 // TODO - This needs to be moved into geom obj's init routine instead of here
121 this.setColor(this.options.stroke, this.options.fill, canvas, "rectTool"); 123 if(!fillM) {
122 124 this.setColor(canvas, this.options.fill, true, "rectTool");
125 }
126 if(!strokeM) {
127 this.setColor(canvas, this.options.stroke, false, "rectTool");
128 }
123 if(canvas.elementModel.isShape) 129 if(canvas.elementModel.isShape)
124 { 130 {
125 this.application.ninja.selectionController.selectElement(canvas); 131 this.application.ninja.selectionController.selectElement(canvas);
126 } 132 }
127
128
129 } 133 }
130 } 134 }
131}); \ No newline at end of file 135}); \ No newline at end of file
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 6ff61546..3cd75be2 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -211,26 +211,16 @@ exports.ShapeTool = Montage.create(DrawingTool, {
211 } 211 }
212 }, 212 },
213 213
214 // We can draw on an existing canvas unless it has only a single shape object
215 setColor: { 214 setColor: {
216 value: function(stroke, fill, canvas, toolId) 215 value: function(canvas, color, isFill, toolId)
217 { 216 {
218 if(stroke && stroke.color) 217 if(color && color.color)
219 { 218 {
220 this.application.ninja.elementMediator.setColor([canvas], {mode:stroke.colorMode, color:stroke.color}, false, "Change", toolId); 219 this.application.ninja.elementMediator.setColor([canvas], {mode:color.colorMode, color:color.color}, isFill, "Change", toolId);
221 } 220 }
222 else 221 else
223 { 222 {
224 this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, false, "Change", toolId); 223 this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, isFill, "Change", toolId);
225 }
226
227 if(fill && fill.color)
228 {
229 this.application.ninja.elementMediator.setColor([canvas], {mode:fill.colorMode, color:fill.color}, true, "Change", toolId);
230 }
231 else
232 {