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
|
// called when any element has changed
|
||||||
var elementChanged = function(window,elem) {
|
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
|
// we update the contextual panel with potentially new
|
||||||
// positional/sizing information (we DON'T want to update the
|
// positional/sizing information (we DON'T want to update the
|
||||||
// toolbar here as that creates an infinite loop)
|
// toolbar here as that creates an infinite loop)
|
||||||
|
@ -518,16 +524,20 @@ function svg_edit_setup() {
|
||||||
$('#tools_ellipse').show();
|
$('#tools_ellipse').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#resolution').change(function(){
|
function changeResolution(x,y) {
|
||||||
var res = this.value.split('x');
|
$('#resolution').val(x+'x'+y);
|
||||||
var x = parseInt(res[0]), y = parseInt(res[1]);
|
|
||||||
svgCanvas.setResolution(x,y);
|
|
||||||
$('#svgroot').css( { 'width': x, 'height': y } );
|
$('#svgroot').css( { 'width': x, 'height': y } );
|
||||||
$('#svgcanvas').css( { 'width': x, 'height': y } );
|
$('#svgcanvas').css( { 'width': x, 'height': y } );
|
||||||
$('div#palette_holder').css('width', x);
|
$('div#palette_holder').css('width', x);
|
||||||
$('#context_tools').css('width', x + 65);
|
$('#context_tools').css('width', x + 65);
|
||||||
$('#tools').css('height', y + 24);
|
$('#tools').css('height', y + 24);
|
||||||
$('#footer').css('width', x + 65);
|
$('#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;
|
return svgCanvas;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
var svgcanvas = null;
|
|
||||||
|
|
||||||
if(!window.console) {
|
if(!window.console) {
|
||||||
window.console = new function() {
|
window.console = new function() {
|
||||||
this.log = function(str) {};
|
this.log = function(str) {};
|
||||||
|
@ -905,8 +903,12 @@ function SvgCanvas(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setResolution = function(x, y) {
|
this.setResolution = function(x, y) {
|
||||||
|
var w = svgroot.getAttribute("width"),
|
||||||
|
h = svgroot.getAttribute("height");
|
||||||
svgroot.setAttribute("width", x);
|
svgroot.setAttribute("width", x);
|
||||||
svgroot.setAttribute("height", y);
|
svgroot.setAttribute("height", y);
|
||||||
|
addCommandToHistory(new ChangeElementCommand(svgroot, {"width":w,"height":h}, "resolution"));
|
||||||
|
call("changed", svgroot);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getMode = function() {
|
this.getMode = function() {
|
||||||
|
|
Loading…
Reference in New Issue