From d44f3196c925332dcaf45f7cf8c64e22a1994bb9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 4 Jun 2012 17:11:06 -0700 Subject: Fill and Ink-Bottle fixes. Signed-off-by: Nivesh Rajbhandari --- js/tools/FillTool.js | 32 +++++++++++++++++++------------- js/tools/InkBottleTool.js | 10 +++++----- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'js/tools') diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 66dd9305..69807bc3 100755 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js @@ -73,22 +73,28 @@ exports.FillTool = Montage.create(ModifierToolBase, { this.isDrawing = true; if(this._canColor && this.application.ninja.selectedElements.length) { + var fillInfo = {}, + color; + if(this.options.useFillColor.checked) { + fillInfo.colorInfo = {}; + color = this.options.fill; + if(color && color.color) + { + fillInfo.colorInfo.mode = color.colorMode; + fillInfo.colorInfo.color = color.color; + } else { + fillInfo.colorInfo.mode = "nocolor"; + fillInfo.colorInfo.color = null; + } + } - var color = this.options.fill, - colorInfo; - if(color && color.color) - { - colorInfo = { mode:color.colorMode, - color:color.color - }; + if(this.options.useWebGL.checked) { + fillInfo.webGLInfo = {}; + fillInfo.webGLInfo.material = this.options.fillMaterial.value; } - else - { - colorInfo = { mode:"nocolor", - color:color.color - }; + if(fillInfo.colorInfo || fillInfo.webGLInfo) { + ElementsMediator.setFill(this.application.ninja.selectedElements, fillInfo, "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 2c03d133..bb5d3ae2 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js @@ -87,18 +87,18 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { colorInfo.borderInfo = {}; if(this.options.useBorderWidth.checked) { - colorInfo.borderInfo.borderWidth = this.options._borderWidth.value; - colorInfo.borderInfo.borderUnits = this.options._borderWidth.units; + colorInfo.borderInfo.borderWidth = this.options.borderWidth.value; + colorInfo.borderInfo.borderUnits = this.options.borderWidth.units; } if(this.options.useBorderStyle.checked) { - colorInfo.borderInfo.borderStyle = this.options._borderStyle.value; + colorInfo.borderInfo.borderStyle = this.options.borderStyle.value; } } if(this.options.useStrokeSize.checked) { colorInfo.strokeInfo = {}; - colorInfo.strokeInfo.strokeSize = this.options._strokeSize.value; - colorInfo.strokeInfo.strokeUnits = this.options._strokeSize.units; + colorInfo.strokeInfo.strokeSize = this.options.strokeSize.value; + colorInfo.strokeInfo.strokeUnits = this.options.strokeSize.units; } ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); -- cgit v1.2.3 From 945fac7b1593260757b6f2864810ca9916d7d698 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 5 Jun 2012 11:36:03 -0700 Subject: Updated ink bottle tool to support color-chip's checkbox and undo/redo for strokes/borders. Signed-off-by: Nivesh Rajbhandari --- js/tools/InkBottleTool.js | 49 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'js/tools') diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index bb5d3ae2..dff0b0fa 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js @@ -69,39 +69,46 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { if(this._canColor && this.application.ninja.selectedElements.length) { - var color = this.options.stroke, - colorInfo; - if(color && color.color) - { - colorInfo = { mode:color.colorMode, - color:color.color - }; - } - else - { - colorInfo = { mode:"nocolor", - color:color.color - }; + var strokeInfo = {}, + color; + if(this.options.useStrokeColor.checked) { + strokeInfo.colorInfo = {}; + color = this.options.stroke; + if(color && color.color) + { + strokeInfo.colorInfo.mode = color.colorMode; + strokeInfo.colorInfo.color = color.color; + } else { + strokeInfo.colorInfo.mode = "nocolor"; + strokeInfo.colorInfo.color = null; + } } if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { - colorInfo.borderInfo = {}; + strokeInfo.borderInfo = {}; if(this.options.useBorderWidth.checked) { - colorInfo.borderInfo.borderWidth = this.options.borderWidth.value; - colorInfo.borderInfo.borderUnits = this.options.borderWidth.units; + strokeInfo.borderInfo.borderWidth = this.options.borderWidth.value; + strokeInfo.borderInfo.borderUnits = this.options.borderWidth.units; } if(this.options.useBorderStyle.checked) { - colorInfo.borderInfo.borderStyle = this.options.borderStyle.value; + strokeInfo.borderInfo.borderStyle = this.options.borderStyle.value; } } if(this.options.useStrokeSize.checked) { - colorInfo.strokeInfo = {}; - colorInfo.strokeInfo.strokeSize = this.options.strokeSize.value; - colorInfo.strokeInfo.strokeUnits = this.options.strokeSize.units; + strokeInfo.shapeInfo = {}; + strokeInfo.shapeInfo.strokeSize = this.options.strokeSize.value; + strokeInfo.shapeInfo.strokeUnits = this.options.strokeSize.units; + } + + if(this.options.useWebGL.checked) { + strokeInfo.webGLInfo = {}; + strokeInfo.webGLInfo.material = this.options.strokeMaterial.value; } - ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, false, "Change", "inkBottleTool"); + if(strokeInfo.colorInfo || strokeInfo.borderInfo || strokeInfo.shapeInfo || strokeInfo.webGLInfo) { + ElementsMediator.setStroke(this.application.ninja.selectedElements, strokeInfo, "Change", "inkBottleTool"); + } } } } -- cgit v1.2.3 From 3bf45fbac80bb3eac7ed6493cfe136899760b497 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 5 Jun 2012 15:10:46 -0700 Subject: Free Transform tool's handle should stop when it reaches the other end. IKNINJA-1335 - Free Transform tool: When one of the handles reaches the other end, the tool should stop. IKNINJA-1261 - [WebGL] [Shape] [Selection] Material shows in the middle of Canvas area if the shape is transformed toward negative coordinate. (This was happening because setting a canvas' width to 0 resets the canvas' width to 300.) Signed-off-by: Nivesh Rajbhandari --- js/tools/SelectionTool.js | 112 +++++++++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 35 deletions(-) (limited to 'js/tools') diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 4bafa12a..7b72a857 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -399,7 +399,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { //Routines to modify the selected objects modifyElements : { value : function(data, event) { - var delta, deltaH = [], deltaW = [], modObject = []; + var delta, modObject = [], left, top, width, height; if(this._handleMode !== null) { // 0 7 6 @@ -411,92 +411,134 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize North-West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; - var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; + width = parseInt(element.elementModel.getProperty("w")) - delta; + if(width <= 0) { + width = 1; + left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + } else { + left = parseInt(element.elementModel.getProperty("x")) + delta; + } + delta = ~~(data.pt1[1] - data.pt0[1]); - var height = parseInt(element.elementModel.getProperty("h")) - delta + "px"; - var top = parseInt(element.elementModel.getProperty("y")) + delta + "px"; - modObject.push({element:element, properties:{width: width, height: height, left: left, top: top}}); + height = parseInt(element.elementModel.getProperty("h")) - delta; + if(height <= 0) { + height = 1; + top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + } else { + top = parseInt(element.elementModel.getProperty("y")) + delta; + } + modObject.push({element:element, properties:{width: width + "px", height: height + "px", left: left + "px", top: top + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); break; case 1: // Resize West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; - var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; - modObject.push({element:element, properties:{left: left, width: width}}); + width = parseInt(element.elementModel.getProperty("w")) - delta; + if(width <= 0) { + width = 1; + left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + } else { + left = parseInt(element.elementModel.getProperty("x")) + delta; + } + modObject.push({element:element, properties:{left: left + "px", width: width + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool"); break; case 2: // Resize South-West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - var width = parseInt(element.elementModel.getProperty("w")) - delta + "px"; - var left = parseInt(element.elementModel.getProperty("x")) + delta + "px"; + width = parseInt(element.elementModel.getProperty("w")) - delta; + if(width <= 0) { + width = 1; + left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + } else { + left = parseInt(element.elementModel.getProperty("x")) + delta; + } delta = ~~(data.pt1[1] - data.pt0[1]); - var height = parseInt(element.elementModel.getProperty("h")) + delta + "px"; - modObject.push({element:element, properties:{width: width, height: height, left: left}}); + height = parseInt(element.elementModel.getProperty("h")) + delta; + if(height <= 0) { + height = 1; + } + modObject.push({element:element, properties:{width: width + "px", height: height + "px", left: left + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); break; case 3: // Resize South this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[1] - data.pt0[1]); - deltaH.push(parseInt(element.elementModel.getProperty("h")) + delta + "px"); - // modObject.push({element:element, properties:{width: width, height: height}}); + height = parseInt(element.elementModel.getProperty("h")) + delta; + if(height <= 0) { + height = 1; + } + modObject.push({element:element, properties:{height: height + "px"}}); }); - ElementsMediator.setProperty(this.application.ninja.selectedElements, "height", deltaH, "Changing", "SelectionTool" ); break; case 4: // Resize South-East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - var width = parseInt(element.elementModel.getProperty("w")) + delta + "px"; + width = parseInt(element.elementModel.getProperty("w")) + delta; + if(width <= 0) { + width = 1; + } delta = ~~(data.pt1[1] - data.pt0[1]); - var height = parseInt(element.elementModel.getProperty("h")) + delta + "px"; - modObject.push({element:element, properties:{width: width, height: height}}); + height = parseInt(element.elementModel.getProperty("h")) + delta; + if(height <= 0) { + height = 1; + } + modObject.push({element:element, properties:{width: width + "px", height: height + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); break; case 5: // Resize East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - deltaW.push(parseInt(element.elementModel.getProperty("w")) + delta + "px"); - // modObject.push({element:element, properties:{width: width, height: height}}); + width = parseInt(element.elementModel.getProperty("w")) + delta; + if(width <= 0) { + width = 1; + } + modObject.push({element:element, properties:{width: width + "px"}}); }); - ElementsMediator.setProperty(this.application.ninja.selectedElements, "width", deltaW, "Changing", "SelectionTool" ); break; case 6: // Resize North-East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - var width = parseInt(element.elementModel.getProperty("w")) + delta + "px"; + width = parseInt(element.elementModel.getProperty("w")) + delta; + if(width <= 0) { + width = 1; + } delta = ~~(data.pt1[1] - data.pt0[1]); - var height = parseInt(element.elementModel.getProperty("h")) - delta + "px"; - var top = parseInt(element.elementModel.getProperty("y")) + delta + "px"; - modObject.push({element:element, properties:{width: width, height: height, top: top}}); + height = parseInt(element.elementModel.getProperty("h")) - delta; + if(height <= 0) { + height = 1; + top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + } else { + top = parseInt(element.elementModel.getProperty("y")) + delta; + } + modObject.push({element:element, properties:{width: width + "px", height: height + "px", top: top + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); break; case 7: // Resize North this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[1] - data.pt0[1]); - var height = parseInt(element.elementModel.getProperty("h")) - delta + "px"; - var top = parseInt(element.elementModel.getProperty("y")) + delta + "px"; - modObject.push({element:element, properties:{height: height, top: top}}); + height = parseInt(element.elementModel.getProperty("h")) - delta; + if(height <= 0) { + height = 1; + top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + } else { + top = parseInt(element.elementModel.getProperty("y")) + delta; + } + modObject.push({element:element, properties:{height: height + "px", top: top + "px"}}); }); - ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); break; default: break; } + ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" ); this._delta = delta; } else -- cgit v1.2.3