Shape shadows

Inge Wallin inge at lysator.liu.se
Wed May 2 19:17:07 BST 2012


On Wednesday, May 02, 2012 19:45:17 Thorsten Zachmann wrote:
> On Wednesday, May 02, 2012 07:34:53 PM Inge Wallin wrote:
> > On Wednesday, May 02, 2012 06:02:57 Thorsten Zachmann wrote:
> > > 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.
> > 
> > Yes, I know what it means.  My question was really why it is so from the
> > beginning.  What is the thinking behind only drawing a shadow if there is
> > a stroke and/or fill (a.k.a background)?  I think Yue should comment
> > because he is the guy who wrote it.
> > 
> > > 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.
> > 
> > We could have such a method but what I am not sure of the connection
> > between the background and the shadow.  In my eyes, if a user wants a
> > shadow he should have the shadow no matter what the shape contains.
> > 
> > Opinions?
> 
> I'm the one who wrote the orignal code of that.

Oh.  'Git blame' blamed yue so I thought he had written it. :)

> if you have a path with out
> filling you only want to draw the shadow of the path and not also a shadow
> for a background that is not visible right?

Yeah, I can see what you mean.

> That is what the code does. As the picture shape does not use background
> this fails, while it works for most other shapes. Changing this would
> brake shadows for all object having no background.

I don't care so much which final solution we pick as long as we make it work.  
How does MS Office and OOo/LO handle this? One possible solution is to put the 
shadow behind the full shape if there is neither a stroke nor a fill and if 
there is either follow the current logic.

In the end I guess just give me a way and I'll implement it so the bug gets 
fixed.

	-Inge




More information about the calligra-devel mailing list