libosmscout 1.1.1
Loading...
Searching...
No Matches
IconAnimation.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_ICONANIMATION_H
2#define OSMSCOUT_CLIENT_QT_ICONANIMATION_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2022 Lukáš Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
24
26
28
29#include <QObject>
30#include <QTimer>
31#include <QPainter>
32#include <QElapsedTimer>
33
34namespace osmscout {
35
37{
38 Q_OBJECT
39private:
40 static constexpr int animationDuration = 200;
41 QTimer timer;
42
43 enum class State {
44 FadeIn,
45 Full,
46 FadeOut
47 };
48
49 struct Animation {
50 MapIcon icon;
51 double size;
52 double startSize;
53 State state;
54 QElapsedTimer duration;
55
56 double MaxSize() const
57 {
58 return icon.image.width();
59 }
60
61 double MinSize() const
62 {
63 return icon.dimensions.width();
64 }
65 };
66
67 std::vector<Animation> icons;
68
69public slots:
70 void tick();
71
72signals:
73 void update();
74
75public:
77 ~IconAnimation() override = default;
78
79 void activate(const MapIcon &icon);
81 void paint(QPainter *painter, const MercatorProjection &projection);
82};
83
84}
85
86#endif // OSMSCOUT_CLIENT_QT_ICONANIMATION_H
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
void activate(const MapIcon &icon)
void paint(QPainter *painter, const MercatorProjection &projection)
~IconAnimation() override=default
Definition MercatorProjection.h:40
Definition Area.h:39
Definition IconLookup.h:43
QRectF dimensions
Definition IconLookup.h:45
QImage image
Definition IconLookup.h:60