=== modified file 'src/gradient-drag.cpp' --- src/gradient-drag.cpp 2012-07-24 12:50:25 +0000 +++ src/gradient-drag.cpp 2012-09-01 04:17:01 +0000 @@ -147,6 +147,8 @@ float cf[4]; cf[0] = cf[1] = cf[2] = cf[3] = 0; + float item_opacity; + item_opacity = 0; int count = 0; @@ -167,6 +169,8 @@ cf[2] += SP_RGBA32_B_F (c); cf[3] += SP_RGBA32_A_F (c); + item_opacity += (draggable->item->style->opacity.set) ? SP_SCALE24_TO_FLOAT(draggable->item->style->opacity.value) : 1.0; + count ++; } } @@ -176,22 +180,30 @@ cf[1] /= count; cf[2] /= count; cf[3] /= count; - - // set both fill and stroke with our stop-color and stop-opacity - style->fill.clear(); - style->fill.setColor( cf[0], cf[1], cf[2] ); - style->fill.set = TRUE; - style->stroke.clear(); - style->stroke.setColor( cf[0], cf[1], cf[2] ); - style->stroke.set = TRUE; - - style->fill_opacity.value = SP_SCALE24_FROM_FLOAT (cf[3]); - style->fill_opacity.set = TRUE; - style->stroke_opacity.value = SP_SCALE24_FROM_FLOAT (cf[3]); - style->stroke_opacity.set = TRUE; - - style->opacity.value = SP_SCALE24_FROM_FLOAT (cf[3]); - style->opacity.set = TRUE; + item_opacity /= count; + + if (property == QUERY_STYLE_PROPERTY_FILL || + property == QUERY_STYLE_PROPERTY_STROKE) { + // set both fill and stroke with our stop-color and stop-opacity + style->fill.clear(); + style->fill.setColor( cf[0], cf[1], cf[2] ); + style->fill.set = TRUE; + style->stroke.clear(); + style->stroke.setColor( cf[0], cf[1], cf[2] ); + style->stroke.set = TRUE; + + style->fill_opacity.value = SP_SCALE24_FROM_FLOAT (cf[3]); + style->fill_opacity.set = TRUE; + style->stroke_opacity.value = SP_SCALE24_FROM_FLOAT (cf[3]); + style->stroke_opacity.set = TRUE; + } + + // Opacity should be the parent + if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) { + + style->opacity.value = SP_SCALE24_FROM_FLOAT (item_opacity); + style->opacity.set = TRUE; + } } return ret; @@ -283,16 +295,25 @@ if (css->attribute("stop-opacity")) { // direct setting of stop-opacity has priority sp_repr_css_set_property(stop, "stop-opacity", css->attribute("stop-opacity")); - } else { // multiply all opacity properties: - gdouble accumulated = 1.0; - accumulated *= sp_svg_read_percentage(css->attribute("flood-opacity"), 1.0); - accumulated *= sp_svg_read_percentage(css->attribute("opacity"), 1.0); - accumulated *= sp_svg_read_percentage(css->attribute("stroke-opacity"), 1.0); - accumulated *= sp_svg_read_percentage(css->attribute("fill-opacity"), 1.0); - - Inkscape::CSSOStringStream os; - os << accumulated; - sp_repr_css_set_property(stop, "stop-opacity", os.str().c_str()); + } else { + + if (css->attribute("flood-opacity") || + css->attribute("stroke-opacity") || + css->attribute("fill-opacity")) { + + // multiply all opacity properties: + + gdouble accumulated = 1.0; + accumulated *= sp_svg_read_percentage(css->attribute("flood-opacity"), 1.0); + //accumulated *= sp_svg_read_percentage(css->attribute("opacity"), 1.0); + accumulated *= sp_svg_read_percentage(css->attribute("stroke-opacity"), 1.0); + accumulated *= sp_svg_read_percentage(css->attribute("fill-opacity"), 1.0); + + Inkscape::CSSOStringStream os; + os << accumulated; + + sp_repr_css_set_property(stop, "stop-opacity", os.str().c_str()); + } if ((css->attribute("fill") && !css->attribute("stroke") && !strcmp(css->attribute("fill"), "none")) || (css->attribute("stroke") && !css->attribute("fill") && !strcmp(css->attribute("stroke"), "none"))) {