added getPaintOpacity() on svgCanvas, used it to simplify mouseDown callback on palette in svgEditor

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2430 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Bruno Heridet 2013-02-19 13:17:27 +00:00
parent bccb227cdd
commit 12f5fd9bce
2 changed files with 19 additions and 18 deletions

View File

@ -1910,12 +1910,11 @@
inp.focus().remove();
});
$('.palette_item').mousedown(function(evt){
var right_click = evt.button === 2;
var isStroke = evt.shiftKey || right_click;
var picker = isStroke ? 'stroke' : 'fill';
var color = $(this).attr('data-rgb');
var paint = null;
$('.palette_item').mousedown(function(evt) {
// shift key or right click for stroke
var picker = evt.shiftKey || evt.button === 2 ? 'stroke' : 'fill';
var color = $(this).data('rgb');
var paint;
// Webkit-based browsers returned 'initial' here for no stroke
if (color === 'none' || color === 'transparent' || color === 'initial') {
@ -1926,17 +1925,10 @@
}
paintBox[picker].setPaint(paint);
svgCanvas.setColor(picker, color);
if (isStroke) {
svgCanvas.setColor('stroke', color);
if (color != 'none' && svgCanvas.getStrokeOpacity() != 1) {
svgCanvas.setPaintOpacity('stroke', 1.0);
}
} else {
svgCanvas.setColor('fill', color);
if (color != 'none' && svgCanvas.getFillOpacity() != 1) {
svgCanvas.setPaintOpacity('fill', 1.0);
}
if (color !== 'none' && svgCanvas.getPaintOpacity(picker) !== 1) {
svgCanvas.setPaintOpacity(picker, 1.0);
}
updateToolButtonState();
}).bind('contextmenu', function(e) {e.preventDefault();});

View File

@ -6860,6 +6860,15 @@ this.setPaintOpacity = function(type, val, preventUndo) {
changeSelectedAttributeNoUndo(type + "-opacity", val);
};
// Function: getPaintOpacity
// Gets the current fill/stroke opacity
//
// Parameters:
// type - String with "fill" or "stroke"
this.getPaintOpacity = function(type) {
return type === 'fill' ? this.getFillOpacity() : this.getStrokeOpacity();
};
// Function: getBlur
// Gets the stdDeviation blur value of the given element
//
@ -6867,8 +6876,8 @@ this.setPaintOpacity = function(type, val, preventUndo) {
// elem - The element to check the blur value for
this.getBlur = function(elem) {
var val = 0;
// var elem = selectedElements[0];
// var elem = selectedElements[0];
if (elem) {
var filter_url = elem.getAttribute('filter');
if (filter_url) {