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

« back to all changes in this revision

Viewing changes to kpresenter/part/animations/KPrAnimationCache.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
1
/* This file is part of the KDE project
2
2
 * Copyright ( C ) 2010 Casper Boemann <cbo@boemannn.dk>
 
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
23
24
#include <QMap>
24
25
#include <QString>
25
26
#include <QVariant>
 
27
#include <QList>
 
28
#include <QSizeF>
26
29
 
27
30
class KoShape;
28
31
class KoTextBlockData;
33
36
 * It relies on the Animation Framework to update it's state.
34
37
 *
35
38
 * It provides a central place for painters of text and shapes to get information
36
 
 * about any needed attributes (position, visibillity etc) of the animated objects
 
39
 * about any needed attributes (position, visibility etc) of the animated objects
37
40
 * (shapes or paragraphs)
38
41
 **/
39
42
class KPrAnimationCache
65
68
     * @param id The id of the value we are asking if is set
66
69
     * @return true if the value is already set.
67
70
     */
68
 
    bool hasValue(KoTextBlockData *textBlockData, const QString &id);
 
71
    bool hasValue(int step, KoTextBlockData *textBlockData, const QString &id);
69
72
 
70
73
    /**
71
74
     * Sets a value, either initially or updating it
77
80
     * @param id The id of the value
78
81
     * @param value The value is should have
79
82
     */
80
 
    void setValue(KoShape *shape, const QString &id, const QVariant &value);
 
83
    void setValue(int step, KoShape *shape, const QString &id, const QVariant &value);
81
84
 
82
85
    /**
83
86
     * Sets a value, either initially or updating it
89
92
     * @param id The id of the value
90
93
     * @param value The value is should have
91
94
     */
92
 
    void setValue(KoTextBlockData *textBlockData, const QString &id, const QVariant &value);
 
95
    void setValue(int step, KoTextBlockData *textBlockData, const QString &id, const QVariant &value);
93
96
 
94
97
    /**
95
 
     * The value 
 
98
     * The value
96
99
     *
97
100
     * Everyone can use this method to query a value.
98
101
     *
113
116
     */
114
117
    QVariant value(KoTextBlockData *textBlockData, const QString &id, const QVariant &defaultValue);
115
118
 
 
119
    // 1. Init cache with values that take effect even before the animation is started
 
120
    //    This information should be kept in the first stack entry
 
121
    //    I think this is only needed for visibility as the other take only effect in the presentation step
 
122
    // 2. For the animation on 1. step
 
123
    //    copy falues from previous step that are still there.
 
124
    //    update values with the values from the animations of that current step
 
125
    //    when all is finished start with the next step
 
126
    //    do the same for each time the effect is triggert until all effects in this step are finished.
 
127
    // go on with step 2 until there are no more steps left
 
128
 
 
129
    // start a new step
 
130
    // copy over all what is at the end of the last step
 
131
 
 
132
    // if we go backward in a presentation we need to setup all steps
 
133
    // if we go forward we can do it while we are at it but maybe it would be better to initilialize also
 
134
    // everything right away.
 
135
 
 
136
    // initialize step with values that will be there at the end of the step
 
137
    // step 0 is the value the object has before any animation is started
 
138
    // step n is the value of the object after the animation, only needed when there is a change to the real value of the object
 
139
    // e.g. the object has been moved to its original position, one the animation is done the value is removed
 
140
    void init(int step, KoShape *shape, KoTextBlockData * textBlockData, const QString &id, const QVariant &value);
 
141
 
 
142
    // update step value by values
 
143
    // will do different things depending on type of QVariant
 
144
    // e.g. for QTransform it will add the value to the matrix
 
145
    // the default action when there is no special handling is to copy the value over
 
146
    // if QVariant is emty it will remove the id from the step
 
147
    // the step in update must match the step of startStep
 
148
    // this will update the values used for the animation.
 
149
    // maybe have an internal method to also use it for updating the stack while init
 
150
    void update(KoShape *shape, KoTextBlockData * textBlockData, const QString &id, const QVariant &value);
 
151
 
 
152
    // trigger copying of data from the last step to the current one
 
153
    // these values will be updated by update.
 
154
    // the step in update must match the step of startStep
 
155
    void startStep(int step);
 
156
    void endStep(int step);
 
157
    void next();
 
158
    QVariant value(int step, KoShape *shape, const QString &id, const QVariant &defaultValue);
 
159
    QVariant value(int step, KoShape *shape, const QString &id);
 
160
 
 
161
    virtual bool hasValue(int step, KoShape *shape, const QString &id);
 
162
 
 
163
    // ending and animation will just activate the values of the step
 
164
    QSizeF pageSize() const;
 
165
    void setPageSize(const QSizeF size);
 
166
    qreal zoom() const;
 
167
    void setZoom(const qreal zoom);
 
168
    void clear();
116
169
private:
117
 
    QMap<KoShape *, QMap<QString, QVariant> > m_shapeValues;
118
 
    QMap<KoTextBlockData *, QMap<QString, QVariant> > m_textBlockDataValues;
 
170
    QList<QMap<KoShape *, QMap<QString, QVariant> > > m_shapeValuesStack;
 
171
    QList<QMap<KoTextBlockData *, QMap<QString, QVariant> > > m_textBlockDataValuesStack;
 
172
    QMap<KoShape *, QMap<QString, QVariant> > m_currentShapeValues;
 
173
    QMap<KoTextBlockData *, QMap<QString, QVariant> > m_currentTextBlockDataValues;
 
174
    int m_step;
 
175
    bool m_next;
 
176
    QSizeF m_pageSize;
 
177
    qreal m_zoom;
119
178
};
120
179
 
121
180