Fixed several group selection bugs
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@896 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
f15a2da457
commit
d0784dcabd
|
@ -4070,8 +4070,8 @@ function BatchCommand(text) {
|
||||||
|
|
||||||
if(bbox) {
|
if(bbox) {
|
||||||
batchCmd = new BatchCommand("Fit Canvas to Content");
|
batchCmd = new BatchCommand("Fit Canvas to Content");
|
||||||
canvas.addToSelection(canvas.getVisibleElements());
|
var visEls = canvas.getVisibleElements();
|
||||||
$.each(selectedElements, function(i, item) {
|
$.each(visEls, function(i, item) {
|
||||||
var sel_bb = item.getBBox();
|
var sel_bb = item.getBBox();
|
||||||
var cmd = recalculateDimensions(item, {
|
var cmd = recalculateDimensions(item, {
|
||||||
x: sel_bb.x - bbox.x,
|
x: sel_bb.x - bbox.x,
|
||||||
|
@ -4081,7 +4081,6 @@ function BatchCommand(text) {
|
||||||
});
|
});
|
||||||
batchCmd.addSubCommand(cmd);
|
batchCmd.addSubCommand(cmd);
|
||||||
});
|
});
|
||||||
canvas.clearSelection();
|
|
||||||
x = Math.round(bbox.width);
|
x = Math.round(bbox.width);
|
||||||
y = Math.round(bbox.height);
|
y = Math.round(bbox.height);
|
||||||
} else {
|
} else {
|
||||||
|
@ -5028,10 +5027,19 @@ function BatchCommand(text) {
|
||||||
if(elem.tagName == 'g') {
|
if(elem.tagName == 'g') {
|
||||||
return canvas.getStrokedBBox(elem.childNodes);
|
return canvas.getStrokedBBox(elem.childNodes);
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
return elem.getBBox();
|
return elem.getBBox();
|
||||||
|
} catch(e) { return null; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var full_bb = getCheckedBBox(elems[0]);
|
var full_bb;
|
||||||
|
$.each(elems, function() {
|
||||||
|
if(full_bb) return;
|
||||||
|
full_bb = getCheckedBBox(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(elems.length == 1) return full_bb;
|
||||||
|
|
||||||
var max_x = full_bb.x + full_bb.width;
|
var max_x = full_bb.x + full_bb.width;
|
||||||
var max_y = full_bb.y + full_bb.height;
|
var max_y = full_bb.y + full_bb.height;
|
||||||
var min_x = full_bb.x;
|
var min_x = full_bb.x;
|
||||||
|
@ -5048,6 +5056,7 @@ function BatchCommand(text) {
|
||||||
|
|
||||||
$.each(elems, function(i, elem) {
|
$.each(elems, function(i, elem) {
|
||||||
var cur_bb = getCheckedBBox(elem);
|
var cur_bb = getCheckedBBox(elem);
|
||||||
|
if(!cur_bb) return;
|
||||||
var offset = getOffset(elem);
|
var offset = getOffset(elem);
|
||||||
min_x = Math.min(min_x, cur_bb.x - offset);
|
min_x = Math.min(min_x, cur_bb.x - offset);
|
||||||
min_y = Math.min(min_y, cur_bb.y - offset);
|
min_y = Math.min(min_y, cur_bb.y - offset);
|
||||||
|
@ -5058,6 +5067,7 @@ function BatchCommand(text) {
|
||||||
|
|
||||||
$.each(elems, function(i, elem) {
|
$.each(elems, function(i, elem) {
|
||||||
var cur_bb = getCheckedBBox(elem);
|
var cur_bb = getCheckedBBox(elem);
|
||||||
|
if(!cur_bb) return;
|
||||||
var offset = getOffset(elem);
|
var offset = getOffset(elem);
|
||||||
max_x = Math.max(max_x, cur_bb.x + cur_bb.width + offset);
|
max_x = Math.max(max_x, cur_bb.x + cur_bb.width + offset);
|
||||||
max_y = Math.max(max_y, cur_bb.y + cur_bb.height + offset);
|
max_y = Math.max(max_y, cur_bb.y + cur_bb.height + offset);
|
||||||
|
@ -5069,15 +5079,14 @@ function BatchCommand(text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getVisibleElements = function(parent, includeBBox) {
|
this.getVisibleElements = function(parent, includeBBox) {
|
||||||
if(!parent) parent = svgcontent;
|
if(!parent) parent = $(svgcontent).children(); // Prevent layers from being included
|
||||||
|
|
||||||
var contentElems = [];
|
var contentElems = [];
|
||||||
$(parent).find('*').each(function(i, elem) {
|
$(parent).children().each(function(i, elem) {
|
||||||
if(elem.nodeName == 'g') return;
|
|
||||||
try {
|
try {
|
||||||
var box = canvas.getBBox(elem);
|
var box = elem.getBBox();
|
||||||
if (box) {
|
if (box) {
|
||||||
var item = includeBBox?{'elem':elem, 'bbox':box}:elem;
|
var item = includeBBox?{'elem':elem, 'bbox':canvas.getStrokedBBox([elem])}:elem;
|
||||||
contentElems.push(item);
|
contentElems.push(item);
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
Loading…
Reference in New Issue