Fixed issue 383: Delete unclosed path node makes the path appear as closed. Also prevented deletion of last two nodes
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1131 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
19efdad647
commit
f76f10e464
|
@ -4212,10 +4212,14 @@ function BatchCommand(text) {
|
||||||
// current_path.setAttribute("d", convertToD(current_path.pathSegList));
|
// current_path.setAttribute("d", convertToD(current_path.pathSegList));
|
||||||
},
|
},
|
||||||
deletePathNode: function() {
|
deletePathNode: function() {
|
||||||
|
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 last_pt = current_path_pts.length/2 - 1;
|
var last_pt = current_path_pts.length/2 - 1;
|
||||||
var pt = current_path_pt, list = current_path.pathSegList;
|
var pt = current_path_pt, list = current_path.pathSegList;
|
||||||
var cur_item = list.getItem(pt);
|
var cur_item = list.getItem(pt);
|
||||||
var next_item = list.getItem(pt+1);
|
|
||||||
|
|
||||||
if(pt == 0) {
|
if(pt == 0) {
|
||||||
var next_x = getPathPoint(1)[0];
|
var next_x = getPathPoint(1)[0];
|
||||||
|
@ -4224,11 +4228,13 @@ function BatchCommand(text) {
|
||||||
replacePathSeg(2, 1, [next_x, next_y]);
|
replacePathSeg(2, 1, [next_x, next_y]);
|
||||||
|
|
||||||
// Reposition last node
|
// Reposition last node
|
||||||
|
if(is_closed) {
|
||||||
var last_item = list.getItem(last_pt);
|
var last_item = list.getItem(last_pt);
|
||||||
replacePathSeg(4, last_pt, [next_x, next_y]);
|
replacePathSeg(4, last_pt, [next_x, next_y]);
|
||||||
removeControlPointGrips(last_pt - 1);
|
removeControlPointGrips(last_pt - 1);
|
||||||
current_path_pts.splice(last_pt*2, 2, next_x, next_y);
|
current_path_pts.splice(last_pt*2, 2, next_x, next_y);
|
||||||
current_path_pts.splice(0, 2);
|
current_path_pts.splice(0, 2);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
current_path_pts.splice(pt*2, 2);
|
current_path_pts.splice(pt*2, 2);
|
||||||
}
|
}
|
||||||
|
@ -4241,6 +4247,10 @@ function BatchCommand(text) {
|
||||||
var cp = $(current_path); cp.attr('d',cp.attr('d'));
|
var cp = $(current_path); cp.attr('d',cp.attr('d'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pt == last_pt && !is_closed) {
|
||||||
|
pt--;
|
||||||
|
}
|
||||||
|
|
||||||
addNodeToSelection(pt);
|
addNodeToSelection(pt);
|
||||||
},
|
},
|
||||||
setPointContainerTransform: setPointContainerTransform,
|
setPointContainerTransform: setPointContainerTransform,
|
||||||
|
|
Loading…
Reference in New Issue