From 250d84a79d9f72c6a98cbbecfe4e21f2c0d53a19 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 13 Jun 2012 10:55:21 -0700 Subject: fixes bug #1623: middle transform handle causes the brush stroke to have a zero width or height and brush stroke cannot be recovered --- js/lib/geom/brush-stroke.js | 69 ++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 0e0406dd..b69139b6 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -31,6 +31,8 @@ var BrushStroke = function GLBrushStroke() { //the HTML5 canvas that holds this brush stroke this._canvas = null; + //flag indicating whether or not to freeze the size and position of canvas + this._freezeCanvas = false; //stroke information this._strokeWidth = 1.0; @@ -174,11 +176,15 @@ BrushStroke.prototype.getStrokeWidth = function () { }; BrushStroke.prototype.setStrokeWidth = function (w) { - this._strokeWidth = w; - if (this._strokeWidth<1) { - this._strokeWidth = 1; + if (this._strokeWidth!==w) { + this._strokeWidth = w; + + if (this._strokeWidth<1) { + this._strokeWidth = 1; + } + this._isDirty=true; + this._freezeCanvas=false; } - this._isDirty=true; }; /* BrushStroke.prototype.getStrokeMaterial = function () { @@ -236,6 +242,7 @@ BrushStroke.prototype.setSmoothingAmount = function(a){ if (this._strokeAmountSmoothing!==a) { this._strokeAmountSmoothing = a; this._isDirty = true; + this._freezeCanvas=false; } }; @@ -274,27 +281,32 @@ BrushStroke.prototype.setStrokeStyle = function (s) { }; BrushStroke.prototype.setWidth = function (newW) { - if (newW<1) { - newW=1; //clamp minimum width to 1 + //get the old width from the canvas controller if the canvas is frozen, or from bbox if not frozen. + var oldCanvasWidth = parseInt(CanvasController.getProperty(this._canvas, "width")); + if (!this._freezeCanvas){ + oldCanvasWidth = Math.round(this._BBoxMax[0]-this._BBoxMin[0]); + } + var minWidth = 1+this._strokeWidth; + if (newW --- js/mediators/element-mediator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 40e94cca..611cf214 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -84,6 +84,7 @@ exports.ElementMediator = Montage.create(Component, { value: function(newChild, oldChild, notify) { this.application.ninja.currentDocument.model.documentRoot.replaceChild(newChild, oldChild); + if (newChild.getAttribute) newChild.setAttribute('data-ninja-node', 'true'); var undoLabel = "replace element"; -- cgit v1.2.3 From 877cb0294fa9a91b6926239d476eac2e6b1c6506 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 13 Jun 2012 11:49:30 -0700 Subject: correct path resizing in case of stroke width other than 1 --- js/lib/geom/sub-path.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index f765b715..ba277197 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js @@ -54,7 +54,7 @@ var GLSubpath = function GLSubpath() { //drawing context this._world = null; this._canvas = null; //todo this might be unnecessary (but faster) since we can get it from the world - + //tool that owns this subpath this._drawingTool = null; @@ -207,24 +207,25 @@ GLSubpath.prototype.geomType = function () { GLSubpath.prototype.setWidth = function (newW) { var strokeWidth = this._strokeWidth; var halfStrokeWidth = strokeWidth*0.5; - if (newW<1) { - newW=1; //clamp minimum width to 1 + var minWidth = 1+strokeWidth; + if (newW --- js/helper-classes/3D/draw-utils.js | 18 ++++++++-------- js/stage/stage.reel/stage.js | 42 ++++++++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index bef1e435..6a84c86b 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -117,7 +117,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { }, initializeFromDocument:{ - value:function(){ + value:function(adjustScrollOffsets){ var i, documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), stage = this.application.ninja.stage, @@ -144,13 +144,15 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { for(i=0; i