From 2edf68e0de786cdc92d5f41548fd61e6c77a57ec Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 13 Feb 2012 09:56:40 -0800 Subject: Updated ink bottle tool to use new setColor routine in the mediator and controllers. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 13 ++++++++++ js/controllers/elements/shapes-controller.js | 8 ++++++ js/tools/FillTool.js | 3 +-- js/tools/InkBottleTool.js | 35 ++++++++++++++++++--------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 65d26bdd..5eb75613 100644 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -115,6 +115,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, } else { + // TODO - Need to update border style and width also el.elementModel.stroke = colorObj; } @@ -159,10 +160,22 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, case 'gradient': this.setProperty(el, "border-image", color.color.css); this.setProperty(el, "border-color", "none"); + if(color.borderInfo) + { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + + color.borderInfo.borderUnits); + this.setProperty(el, "border-style", color.borderInfo.borderStyle); + } break; default: this.setProperty(el, "border-image", "none"); this.setProperty(el, "border-color", color.color.css); + if(color.borderInfo) + { + this.setProperty(el, "border-width", color.borderInfo.borderWidth + + color.borderInfo.borderUnits); + this.setProperty(el, "border-style", color.borderInfo.borderStyle); + } } } el.elementModel.stroke = color; diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 640119c4..42c2528f 100644 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -260,6 +260,14 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); this.setShapeProperty(el, "stroke", webGl); this.setShapeProperty(el, "border", color); + if(color.strokeInfo) + { + var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize, + color.strokeInfo.strokeUnits); + el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth); + this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " + + color.strokeInfo.strokeUnits); + } } el.elementModel.shapeModel.GLWorld.render(); } diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index fabcec69..46d76a19 100644 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js @@ -63,15 +63,14 @@ exports.FillTool = Montage.create(ModifierToolBase, { colorInfo = { mode:color.colorMode, color:color.color }; - ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); } else { colorInfo = { mode:"nocolor", color:color.color }; - ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); } + ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); } } } diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index cc20d94c..2be74ada 100644 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js @@ -48,20 +48,33 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { value: function(event) { this.isDrawing = true; - if(this._canColor) + if(this._canColor && this.application.ninja.selectedElements.length) { -// var color = this.application.ninja.colorController.colorToolbar.stroke; -// ElementsMediator.setColor(this.application.ninja.selectedElements, color, false, "Change", "inkBottleTool"); + var color = this.application.ninja.colorController.colorToolbar.stroke, + colorInfo; + if(color && color.color) + { + colorInfo = { mode:color.colorMode, + color:color.color + }; + } + else + { + colorInfo = { mode:"nocolor", + color:color.color + }; + } + + colorInfo.borderInfo = { borderStyle:this.options._borderStyle.value, + borderWidth:this.options._borderWidth.value, + borderUnits:this.options._borderWidth.units + }; - var strokeInfo = { borderStyle:this.options._borderStyle.value, - borderWidth:this.options._borderWidth.value, - borderUnits:this.options._borderWidth.units, - strokeSize:this.options._strokeSize.value, - strokeUnits:this.options._strokeSize.units, - color:this.application.ninja.colorController.colorToolbar.stroke - }; + colorInfo.strokeInfo = { strokeSize:this.options._strokeSize.value, + strokeUnits:this.options._strokeSize.units + }; - ElementsMediator.setStroke(this.application.ninja.selectedElements, strokeInfo, "Change", "inkBottleTool"); + ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); } } } -- cgit v1.2.3