From 1c38606a34a000d3011d7ff8ad42c931dba9fc2c Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Wed, 9 Mar 2011 20:00:49 +0000 Subject: [PATCH] Fixed Issue 760: Drawing with an imported Image selected sets default stroke and fill to none git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2028 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 14 +++++++++++--- editor/svgcanvas.js | 25 ++++++++++++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 826beb58..79a26bf4 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -3480,7 +3480,15 @@ if(!selectedElement) return; var type = this.type; - if(selectedElement.tagName === 'g') { + switch ( selectedElement.tagName ) { + case 'use': + case 'image': + case 'foreignObject': + // These elements don't have fill or stroke, so don't change + // the current value + return; + case 'g': + case 'a': var gPaint = null; var childs = selectedElement.getElementsByTagName('*'); @@ -3502,8 +3510,8 @@ var paintColor = gPaint; var paintOpacity = 1; - - } else { + break; + default: var paintOpacity = parseFloat(selectedElement.getAttribute(type + "-opacity")); if (isNaN(paintOpacity)) { paintOpacity = 1.0; diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 39ee8e81..386b22fe 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -3130,16 +3130,23 @@ var getMouseTarget = this.getMouseTarget = function(evt) { if (selectedElements[1] == null) { // set our current stroke/fill properties to the element's var selected = selectedElements[0]; - if (selected.tagName != "g" && selected.tagName != "image" && selected.tagName != "foreignObject") { - cur_properties.fill = selected.getAttribute("fill"); - cur_properties.fill_opacity = selected.getAttribute("fill-opacity"); - cur_properties.stroke = selected.getAttribute("stroke"); - cur_properties.stroke_opacity = selected.getAttribute("stroke-opacity"); - cur_properties.stroke_width = selected.getAttribute("stroke-width"); - cur_properties.stroke_dasharray = selected.getAttribute("stroke-dasharray"); - cur_properties.stroke_linejoin = selected.getAttribute("stroke-linejoin"); - cur_properties.stroke_linecap = selected.getAttribute("stroke-linecap"); + switch ( selected.tagName ) { + case "g": + case "use": + case "image": + case "foreignObject": + break; + default: + cur_properties.fill = selected.getAttribute("fill"); + cur_properties.fill_opacity = selected.getAttribute("fill-opacity"); + cur_properties.stroke = selected.getAttribute("stroke"); + cur_properties.stroke_opacity = selected.getAttribute("stroke-opacity"); + cur_properties.stroke_width = selected.getAttribute("stroke-width"); + cur_properties.stroke_dasharray = selected.getAttribute("stroke-dasharray"); + cur_properties.stroke_linejoin = selected.getAttribute("stroke-linejoin"); + cur_properties.stroke_linecap = selected.getAttribute("stroke-linecap"); } + if (selected.tagName == "text") { cur_text.font_size = selected.getAttribute("font-size"); cur_text.font_family = selected.getAttribute("font-family");