on 6ca9421 help sign in
unity8/plugins/Utils/easingcurve.h
70 lines 2.1 kB history raw
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17*/
19#ifndef EASINGCURVE_H
20#define EASINGCURVE_H
22#include <QObject>
23#include <QEasingCurve>
25/**
26 * @brief The EasingCurve class
27 *
28 * This class exposes the QEasingCurve C++ API to QML.
29 * This is useful for user interactive animations. While the QML Animation types
30 * all require a "from", "to" and "duration", this one is based on "period" and
31 * "progress". So you can control the position of the animation by changing the
32 * progress, also going back and forward in the aimation. Depending on the type
33 * of the easing curve, value will return the transformed progress.
34 */
36class EasingCurve: public QObject
38 Q_OBJECT
39 Q_ENUMS(QEasingCurve::Type)
40 Q_PROPERTY(QEasingCurve::Type type READ type WRITE setType NOTIFY typeChanged)
41 Q_PROPERTY(qreal period READ period WRITE setPeriod NOTIFY periodChanged)
42 Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
43 Q_PROPERTY(qreal value READ value NOTIFY progressChanged)
45public:
46 EasingCurve(QObject *parent = 0);
48 QEasingCurve::Type type() const;
49 void setType(const QEasingCurve::Type &type);
51 qreal period() const;
52 void setPeriod(qreal period);
54 qreal progress() const;
55 void setProgress(qreal progress);
57 qreal value() const;
59Q_SIGNALS:
60 void typeChanged();
61 void periodChanged();
62 void progressChanged();
64private:
65 QEasingCurve m_easingCurve;
66 qreal m_progress;
67 qreal m_value;
68};
70#endif