From f2c98ab46ed99781cecb8396150c055d0ce5e4cd Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 13 Dec 2009 03:31:30 +0000 Subject: [PATCH] fixtransforms branch: groups with skewed elements now resize/move properly git-svn-id: http://svg-edit.googlecode.com/svn/branches/fixtransforms@1034 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c0a2229e..aaac6973 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -11,10 +11,9 @@ /* TODOs for TransformList: - * fix resizing of rotated elements - * when resizing a group and elements are rotated within, collapse matrices now that it works - * go through ungrouping again + * go through Selector.resize() and make sure groups account for rotated/skewed children * go through Selector.resize() and rework so that they are always rectangular + * go through ungrouping again */ /* TODOs for Localizing: @@ -1617,14 +1616,16 @@ function BatchCommand(text) { var m = transformListToTransform(childTlist).matrix; var angle = canvas.getRotationAngle(child); - if(angle) { - var em = matrixMultiply(tm, sm, tmn); + if(angle || hasMatrixTransform(childTlist)) { + var em = matrixMultiply(tm, sm, tmn, m); // this does not appear to work, something wrong with my logic here var e2t = svgroot.createSVGTransform(); e2t.setMatrix(em); - childTlist.insertItemBefore(e2t,0); + childTlist.clear(); + childTlist.appendItem(e2t,0); } + // if not rotated or skewed, push the [T][S][-T] down to the child else { // update the transform list with translate,scale,translate @@ -2001,6 +2002,14 @@ function BatchCommand(text) { } return svgroot.createSVGTransformFromMatrix(m); }; + + var hasMatrixTransform = function(tlist) { + var num = tlist.numberOfItems; + while (num--) { + if (tlist.getItem(num).type == 1) return true; + } + return false; + } // // Easy way to loop through transform list, but may not be worthwhile // var eachXform = function(elem, callback) {