Added shift-for-equal-width&height option when drawing rects, ellipses and images

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@943 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-11-13 16:55:58 +00:00
parent 5e7da751ec
commit d4fcca35ae
1 changed files with 26 additions and 22 deletions

View File

@ -2444,7 +2444,28 @@ function BatchCommand(text) {
y = mouse_y / current_zoom; y = mouse_y / current_zoom;
evt.preventDefault(); evt.preventDefault();
var setRect = function(square) {
var w = Math.abs(x - start_x),
h = Math.abs(y - start_y),
new_x, new_y;
if(square) {
w = h = Math.max(w, h);
new_x = start_x < x ? start_x : start_x - w;
new_y = start_y < y ? start_y : start_y - h;
} else {
new_x = Math.min(start_x,x);
new_y = Math.min(start_y,y);
}
assignAttributes(shape,{
'width': w,
'height': h,
'x': new_x,
'y': new_y
},1000);
}
switch (current_mode) switch (current_mode)
{ {
case "select": case "select":
@ -2643,29 +2664,11 @@ function BatchCommand(text) {
if (!window.opera) svgroot.unsuspendRedraw(handle); if (!window.opera) svgroot.unsuspendRedraw(handle);
break; break;
case "square": case "square":
var size = Math.max( Math.abs(x - start_x), Math.abs(y - start_y) ); setRect(true);
assignAttributes(shape,{
'width': size,
'height': size,
'x': start_x < x ? start_x : start_x - size,
'y': start_y < y ? start_y : start_y - size
},1000);
break; break;
case "rect": case "rect":
assignAttributes(shape,{
'width': Math.abs(x-start_x),
'height': Math.abs(y-start_y),
'x': Math.min(start_x,x),
'y': Math.min(start_y,y)
},1000);
break;
case "image": case "image":
assignAttributes(shape,{ setRect(evt.shiftKey);
'width': Math.abs(x-start_x),
'height': Math.abs(y-start_y),
'x': Math.min(start_x,x),
'y': Math.min(start_y,y)
},1000);
break; break;
case "circle": case "circle":
var cx = shape.getAttributeNS(null, "cx"); var cx = shape.getAttributeNS(null, "cx");
@ -2680,7 +2683,8 @@ function BatchCommand(text) {
var handle = null; var handle = null;
if (!window.opera) svgroot.suspendRedraw(1000); if (!window.opera) svgroot.suspendRedraw(1000);
shape.setAttributeNS(null, "rx", Math.abs(x - cx) ); shape.setAttributeNS(null, "rx", Math.abs(x - cx) );
shape.setAttributeNS(null, "ry", Math.abs(y - cy) ); var ry = Math.abs(evt.shiftKey?(x - cx):(y - cy));
shape.setAttributeNS(null, "ry", ry );
if (!window.opera) svgroot.unsuspendRedraw(handle); if (!window.opera) svgroot.unsuspendRedraw(handle);
break; break;
case "fhellipse": case "fhellipse":