Made un-rotated child elements properly resize when resizing non-rotated groups

git-svn-id: http://svg-edit.googlecode.com/svn/branches/fixtransforms@997 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-12-04 17:53:05 +00:00
parent 4b0d3b23d3
commit 4c66ccbabe
1 changed files with 54 additions and 8 deletions

View File

@ -1437,9 +1437,43 @@ function BatchCommand(text) {
tx = m.e;
ty = m.f;
tlist.removeItem(0);
} // if we have a translate/scale/translate transform, push down to children
else if(tlist.numberOfItems >= 3 && tlist.getItem(1).type == 3) {
var trans_m = tlist.getItem(0).matrix;
var scale_m = tlist.getItem(1).matrix;
var children = selected.childNodes;
var c = children.length;
while (c--) {
var child = children.item(c);
if (child.nodeType == 1) {
var angle = canvas.getRotationAngle(child);
if(angle) {
// TODO: Deal with rotated childen...
}
// if we have any other transforms, collapse them all down to a matrix
// update the transform list with translate,scale,translate
var childTlist = canvas.getTransformList(child);
var translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(trans_m.e*-1, trans_m.f*-1);
scale.setScale(scale_m.a, scale_m.d);
translateBack.setTranslate(trans_m.e, trans_m.f);
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
batchCmd.addSubCommand( recalculateDimensions(child) );
}
}
// Remove these transforms from group
var N = tlist.numberOfItems;
tlist.removeItem(N-1);
tlist.removeItem(N-2);
tlist.removeItem(N-3);
} // if we have any other transforms, collapse them all down to a matrix
else if(tlist.numberOfItems > 0) {
var m = transformListToTransform(tlist).matrix;
if (tlist.numberOfItems > 0) {
var newxform = svgroot.createSVGTransform();
@ -1447,6 +1481,7 @@ function BatchCommand(text) {
tlist.clear();
tlist.appendItem(newxform);
}
}
if (tx != 0 || ty != 0) {
var a = m.a, b = m.b, c = m.c, d = m.d;
@ -1955,6 +1990,17 @@ function BatchCommand(text) {
return svgroot.createSVGTransformFromMatrix(m);
};
// // Easy way to loop through transform list, but may not be worthwhile
// var eachXform = function(elem, callback) {
// var tlist = canvas.getTransformList(elem);
// var num = tlist.numberOfItems;
// if(num == 0) return;
// while(num--) {
// var xform = tlist.getItem(num);
// callback(xform, tlist);
// }
// }
// FIXME: this should not have anything to do with zoom here - update the one place it is used this way
// converts a tiny object equivalent of a SVGTransform
// has the following properties: