From 7471fed84447297e4b46831dd975d155921b66d6 Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Thu, 31 Dec 2009 21:14:41 +0000 Subject: [PATCH] minor optimization, fix git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1136 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 1 + editor/svgcanvas.js | 48 +++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index b8d6cc64..7c735b91 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1281,6 +1281,7 @@ function svg_edit_setup() { }, ".dropdown button": { 'height': {s: '18px', l: '34px', xl: '40px'}, + 'line-height': {s: '18px', l: '34px', xl: '40px'}, 'margin-top': {s: '3px'} }, "#tools_top label, #tools_bottom label": { diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index cd804bb0..340315d4 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2286,7 +2286,7 @@ function BatchCommand(text) { maxx: null, maxy: null }; - + // - when we are in a create mode, the element is added to the canvas // but the action is not recorded until mousing up // - when we are in select mode, select the element, remember the position @@ -2621,27 +2621,6 @@ function BatchCommand(text) { 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) { case "select": @@ -2832,11 +2811,30 @@ function BatchCommand(text) { if (!window.opera) svgroot.unsuspendRedraw(handle); break; case "square": - setRect(true); - break; + // fall through case "rect": + // fall through case "image": - setRect(evt.shiftKey); + var square = (current_mode == 'square') || evt.shiftKey; + 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); + break; case "circle": var cx = shape.getAttributeNS(null, "cx");