22
23
#include <QPainter>
23
24
#include <KoShape.h>
24
25
#include <KoShapeManager.h>
26
#include <KoPAPageBase.h>
26
28
#include "KPrShapeAnimations.h"
27
29
#include "KPrPlaceholderShape.h"
28
#include "KPrAnimationDirector.h"
29
#include "shapeanimations/KPrShapeAnimation.h"
30
#include "animations/KPrAnimationCache.h"
31
#include "KPrPageSelectStrategyBase.h"
31
32
#include "kdebug.h"
33
KPrShapeManagerAnimationStrategy::KPrShapeManagerAnimationStrategy( KoShapeManager * shapeManager, KPrAnimationDirector * animationDirector )
34
KPrShapeManagerAnimationStrategy::KPrShapeManagerAnimationStrategy( KoShapeManager *shapeManager, KPrAnimationCache* animationCache,
35
KPrPageSelectStrategyBase * strategy )
34
36
: KoShapeManagerPaintingStrategy( shapeManager )
35
, m_animationDirector( animationDirector )
37
, m_animationCache( animationCache )
38
, m_strategy( strategy )
39
42
KPrShapeManagerAnimationStrategy::~KPrShapeManagerAnimationStrategy()
43
47
void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
45
if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) ) {
46
if ( m_animationDirector->shapeShown( shape ) ) {
49
if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) && m_strategy->page()->displayShape( shape ) ) {
50
if ( m_animationCache->value(shape, "visibility", true).toBool() ) {
49
painter.setMatrix( shape->absoluteTransformation( &converter ) * painter.matrix() );
51
QPair<KPrShapeAnimation *, KPrAnimationData *> animation = m_animationDirector->shapeAnimation( shape );
52
if ( animation.first ) {
53
animation.first->animate( painter, converter, animation.second );
52
QTransform animationTransform = m_animationCache->value(shape, "transform", QTransform()).value<QTransform>();;
53
QTransform transform(painter.transform() * shape->absoluteTransformation(&converter));
54
if (animationTransform.isScaling()) {
55
transform = animationTransform * transform;
57
transform = transform * animationTransform;
60
painter.setTransform(transform);
56
62
shapeManager()->paintShape( shape, painter, converter, forPrint );
57
painter.restore(); // for the matrix
63
painter.restore(); // for the transform
62
68
void KPrShapeManagerAnimationStrategy::adapt( KoShape * shape, QRectF & rect )
64
QPair<KPrShapeAnimation *, KPrAnimationData *> animation = m_animationDirector->shapeAnimation( shape );
65
if ( animation.first ) {
66
animation.first->animateRect( rect, animation.second );