Fix Issue 54: prevent lines and paths from having their fill set
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@283 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
91138001c4
commit
45fdd03682
|
@ -1292,7 +1292,17 @@ function SvgCanvas(c)
|
||||||
|
|
||||||
this.setFillColor = function(val) {
|
this.setFillColor = function(val) {
|
||||||
current_fill = val;
|
current_fill = val;
|
||||||
this.changeSelectedAttribute("fill", val);
|
// take out any path/line elements when setting fill
|
||||||
|
var elems = [];
|
||||||
|
var i = selectedElements.length;
|
||||||
|
while(i--) {
|
||||||
|
var elem = selectedElements[i];
|
||||||
|
if (elem && elem.tagName != "path" && elem.tagName != "line") {
|
||||||
|
elems.push(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (elems.length > 0)
|
||||||
|
this.changeSelectedAttribute("fill", val, elems);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getStrokeWidth = function() {
|
this.getStrokeWidth = function() {
|
||||||
|
@ -1448,29 +1458,32 @@ function SvgCanvas(c)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: to prevent paths/lines from getting fill values set, we can special-case
|
// If you want to change all selectedElements, ignore the elems argument.
|
||||||
// the fill attribute here and if tagName == "path" or "line" then ignore it?
|
// If you want to change only a subset of selectedElements, then send the
|
||||||
// ^^^ is a hack though
|
// subset to this function in the elems argument.
|
||||||
this.changeSelectedAttribute = function(attr, val) {
|
this.changeSelectedAttribute = function(attr, val, elems) {
|
||||||
|
var elems = elems || selectedElements;
|
||||||
var batchCmd = new BatchCommand("Change " + attr);
|
var batchCmd = new BatchCommand("Change " + attr);
|
||||||
var len = selectedElements.length;
|
var i = elems.length;
|
||||||
for (var i = 0; i < len; ++i) {
|
while(i--) {
|
||||||
var selected = selectedElements[i];
|
var elem = elems[i];
|
||||||
if (selected == null) break;
|
if (elem == null) continue;
|
||||||
|
|
||||||
var oldval = (attr == "#text" ? selected.textContent : selected.getAttribute(attr));
|
var oldval = (attr == "#text" ? elem.textContent : elem.getAttribute(attr));
|
||||||
if (oldval != val) {
|
if (oldval != val) {
|
||||||
if (attr == "#text") selected.textContent = val;
|
if (attr == "#text") elem.textContent = val;
|
||||||
else selected.setAttribute(attr, val);
|
else elem.setAttribute(attr, val);
|
||||||
selectedBBoxes[i] = selected.getBBox();
|
selectedBBoxes[i] = elem.getBBox();
|
||||||
selectorManager.requestSelector(selected).resize(selectedBBoxes[i]);
|
selectorManager.requestSelector(elem).resize(selectedBBoxes[i]);
|
||||||
var changes = {};
|
var changes = {};
|
||||||
changes[attr] = oldval;
|
changes[attr] = oldval;
|
||||||
batchCmd.addSubCommand(new ChangeElementCommand(selected, changes, attr));
|
batchCmd.addSubCommand(new ChangeElementCommand(elem, changes, attr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!batchCmd.isEmpty()) addCommandToHistory(batchCmd);
|
if (!batchCmd.isEmpty()) {
|
||||||
call("changed", selectedElements);
|
addCommandToHistory(batchCmd);
|
||||||
|
call("changed", elems);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(container).mouseup(mouseUp);
|
$(container).mouseup(mouseUp);
|
||||||
|
|
Loading…
Reference in New Issue