aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-28 17:54:15 -0700
committerNivesh Rajbhandari2012-06-28 17:54:15 -0700
commite3eb68c3a0b911acd873ee6211931b8f4e620030 (patch)
treea0b1fa11fb6bca1c232adff0f52a19d71404984a
parentb4b54f6cc084b3f7483ebed1e15c1b4770949d58 (diff)
downloadninja-e3eb68c3a0b911acd873ee6211931b8f4e620030.tar.gz
Fixed not being able to draw linear and radial gradients. Also fixed IKNINJA-1721 - File dirty marker does not show when modifying elements and IKNinja-1581 and IKNinja-1758 - Paint bucket fill bugs with lines and brush objects. Squashed commit of the following:
commit 7cad082c89911d34a99feeef8e91d22b89cae8f1 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jun 28 17:52:07 2012 -0700 Fix for not being able to draw linear and radial gradient materials. I'm turning off pre-flight support of gradients for WebGL since it conflicts with the materials' color support. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit d0df8a2bff052d855bafb7885792b1dfff8eab7d Merge: 2c67d26 b4b54f6 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jun 28 17:50:11 2012 -0700 Merge branch 'refs/heads/ninja-internal' into ToolFixes commit 2c67d264851f0897fdca8ca887c1c82d0e434217 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jun 28 15:06:13 2012 -0700 IKNINJA-1721 - File dirty marker does not show when modifying elements. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit bb4b6a52eb75efb2f435cdb53f810ae3bc1f1fc3 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jun 28 11:15:34 2012 -0700 IKNinja-1581 and IKNinja-1758 - Paint bucket fill bugs with lines and brush objects. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rwxr-xr-xjs/controllers/elements/shapes-controller.js8
-rwxr-xr-xjs/controllers/styles-controller.js2
-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
7 files changed, 55 insertions, 37 deletions
<
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 74353454..5920d51a 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -138,6 +138,10 @@ exports.ShapesController = Montage.create(CanvasController, {
138 this.application.ninja.elementMediator.replaceElement(canvas, el); 138 this.application.ninja.elementMediator.replaceElement(canvas, el);
139 break; 139 break;
140 case "strokeMaterial": 140 case "strokeMaterial":
141 // skip shape types that don't support WebGL
142 if(!el.elementModel.shapeModel.GLGeomObj.useWebGl) {
143 return;
144 }
141 m = Object.create(MaterialsModel.getMaterial(value)); 145 m = Object.create(MaterialsModel.getMaterial(value));
142 if(m) 146 if(m)
143 { 147 {
@@ -152,6 +156,10 @@ exports.ShapesController = Montage.create(CanvasController, {
152 } 156 }
153 break; 157 break;
154 case "fillMaterial": 158 case "fillMaterial":
159 // skip shape types that don't support WebGL or fill color
160 if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.GLGeomObj.useWebGl) {
161 return;
162 }
155 m = Object.create(MaterialsModel.getMaterial(value)); 163 m = Object.create(MaterialsModel.getMaterial(value));
156 if(m) 164 if(m)
157 { 165 {
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 0f847653..e7f95335 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1437,11 +1437,11 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1437 1437
1438 ///// Dispatch modified event 1438 ///// Dispatch modified event
1439 NJevent('styleSheetModified', eventData); 1439 NJevent('styleSheetModified', eventData);
1440 this.currentDocument.model.needsSave = true;
1440 1441
1441 ///// If the sheet doesn't already exist in the list of modified 1442 ///// If the sheet doesn't already exist in the list of modified
1442 ///// sheets, dispatch dirty event and add the sheet to the list 1443 ///// sheets, dispatch dirty event and add the sheet to the list
1443 if(sheetSearch.length === 0) { 1444 if(sheetSearch.length === 0) {
1444 this.currentDocument.model.needsSave = true;
1445 this.dirtyStyleSheets.push({ 1445 this.dirtyStyleSheets.push({
1446 document : sheet.ownerNode.ownerDocument, 1446 document : sheet.ownerNode.ownerDocument,
1447 stylesheet : sheet 1447 stylesheet : sheet
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;