Make changing resolution undo/redo-able
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@202 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
ecb0f0e74e
commit
cfa488a502
|
@ -37,6 +37,12 @@ function svg_edit_setup() {
|
|||
|
||||
// called when any element has changed
|
||||
var elementChanged = function(window,elem) {
|
||||
// if the element changed was the svg, then it must be a resolution change
|
||||
if (elem && elem.tagName == "svg") {
|
||||
changeResolution(parseInt(elem.getAttribute("width")),
|
||||
parseInt(elem.getAttribute("height")));
|
||||
}
|
||||
|
||||
// we update the contextual panel with potentially new
|
||||
// positional/sizing information (we DON'T want to update the
|
||||
// toolbar here as that creates an infinite loop)
|
||||
|
@ -518,16 +524,20 @@ function svg_edit_setup() {
|
|||
$('#tools_ellipse').show();
|
||||
});
|
||||
|
||||
$('#resolution').change(function(){
|
||||
var res = this.value.split('x');
|
||||
var x = parseInt(res[0]), y = parseInt(res[1]);
|
||||
svgCanvas.setResolution(x,y);
|
||||
function changeResolution(x,y) {
|
||||
$('#resolution').val(x+'x'+y);
|
||||
$('#svgroot').css( { 'width': x, 'height': y } );
|
||||
$('#svgcanvas').css( { 'width': x, 'height': y } );
|
||||
$('div#palette_holder').css('width', x);
|
||||
$('#context_tools').css('width', x + 65);
|
||||
$('#tools').css('height', y + 24);
|
||||
$('#footer').css('width', x + 65);
|
||||
}
|
||||
|
||||
$('#resolution').change(function(){
|
||||
var res = this.value.split('x');
|
||||
var x = parseInt(res[0]), y = parseInt(res[1]);
|
||||
svgCanvas.setResolution(x,y);
|
||||
});
|
||||
|
||||
return svgCanvas;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var svgcanvas = null;
|
||||
|
||||
if(!window.console) {
|
||||
window.console = new function() {
|
||||
this.log = function(str) {};
|
||||
|
@ -905,8 +903,12 @@ function SvgCanvas(c)
|
|||
}
|
||||
|
||||
this.setResolution = function(x, y) {
|
||||
var w = svgroot.getAttribute("width"),
|
||||
h = svgroot.getAttribute("height");
|
||||
svgroot.setAttribute("width", x);
|
||||
svgroot.setAttribute("height", y);
|
||||
addCommandToHistory(new ChangeElementCommand(svgroot, {"width":w,"height":h}, "resolution"));
|
||||
call("changed", svgroot);
|
||||
}
|
||||
|
||||
this.getMode = function() {
|
||||
|
|
Loading…
Reference in New Issue