Made big improvement to issue 382
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1124 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -354,8 +354,6 @@ function svg_edit_setup() {
|
|||||||
$('#angle').val(ang);
|
$('#angle').val(ang);
|
||||||
$('#tool_reorient').toggleClass('tool_button_disabled', ang == 0);
|
$('#tool_reorient').toggleClass('tool_button_disabled', ang == 0);
|
||||||
return;
|
return;
|
||||||
} else if(svgCanvas.addedNew && elem != null && elname == 'image') {
|
|
||||||
promptImgURL();
|
|
||||||
}
|
}
|
||||||
var is_node = elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
|
var is_node = elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
|
||||||
|
|
||||||
@@ -366,6 +364,15 @@ function svg_edit_setup() {
|
|||||||
var angle = svgCanvas.getRotationAngle(elem);
|
var angle = svgCanvas.getRotationAngle(elem);
|
||||||
$('#angle').val(angle);
|
$('#angle').val(angle);
|
||||||
|
|
||||||
|
if(svgCanvas.addedNew) {
|
||||||
|
console.log(elname)
|
||||||
|
if(elname == 'image') {
|
||||||
|
promptImgURL();
|
||||||
|
} else if(elname == 'text') {
|
||||||
|
// TODO: Do something here for new text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_node && currentMode != 'pathedit') {
|
if(!is_node && currentMode != 'pathedit') {
|
||||||
$('#selected_panel').show();
|
$('#selected_panel').show();
|
||||||
// Elements in this array already have coord fields
|
// Elements in this array already have coord fields
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ var svgWhiteList = {
|
|||||||
function SvgCanvas(c)
|
function SvgCanvas(c)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
console.log('Start profiling')
|
||||||
|
setTimeout(function() {
|
||||||
|
canvas.addToSelection(canvas.getVisibleElements());
|
||||||
|
console.log('Stop profiling')
|
||||||
|
},3000);
|
||||||
|
|
||||||
|
|
||||||
var uiStrings = {
|
var uiStrings = {
|
||||||
"pathNodeTooltip":"Drag node to move it. Double-click node to change segment type",
|
"pathNodeTooltip":"Drag node to move it. Double-click node to change segment type",
|
||||||
"pathCtrlPtTooltip":"Drag control point to adjust curve properties"
|
"pathCtrlPtTooltip":"Drag control point to adjust curve properties"
|
||||||
@@ -299,11 +306,10 @@ function BatchCommand(text) {
|
|||||||
this.locked = true;
|
this.locked = true;
|
||||||
|
|
||||||
// this function is used to reset the id and element that the selector is attached to
|
// this function is used to reset the id and element that the selector is attached to
|
||||||
this.reset = function(e) {
|
this.reset = function(e, update) {
|
||||||
this.locked = true;
|
this.locked = true;
|
||||||
this.selectedElement = e;
|
this.selectedElement = e;
|
||||||
this.resize();
|
this.resize();
|
||||||
selectorManager.update();
|
|
||||||
this.selectorGroup.setAttribute("display", "inline");
|
this.selectorGroup.setAttribute("display", "inline");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -448,10 +454,14 @@ function BatchCommand(text) {
|
|||||||
|
|
||||||
//*
|
//*
|
||||||
var nbox = transformBox(l*current_zoom, t*current_zoom, w*current_zoom, h*current_zoom, m);
|
var nbox = transformBox(l*current_zoom, t*current_zoom, w*current_zoom, h*current_zoom, m);
|
||||||
|
var nbax = nbox.aabox.x,
|
||||||
|
nbay = nbox.aabox.y,
|
||||||
|
nbaw = nbox.aabox.width,
|
||||||
|
nbah = nbox.aabox.height;
|
||||||
|
|
||||||
// now if the shape is rotated, un-rotate it
|
// now if the shape is rotated, un-rotate it
|
||||||
var cx = nbox.aabox.x + nbox.aabox.width/2; //nbox.tl.x + (nbox.tr.x - nbox.tl.x)/2;
|
var cx = nbax + nbaw/2; //nbox.tl.x + (nbox.tr.x - nbox.tl.x)/2;
|
||||||
var cy = nbox.aabox.y + nbox.aabox.height/2; //nbox.tl.y + (nbox.bl.y - nbox.tl.y)/2;
|
var cy = nbay + nbah/2; //nbox.tl.y + (nbox.bl.y - nbox.tl.y)/2;
|
||||||
var angle = canvas.getRotationAngle(selected);
|
var angle = canvas.getRotationAngle(selected);
|
||||||
if (angle) {
|
if (angle) {
|
||||||
|
|
||||||
@@ -474,37 +484,39 @@ function BatchCommand(text) {
|
|||||||
maxx = Math.max(maxx, Math.max(nbox.tr.x, Math.max(nbox.bl.x, nbox.br.x) ) );
|
maxx = Math.max(maxx, Math.max(nbox.tr.x, Math.max(nbox.bl.x, nbox.br.x) ) );
|
||||||
maxy = Math.max(maxy, Math.max(nbox.tr.y, Math.max(nbox.bl.y, nbox.br.y) ) );
|
maxy = Math.max(maxy, Math.max(nbox.tr.y, Math.max(nbox.bl.y, nbox.br.y) ) );
|
||||||
|
|
||||||
nbox.aabox.x = minx;
|
nbax = minx;
|
||||||
nbox.aabox.y = miny;
|
nbay = miny;
|
||||||
nbox.aabox.width = (maxx-minx);
|
nbaw = (maxx-minx);
|
||||||
nbox.aabox.height = (maxy-miny);
|
nbah = (maxy-miny);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle negative?
|
|
||||||
|
|
||||||
var sr_handle = svgroot.suspendRedraw(100);
|
var sr_handle = svgroot.suspendRedraw(100);
|
||||||
|
|
||||||
var dstr = "M" + nbox.aabox.x + "," + nbox.aabox.y
|
var dstr = "M" + nbax + "," + nbay
|
||||||
+ " L" + (nbox.aabox.x+nbox.aabox.width) + "," + nbox.aabox.y
|
+ " L" + (nbax+nbaw) + "," + nbay
|
||||||
+ " " + (nbox.aabox.x+nbox.aabox.width) + "," + (nbox.aabox.y+nbox.aabox.height)
|
+ " " + (nbax+nbaw) + "," + (nbay+nbah)
|
||||||
+ " " + nbox.aabox.x + "," + (nbox.aabox.y+nbox.aabox.height) + "z";
|
+ " " + nbax + "," + (nbay+nbah) + "z";
|
||||||
assignAttributes(selectedBox, {'d': dstr});
|
assignAttributes(selectedBox, {'d': dstr});
|
||||||
|
|
||||||
var gripCoords = {
|
var gripCoords = {
|
||||||
nw: [nbox.aabox.x, nbox.aabox.y],
|
nw: [nbax, nbay],
|
||||||
ne: [nbox.aabox.x+nbox.aabox.width, nbox.aabox.y],
|
ne: [nbax+nbaw, nbay],
|
||||||
sw: [nbox.aabox.x, nbox.aabox.y+nbox.aabox.height],
|
sw: [nbax, nbay+nbah],
|
||||||
se: [nbox.aabox.x+nbox.aabox.width, nbox.aabox.y+nbox.aabox.height],
|
se: [nbax+nbaw, nbay+nbah],
|
||||||
n: [nbox.aabox.x + (nbox.aabox.width)/2, nbox.aabox.y],
|
n: [nbax + (nbaw)/2, nbay],
|
||||||
w: [nbox.aabox.x, nbox.aabox.y + (nbox.aabox.height)/2],
|
w: [nbax, nbay + (nbah)/2],
|
||||||
e: [nbox.aabox.x + nbox.aabox.width, nbox.aabox.y + (nbox.aabox.height)/2],
|
e: [nbax + nbaw, nbay + (nbah)/2],
|
||||||
s: [nbox.aabox.x + (nbox.aabox.width)/2, nbox.aabox.y + nbox.aabox.height],
|
s: [nbax + (nbaw)/2, nbay + nbah],
|
||||||
};
|
};
|
||||||
$.each(gripCoords, function(dir, coords) {
|
|
||||||
assignAttributes(selectedGrips[dir], {
|
if(selected == selectedElements[0]) {
|
||||||
cx: coords[0], cy: coords[1]
|
for(dir in gripCoords) {
|
||||||
});
|
var coords = gripCoords[dir];
|
||||||
});
|
assignAttributes(selectedGrips[dir], {
|
||||||
|
cx: coords[0], cy: coords[1]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (angle) {
|
if (angle) {
|
||||||
this.selectorGroup.setAttribute("transform", "rotate(" + [angle,cx,cy].join(",") + ")");
|
this.selectorGroup.setAttribute("transform", "rotate(" + [angle,cx,cy].join(",") + ")");
|
||||||
@@ -514,12 +526,12 @@ function BatchCommand(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we want to go 20 pixels in the negative transformed y direction, ignoring scale
|
// we want to go 20 pixels in the negative transformed y direction, ignoring scale
|
||||||
assignAttributes(this.rotateGripConnector, { x1: nbox.aabox.x + (nbox.aabox.width)/2,
|
assignAttributes(this.rotateGripConnector, { x1: nbax + (nbaw)/2,
|
||||||
y1: nbox.aabox.y,
|
y1: nbay,
|
||||||
x2: nbox.aabox.x + (nbox.aabox.width)/2,
|
x2: nbax + (nbaw)/2,
|
||||||
y2: nbox.aabox.y- 20});
|
y2: nbay- 20});
|
||||||
assignAttributes(this.rotateGrip, { cx: nbox.aabox.x + (nbox.aabox.width)/2,
|
assignAttributes(this.rotateGrip, { cx: nbax + (nbaw)/2,
|
||||||
cy: nbox.aabox.y - 20 });
|
cy: nbay - 20 });
|
||||||
|
|
||||||
svgroot.unsuspendRedraw(sr_handle);
|
svgroot.unsuspendRedraw(sr_handle);
|
||||||
};
|
};
|
||||||
@@ -557,7 +569,6 @@ function BatchCommand(text) {
|
|||||||
mgr.selectorMap = {};
|
mgr.selectorMap = {};
|
||||||
mgr.selectors = [];
|
mgr.selectors = [];
|
||||||
mgr.rubberBandBox = null;
|
mgr.rubberBandBox = null;
|
||||||
mgr.update();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.requestSelector = function(elem) {
|
this.requestSelector = function(elem) {
|
||||||
@@ -606,12 +617,6 @@ function BatchCommand(text) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// this keeps the selector groups as the last child in the document
|
|
||||||
this.update = function() {
|
|
||||||
if (svgroot.lastChild != this.selectorParentGroup)
|
|
||||||
this.selectorParentGroup = svgroot.appendChild(this.selectorParentGroup);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getRubberBandBox = function() {
|
this.getRubberBandBox = function() {
|
||||||
if (this.rubberBandBox == null) {
|
if (this.rubberBandBox == null) {
|
||||||
this.rubberBandBox = this.selectorParentGroup.appendChild(
|
this.rubberBandBox = this.selectorParentGroup.appendChild(
|
||||||
@@ -4330,7 +4335,6 @@ function BatchCommand(text) {
|
|||||||
element.setAttribute("opacity", cur_shape.opacity);
|
element.setAttribute("opacity", cur_shape.opacity);
|
||||||
element.setAttribute("style", "pointer-events:inherit");
|
element.setAttribute("style", "pointer-events:inherit");
|
||||||
cleanupElement(element);
|
cleanupElement(element);
|
||||||
selectorManager.update();
|
|
||||||
if(current_mode == "path") {
|
if(current_mode == "path") {
|
||||||
current_path = element;
|
current_path = element;
|
||||||
current_mode = "pathedit";
|
current_mode = "pathedit";
|
||||||
@@ -4485,6 +4489,8 @@ function BatchCommand(text) {
|
|||||||
// reset transform lists
|
// reset transform lists
|
||||||
svgTransformLists = {};
|
svgTransformLists = {};
|
||||||
canvas.clearSelection();
|
canvas.clearSelection();
|
||||||
|
svgroot.appendChild(selectorManager.selectorParentGroup);
|
||||||
|
|
||||||
addCommandToHistory(batchCmd);
|
addCommandToHistory(batchCmd);
|
||||||
call("changed", [svgcontent]);
|
call("changed", [svgcontent]);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -5908,8 +5914,7 @@ function BatchCommand(text) {
|
|||||||
}
|
}
|
||||||
if (!batchCmd.isEmpty()) addCommandToHistory(batchCmd);
|
if (!batchCmd.isEmpty()) addCommandToHistory(batchCmd);
|
||||||
|
|
||||||
// ensure selectors are at bottom and update selection
|
// update selection
|
||||||
selectorManager.update();
|
|
||||||
canvas.clearSelection();
|
canvas.clearSelection();
|
||||||
canvas.addToSelection([g], true);
|
canvas.addToSelection([g], true);
|
||||||
};
|
};
|
||||||
@@ -6040,8 +6045,7 @@ function BatchCommand(text) {
|
|||||||
|
|
||||||
if (!batchCmd.isEmpty()) addCommandToHistory(batchCmd);
|
if (!batchCmd.isEmpty()) addCommandToHistory(batchCmd);
|
||||||
|
|
||||||
// ensure selectors are at bottom and update selection
|
// update selection
|
||||||
selectorManager.update();
|
|
||||||
canvas.addToSelection(children);
|
canvas.addToSelection(children);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user