diff options
author | hwc487 | 2012-06-29 13:01:02 -0700 |
---|---|---|
committer | hwc487 | 2012-06-29 13:01:02 -0700 |
commit | 44eba9c1f7935ae13e87a6dcf6ddea0efa63eb05 (patch) | |
tree | 77ec7650cbc397c1792254529b0430cd691fad08 /js/tools | |
parent | 230b3d0fdfd29e998b82fef9f1ff5d2ca7ef8596 (diff) | |
parent | ecd9e3b3b09695e3e7115c04e75add5a20c5c6fe (diff) | |
download | ninja-44eba9c1f7935ae13e87a6dcf6ddea0efa63eb05.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Taper
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 15 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 3 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 3 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 32 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 3 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 26 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 13 | ||||
-rw-r--r-- | js/tools/bindingTool.js | 20 |
8 files changed, 83 insertions, 32 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/LineTool.js b/js/tools/LineTool.js index 07429bc0..fde09959 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -270,6 +270,9 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
270 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 270 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
271 | } | 271 | } |
272 | 272 | ||
273 | // TODO - This needs to be moved into geom obj's init routine instead of here | ||
274 | this.setColor(this.options.stroke, null, canvas, "lineTool"); | ||
275 | |||
273 | if(canvas.elementModel.isShape) | 276 | if(canvas.elementModel.isShape) |
274 | { | 277 | { |
275 | this.application.ninja.selectionController.selectElement(canvas); | 278 | this.application.ninja.selectionController.selectElement(canvas); |
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index ce812398..33bf763d 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -94,6 +94,9 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
94 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 94 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
95 | } | 95 | } |
96 | 96 | ||
97 | // 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 | |||
97 | if(canvas.elementModel.isShape) | 100 | if(canvas.elementModel.isShape) |
98 | { | 101 | { |
99 | this.application.ninja.selectionController.selectElement(canvas); | 102 | 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..df049395 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js | |||
@@ -117,6 +117,9 @@ exports.RectTool = Montage.create(ShapeTool, { | |||
117 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 117 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
118 | } | 118 | } |
119 | 119 | ||
120 | // 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"); | ||
122 | |||
120 | if(canvas.elementModel.isShape) | 123 | if(canvas.elementModel.isShape) |
121 | { | 124 | { |
122 | this.application.ninja.selectionController.selectElement(canvas); | 125 | this.application.ninja.selectionController.selectElement(canvas); |
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 8d381711..6ff61546 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -209,7 +209,31 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
209 | 209 | ||
210 | return target; | 210 | return target; |
211 | } | 211 | } |
212 | } | 212 | }, |
213 | |||
214 | // We can draw on an existing canvas unless it has only a single shape object | ||
215 | setColor: { | ||
216 | value: function(stroke, fill, canvas, toolId) | ||
217 | { | ||
218 | if(stroke && stroke.color) | ||
219 | { | ||
220 | this.application.ninja.elementMediator.setColor([canvas], {mode:stroke.colorMode, color:stroke.color}, false, "Change", toolId); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, false, "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 | { | ||
233 | this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, true, "Change", toolId); | ||
234 | } | ||
235 | } | ||
236 | } | ||
213 | 237 | ||
214 | }); | 238 | }); |
215 | 239 | ||
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index fac6798f..31918f92 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js | |||
@@ -81,7 +81,7 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
81 | // TODO: Add position support | 81 | // TODO: Add position support |
82 | insertElement: { | 82 | insertElement: { |
83 | value: function(drawData) { | 83 | value: function(drawData) { |
84 | var element, styles; | 84 | var element, styles, color; |
85 | 85 | ||
86 | // Create the element | 86 | // Create the element |
87 | if(this.options.selectedElement === "custom") { | 87 | if(this.options.selectedElement === "custom") { |
@@ -95,8 +95,15 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
95 | styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); | 95 | styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); |
96 | 96 | ||
97 | // Add color | 97 | // Add color |
98 | if(this.options.getProperty("fill.colorMode") !== "nocolor") { | 98 | color = this.options.fill; |
99 | styles['background-color'] = this.options.getProperty("fill.color.css"); | 99 | switch(color.colorMode) { |
100 | case "nocolor": | ||
101 | break; | ||
102 | case "gradient": | ||
103 | styles['background-image'] = color.color.css; | ||
104 | break; | ||
105 | default: | ||
106 | styles['background-color'] = color.color.css; | ||
100 | } | 107 | } |
101 | 108 | ||
102 | // Add the element and styles | 109 | // Add the element and styles |
diff --git a/js/tools/bindingTool.js b/js/tools/bindingTool.js index 1e1c9e5b..3704a451 100644 --- a/js/tools/bindingTool.js +++ b/js/tools/bindingTool.js | |||
@@ -12,17 +12,17 @@ SelectionTool = require("js/tools/SelectionTool").SelectionTool; | |||
12 | 12 | ||
13 | exports.BindingTool = Montage.create(ModifierToolBase, { | 13 | exports.BindingTool = Montage.create(ModifierToolBase, { |
14 | drawingFeedback: { value: { mode: "Draw2D", type: "" } }, | 14 | drawingFeedback: { value: { mode: "Draw2D", type: "" } }, |
15 | _selectedComponent: { | 15 | _selectedElement: { |
16 | value: null | 16 | value: null |
17 | }, | 17 | }, |
18 | 18 | ||
19 | selectedComponent: { | 19 | selectedElement: { |
20 | get:function() { | 20 | get:function() { |
21 | return this._selectedComponent; | 21 | return this._selectedElement; |
22 | }, | 22 | }, |
23 | set: function(val) { | 23 | set: function(val) { |
24 | this._selectedComponent = val; | 24 | this._selectedElement = val; |
25 | this.application.ninja.stage.bindingView.selectedComponent = val; | 25 | this.application.ninja.stage.bindingView.selectedElement = val; |
26 | } | 26 | } |
27 | }, | 27 | }, |
28 | 28 | ||
@@ -33,9 +33,10 @@ exports.BindingTool = Montage.create(ModifierToolBase, { | |||
33 | { | 33 | { |
34 | NJevent("enableStageMove"); | 34 | NJevent("enableStageMove"); |
35 | this.application.ninja.workspaceMode = "binding"; | 35 | this.application.ninja.workspaceMode = "binding"; |
36 | this.application.ninja.stage.bindingView.hide = false; | ||
36 | if (this.application.ninja.selectedElements.length !== 0 ) { | 37 | if (this.application.ninja.selectedElements.length !== 0 ) { |
37 | if(typeof(this.application.ninja.selectedElements[0].controller) !== "undefined") { | 38 | if(typeof(this.application.ninja.selectedElements[0].controller) !== "undefined") { |
38 |