Shape shadows

Thorsten Zachmann t.zachmann at zagge.de
Wed May 2 05:02:57 BST 2012


On Wednesday, May 02, 2012 12:16:34 AM Inge Wallin wrote:
> https://bugs.kde.org/show_bug.cgi?id=260535 has the title:
> 
> kpresenter:openoffice:Shadow of the picture is not getting displayed.
> 
> I had a look at this, and the reason is the following code in void
> KoShapeShadow::Private::paintShadow() at line 86 in
> libs/flake/KoShapeShadow.cpp:
> 
>     if (shape->background()) {
>         painter.save();
>         KoShape::applyConversion(painter, converter);
>         painter.setBrush(QBrush(color));
>         QPainterPath path(shape->outline());
>         KoPathShape * pathShape = dynamic_cast<KoPathShape*>(shape);
>         if (pathShape)
>             path.setFillRule(pathShape->fillRule());
>         painter.drawPath(path);
>         painter.restore();
>     }
> 
> There is a similar test for stroke right behind it.
> 
> This means that only shapes with a defined background can ever get a shadow.
> I don't really see the reason for this.  Shouldn't it be enough to remove
> the test to make it work everywhere? What would be the drawbacks?

That means we only draw a shadow for the background if there is actually a 
background. E.g. if there is a shape that only has a outline only a shadow for 
the outline will be draw. This is done by the code in the test for the stroke. 
So if that would be changed also e.g. a polygon would show a background.

I see the problem is that the picture shape has no background and therefore 
this fails. One idea would be to add a method to test if there is a shadow for 
the shape background the would in KoShape test if shape->background is set and 
return true in case it is a picture shape. But maybe others have a better 
idea. However that might fail in case the image has transparency at the edges. 
Not sure if that is something we need to support.

Thorsten



More information about the calligra-devel mailing list