~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to kpresenter/part/KPrShapeManagerAnimationStrategy.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the KDE project
2
2
 * Copyright ( C ) 2007 Thorsten Zachmann <zachmann@kde.org>
 
3
 * Copyright (C) 2010 Benjamin Port <port.benjamin@gmail.com>
3
4
 *
4
5
 * This library is free software; you can redistribute it and/or
5
6
 * modify it under the terms of the GNU Library General Public
22
23
#include <QPainter>
23
24
#include <KoShape.h>
24
25
#include <KoShapeManager.h>
 
26
#include <KoPAPageBase.h>
25
27
 
26
28
#include "KPrShapeAnimations.h"
27
29
#include "KPrPlaceholderShape.h"
28
 
#include "KPrAnimationDirector.h"
29
 
#include "shapeanimations/KPrShapeAnimation.h"
30
 
 
 
30
#include "animations/KPrAnimationCache.h"
 
31
#include "KPrPageSelectStrategyBase.h"
31
32
#include "kdebug.h"
32
33
 
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 )
36
39
{
37
40
}
38
41
 
39
42
KPrShapeManagerAnimationStrategy::~KPrShapeManagerAnimationStrategy()
40
43
{
 
44
    delete m_strategy;
41
45
}
42
46
 
43
47
void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
44
48
{
45
 
    if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) ) {
46
 
        if ( m_animationDirector->shapeShown( shape ) ) {
47
 
            //kDebug() << shape;
 
49
    if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) && m_strategy->page()->displayShape( shape ) ) {
 
50
        if ( m_animationCache->value(shape, "visibility", true).toBool() ) {
48
51
            painter.save();
49
 
            painter.setMatrix( shape->absoluteTransformation( &converter ) * painter.matrix() );
50
 
            // animate shape
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;
 
56
            } else {
 
57
                transform = transform * animationTransform;
54
58
            }
 
59
 
 
60
            painter.setTransform(transform);
55
61
            // paint shape
56
62
            shapeManager()->paintShape( shape, painter, converter, forPrint );
57
 
            painter.restore();  // for the matrix
 
63
            painter.restore();  // for the transform
58
64
        }
59
65
    }
60
66
}
61
67
 
62
68
void KPrShapeManagerAnimationStrategy::adapt( KoShape * shape, QRectF & rect )
63
69
{
64
 
    QPair<KPrShapeAnimation *, KPrAnimationData *> animation = m_animationDirector->shapeAnimation( shape );
65
 
    if ( animation.first ) {
66
 
        animation.first->animateRect( rect, animation.second );
67
 
    }
 
70
    Q_UNUSED(shape)
 
71
    Q_UNUSED(rect)
68
72
}