From d0661d6c587aced68a68e36a5ec4e81f8a2096e8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 23 Feb 2012 16:57:55 -0800 Subject: bug fixes for canvas 2d shape drawing. --- js/tools/LineTool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 233316a5..0a7c0534 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -42,7 +42,10 @@ exports.LineTool = Montage.create(ShapeTool, { } this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null); - this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; + if (this.application.ninja.colorController.colorToolbar.stroke.color) + this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; + else + this._strokeColor = [0,0,0,1]; this.startDraw(event); } }, -- cgit v1.2.3 From b194efa0556806593b29eb197250df462e89fcc4 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 27 Feb 2012 14:03:11 -0800 Subject: Enable shift key constraint for Pan Tool. --- js/tools/PanTool.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 71301d46..0537a27b 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -81,6 +81,14 @@ exports.PanTool = Montage.create(toolBase, { this._altKeyDown = true; } + else if (event.shiftKey) + { + if (!this._shiftKeyDown) + { + this._shiftKeyDown = true; + this._shiftPt = this._lastGPt.slice(); + } + } } }, @@ -90,6 +98,10 @@ exports.PanTool = Montage.create(toolBase, { this._altKeyDown = false; } + else if (event.keyCode === Keyboard.SHIFT) + { + this._shiftKeyDown = false; + } } }, @@ -221,6 +233,7 @@ exports.PanTool = Montage.create(toolBase, var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); this._lastGPt = this._globalPt.slice(); + this._shiftPt = this._lastGPt.slice(); this._lastY = this._lastGPt[1]; // set up the matrices we will be needing @@ -285,6 +298,16 @@ exports.PanTool = Montage.create(toolBase, this._globalPt[2] += dy; gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; } + else if (this._shiftKeyDown) + { + var dx = Math.abs( this._shiftPt[0] - gPt[0] ), + dy = Math.abs( this._shiftPt[1] - gPt[1] ); + + if (dx >= dy) + gPt[1] = this._shiftPt[1]; + else + gPt[0] = this._shiftPt[0]; + } // update the scrollbars var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); -- cgit v1.2.3 From ef38731ae2769dcb2247db599cdfe62d38e34b28 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 27 Feb 2012 15:39:16 -0800 Subject: Reset translation values as well when double-clicking to reset the rotation values. Signed-off-by: Nivesh Rajbhandari --- js/tools/Rotate3DToolBase.js | 11 ++++------- js/tools/Translate3DToolBase.js | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index aa91b2f4..b04e8b0a 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -447,16 +447,13 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { iMat; for(var i = 0; i < len; i++) { - // Reset to the identity matrix but retain the rotation values + // Reset to the identity matrix item = this._targets[i]; - elt = item.elt; - - // Reset to the identity matrix but retain the translation values iMat = Matrix.I(4); mat = item.mat; - iMat[12] = mat[12]; - iMat[13] = mat[13]; - iMat[14] = mat[14]; +// iMat[12] = mat[12]; +// iMat[13] = mat[13]; +// iMat[14] = mat[14]; dist = this._undoArray[i].dist; diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index cbf76830..3d9191da 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -85,7 +85,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, { // Reset to the identity matrix but retain the rotation values item = this._targets[i]; - elt = item.elt; mat = item.mat.slice(0); mat[12] = 0; mat[13] = 0; -- cgit v1.2.3 From 7cbd26d475eaad817042692f9116f9a24ae60997 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 28 Feb 2012 10:24:06 -0800 Subject: Bug fixes: 1152: allow deleting of multiple paths from inside pen tool 1128: keyboard hotkey shortcut 'P' for pen tool 941: changing width or height of the path scales the path --- js/tools/PenTool.js | 77 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 7749d525..bb9c71e7 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -955,33 +955,64 @@ exports.PenTool = Montage.create(ShapeTool, { handleDelete:{ value: function(event){ - //clear the selected subpath...the only new additions to this function w.r.t. ToolBase - if (this._selectedSubpath){ - if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ - this._hoveredAnchorIndex=-1; - this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); - this._selectedSubpath.createSamples(); - //clear the canvas - this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); - this.DrawSubpathAnchors(this._selectedSubpath); - this.ShowSelectedSubpath(); + var len = this.application.ninja.selectedElements.length; + if (len===0) { + //clear the selected subpath...the only new additions to this function w.r.t. ToolBase + if (this._selectedSubpath){ + if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ + this._hoveredAnchorIndex=-1; + this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); + this._selectedSubpath.createSamples(); + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + this.DrawSubpathAnchors(this._selectedSubpath); + this.ShowSelectedSubpath(); + } + else { + this._selectedSubpath.clearAllAnchors(); //perhaps unnecessary + this._selectedSubpath = null; + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + + //undo/redo...go through ElementController and NJEvent + var els = []; + ElementController.removeElement(this._penCanvas); + els.push(this._penCanvas); + NJevent( "deleteSelection", els ); + this._penCanvas = null; + } + } + //do nothing if there was no selected subpath and if there was no selection + } + else { + + //undo/redo...go through ElementMediator (see ElementMediator.handleDeleting() from where the much of this function is copied) + //clear the canvas + this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); + var els = []; + for(var i = 0; i=0 && this._hoveredAnchorIndex=0 && this._hoveredAnchorIndex