Added 'add sub-path' button to pathedit context panel
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1443 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
66457b70bf
commit
fde7386d75
|
@ -198,6 +198,26 @@
|
|||
</svg>
|
||||
</g>
|
||||
|
||||
<g id="add_subpath">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 124 124" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="svg_4" x1="0.33594" y1="0.28125" x2="1" y2="1">
|
||||
<stop offset="0" stop-color="#ffffff" stop-opacity="1"/>
|
||||
<stop offset="1" stop-color="#33a533" stop-opacity="1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g>
|
||||
<path d="m6,103l55,-87c85,33.64 -26,37.12 55,87l-110,0z" id="svg_1" fill="url(#svg_4)" stroke="#000000" stroke-width="4" stroke-dasharray="null"/>
|
||||
<g id="svg_7">
|
||||
<circle stroke-dasharray="null" stroke-width="5" stroke="#000000" fill="#ffffff" id="svg_6" r="22.63281" cy="88.5" cx="45.5"/>
|
||||
<line stroke-dasharray="null" stroke-width="7" stroke="#000000" id="svg_2" y2="104.03768" x2="45.5" y1="72.96232" x1="45.5"/>
|
||||
<line stroke-dasharray="null" stroke-width="7" stroke="#000000" id="svg_3" y2="88.5" x2="61.03768" y1="88.5" x1="29.96232"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</g>
|
||||
|
||||
|
||||
<g id="image">
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<defs>
|
||||
|
|
|
@ -365,6 +365,7 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
|||
</select>
|
||||
<div class="tool_button" id="tool_node_clone" title="Clone Node"></div>
|
||||
<div class="tool_button" id="tool_node_delete" title="Delete Node"></div>
|
||||
<div class="tool_button" id="tool_add_subpath" title="Add sub-path"></div>
|
||||
</div>
|
||||
|
||||
</div> <!-- tools_top -->
|
||||
|
|
|
@ -794,6 +794,7 @@ function svg_edit_setup() {
|
|||
$('#tool_reorient').toggleClass('disabled', angle == 0);
|
||||
} else {
|
||||
var point = path.getNodePoint();
|
||||
$('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');
|
||||
$('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);
|
||||
if(point) {
|
||||
var seg_type = $('#seg_type');
|
||||
|
@ -1415,6 +1416,20 @@ function svg_edit_setup() {
|
|||
}
|
||||
};
|
||||
|
||||
var addSubPath = function() {
|
||||
var button = $('#tool_add_subpath');
|
||||
var sp = !button.hasClass('push_button_pressed');
|
||||
if (sp) {
|
||||
button.addClass('push_button_pressed').removeClass('tool_button');
|
||||
} else {
|
||||
button.removeClass('push_button_pressed').addClass('tool_button');
|
||||
}
|
||||
|
||||
path.addSubPath(sp);
|
||||
|
||||
};
|
||||
|
||||
|
||||
var selectNext = function() {
|
||||
svgCanvas.cycleElement(1);
|
||||
};
|
||||
|
@ -2486,6 +2501,7 @@ function svg_edit_setup() {
|
|||
{sel:'#tool_node_link', fn: linkControlPoints, evt: 'click'},
|
||||
{sel:'#tool_node_clone', fn: clonePathNode, evt: 'click'},
|
||||
{sel:'#tool_node_delete', fn: deletePathNode, evt: 'click'},
|
||||
{sel:'#tool_add_subpath', fn: addSubPath, evt: 'click'},
|
||||
{sel:'#tool_move_top', fn: moveToTopSelected, evt: 'click', key: 'shift+up'},
|
||||
{sel:'#tool_move_bottom', fn: moveToBottomSelected, evt: 'click', key: 'shift+down'},
|
||||
{sel:'#tool_topath', fn: convertToPath, evt: 'click'},
|
||||
|
@ -2885,6 +2901,7 @@ function svg_edit_setup() {
|
|||
|
||||
'#tool_clone,#tool_clone_multi,#tool_node_clone':'clone',
|
||||
'#layer_delete,#tool_delete,#tool_delete_multi,#tool_node_delete':'delete',
|
||||
'#tool_add_subpath':'add_subpath',
|
||||
'#tool_move_top':'move_top',
|
||||
'#tool_move_bottom':'move_bottom',
|
||||
'#tool_topath':'to_path',
|
||||
|
|
|
@ -3741,6 +3741,7 @@ function BatchCommand(text) {
|
|||
|
||||
var pathActions = function() {
|
||||
|
||||
var subpath = false;
|
||||
var pathData = {};
|
||||
var current_path;
|
||||
var path;
|
||||
|
@ -4347,6 +4348,13 @@ function BatchCommand(text) {
|
|||
|
||||
this.selectPt = function(pt, ctrl_num) {
|
||||
p.clearSelection();
|
||||
if(pt == null) {
|
||||
p.eachSeg(function(i) {
|
||||
if(this.prev) {
|
||||
pt = i;
|
||||
}
|
||||
});
|
||||
}
|
||||
p.addPtsToSelection(pt);
|
||||
if(ctrl_num) {
|
||||
p.dragctrl = ctrl_num;
|
||||
|
@ -4806,7 +4814,8 @@ function BatchCommand(text) {
|
|||
'x2': mouse_x,
|
||||
'y2': mouse_y
|
||||
});
|
||||
addPointGrip(0,mouse_x,mouse_y);
|
||||
var index = subpath ? path.segs.length : 0;
|
||||
addPointGrip(index, mouse_x, mouse_y);
|
||||
}
|
||||
else {
|
||||
// determine if we clicked on an existing point
|
||||
|
@ -4849,13 +4858,23 @@ function BatchCommand(text) {
|
|||
keep = false;
|
||||
return keep;
|
||||
}
|
||||
// removeAllPointGripsFromPath();
|
||||
$(stretchy).remove();
|
||||
|
||||
// this will signal to commit the path
|
||||
element = newpath;
|
||||
current_path_pts = [];
|
||||
started = false;
|
||||
|
||||
if(subpath) {
|
||||
var new_d = newpath.getAttribute("d");
|
||||
var orig_d = $(path.elem).attr("d");
|
||||
$(path.elem).attr("d", orig_d + new_d);
|
||||
$(newpath).remove();
|
||||
path.init();
|
||||
pathActions.toEditMode(path.elem);
|
||||
path.selectPt();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// else, create a new point, append to pts array, update path element
|
||||
else {
|
||||
|
@ -4880,7 +4899,9 @@ function BatchCommand(text) {
|
|||
'x2': mouse_x,
|
||||
'y2': mouse_y
|
||||
});
|
||||
addPointGrip((current_path_pts.length/2 - 1),mouse_x,mouse_y);
|
||||
var index = (current_path_pts.length/2 - 1);
|
||||
if(subpath) index += path.segs.length;
|
||||
addPointGrip(index, mouse_x, mouse_y);
|
||||
}
|
||||
keep = true;
|
||||
}
|
||||
|
@ -4931,6 +4952,7 @@ function BatchCommand(text) {
|
|||
canvas.clearSelection();
|
||||
path.show(true).update();
|
||||
path.oldbbox = canvas.getBBox(path.elem);
|
||||
subpath = false;
|
||||
},
|
||||
toSelectMode: function(elem) {
|
||||
var selPath = (elem == path.elem);
|
||||
|
@ -4949,6 +4971,17 @@ function BatchCommand(text) {
|
|||
canvas.addToSelection([elem], true);
|
||||
}
|
||||
},
|
||||
addSubPath: function(on) {
|
||||
if(on) {
|
||||
// Internally we go into "path" mode, but in the UI it will
|
||||
// still appear as if in "pathedit" mode.
|
||||
current_mode = "path";
|
||||
subpath = true;
|
||||
} else {
|
||||
pathActions.clear(true);
|
||||
pathActions.toEditMode(path.elem);
|
||||
}
|
||||
},
|
||||
select: function(target) {
|
||||
if (current_path == target) {
|
||||
pathActions.toEditMode(target);
|
||||
|
|
Loading…
Reference in New Issue