Fixed Issue 232: undo after fit to content (Document properties)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@876 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-10-23 18:03:48 +00:00
parent 80696e17eb
commit 0fa6da2afc
2 changed files with 8 additions and 3 deletions

View File

@ -53,7 +53,7 @@ function svg_edit_setup() {
// upon creation of a text element the editor is switched into // upon creation of a text element the editor is switched into
// select mode and this event fires - we need our UI to be in sync // select mode and this event fires - we need our UI to be in sync
is_node = selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0; is_node = !!(selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0);
if (svgCanvas.getMode() != "multiselect" && !is_node) { if (svgCanvas.getMode() != "multiselect" && !is_node) {
setSelectMode(); setSelectMode();

View File

@ -3907,6 +3907,7 @@ function BatchCommand(text) {
this.setResolution = function(x, y) { this.setResolution = function(x, y) {
var res = canvas.getResolution(); var res = canvas.getResolution();
var w = res.w, h = res.h; var w = res.w, h = res.h;
var batchCmd;
if(x == 'fit') { if(x == 'fit') {
canvas.clearSelection(); canvas.clearSelection();
@ -3915,15 +3916,17 @@ function BatchCommand(text) {
var bbox = canvas.getStrokedBBox(); var bbox = canvas.getStrokedBBox();
if(bbox) { if(bbox) {
batchCmd = new BatchCommand("Fit Canvas to Content");
canvas.addToSelection(canvas.getVisibleElements()); canvas.addToSelection(canvas.getVisibleElements());
$.each(selectedElements, function(i, item) { $.each(selectedElements, function(i, item) {
var sel_bb = item.getBBox(); var sel_bb = item.getBBox();
recalculateDimensions(item, { var cmd = recalculateDimensions(item, {
x: sel_bb.x - bbox.x, x: sel_bb.x - bbox.x,
y: sel_bb.y - bbox.y, y: sel_bb.y - bbox.y,
width: sel_bb.width, width: sel_bb.width,
height: sel_bb.height height: sel_bb.height
}); });
batchCmd.addSubCommand(cmd);
}); });
canvas.clearSelection(); canvas.clearSelection();
x = Math.round(bbox.width); x = Math.round(bbox.width);
@ -3936,7 +3939,9 @@ function BatchCommand(text) {
y *= current_zoom; y *= current_zoom;
if (x != w || y != h) { if (x != w || y != h) {
var handle = svgroot.suspendRedraw(1000); var handle = svgroot.suspendRedraw(1000);
var batchCmd = new BatchCommand("Change Image Dimensions"); if(!batchCmd) {
batchCmd = new BatchCommand("Change Image Dimensions");
}
svgroot.setAttribute('width', x); svgroot.setAttribute('width', x);
svgroot.setAttribute('height', y); svgroot.setAttribute('height', y);
batchCmd.addSubCommand(new ChangeElementCommand(svgroot, {"width":w, "height":h})); batchCmd.addSubCommand(new ChangeElementCommand(svgroot, {"width":w, "height":h}));