Sync with latext SVG-Edit

Subpath tool.

Also make the itex tool a little more selective
(only applies to <foreignObject>s with a <math> firstChild.
This commit is contained in:
Jacques Distler 2010-03-04 00:05:36 -06:00
parent 932c42c24a
commit e75c0cc81c
8 changed files with 187 additions and 11 deletions

View file

@ -1190,7 +1190,7 @@ function BatchCommand(text) {
stroke: "#000000",
stroke_paint: null,
stroke_opacity: 1,
stroke_width: 2,
stroke_width: 5,
stroke_style: 'none',
opacity: 1
}
@ -3740,6 +3740,7 @@ function BatchCommand(text) {
var pathActions = function() {
var subpath = false;
var pathData = {};
var current_path;
var path;
@ -4346,6 +4347,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;
@ -4805,7 +4813,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
@ -4848,13 +4857,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 {
@ -4879,7 +4898,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;
}
@ -4930,6 +4951,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);
@ -4948,6 +4970,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);
@ -7955,7 +7988,7 @@ function BatchCommand(text) {
// Function: getVersion
// Returns a string which describes the revision number of SvgCanvas.
this.getVersion = function() {
return "svgcanvas.js ($Rev: 1433 $)";
return "svgcanvas.js ($Rev: 1443 $)";
};
this.setUiStrings = function(strs) {