Begin implementation of PUD in CV. Some enhancements to GraphicsItemFader as well...
[amarok.git] / src / contextview / graphicsitemfader.h
blob87ce6edbabd28ffc67fd1917dce2a50851af26c3
1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifndef GRAPHICSITEMFADER_H
21 #define GRAPHICSITEMFADER_H
23 #include <QObject>
24 #include <QGraphicsPixmapItem>
25 #include <QGraphicsRectItem>
26 #include <QTimeLine>
28 namespace Context
32 /**
33 A simple "widget" for the context view that provides a fading image
34 Will be ported to use QGraphicsSvgItem once that successfully renders
35 the Amarok logo file
37 @author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
39 class GraphicsItemFader : public QObject, public QGraphicsItem
42 Q_OBJECT
43 public:
44 explicit GraphicsItemFader( QGraphicsItem * item, QGraphicsItem * parent = 0 );
45 ~GraphicsItemFader();
47 virtual QRectF boundingRect () const;
48 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget );
50 void setFadeColor( const QColor &color );
51 void setStartAlpha( int alpha );
52 void setTargetAlpha( int alpha );
53 void setDuration( int ms );
54 void setFPS( int fps );
55 void startFading();
56 QGraphicsItem* contentItem() { return m_contentItem; }
58 signals:
59 void animationComplete();
61 public slots:
62 void fadeSlot( int step );
63 void fadeFinished();
65 private:
66 QTimeLine * m_timeLine;
67 QGraphicsItem * m_contentItem;
68 QGraphicsRectItem * m_shadeRectItem;
69 QGraphicsItem * m_itemPreviousParent;
71 QColor m_fadeColor;
72 int m_startAlpha;
73 int m_targetAlpha;
74 float m_alphaStep;
75 int m_fps;
76 int m_duration;
77 int m_animationSteps;
78 int m_width;
79 int m_height;
87 #endif