Issue 40: Fix move, resize, rotate of groups. Ungroup with rotations do not work properly yet.

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@604 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-09-06 01:59:26 +00:00
parent 45388a21f3
commit e1382ac70a
1 changed files with 27 additions and 3 deletions

View File

@ -973,9 +973,36 @@ function BatchCommand(text) {
pointGripContainer.removeAttribute("transform");
}
}
// if it's a group, transfer the transform attribute to each child element
// and recursively call recalculateDimensions()
if (selected.tagName == "g") {
var batchCmd = new BatchCommand("Transform Group");
var xform = selected.getAttribute("transform");
var children = selected.childNodes;
var i = children.length;
while (i--) {
var child = children.item(i);
if (child.nodeType == 1) {
var childBox = child.getBBox();
if (childBox) {
var pt = remap(childBox.x,childBox.y),
w = scalew(childBox.width),
h = scaleh(childBox.height);
childBox.x = pt.x; childBox.y = pt.y;
childBox.width = w; childBox.height = h;
batchCmd.addSubCommand(recalculateDimensions(child, childBox));
}
}
}
return batchCmd;
}
switch (selected.tagName)
{
case "g":
// do work here :P
break;
// NOTE: at the moment, there's no way to create an actual polygon element except by
// editing source or importing from somewhere else but we'll cover it here anyway
// polygon is handled just like polyline
@ -1153,9 +1180,6 @@ function BatchCommand(text) {
'height': scaleh(changes["height"])
}, 1000);
break;
case "g":
// do work here :P
break;
default: // rect
console.log("Unknown shape type: " + selected.tagName);
break;