PageRenderTime 132ms CodeModel.GetById 71ms app.highlight 4ms RepoModel.GetById 56ms app.codeStats 0ms

/src/sourcetree/animationhelper.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 76 lines | 42 code | 16 blank | 18 comment | 0 complexity | 88b5d3649ef8ad523d4c7873ec0d1ab9 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright 2011, Michael Zanetti <mzanetti@kde.org>
 5 *
 6 *   Tomahawk is free software: you can redistribute it and/or modify
 7 *   it under the terms of the GNU General Public License as published by
 8 *   the Free Software Foundation, either version 3 of the License, or
 9 *   (at your option) any later version.
10 *
11 *   Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef ANIMATIONHELPER_H
21#define ANIMATIONHELPER_H
22
23#include <QObject>
24#include <QModelIndex>
25#include <QSize>
26#include <QTimer>
27#include <QPropertyAnimation>
28
29class AnimationHelper: public QObject
30{
31    Q_OBJECT
32    Q_PROPERTY( QSize size READ size WRITE setSize NOTIFY sizeChanged )
33
34public:
35    AnimationHelper( const QModelIndex& index, QObject *parent = 0 );
36
37    QSize originalSize() const;
38    QSize size() const;
39
40    bool initialized() const;
41    void initialize( const QSize& startValue, const QSize& endValue, int duration );
42
43    void setSize( const QSize& size );
44
45    void expand();
46    void collapse( bool immediately = false );
47
48    bool partlyExpanded();
49    bool fullyExpanded();
50
51signals:
52    void sizeChanged();
53    void finished( const QModelIndex& index);
54
55private slots:
56    void expandTimeout();
57    void collapseTimeout();
58    void expandAnimationFinished();
59    void collapseAnimationFinished();
60
61private:
62    QModelIndex m_index;
63    QSize m_size;
64    QSize m_targetSize;
65    QSize m_startSize;
66
67    QTimer m_expandTimer;
68    QTimer m_collapseTimer;
69
70    bool m_fullyExpanded;
71
72    QPropertyAnimation *m_expandAnimation;
73    QPropertyAnimation *m_collapseAnimation;
74};
75
76#endif // ANIMATIONHELPER_H