Fixed a jump in the map when moving from dragging to kinetic effect
[situare] / src / map / mapscroller.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20 */
21
22
23 #ifndef MAPSCROLLER_H
24 #define MAPSCROLLER_H
25
26 #include <QVariantAnimation>
27
28 #include "coordinates/scenecoordinate.h"
29
30 /**
31 * @brief Map scroller
32 *
33 * Used for kinetic and smooth scroll effects. Class implementation is following the singleton
34 * desing pattern.
35 *
36 * Use QPointF datatype for startValue and endValue. Emitted datatype is SceneCoordinate.
37 *
38 * @author Sami Rämö - sami.ramo@ixonos.com
39 */
40 class MapScroller : public QVariantAnimation
41 {
42     Q_OBJECT
43
44 private:
45     /**
46     * @brief Constructor in not accessible because class is using singleton design pattern.
47     */
48     MapScroller();
49
50     /**
51     * @brief Destructor in not accessible because class is using singleton design pattern.
52     */
53     ~MapScroller() {}
54
55     /**
56     * @brief Copy constructor in not accessible because class is using singleton design pattern.
57     */
58     MapScroller(const MapScroller &);
59
60     /**
61     * @brief Assignment operator in not accessible because class is using singleton design pattern.
62     */
63     MapScroller & operator=(const MapScroller &);
64
65 /*******************************************************************************
66  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
67  ******************************************************************************/
68 private:
69     /**
70     * @brief Reimplemented from QVariantAnimation::updateCurrentValue()
71     *
72     * Called every time the animation's current value changes. Does emit coordinateUpdated() signal
73     * if animation is in the running state.
74     *
75     * @param value New value
76     */
77     void updateCurrentValue(const QVariant &value);
78
79 /*******************************************************************************
80  * MEMBER FUNCTIONS AND SLOTS
81  ******************************************************************************/
82 public:
83     /**
84     * @brief Get reference to instance of this class
85     *
86     * Also registers the custom SceneCoordinate interpolator method.
87     *
88     * @return reference to instance of this class
89     */
90     static MapScroller &getInstance();
91
92     /**
93     * @brief Set flag for kinetic scroll
94     *
95     * @param isKineticScroll Set to true if starting a kinetic scroll
96     */
97     void setKineticScrollFlag(bool isKineticScroll);
98
99 /*******************************************************************************
100  * SIGNALS
101  ******************************************************************************/
102 signals:
103     /**
104     * @brief Signal if emitted when coordinate value is updated
105     *
106     * @param coordinate New coordinate value
107     * @param isKineticScroll True if currently running a kinetic scroll animation
108     */
109     void coordinateUpdated(SceneCoordinate coordinate, bool isKineticScroll);
110
111 /*******************************************************************************
112  * DATA MEMBERS
113  ******************************************************************************/
114 private:
115     bool m_isKineticScroll;     ///< Is the current animation a kinetic scroll animation?
116 };
117
118 #endif // MAPSCROLLER_H