]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/pictureflow.hpp
Qt4: change the handle size and color
[vlc] / modules / gui / qt4 / util / pictureflow.hpp
1 /*
2   PictureFlow - animated image show widget
3   http://pictureflow.googlecode.com
4
5   Copyright (C) 2009 Ariya Hidayat (ariya@kde.org)
6   Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
7   Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
8
9   Permission is hereby granted, free of charge, to any person obtaining a copy
10   of this software and associated documentation files (the "Software"), to deal
11   in the Software without restriction, including without limitation the rights
12   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13   copies of the Software, and to permit persons to whom the Software is
14   furnished to do so, subject to the following conditions:
15
16   The above copyright notice and this permission notice shall be included in
17   all copies or substantial portions of the Software.
18
19   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25   THE SOFTWARE.
26 */
27
28 #ifndef PICTUREFLOW_H
29 #define PICTUREFLOW_H
30
31 #include <qwidget.h>
32 #include "../components/playlist/playlist_model.hpp" /* getArtPixmap etc */
33
34 class PictureFlowPrivate;
35
36 /*!
37   Class PictureFlow implements an image show widget with animation effect
38   like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form
39   of slides, one main slide is shown at the center with few slides on
40   the left and right sides of the center slide. When the next or previous
41   slide is brought to the front, the whole slides flow to the right or
42   the right with smooth animation effect; until the new slide is finally
43   placed at the center.
44
45  */
46 class PictureFlow : public QWidget
47 {
48     Q_OBJECT
49
50     Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
51     Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize)
52     Q_PROPERTY(int slideCount READ slideCount)
53     Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex)
54
55 public:
56
57     enum ReflectionEffect {
58         NoReflection,
59         PlainReflection,
60         BlurredReflection
61     };
62
63     /*!
64       Creates a new PictureFlow widget.
65     */
66     PictureFlow(QWidget* parent = 0, VLCModel *model = 0);
67
68     /*!
69       Destroys the widget.
70     */
71     ~PictureFlow();
72
73     /*!
74       Returns the background color.
75     */
76     QColor backgroundColor() const;
77
78     /*!
79       Sets the background color. By default it is black.
80     */
81     void setBackgroundColor(const QColor& c);
82
83     /*!
84       Returns the dimension of each slide (in pixels).
85     */
86     QSize slideSize() const;
87
88     /*!
89       Sets the dimension of each slide (in pixels).
90     */
91     void setSlideSize(QSize size);
92
93     /*!
94       Returns the total number of slides.
95     */
96     int slideCount() const;
97
98     /*!
99       Returns the index of slide currently shown in the middle of the viewport.
100     */
101     int centerIndex() const;
102
103     /*!
104       Returns the effect applied to the reflection.
105     */
106     ReflectionEffect reflectionEffect() const;
107
108     /*!
109       Sets the effect applied to the reflection. The default is PlainReflection.
110     */
111     void setReflectionEffect(ReflectionEffect effect);
112
113
114 public slots:
115
116     /*!
117       Sets slide to be shown in the middle of the viewport. No animation
118       effect will be produced, unlike using showSlide.
119     */
120     void setCenterIndex(int index);
121
122     /*!
123       Clears all slides.
124     */
125     void clear();
126
127     /*!
128       Shows previous slide using animation effect.
129     */
130     void showPrevious();
131
132     /*!
133       Shows next slide using animation effect.
134     */
135     void showNext();
136
137     /*!
138       Go to specified slide using animation effect.
139     */
140     void showSlide(int index);
141
142     /*!
143       Rerender the widget. Normally this function will be automatically invoked
144       whenever necessary, e.g. during the transition animation.
145     */
146     void render();
147
148     /*!
149       Schedules a rendering update. Unlike render(), this function does not cause
150       immediate rendering.
151     */
152     void triggerRender();
153
154 signals:
155     void centerIndexChanged(int index);
156
157 protected:
158     void paintEvent(QPaintEvent *event);
159     void keyPressEvent(QKeyEvent* event);
160     void mousePressEvent(QMouseEvent* event);
161     void resizeEvent(QResizeEvent* event);
162
163 private slots:
164     void updateAnimation();
165
166 private:
167     PictureFlowPrivate* d;
168 };
169
170 #endif // PICTUREFLOW_H
171