Fixed issue 432

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1271 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-01-21 17:38:37 +00:00
parent 86ac38547f
commit 3df4a5d616
2 changed files with 30 additions and 12 deletions

View File

@ -141,7 +141,7 @@ function svg_edit_setup() {
svgCanvas.setMode('select');
};
var togglePathEditMode = function(editmode) {
var togglePathEditMode = function(editmode, elems) {
$('#path_node_panel').toggle(editmode);
$('#tools_bottom_2,#tools_bottom_3').toggle(!editmode);
var size = $('#tool_select > svg, #tool_select > img')[0].getAttribute('width');
@ -151,6 +151,9 @@ function svg_edit_setup() {
$('#tool_select').addClass('tool_button_current')
.empty().append($.getSvgIcon('select_node'));
multiselected = false;
if(elems.length) {
selectedElement = elems[0];
}
} else {
$('#tool_select').empty().append($.getSvgIcon('select'));
}
@ -198,7 +201,8 @@ function svg_edit_setup() {
} // if (elem != null)
// Deal with pathedit mode
togglePathEditMode(is_node);
togglePathEditMode(is_node, elems);
updateContextPanel();
};
@ -401,6 +405,7 @@ function svg_edit_setup() {
$('#tool_reorient').toggleClass('tool_button_disabled', angle == 0);
} else {
var point = path.getNodePoint();
$('#tool_node_delete').toggleClass('tool_button_disabled', !path.canDeleteNodes);
if(point) {
var seg_type = $('#seg_type');
$('#path_node_x').val(point.x);

View File

@ -3336,6 +3336,8 @@ function BatchCommand(text) {
//
var addNodeToSelection = function(points) {
// var point = points;
if(!$.isArray(points)) points = [points];
for(var i=0; i< points.length; i++) {
@ -3350,6 +3352,10 @@ function BatchCommand(text) {
i = selected_pts.length,
last_pt = current_path_pts.length/2 - 1,
grips = new Array(i);
// Check if amount of selected nodes are allowed to be deleted
var tot_pts = current_path_pts.length/2 - (is_closed?1:0);
pathActions.canDeleteNodes = (tot_pts - i >= 2);
$('#pathpointgrip_container circle').attr('stroke','#00F');
@ -3391,6 +3397,7 @@ function BatchCommand(text) {
updateSegLine();
updateSegLine(true);
// TODO: Set grips
// call("selected", grips);
};
@ -4017,17 +4024,24 @@ function BatchCommand(text) {
var diff_x = mouse_x - current_path_pts[current_path_pt*2];
var diff_y = mouse_y - current_path_pts[current_path_pt*2+1];
// var rot = !!canvas.getRotationAngle(current_path);
// if(rot) {
// var m = canvas.getTransformList(current_path).getItem(0).matrix;
// }
var rot = !!canvas.getRotationAngle(current_path);
if(rot) {
var m = canvas.getTransformList(current_path).getItem(0).matrix;
}
for(var i=0; i<selected_pts.length; i++) {
var sel_pt = selected_pts[i];
var sel_pt_x = current_path_pts[sel_pt*2] + diff_x;
var sel_pt_y = current_path_pts[sel_pt*2+1] + diff_y;
//
if(rot) {
// var pt = transformPoint(current_path_pts[sel_pt*2], current_path_pts[sel_pt*2+1], m);
// var dpt = transformPoint(diff_x, diff_y, m);
// sel_pt_x = pt.x + dpt.x;
// sel_pt_y = pt.y + dpt.y;
}
current_path_pt_drag = sel_pt;
updatePath(sel_pt_x, sel_pt_y, old_path_pts);
}
@ -4487,14 +4501,13 @@ function BatchCommand(text) {
// current_path.setAttribute("d", convertToD(current_path.pathSegList));
},
deletePathNode: function() {
if(!pathActions.canDeleteNodes) return;
var is_closed = pathIsClosed();
// TODO: Make delete node button disabled when there's only 2 nodes
if(current_path_pts.length <= (is_closed?6:4)) return;
var d = getD();
var len = selected_pts.length;
var d = getD();
while(len--) {
var pt = selected_pts[len];
var last_pt = current_path_pts.length/2 - 1;