~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kpresenter/part/shapeanimations/KPrShapeAnimation.h

  • 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
 
/* This file is part of the KDE project
2
 
 * Copyright ( C ) 2007 Thorsten Zachmann <zachmann@kde.org>
3
 
 *
4
 
 * This library is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU Library General Public
6
 
 * License as published by the Free Software Foundation; either
7
 
 * version 2 of the License, or (  at your option ) any later version.
8
 
 *
9
 
 * This library is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
 * Library General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU Library General Public License
15
 
 * along with this library; see the file COPYING.LIB.  If not, write to
16
 
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 
 * Boston, MA 02110-1301, USA.
18
 
 */
19
 
 
20
 
#ifndef KPRSHAPEANIMATION_H
21
 
#define KPRSHAPEANIMATION_H
22
 
 
23
 
#include <QTimeLine>
24
 
 
25
 
#include "kpresenter_export.h"
26
 
 
27
 
#define TIMEFACTOR 1000.0
28
 
 
29
 
class QPainter;
30
 
class QRectF;
31
 
class KoShape;
32
 
class KoShapeManager;
33
 
class KoCanvasBase;
34
 
class KoViewConverter;
35
 
class KPrAnimationData;
36
 
 
37
 
/**
38
 
 * This is the base class for shape animations.
39
 
 *
40
 
 * In the animation itself the state of the animation is not stored.
41
 
 * With this design it is possible to use the same animation object 
42
 
 * for running the same animation e.g. on different views or at a 
43
 
 * different time.
44
 
 * The state of the animation is kept in the animationData and is 
45
 
 * passed to the ainmation when it is run e.g. on a special view.
46
 
 */
47
 
class KPRESENTER_TEST_EXPORT KPrShapeAnimation
48
 
{
49
 
public:
50
 
    enum Type
51
 
    {
52
 
        Appear,
53
 
        Disappear
54
 
    };
55
 
 
56
 
    virtual ~KPrShapeAnimation();
57
 
 
58
 
    /**
59
 
     * Get a animation data object
60
 
     *
61
 
     * The object is created on the heap by new so the caller of this function
62
 
     * has to make sure to delete the object when he no longer needs it to 
63
 
     * avoid leaking memory. The object holds the data needed for running an 
64
 
     * animation.
65
 
     *
66
 
     * @param canvas The canvas on which the animation will take place
67
 
     * @return animationData the caller has to delete the animationData when
68
 
     *                       it is no longer used.
69
 
     */
70
 
    virtual KPrAnimationData * animationData( KoCanvasBase * canvas, KoShapeManager * shapeManager, const QRectF & pageRect ) = 0;
71
 
 
72
 
    /**
73
 
     * @brief Animate the shape
74
 
     *
75
 
     * This is done by maniplating the painter used for painting the shape.
76
 
     *
77
 
     * @param painter The painter used for painting the shape
78
 
     * @param converter The converter to convert between internal and view coordinates
79
 
     * @param animationData The data needed for running the animation
80
 
     *
81
 
     * @return true when the animations is finished
82
 
     */
83
 
    virtual bool animate( QPainter &painter, const KoViewConverter &converter, KPrAnimationData * animationData ) = 0;
84
 
 
85
 
    /**
86
 
     * @brief Update the bounding rect of the shape in the animation
87
 
     *
88
 
     * @param rect The bounding rect of the shape to update
89
 
     * @param animationData The data needed for running the animation
90
 
     */
91
 
    virtual void animateRect( QRectF & rect, KPrAnimationData * animationData ) = 0;
92
 
 
93
 
    /**
94
 
     * @brief Trigger an update of the canvas needed for the given time
95
 
     *
96
 
     * @param currentTime
97
 
     * @param animationData The data needed for running the animation
98
 
     */
99
 
    virtual void next( int currentTime, KPrAnimationData * animationData ) = 0;
100
 
 
101
 
    /**
102
 
     * @brief Finish the shape animation
103
 
     *
104
 
     * @param animationData The data needed for running the animation
105
 
     */
106
 
    virtual void finish( KPrAnimationData * animationData ) = 0;
107
 
 
108
 
    /**
109
 
     * Get the duration of the shape animation
110
 
     *
111
 
     * @return The duration of the shape animation
112
 
     */
113
 
    int duration() const;
114
 
 
115
 
    /**
116
 
     * @brief Get the step on which the animation is shown.
117
 
     */
118
 
    int step() const;
119
 
 
120
 
    /**
121
 
     * @brief Set the step on which the animation is shown.
122
 
     */
123
 
    void setStep( int step );
124
 
 
125
 
    /**
126
 
     * @brief Get the shape the animation is for
127
 
     */
128
 
    KoShape * shape() const;
129
 
 
130
 
    /**
131
 
     * @brief Get the type of the animation
132
 
     */
133
 
    Type type() const;
134
 
 
135
 
protected:
136
 
    /**
137
 
     * Constructor
138
 
     *
139
 
     * Only to be called form derived classes
140
 
     */
141
 
    KPrShapeAnimation( KoShape * shape, int step, Type type );
142
 
 
143
 
    // the shape for which is aminated
144
 
    KoShape * m_shape;
145
 
    // the timeline used for calculating the animation position
146
 
    QTimeLine m_timeLine;
147
 
    // the step ( click ) on which the animation is done
148
 
    int m_step;
149
 
    // The type of animation
150
 
    Type m_type;
151
 
    // Indicates that the animation is finished
152
 
    bool m_finished;
153
 
};
154
 
 
155
 
#endif // KPRSHAPEANIMATION_H